self.key = Signal(key_size)
# Input
- self.command = Signal(2) # 00 => NA 01 => Read 10 => Write 11 => Reserve
+ self.command = Signal(2) # 00 => NA 01 => Read 10 => Write 11 => Reset
self.key_in = Signal(key_size) # Reference key for the CAM
self.data_in = Signal(data_size) # Data input when writing
def elaborate(self, platform=None):
m = Module()
with m.Switch(self.command):
+ with m.Case("00"):
+ m.d.sync += self.match.eq(0)
with m.Case("01"):
with m.If(self.key_in == self.key):
m.d.sync += self.match.eq(1)
self.match.eq(0)
]
with m.Case():
- m.d.sync += self.match.eq(0)
+ m.d.sync += [
+ self.match.eq(0),
+ self.data.eq(0),
+ self.key.eq(0)
+ ]
return m
yield from set_cam_entry(dut, command, key, data)
yield from check_all(dut, key, data, match, 0, 0, 0)
+ # Check reset
+ command = 3
+ key = 0
+ data = 0
+ match = 0
+ yield from set_cam_entry(dut, command, key, data)
+ yield from check_all(dut, key, data, match, 0, 0, 0)
+
# Extra clock cycle for waveform
yield