From: Luke Kenneth Casson Leighton Date: Sat, 16 Feb 2019 08:54:33 +0000 (+0000) Subject: create get_op function X-Git-Tag: ls180-24jan2020~1969 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bc07e0680fb8dad61471ffe5b8a66a1d83688747;p=ieee754fpu.git create get_op function --- diff --git a/src/add/nmigen_add_experiment.py b/src/add/nmigen_add_experiment.py index cad063c1..6f9f3a7e 100644 --- a/src/add/nmigen_add_experiment.py +++ b/src/add/nmigen_add_experiment.py @@ -112,6 +112,16 @@ class FPADD: self.in_b = FPOp(width) self.out_z = FPOp(width) + def get_op(self, m, op, v, next_state): + with m.If((op.ack) & (op.stb)): + m.next = next_state + m.d.sync += [ + v.eq(op.v), + op.ack.eq(0) + ] + with m.Else(): + m.d.sync += op.ack.eq(1) + def get_fragment(self, platform=None): m = Module() @@ -132,14 +142,7 @@ class FPADD: # gets operand a with m.State("get_a"): - with m.If((self.in_a.ack) & (self.in_a.stb)): - m.next = "get_b" - m.d.sync += [ - a.v.eq(self.in_a.v), - self.in_a.ack.eq(0) - ] - with m.Else(): - m.d.sync += self.in_a.ack.eq(1) + self.get_op(m, self.in_a, a.v, "get_b") # ****** # gets operand b