Skip to content

Commit

Permalink
Wrap exp with parentheses in macros
Browse files Browse the repository at this point in the history
This change ensures correct operator precedence in assertions to prevent logical errors caused by missing parentheses.
  • Loading branch information
ping-ee committed Sep 23, 2024
1 parent d2b4d62 commit f9e5007
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions svut/svut_h.sv
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ endfunction
`define FAIL_IF_NOT(exp, message="") \
svut_status = 0; \
svut_msg = create_msg("FAIL_IF_NOT", message); \
if (!exp) begin \
if (!(exp)) begin \
`ERROR(svut_msg); \
svut_status = 1; \
end
Expand All @@ -156,7 +156,7 @@ endfunction
`define ASSERT(exp, message="") \
svut_status = 0; \
svut_msg = create_msg("ASSERT", message); \
if (!exp) begin \
if (!(exp)) begin \
`ERROR(svut_msg); \
svut_status = 1; \
end
Expand Down
2 changes: 1 addition & 1 deletion svut/template.sv
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ${module_inst}
// - `FAIL_IF_EQUAL(aSignal, 23): Increment error counter if evaluation is equal
// - `FAIL_IF_NOT_EQUAL(aSignal, 45): Increment error counter if evaluation is not equal
// - `ASSERT(aSignal): Increment error counter if evaluation is not true
// - `ASSERT((aSignal == 0)): Increment error counter if evaluation is not true
// - `ASSERT(aSignal == 0): Increment error counter if evaluation is not true
//
// Available flag:
//
Expand Down

0 comments on commit f9e5007

Please sign in to comment.