from nmigen.compat.sim import run_simulation
-from test_helper import check
+from test_helper import assert_eq, assert_ne
from CamEntry import CamEntry
# This function allows for the easy setting of values to the Cam Entry
# op (Operation): (0 => ==), (1 => !=)
def check_key(dut, k, op):
out_k = yield dut.key
- check("Key", out_k, k, op)
+ if op == 0:
+ assert_eq("Key", out_k, k)
+ else:
+ assert_ne("Key", out_k, k)
# Checks the data state of the CAM entry
# Arguments:
# op (Operation): (0 => ==), (1 => !=)
def check_data(dut, d, op):
out_d = yield dut.data
- check("Data", out_d, d, op)
+ if op == 0:
+ assert_eq("Data", out_d, d)
+ else:
+ assert_ne("Data", out_d, d)
# Checks the match state of the CAM entry
# Arguments:
# op (Operation): (0 => ==), (1 => !=)
def check_match(dut, m, op):
out_m = yield dut.match
- check("Match", out_m, m, op)
+ if op == 0:
+ assert_eq("Match", out_m, m)
+ else:
+ assert_ne("Match", out_m, m)
# Checks the state of the CAM entry
# Arguments:
-# Verifies the given values via the requested operation
+# 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
# op (Operation): (0 => ==), (1 => !=)
-def check(p, o, e, op):
- if(op == 0):
- assert o == e, p + " Output " + str(o) + " Expected " + str(e)
- else:
- assert o != e, p + " Output " + str(o) + " Not Expecting " + str(e)
\ No newline at end of file
+def assert_eq(p, o, e):
+ assert o == e, p + " Output " + str(o) + " Expected " + str(e)
+
+# Verifies the given values are not equal
+# Arguments:
+# p (Prefix): Appended to the front of the assert statement
+# e (Expected): The expected value
+# o (Output): The output result
+def assert_ne(p, o, e):
+ assert o != e, p + " Output " + str(o) + " Not Expecting " + str(e)
\ No newline at end of file