diff options
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 |
