terapage lookup
[soc.git] / src / TLB / ariane / test / test_tlb_content.py
1 import sys
2 sys.path.append("../src")
3 sys.path.append("../../../TestUtil")
4
5 from nmigen.compat.sim import run_simulation
6
7 from TLB.ariane.tlb_content import TLBContent
8 from TestUtil.test_helper import assert_op, assert_eq
9
10 def update(dut,a,t,g,m):
11 yield dut.replace_en_i.eq(1)
12 yield dut.update_i.valid.eq(1)
13 yield dut.update_i.is_512G.eq(t)
14 yield dut.update_i.is_1G.eq(g)
15 yield dut.update_i.is_2M.eq(m)
16 yield dut.update_i.vpn.eq(a)
17 yield
18 yield
19
20 def check_hit(dut,hit,t):
21 hit_d = yield dut.lu_hit_o
22 assert_eq("hit", hit_d, hit)
23 t_d = yield dut.lu_is_512G_o
24 assert_eq("t", t_d, t)
25
26 def addr(a,b,c,d):
27 return a | b << 9 | c << 18 | d << 27
28
29 def tbench(dut):
30 yield dut.vpn0.eq(0xAA)
31 yield dut.vpn1.eq(0xBB)
32 yield dut.vpn2.eq(0xCC)
33 yield dut.vpn3.eq(0x0D)
34 yield from update(dut,addr(0x0A,0x0B,0x0C,0x0D),1,0,0)
35 yield from check_hit(dut,1,1)
36 yield from update(dut,addr(0x0A,0x0B,0x0C,0x0D),0,1,0)
37 yield from update(dut,addr(0x0A,0x0B,0x0C,0x0D),0,0,1)
38
39
40
41
42 if __name__ == "__main__":
43 dut = TLBContent(4,4)
44 #
45 run_simulation(dut, tbench(dut), vcd_name="test_tlb_content.vcd")
46 print("TLBContent Unit Test Success")