From 55b207a0996c96c3082fb1d8381b01b53bc6b885 Mon Sep 17 00:00:00 2001 From: Peter Monsson Date: Tue, 18 Nov 2025 20:32:48 +0100 Subject: [PATCH 1/5] Fixing string comparison so that commercial tools work --- src/uvmkit_check.sv | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/uvmkit_check.sv b/src/uvmkit_check.sv index ae204f3..f84bb64 100644 --- a/src/uvmkit_check.sv +++ b/src/uvmkit_check.sv @@ -139,6 +139,58 @@ end \ end +<<<<<<< Updated upstream +======= +`define uvmkit_check_equals_enum(enum_t, expected, actual, msg="") \ + begin \ + enum_t _expected; \ + enum_t _actual; \ + _expected = expected; \ + _actual = actual; \ + if (_expected !== _actual) begin \ + `uvmkit_error_msg_fmt("uvmkit_check_equals_enum", $sformatf("Expected '%s' to equal '%s', but %s !== %s", `"expected`", `"actual`", _expected.name(), _actual.name()), msg) \ + end \ + end + +`define uvmkit_check_not_equals_enum(enum_t, expected, actual, msg="") \ + begin \ + enum_t _expected; \ + enum_t _actual; \ + _expected = expected; \ + _actual = actual; \ + if (_expected === _actual) begin \ + `uvmkit_error_msg_fmt("uvmkit_check_not_equals_enum", $sformatf("Expected '%s' to not equal '%s', but both are %s", `"expected`", `"actual`", _expected.name()), msg) \ + end \ + end + + +// String-specific comparison macros (work with all simulators including Verilator) +`define uvmkit_check_equals_string(a, b, msg="") \ + begin \ + string _a_str; \ + string _b_str; \ + automatic logic _exp_result; \ + _a_str = (a); \ + _b_str = (b); \ + _exp_result = _a_str == _b_str; \ + if (_exp_result !== 1'b1) begin \ + `uvmkit_error_msg_fmt("uvmkit_check_equals_string", $sformatf("Expected strings to be equal:\n Expected: \"%s\"\n Actual: \"%s\"", _a_str, _b_str), msg) \ + end \ + end + +`define uvmkit_check_not_equals_string(a, b, msg="") \ + begin \ + string _a_str; \ + string _b_str; \ + automatic logic _exp_result; \ + _a_str = (a); \ + _b_str = (b); \ + _exp_result = _a_str != _b_str; \ + if (_exp_result !== 1'b1) begin \ + `uvmkit_error_msg_fmt("uvmkit_check_not_equals_string", $sformatf("Expected strings to be different, but both are:\n \"%s\"", _a_str), msg) \ + end \ + end +>>>>>>> Stashed changes // String-specific comparison macros (work with all simulators including Verilator) `define uvmkit_check_equals_string(a, b, msg="") \ From 9466a2d6adeddc100eb793a9dddae55774c415d7 Mon Sep 17 00:00:00 2001 From: Peter Monsson Date: Tue, 18 Nov 2025 20:33:30 +0100 Subject: [PATCH 2/5] Adding examples that can be run from EDA playground --- examples/all_checks_example.sv | 149 +++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 examples/all_checks_example.sv diff --git a/examples/all_checks_example.sv b/examples/all_checks_example.sv new file mode 100644 index 0000000..0306b08 --- /dev/null +++ b/examples/all_checks_example.sv @@ -0,0 +1,149 @@ +// Example demonstrating all uvmkit_check macros with passing cases +// This example shows successful assertions for each macro type + +`include "../src/uvmkit_check.sv" + +module tb; + + // Example class for object checks + class MyClass; + int value; + function new(int v); + value = v; + endfunction + endclass + + // Example enum for enum checks + typedef enum {RED, GREEN, BLUE} color_e; + + initial begin + MyClass obj1, obj2; + color_e color1, color2; + string str1, str2; + real r1, r2; + + $display("=== uvmkit_check Examples ===\n"); + + // ======================================== + // Basic Checks + // ======================================== + $display("--- Basic Checks ---"); + + // check_true: passes when expression is true + `uvmkit_check_true(1) + `uvmkit_check_true(5 > 3) + + // check_false: passes when expression is false + `uvmkit_check_false(0) + `uvmkit_check_false(2 < 1) + + // ======================================== + // Equality Checks + // ======================================== + $display("--- Equality Checks ---"); + + // check_equals: passes when values are equal + `uvmkit_check_equals(1, 1) + `uvmkit_check_equals(8'hAA, 8'hAA) + `uvmkit_check_equals(1'bx, 1'bx) + + // check_not_equals: passes when values are not equal + `uvmkit_check_not_equals(1, 0) + `uvmkit_check_not_equals(8'hAA, 8'h55) + `uvmkit_check_not_equals(1'bx, 1'b0) + + // ======================================== + // Null Checks + // ======================================== + $display("--- Null Checks ---"); + + obj1 = null; + obj2 = new(42); + + // check_null: passes when object is null + `uvmkit_check_null(obj1) + + // check_not_null: passes when object is not null + `uvmkit_check_not_null(obj2) + + // ======================================== + // Object Identity Checks + // ======================================== + $display("--- Object Identity Checks ---"); + + obj1 = new(10); + obj2 = obj1; // Same object reference + + // check_same: passes when objects are the same reference + `uvmkit_check_same(obj1, obj2) + + obj2 = new(10); // Different object + + // check_not_same: passes when objects are different references + `uvmkit_check_not_same(obj1, obj2) + + // ======================================== + // Real Number Checks + // ======================================== + $display("--- Real Number Checks ---"); + + r1 = 3.14159; + r2 = 3.14160; + + // check_equals_real: passes when values are within delta + `uvmkit_check_equals_real(r1, r2, 0.001) + `uvmkit_check_equals_real(1.0, 1.0, 0.0) + + // check_not_equals_real: passes when values differ by more than delta + `uvmkit_check_not_equals_real(r1, r2, 0.00001) + `uvmkit_check_not_equals_real(1.0, 2.0, 0.5) + + // ======================================== + // Enum Checks + // ======================================== + $display("--- Enum Checks ---"); + + color1 = RED; + color2 = RED; + + // check_equals_enum: passes when enum values are equal + `uvmkit_check_equals_enum(color_e, color1, color2) + `uvmkit_check_equals_enum(color_e, RED, RED) + + color2 = BLUE; + + // check_not_equals_enum: passes when enum values differ + `uvmkit_check_not_equals_enum(color_e, color1, color2) + `uvmkit_check_not_equals_enum(color_e, RED, BLUE) + + // ======================================== + // String Checks + // ======================================== + $display("--- String Checks ---"); + + str1 = "hello"; + str2 = "hello"; + + // check_equals_string: passes when strings are equal + `uvmkit_check_equals_string(str1, str2) + `uvmkit_check_equals_string("test", "test") + + str2 = "world"; + + // check_not_equals_string: passes when strings differ + `uvmkit_check_not_equals_string(str1, str2) + `uvmkit_check_not_equals_string("hello", "world") + + // ======================================== + // Checks with Custom Messages + // ======================================== + $display("--- Checks with Custom Messages ---"); + + `uvmkit_check_true(1, "This check should pass") + `uvmkit_check_equals(42, 42, "Answer to life") + `uvmkit_check_equals_string("pass", "pass", "String comparison") + + $finish; + end + +endmodule From 3029f3ea9b09b83ca82b96d24755f0ca05803656 Mon Sep 17 00:00:00 2001 From: Peter Monsson Date: Tue, 18 Nov 2025 20:39:21 +0100 Subject: [PATCH 3/5] fix stashed diff --- src/uvmkit_check.sv | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/uvmkit_check.sv b/src/uvmkit_check.sv index f84bb64..b072ce1 100644 --- a/src/uvmkit_check.sv +++ b/src/uvmkit_check.sv @@ -139,8 +139,6 @@ end \ end -<<<<<<< Updated upstream -======= `define uvmkit_check_equals_enum(enum_t, expected, actual, msg="") \ begin \ enum_t _expected; \ @@ -190,7 +188,6 @@ `uvmkit_error_msg_fmt("uvmkit_check_not_equals_string", $sformatf("Expected strings to be different, but both are:\n \"%s\"", _a_str), msg) \ end \ end ->>>>>>> Stashed changes // String-specific comparison macros (work with all simulators including Verilator) `define uvmkit_check_equals_string(a, b, msg="") \ From ce7e799eac91bbf5723f591731c7598c31b9cb63 Mon Sep 17 00:00:00 2001 From: Peter Monsson Date: Tue, 18 Nov 2025 20:51:18 +0100 Subject: [PATCH 4/5] Trying to fix small errors --- examples/all_checks_example.sv | 2 -- src/uvmkit_check.sv | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/all_checks_example.sv b/examples/all_checks_example.sv index 0306b08..27b52ce 100644 --- a/examples/all_checks_example.sv +++ b/examples/all_checks_example.sv @@ -1,8 +1,6 @@ // Example demonstrating all uvmkit_check macros with passing cases // This example shows successful assertions for each macro type -`include "../src/uvmkit_check.sv" - module tb; // Example class for object checks diff --git a/src/uvmkit_check.sv b/src/uvmkit_check.sv index b072ce1..ca6da4b 100644 --- a/src/uvmkit_check.sv +++ b/src/uvmkit_check.sv @@ -183,7 +183,7 @@ automatic logic _exp_result; \ _a_str = (a); \ _b_str = (b); \ - _exp_result = _a_str != _b_str; \ + _exp_result = _a_str != _b_str; \ if (_exp_result !== 1'b1) begin \ `uvmkit_error_msg_fmt("uvmkit_check_not_equals_string", $sformatf("Expected strings to be different, but both are:\n \"%s\"", _a_str), msg) \ end \ From f42c734c28030e3fc61cebf6846b50dbe2f0e2af Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 19 Nov 2025 09:47:22 +0000 Subject: [PATCH 5/5] Remove uvmkit_check.sv changes - keep only examples This PR should only contain the example files, not modifications to the core uvmkit_check.sv library. Reverting those changes. --- src/uvmkit_check.sv | 49 --------------------------------------------- 1 file changed, 49 deletions(-) diff --git a/src/uvmkit_check.sv b/src/uvmkit_check.sv index ca6da4b..ae204f3 100644 --- a/src/uvmkit_check.sv +++ b/src/uvmkit_check.sv @@ -139,55 +139,6 @@ end \ end -`define uvmkit_check_equals_enum(enum_t, expected, actual, msg="") \ - begin \ - enum_t _expected; \ - enum_t _actual; \ - _expected = expected; \ - _actual = actual; \ - if (_expected !== _actual) begin \ - `uvmkit_error_msg_fmt("uvmkit_check_equals_enum", $sformatf("Expected '%s' to equal '%s', but %s !== %s", `"expected`", `"actual`", _expected.name(), _actual.name()), msg) \ - end \ - end - -`define uvmkit_check_not_equals_enum(enum_t, expected, actual, msg="") \ - begin \ - enum_t _expected; \ - enum_t _actual; \ - _expected = expected; \ - _actual = actual; \ - if (_expected === _actual) begin \ - `uvmkit_error_msg_fmt("uvmkit_check_not_equals_enum", $sformatf("Expected '%s' to not equal '%s', but both are %s", `"expected`", `"actual`", _expected.name()), msg) \ - end \ - end - - -// String-specific comparison macros (work with all simulators including Verilator) -`define uvmkit_check_equals_string(a, b, msg="") \ - begin \ - string _a_str; \ - string _b_str; \ - automatic logic _exp_result; \ - _a_str = (a); \ - _b_str = (b); \ - _exp_result = _a_str == _b_str; \ - if (_exp_result !== 1'b1) begin \ - `uvmkit_error_msg_fmt("uvmkit_check_equals_string", $sformatf("Expected strings to be equal:\n Expected: \"%s\"\n Actual: \"%s\"", _a_str, _b_str), msg) \ - end \ - end - -`define uvmkit_check_not_equals_string(a, b, msg="") \ - begin \ - string _a_str; \ - string _b_str; \ - automatic logic _exp_result; \ - _a_str = (a); \ - _b_str = (b); \ - _exp_result = _a_str != _b_str; \ - if (_exp_result !== 1'b1) begin \ - `uvmkit_error_msg_fmt("uvmkit_check_not_equals_string", $sformatf("Expected strings to be different, but both are:\n \"%s\"", _a_str), msg) \ - end \ - end // String-specific comparison macros (work with all simulators including Verilator) `define uvmkit_check_equals_string(a, b, msg="") \