tlb_content now supports 512G pages
authorTobias Platen <tplaten@posteo.de>
Mon, 16 Sep 2019 16:42:15 +0000 (18:42 +0200)
committerTobias Platen <tplaten@posteo.de>
Mon, 16 Sep 2019 16:42:15 +0000 (18:42 +0200)
src/TLB/ariane/test/test_tlb_content.py
src/TLB/ariane/tlb_content.py

index 28960d134b8660e551447522c7a90f2058bb6f4e..145ded7d32797e4a4feec808384e9adb8509962f 100644 (file)
@@ -17,26 +17,43 @@ def update(dut,a,t,g,m):
     yield
     yield
 
-def check_hit(dut,hit,t):
+def check_hit(dut,hit,pagesize):
     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)
+
+    if(hit):
+        if(pagesize=="t"):
+            hitp = yield dut.lu_is_512G_o
+            assert_eq("lu_is_512G_o", hitp, 1)
+        elif(pagesize=="g"):
+            hitp = yield dut.lu_is_1G_o
+            assert_eq("lu_is_1G_o", hitp, 1)
+        elif(pagesize=="m"):
+            hitp = yield dut.lu_is_2M_o
+            assert_eq("lu_is_2M_o", hitp, 1)
 
 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.vpn0.eq(0x0A)
+    yield dut.vpn1.eq(0x0B)
+    yield dut.vpn2.eq(0x0C)
     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)
+    yield from update(dut,addr(0xFF,0xFF,0xFF,0x0D),1,0,0)
+    yield from check_hit(dut,1,"t")
+    
+    yield from update(dut,addr(0xFF,0xFF,0x0C,0x0D),0,1,0)
+    yield from check_hit(dut,1,"g")
     
+    yield from update(dut,addr(0xFF,0x0B,0x0C,0x0D),0,0,1)
+    yield from check_hit(dut,1,"m")
     
+    yield from update(dut,addr(0x0A,0x0B,0x0C,0x0D),0,0,0)
+    yield from check_hit(dut,1,"")
+
+    yield from update(dut,addr(0xAA,0xBB,0xCC,0xDD),0,0,0)
+    yield from check_hit(dut,0,"miss")
     
 
 if __name__ == "__main__":
index 0e171e96c80d4a90fe153fee043184696a761648..3384c88502d469b5edc111ea0e1c8c2e84dced3d 100644 (file)
@@ -61,44 +61,43 @@ class TLBContent(Elaboratable):
                      self.lu_is_2M_o.eq(0),
                      self.lu_is_1G_o.eq(0)]
 
-        # temporaries for all levels
+        # temporaries for lookup
         asid_ok = Signal(reset_less=True)
-        tags_ok = Signal(reset_less=True)
+        tags_ok = 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),
-                     vpn3_ok.eq(tags.vpn3 == self.vpn3),
-                    ]
-        # temporaries for 2nd level match
         vpn1_ok = Signal(reset_less=True)
-        tags_2M = Signal(reset_less=True)
         vpn0_ok = Signal(reset_less=True)
+
+        #tags_2M = Signal(reset_less=True)
         vpn0_or_2M = Signal(reset_less=True)
-        m.d.comb += [vpn1_ok.eq(self.vpn1 == tags.vpn1),
-                     tags_2M.eq(tags.is_2M),
-                     vpn0_ok.eq(self.vpn0 == tags.vpn0),
-                     vpn0_or_2M.eq(tags_2M | vpn0_ok)]
+    
+        m.d.comb += [
+                     #compare asid and vpn*
+                     asid_ok.eq(tags.asid == self.lu_asid_i),
+                     vpn3_ok.eq(tags.vpn3 == self.vpn3),
+                     vpn2_ok.eq(tags.vpn2 == self.vpn2),
+                     vpn1_ok.eq(tags.vpn1 == self.vpn1),
+                     vpn0_ok.eq(tags.vpn0 == self.vpn0),
+                     vpn0_or_2M.eq(tags.is_2M | vpn0_ok)
+        ]
         
         
-        with m.If(asid_ok & tags_ok):
+        with m.If(asid_ok & tags.valid):
             # 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.Elif (tags.is_1G & vpn2_ok):
+            # second level , second level vpn2 and vpn3 need to match
+            with m.Elif (tags.is_1G & vpn2_ok & vpn3_ok):
                 m.d.comb += [ self.lu_content_o.eq(content),
                               self.lu_is_1G_o.eq(1),
                               self.lu_hit_o.eq(1),
                             ]
-            # not a giga page hit so check further
+            # not a giga page hit nor a tera page hit so check further
             with m.Elif(vpn1_ok):
                 # this could be a 2 mega page hit or a 4 kB hit
                 # output accordingly