@@ -31,7 +31,7 @@ architecture Behavioral of GammaCPU is
3131 port (
3232 a : in std_logic_vector (31 downto 0 ); -- Operand A.
3333 b : in std_logic_vector (31 downto 0 ); -- Operand B.
34- op : in std_logic_vector ( 3 downto 0 ); -- Operation code.
34+ op : in unsigned ( 15 downto 0 ); -- Operation code.
3535 result : out std_logic_vector (31 downto 0 ); -- Result of the operation.
3636 reset : in std_logic ; -- Active high reset.
3737 enable : in std_logic ; -- Active high to perform the operation.
@@ -58,7 +58,7 @@ architecture Behavioral of GammaCPU is
5858 signal alu_result : std_logic_vector (31 downto 0 ) := (others => '0' );
5959
6060 -- ALU inputs and outputs
61- signal alu_op : std_logic_vector ( 3 downto 0 );
61+ signal alu_op : unsigned ( 15 downto 0 );
6262 signal alu_a, alu_b : std_logic_vector (31 downto 0 );
6363 signal alu_enable : std_logic ;
6464
@@ -125,49 +125,49 @@ begin
125125 state <= StackOperation;
126126
127127 when x"6A" => -- i32.add
128- alu_op <= "0000" ; -- ADD
128+ alu_op <= to_unsigned ( 0 , 16 ); -- ADD
129129 state <= Execute;
130130
131131 when x"6B" => -- i32.sub
132- alu_op <= "0001" ; -- SUB
132+ alu_op <= to_unsigned ( 1 , 16 ) ; -- SUB
133133 state <= Execute;
134134
135135 when x"6C" => -- i32.mul
136- alu_op <= "0010" ; -- MUL
136+ alu_op <= to_unsigned ( 2 , 16 ) ; -- MUL
137137 state <= Execute;
138138
139139 when x"6D" => -- i32.div_s
140- alu_op <= "0011" ; -- DIV
140+ alu_op <= to_unsigned ( 3 , 16 ) ; -- DIV
141141 state <= Execute;
142142
143143 -- Comparisions
144144 when x"45" => -- i32.eqz
145- alu_op <= "0100" ; -- Equal to zero
145+ alu_op <= to_unsigned ( 4 , 16 ) ; -- Equal to zero
146146 only_first_stack <= '1' ;
147147 state <= Execute;
148148
149149 when x"46" => -- i32.eq
150- alu_op <= "0100" ; -- Equal
150+ alu_op <= to_unsigned ( 5 , 16 ) ; -- Equal
151151 state <= Execute;
152152
153153 when x"47" => -- i32.ne
154- alu_op <= "0101" ; -- Not Equal
154+ alu_op <= to_unsigned ( 6 , 16 ) ; -- Not Equal
155155 state <= Execute;
156156
157157 when x"4b" => -- i32.gt_s
158- alu_op <= "0110" ; -- Greater than
158+ alu_op <= to_unsigned ( 7 , 16 ) ; -- Greater than
159159 state <= Execute;
160160
161161 when x"48" => -- i32.lt_s
162- alu_op <= "0111" ; -- Less than
162+ alu_op <= to_unsigned ( 8 , 16 ) ; -- Less than
163163 state <= Execute;
164164
165165 when x"4e" => -- i32.ge_s
166- alu_op <= "1000" ; -- Greater than or equal
166+ alu_op <= to_unsigned ( 9 , 16 ) ; -- Greater than or equal
167167 state <= Execute;
168168
169169 when x"4C" => -- i32.le_s
170- alu_op <= "1001" ; -- Less than or equal
170+ alu_op <= to_unsigned ( 10 , 16 ) ; -- Less than or equal
171171 state <= Execute;
172172
173173 when others =>
0 commit comments