From: Luke Kenneth Casson Leighton Date: Mon, 16 Mar 2020 13:18:48 +0000 (+0000) Subject: add exploratory unit test for partial address matching X-Git-Tag: div_pipeline~1694 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=da2db654687f7883b8749d55ba4f57d1af15432d;p=soc.git add exploratory unit test for partial address matching --- diff --git a/src/soc/scoreboard/addr_match.py b/src/soc/scoreboard/addr_match.py index 895701ca..c34b8950 100644 --- a/src/soc/scoreboard/addr_match.py +++ b/src/soc/scoreboard/addr_match.py @@ -67,7 +67,7 @@ class PartialAddrMatch(Elaboratable): # array of address-latches m.submodules.l = self.l = l = SRLatch(llen=self.n_adr, sync=False) - self.addrs_r = addrs_r = Array(Signal(self.bitwid, reset_less=True, + self.adrs_r = adrs_r = Array(Signal(self.bitwid, reset_less=True, name="a_r") \ for i in range(self.n_adr)) @@ -77,7 +77,7 @@ class PartialAddrMatch(Elaboratable): # copy in addresses (and "enable" signals) for i in range(self.n_adr): - latchregister(m, self.addrs_i[i], addrs_r[i], l.q[i]) + latchregister(m, self.addrs_i[i], adrs_r[i], l.q[i]) # is there a clash, yes/no matchgrp = [] @@ -94,7 +94,7 @@ class PartialAddrMatch(Elaboratable): def is_match(self, i, j): if i == j: return Const(0) # don't match against self! - return self.addrs_r[i] == self.addrs_r[j] + return self.adrs_r[i] == self.adrs_r[j] def __iter__(self): yield from self.addrs_i @@ -123,7 +123,7 @@ class LenExpand(Elaboratable): self.bit_len = bit_len self.len_i = Signal(bit_len, reset_less=True) self.addr_i = Signal(bit_len, reset_less=True) - self.explen_o = Signal(1<<(bit_len+1), reset_less=True) + self.lexp_o = Signal(1<<(bit_len+1), reset_less=True) def elaborate(self, platform): m = Module() @@ -131,13 +131,13 @@ class LenExpand(Elaboratable): # temp binlen = Signal((1<> 1 expwid2 = expwid + hexp print (self.lsbwid, expwid) - return ((self.addrs_r[i] == self.addrs_r[j]) & \ - (self.explen[i][:expwid] & self.explen[j][:expwid]).bool() | - (self.addr1s[i] == self.addrs_r[j]) & \ - (self.explen[i][expwid:expwid2] & self.explen[j][:hexp]).bool()) + return (((self.adrs_r[i] == self.adrs_r[j]) & + (self.lexp[i][:expwid] & self.lexp[j][:expwid]).bool()) | + ((self.addr1s[i] == self.adrs_r[j]) & + (self.lexp[i][expwid:expwid2] & self.lexp[j][:hexp]).bool()) + ) + # ((self.addr1s[j] == self.adrs_r[i]) & + # (self.lexp[j][expwid:expwid2] & self.lexp[i][:hexp]).bool())) def __iter__(self): yield from self.faddrs_i @@ -256,6 +259,30 @@ def part_addr_sim(dut): yield dut.go_wr_i.eq(0) yield +def part_addr_bit(dut): + yield dut.len_i[0].eq(8) + yield dut.faddrs_i[0].eq(0b1011011) + yield dut.addr_en_i[0].eq(1) + yield + yield dut.addr_en_i[0].eq(0) + yield + yield dut.len_i[1].eq(2) + yield dut.faddrs_i[1].eq(0b1100010) + yield dut.addr_en_i[1].eq(1) + yield + yield dut.addr_en_i[1].eq(0) + yield + yield dut.len_i[2].eq(2) + yield dut.faddrs_i[2].eq(0b1011010) + yield dut.addr_en_i[2].eq(1) + yield + yield dut.addr_en_i[2].eq(0) + yield + yield dut.addr_rs_i[1].eq(1) + yield + yield dut.addr_rs_i[1].eq(0) + yield + def test_part_addr(): dut = LenExpand(4) vl = rtlil.convert(dut, ports=dut.ports()) @@ -267,6 +294,8 @@ def test_part_addr(): with open("test_part_bit.il", "w") as f: f.write(vl) + run_simulation(dut, part_addr_bit(dut), vcd_name='test_part_bit.vcd') + dut = PartialAddrMatch(3, 10) vl = rtlil.convert(dut, ports=dut.ports()) with open("test_part_addr.il", "w") as f: