From: Daniel Benusovich Date: Sat, 23 Feb 2019 23:01:42 +0000 (-0800) Subject: Updating CAM to (hopefully) full functionality. Needs more testing first though X-Git-Tag: div_pipeline~2371 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=327d29ac18edf096b2d1975c32c4af33784e91d3;p=soc.git Updating CAM to (hopefully) full functionality. Needs more testing first though --- diff --git a/TLB/src/Cam.py b/TLB/src/Cam.py index 92d6e675..42b7f028 100644 --- a/TLB/src/Cam.py +++ b/TLB/src/Cam.py @@ -22,13 +22,9 @@ class Cam(): # cam_size: (entry count) The number of entries int he CAM def __init__(self, key_size, data_size, cam_size): # Internal - self.clk = ClockDomain(reset_less=True) - self.key_size = key_size - self.data_size = data_size self.cam_size = cam_size self.entry_array = Array(CamEntry(key_size, data_size) \ for x in range(cam_size)) - self.encoder_input = Signal(cam_size) # Input self.command = Signal(2) # 00 => NA 01 => Read 10 => Write 11 => Search @@ -65,9 +61,10 @@ class Cam(): m.d.comb += [ self.entry_array[index].key_in.eq(self.key_in), self.entry_array[index].data_in.eq(self.data_in), - self.encoder_input[index].eq(self.entry_array[index].match) + encoder.i[index].eq(self.entry_array[index].match) ] + with m.Switch(self.command): # Read with m.Case("01"): @@ -82,18 +79,14 @@ class Cam(): self.entry_array[self.address].key_in.eq(self.key_in), self.entry_array[self.address].data_in.eq(self.data_in) ] - # Search - with m.Case("11"): - m.d.comb += encoder.i.eq(self.encoder_input) + # NA / Searching + with m.Case(): with m.If(encoder.n == 0): m.d.comb += [ - self.data_hit.eq(0), - self.data_out.eq(self.entry_array[encoder.o].data) + self.data_hit.eq(1), + self.data_out.eq(self.entry_array[encoder.o].data) ] with m.Else(): - m.d.comb += self.data_hit.eq(1) - # NA - with m.Case(): - m.d.comb += self.data_hit.eq(0) + m.d.comb += self.data_hit.eq(0) return m diff --git a/TLB/test/test_cam.py b/TLB/test/test_cam.py index 925a14eb..c5141a93 100644 --- a/TLB/test/test_cam.py +++ b/TLB/test/test_cam.py @@ -9,17 +9,11 @@ from Cam import Cam from test_helper import assert_eq, assert_ne def set_cam(dut, c, a, k, d): - print("asdf") yield dut.command.eq(c) yield dut.address.eq(a) yield dut.key_in.eq(k) yield dut.data_in.eq(d) - yield - yield dut.command.eq(0) - yield dut.address.eq(0) - yield dut.key_in.eq(0) - yield dut.data_in.eq(0) - yield + yield def check_data_hit(dut, dh, op): out_dh = yield dut.data_hit @@ -48,7 +42,7 @@ def testbench(dut): data = 0 data_hit = 0 yield from set_cam(dut, command, address, key, data) - #yield from check_data_hit(dut, data_hit, 0) + yield from check_data_hit(dut, data_hit, 0) # Search command = 3 @@ -57,7 +51,7 @@ def testbench(dut): data = 0 data_hit = 0 yield from set_cam(dut, command, address, key, data) - #yield from check_data_hit(dut, data_hit, 0) + yield from check_data_hit(dut, data_hit, 0) # Write Entry 0 command = 2 @@ -66,7 +60,7 @@ def testbench(dut): data = 4 data_hit = 0 yield from set_cam(dut, command, address, key, data) - #yield from check_data_hit(dut, data_hit, 0) + yield from check_data_hit(dut, data_hit, 0) # Read Entry 0 command = 1 @@ -75,7 +69,7 @@ def testbench(dut): data = 4 data_hit = 0 yield from set_cam(dut, command, address, key, data) - #yield from check_all(dut, data_hit, data, 0, 0) + yield from check_all(dut, data_hit, data, 0, 0) # Search command = 3 @@ -84,7 +78,8 @@ def testbench(dut): data = 4 data_hit = 1 yield from set_cam(dut, command, address, key, data) - #yield from check_all(dut, data_hit, data, 0, 0) + yield + yield from check_all(dut, data_hit, data, 0, 0) yield