diff options
| author | uvok | 2026-01-11 20:02:40 +0100 |
|---|---|---|
| committer | uvok | 2026-01-11 20:02:40 +0100 |
| commit | 6632a01b75610edcd54299e97f8edbe7ff86b010 (patch) | |
| tree | 7f9cd1dca06de04ad6d62866f9efaa6fa8531545 /nandgame/hack_alu.sv | |
| parent | 682a0409dd7c6c372945b0f4e5f366d3ded907e8 (diff) | |
fix alu: bit negate
Diffstat (limited to 'nandgame/hack_alu.sv')
| -rw-r--r-- | nandgame/hack_alu.sv | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/nandgame/hack_alu.sv b/nandgame/hack_alu.sv index 267b4a7..6d66a08 100644 --- a/nandgame/hack_alu.sv +++ b/nandgame/hack_alu.sv @@ -42,12 +42,13 @@ logic [(DATA_WIDTH-1):0] x1, x2, y1, y2, res1, res2 /* verilator public */; // logic [(DATA_WIDTH-1):0] int_result_arith; // logic [(DATA_WIDTH-1):0] int_result_logic; +// bit-wise negation assign x1 = zx ? 0 : X_in; assign y1 = zy ? 0 : Y_in; -assign x2 = nx ? -x1 : x1; -assign y2 = ny ? -y1 : y1; +assign x2 = nx ? ~x1 : x1; +assign y2 = ny ? ~y1 : y1; assign res1 = f_arith_nlogic_in ? (x2 + y2) : (x2 & y2); -assign res2 = neg_out ? -res1 : res1; +assign res2 = neg_out ? ~res1 : res1; assign result_out = res2; assign zero_out = result_out == 0; assign negate_out = result_out[DATA_WIDTH-1] == 1; |
