from nmigen.compat.sim import run_simulation
from TLB.ariane.tlb_content import TLBContent
+from TestUtil.test_helper import assert_op, assert_eq
-def update():
- yield dut.replace_en_i.eq(1)
-
-def tbench(dut):
+def update(dut,a,t,g,m):
yield dut.replace_en_i.eq(1)
yield dut.update_i.valid.eq(1)
- yield dut.update_i.is_512G.eq(1)
- yield dut.update_i.vpn.eq(0xFFFFFFFF)
+ yield dut.update_i.is_512G.eq(t)
+ yield dut.update_i.is_1G.eq(g)
+ yield dut.update_i.is_2M.eq(m)
+ yield dut.update_i.vpn.eq(a)
yield
yield
+
+def check_hit(dut,hit,t):
+ hit_d = yield dut.lu_hit_o
+ assert_eq("hit", hit_d, hit)
+ t_d = yield dut.lu_is_512G_o
+ assert_eq("t", t_d, t)
+
+def addr(a,b,c,d):
+ return a | b << 9 | c << 18 | d << 27
+
+def tbench(dut):
+ yield dut.vpn0.eq(0xAA)
+ yield dut.vpn1.eq(0xBB)
+ yield dut.vpn2.eq(0xCC)
+ yield dut.vpn3.eq(0x0D)
+ yield from update(dut,addr(0x0A,0x0B,0x0C,0x0D),1,0,0)
+ yield from check_hit(dut,1,1)
+ yield from update(dut,addr(0x0A,0x0B,0x0C,0x0D),0,1,0)
+ yield from update(dut,addr(0x0A,0x0B,0x0C,0x0D),0,0,1)
+
+
if __name__ == "__main__":
m = Module()
tags = TLBEntry(self.asid_width)
- #TODO signal names, RecordObject
- print("TAGS:")
- #print(tags)
content = Signal(self.pte_width)
m.d.comb += [self.lu_hit_o.eq(0),
+ self.lu_is_512G_o.eq(0),
self.lu_is_2M_o.eq(0),
self.lu_is_1G_o.eq(0)]
- # temporaries for 1st level match
+ # temporaries for all levels
asid_ok = Signal(reset_less=True)
- vpn2_ok = Signal(reset_less=True)
tags_ok = Signal(reset_less=True)
- vpn2_hit = Signal(reset_less=True)
+
+ vpn3_ok = Signal(reset_less=True)
+ vpn2_ok = Signal(reset_less=True)
+
+
m.d.comb += [tags_ok.eq(tags.valid),
asid_ok.eq(tags.asid == self.lu_asid_i),
vpn2_ok.eq(tags.vpn2 == self.vpn2),
- vpn2_hit.eq(tags_ok & asid_ok & vpn2_ok)]
+ vpn3_ok.eq(tags.vpn3 == self.vpn3),
+ ]
# temporaries for 2nd level match
vpn1_ok = Signal(reset_less=True)
tags_2M = Signal(reset_less=True)
tags_2M.eq(tags.is_2M),
vpn0_ok.eq(self.vpn0 == tags.vpn0),
vpn0_or_2M.eq(tags_2M | vpn0_ok)]
- # TODO temporaries for 3rd level match
- # first level match, this may be a giga page,
- # check the ASID flags as well
- with m.If(vpn2_hit):
+
+ with m.If(asid_ok & tags_ok):
+ # first level, only vpn3 needs to match
+ with m.If (tags.is_512G & vpn3_ok):
+ m.d.comb += [ self.lu_content_o.eq(content),
+ self.lu_is_512G_o.eq(1),
+ self.lu_hit_o.eq(1),
+ ]
# second level
- with m.If (tags.is_1G):
+ with m.Elif (tags.is_1G & vpn2_ok):
m.d.comb += [ self.lu_content_o.eq(content),
self.lu_is_1G_o.eq(1),
self.lu_hit_o.eq(1),