def action(self, m):
m.next = "add_1"
+ # NOTE: these could be done as combinatorial (merge add0+add1)
m.d.sync += self.out_z.copy(self.mod.out_z)
m.d.sync += self.out_tot.eq(self.mod.out_tot)
self.temp_z = FPNumBase(width)
self.temp_of = Overflow()
self.out_z = FPNumBase(width)
- self.out_of = Overflow()
+ self.out_roundz = Signal(reset_less=True)
def setup(self, m, in_z, in_of, norm_stb):
""" links module to inputs and outputs
m.d.comb += self.mod.temp_of.copy(self.temp_of)
m.d.comb += self.out_z.copy(self.mod.out_z)
- m.d.comb += self.out_of.copy(self.mod.out_of)
m.d.comb += self.out_norm.eq(self.mod.out_norm)
m.d.comb += self.stb.eq(norm_stb)
m.d.sync += self.ack.eq(0) # sets to zero when not in normalise_1 state
def action(self, m):
+
m.d.comb += self.in_accept.eq((~self.ack) & (self.stb))
- m.d.sync += self.of.copy(self.out_of)
- m.d.sync += self.z.copy(self.out_z)
- m.d.sync += self.temp_of.copy(self.out_of)
+ m.d.sync += self.temp_of.copy(self.mod.out_of)
m.d.sync += self.temp_z.copy(self.out_z)
with m.If(self.out_norm):
with m.If(self.in_accept):
# normalisation not required (or done).
m.next = "round"
m.d.sync += self.ack.eq(1)
+ m.d.sync += self.out_roundz.eq(self.mod.out_of.roundz)
class FPRoundMod:
self.in_z = FPNumBase(width, False)
self.out_z = FPNumBase(width, False)
- def setup(self, m, in_z, out_z, in_of):
- """ links module to inputs and outputs
- """
- m.d.comb += self.in_z.copy(in_z)
- m.d.comb += out_z.copy(self.out_z)
- m.d.comb += self.in_roundz.eq(in_of.roundz)
-
def elaborate(self, platform):
m = Module()
m.d.comb += self.out_z.copy(self.in_z)
self.mod = FPRoundMod(width)
self.out_z = FPNumBase(width)
+ def setup(self, m, in_z, roundz):
+ """ links module to inputs and outputs
+ """
+ m.submodules.roundz = self.mod
+
+ m.d.comb += self.mod.in_z.copy(in_z)
+ m.d.comb += self.mod.in_roundz.eq(roundz)
+
def action(self, m):
- m.d.sync += self.z.copy(self.out_z)
+ m.d.sync += self.out_z.copy(self.mod.out_z)
m.next = "corrections"
add1 = self.add_state(FPAddStage1(self.width))
add1.setup(m, add0.out_tot, add0.out_z)
- az = add1.out_z
-
n1 = self.add_state(FPNorm1(self.width))
- n1.set_inputs({"z": az, "of": add1.out_of}) # XXX Z as output
- n1.set_outputs({"z": az}) # XXX Z as output
- n1.setup(m, az, add1.out_of, add1.norm_stb)
-
- rnz = FPNumOut(self.width, False)
- m.submodules.fpnum_rnz = rnz
+ n1.set_inputs({"of": add1.out_of}) # XXX Z as output
+ n1.setup(m, add1.out_z, add1.out_of, add1.norm_stb)
rn = self.add_state(FPRound(self.width))
- rn.set_inputs({"of": n1.out_of})
- rn.set_outputs({"z": rnz})
- rn.mod.setup(m, n1.out_z, rn.out_z, add1.out_of)
- m.submodules.roundz = rn.mod
+ rn.setup(m, n1.out_z, n1.out_roundz)
cor = self.add_state(FPCorrections(self.width))
- cor.set_inputs({"z": rnz}) # XXX Z as output
- cor.mod.setup(m, rnz, cor.out_z)
+ cor.set_inputs({"z": rn.out_z}) # XXX Z as output
+ cor.mod.setup(m, rn.out_z, cor.out_z)
m.submodules.corrections = cor.mod
pa = self.add_state(FPPack(self.width))