Hi Jeremy, On Mon, Nov 12, 2012 at 6:10 AM, Jeremy Bennett <[email protected] > wrote:
> On Thu, 2012-11-08 at 17:40 -0500, Peter Gavin wrote: > > > > I was just wondering if there's a real implementation that actually > > implements the l.mul and l.mulu instructions correctly, including the > > OV and CY flags, and if any software actually uses them. > > Hi Pete, > > I thought Or1ksim got this right? > Yes, indeed it does. I meant a *hardware* implementation. :) It seems to me if the only implementation that gets it right is or1ksim, we can change it without causing significant problems. >From looking at the source, it looks like the or1200 does not actually implement it correctly, because the or1200_mult_mac module only has an output for OV, not both OV and CY. I believe Ruben verified that it does not work with his OrBuild tool. > And (as we have found out the hard way), you would be amazed at how much > hand-coded assembler is out there. BTW have you looked at whether these > instructions are used in the GCC library routines? > I'll take a look. I suppose I should check the arch subdirectory of the linux kernel as well. > It sounds like you are fixing the wrong problem. It should be the case > that CY is used for unsigned overflow and OV for 2's complement > overflow. These flags should be set by arithmetic, but not logical > instructions. > The problem is that the l.mul instruction sets both CY and OV. It's not really possible to recover both flags without hand-coding the multiplier, or using two multipliers, one to do signed and the other to do unsigned. The specific problem I'm trying to fix is to make OpenRISC easy to implement on an FPGA. This is a big sticking point for that goal. > > IIUC, you want to make l.mulu (only) use the OV flag for unsigned > overflow, because it then allows you to use the OVE flag to control > exception handling. > Actually, what I'd like to do now is make l.mulu *only* set the CY flag, and not even touch the OV flag. Similarly, I'd like l.mul to *only* set the OV flag, and not touch the CY flag. Surely the correct thing if you need fine-grained control of both signed > and unsigned overflow is to add a CYE flag? > Initially I wanted to make both instructions use OV for overflow, and Ruben suggested just adding the CYE flag. The proposal I added to the wiki suggests adding the CYE flag as you're suggesting here. -Pete
_______________________________________________ OpenRISC mailing list [email protected] http://lists.openrisc.net/listinfo/openrisc
