FSGNJ working now in all three modes
[ieee754fpu.git] / src / ieee754 / fsgnj / fsgnj.py
index 4bb037345e9ca5ce203d45a5afb5047bac28ad02..8aef149cfb319b6f309c73b72378b69deb51c0d8 100644 (file)
@@ -38,12 +38,24 @@ class FSGNJPipeMod(PipeModBase):
         # decode: XXX really should move to separate stage
         z1 = self.o.z
         a = self.i.a
+        b = self.i.b
+
+        opcode = self.i.ctx.op
+
+        sign = Signal()
+
+        with m.Switch(opcode):
+            with m.Case(0b00):
+                comb += sign.eq(b[31])
+            with m.Case(0b01):
+                comb += sign.eq(~b[31])
+            with m.Case(0b10):
+                comb += sign.eq(a[31] ^ b[31])
+
+        comb += z1.eq(Cat(a[0:31], sign))
 
-        comb += z1.eq(a)
 
         # copy the context (muxid, operator)
         comb += self.o.ctx.eq(self.i.ctx)
 
         return m
-
-