diff options
| author | uvok | 2026-01-02 19:36:30 +0100 |
|---|---|---|
| committer | uvok | 2026-01-02 19:36:30 +0100 |
| commit | 6c1db8cded8b8bb1c4d31a840f7dd9dddb8bbf7d (patch) | |
| tree | e8bb18228b55baf35dd540cd6e607857e9ecbaef /nandgame/arith_unit.sv | |
| parent | e49b8a787f72daa3d08e278a9c32663c16531827 (diff) | |
Rename variables to be more clear, document
Diffstat (limited to 'nandgame/arith_unit.sv')
| -rw-r--r-- | nandgame/arith_unit.sv | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/nandgame/arith_unit.sv b/nandgame/arith_unit.sv index e0254aa..53ea17e 100644 --- a/nandgame/arith_unit.sv +++ b/nandgame/arith_unit.sv @@ -10,20 +10,24 @@ module arith_unit #( parameter DATA_WIDTH = 16 ) ( - input [(DATA_WIDTH-1):0] X, - input [(DATA_WIDTH-1):0] Y, - input ArithCode operation, - - output logic [(DATA_WIDTH-1):0] RES + // first operand + input [(DATA_WIDTH-1):0] X_in, + // second operand + input [(DATA_WIDTH-1):0] Y_in, + // opcode, see ArithCode + input ArithCode arith_operation_in, + + // result of operation + output logic [(DATA_WIDTH-1):0] result_out ); always_comb begin - case (operation) - ARITH_PLUS: RES = X + Y; - ARITH_MINUS: RES = X - Y; - ARITH_INC: RES = X + 1; - ARITH_DEC: RES = X - 1; - default: RES = 0; + case (arith_operation_in) + ARITH_PLUS: result_out = X_in + Y_in; + ARITH_MINUS: result_out = X_in - Y_in; + ARITH_INC: result_out = X_in + 1; + ARITH_DEC: result_out = X_in - 1; + default: result_out = 0; endcase end |
