from Cam import Cam
-from test_helper import assert_eq, assert_ne
+from test_helper import assert_eq, assert_ne, assert_op
def set_cam(dut, e, we, a, d):
yield dut.enable.eq(e)
def check_multiple_match(dut, mm, op):
out_mm = yield dut.multiple_match
- if op == 0:
- assert_eq("Multiple Match", out_mm, mm)
- else:
- assert_ne("Multiple Match", out_mm, mm)
+ assert_op("Multiple Match", out_mm, mm, op)
def check_single_match(dut, sm, op):
out_sm = yield dut.single_match
- if op == 0:
- assert_eq("Single Match", out_sm, sm)
- else:
- assert_ne("Single Match", out_sm, sm)
+ assert_op("Single Match", out_sm, sm, op)
def check_match_address(dut, ma, op):
out_ma = yield dut.match_address
- if op == 0:
- assert_eq("Match Address", out_ma, ma)
- else:
- assert_ne("Match Address", out_ma, ma)
+ assert_op("Match Address", out_ma, ma, op)
def check_all(dut, multiple_match, single_match, match_address, mm_op, sm_op, ma_op):
yield from check_multiple_match(dut, multiple_match, mm_op)
from nmigen.compat.sim import run_simulation
-from test_helper import assert_eq, assert_ne
+from test_helper import assert_eq, assert_ne, assert_op
from CamEntry import CamEntry
# This function allows for the easy setting of values to the Cam Entry
# op (Operation): (0 => ==), (1 => !=)
def check_data(dut, d, op):
out_d = yield dut.data
- if op == 0:
- assert_eq("Data", out_d, d)
- else:
- assert_ne("Data", out_d, d)
+ assert_op("Data", out_d, d, op)
# Checks the match state of the CAM entry
# Arguments:
# op (Operation): (0 => ==), (1 => !=)
def check_match(dut, m, op):
out_m = yield dut.match
- if op == 0:
- assert_eq("Match", out_m, m)
- else:
- assert_ne("Match", out_m, m)
+ assert_op("Match", out_m, m, op)
# Checks the state of the CAM entry
# Arguments:
-# Verifies the given values are equal
+# Verifies the given values given the particular operand
# Arguments:
# p (Prefix): Appended to the front of the assert statement
# e (Expected): The expected value
# o (Output): The output result
# op (Operation): (0 => ==), (1 => !=)
+def assert_op(pre, o, e, op):
+ if op == 0:
+ assert_eq(pre, o, e)
+ else:
+ assert_ne(pre, o, e)
+
+# Verifies the given values are equal
+# Arguments:
+# p (Prefix): Appended to the front of the assert statement
+# e (Expected): The expected value
+# o (Output): The output result
def assert_eq(p, o, e):
assert o == e, p + " Output " + str(o) + " Expected " + str(e)