From 3bc4518545705c5e3426d3cf338e26863d36f833 Mon Sep 17 00:00:00 2001 From: Tobias Platen Date: Wed, 11 Sep 2019 21:14:11 +0200 Subject: [PATCH] terapage lookup --- src/TLB/ariane/test/test_tlb_content.py | 33 ++++++++++++++++++++----- src/TLB/ariane/tlb_content.py | 30 +++++++++++++--------- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/src/TLB/ariane/test/test_tlb_content.py b/src/TLB/ariane/test/test_tlb_content.py index 0da2aff5..28960d13 100644 --- a/src/TLB/ariane/test/test_tlb_content.py +++ b/src/TLB/ariane/test/test_tlb_content.py @@ -5,17 +5,38 @@ sys.path.append("../../../TestUtil") 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__": diff --git a/src/TLB/ariane/tlb_content.py b/src/TLB/ariane/tlb_content.py index 4010e377..0e171e96 100644 --- a/src/TLB/ariane/tlb_content.py +++ b/src/TLB/ariane/tlb_content.py @@ -52,26 +52,28 @@ class TLBContent(Elaboratable): 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) @@ -81,13 +83,17 @@ class TLBContent(Elaboratable): 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), -- 2.30.2