def elaborate(self, platform):
m = Module()
q_int = Signal(reset_less=True)
- qn_int = Signal(reset_less=True)
- m.d.comb += self.q.eq(~(self.s | qn_int))
- m.d.comb += self.qn.eq(~(self.r | q_int))
+ with m.If(self.s):
+ m.d.sync += q_int.eq(1)
+ with m.Elif(self.r):
+ m.d.sync += q_int.eq(0)
- m.d.sync += q_int.eq(self.q)
- m.d.sync += qn_int.eq(self.qn)
+ m.d.comb += self.q.eq(q_int)
+ m.d.comb += self.qn.eq(~q_int)
return m
yield dut.s.eq(0)
yield dut.r.eq(0)
yield
+ yield
+ yield
yield dut.s.eq(1)
yield
+ yield
+ yield
yield dut.s.eq(0)
yield
+ yield
+ yield
yield dut.r.eq(1)
yield
+ yield
+ yield
yield dut.r.eq(0)
yield
yield
+ yield
def test_sr():
dut = SRLatch()
m.submodules.src2_l = src2_l = SRLatch()
# destination latch: reset on go_write HI, set on dest and issue
- m.d.sync += dest_l.s.eq(self.issue_i & self.dest_i)
- m.d.sync += dest_l.r.eq(self.go_write_i)
+ m.d.comb += dest_l.s.eq(self.issue_i & self.dest_i)
+ m.d.comb += dest_l.r.eq(self.go_write_i)
# src1 latch: reset on go_read HI, set on src1_i and issue
- m.d.sync += src1_l.s.eq(self.issue_i & self.src1_i)
- m.d.sync += src1_l.r.eq(self.go_read_i)
+ m.d.comb += src1_l.s.eq(self.issue_i & self.src1_i)
+ m.d.comb += src1_l.r.eq(self.go_read_i)
# src2 latch: reset on go_read HI, set on op2_i and issue
- m.d.sync += src2_l.s.eq(self.issue_i & self.src2_i)
- m.d.sync += src2_l.r.eq(self.go_read_i)
+ m.d.comb += src2_l.s.eq(self.issue_i & self.src2_i)
+ m.d.comb += src2_l.r.eq(self.go_read_i)
# FU "Forward Progress" (read out horizontally)
m.d.comb += self.dest_fwd_o.eq(dest_l.qn & self.dest_i)
yield dut.src1_i.eq(1)
yield dut.issue_i.eq(1)
yield
+ yield
+ yield
yield dut.issue_i.eq(0)
yield
yield dut.go_read_i.eq(1)
m.submodules.wr_l = wr_l = SRLatch()
# write latch: reset on go_write HI, set on write pending and issue
- m.d.sync += wr_l.s.eq(self.issue_i & self.wr_pend_i)
- m.d.sync += wr_l.r.eq(self.go_write_i)
+ m.d.comb += wr_l.s.eq(self.issue_i & self.wr_pend_i)
+ m.d.comb += wr_l.r.eq(self.go_write_i)
# read latch: reset on go_read HI, set on read pending and issue
- m.d.sync += rd_l.s.eq(self.issue_i & self.rd_pend_i)
- m.d.sync += rd_l.r.eq(self.go_read_i)
+ m.d.comb += rd_l.s.eq(self.issue_i & self.rd_pend_i)
+ m.d.comb += rd_l.r.eq(self.go_read_i)
# Read/Write Pending Latches (read out horizontally)
m.d.comb += self.wr_pend_o.eq(wr_l.qn)