From 6c1db8cded8b8bb1c4d31a840f7dd9dddb8bbf7d Mon Sep 17 00:00:00 2001 From: uvok Date: Fri, 2 Jan 2026 19:36:30 +0100 Subject: Rename variables to be more clear, document --- nandgame/arith_unit.sv | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'nandgame/arith_unit.sv') 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 -- cgit v1.2.3