Spiz
Newbie level 4
Hello!
I'm sorry if I'm posting a question with a rather simple solution, but I have looked everywhere and I couldn't find a solution to my problem.
We had to design a 4-bit ALU module (without usage of process block) and I guess I managed to get most of it right.
However whenever I try to synthetize my module, I get following error message:
Width mismatch, location has width 4, value 8
and it leads me to the line with multiplication, which basically means I don't know how to make Z width have value 8 while my ALU is multiplying and have value 4 when performing other operations.
I am hoping someone might have a solution to that.
Below is my ALU code:
I'm sorry if I'm posting a question with a rather simple solution, but I have looked everywhere and I couldn't find a solution to my problem.
We had to design a 4-bit ALU module (without usage of process block) and I guess I managed to get most of it right.
However whenever I try to synthetize my module, I get following error message:
Width mismatch, location has width 4, value 8
and it leads me to the line with multiplication, which basically means I don't know how to make Z width have value 8 while my ALU is multiplying and have value 4 when performing other operations.
I am hoping someone might have a solution to that.
Below is my ALU code:
Code:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
use ieee.numeric_std.all;
entity ALU is
generic (
C_data_width: integer := 4
);
port
(
A, B: in std_logic_vector((C_data_width - 1) downto 0);
ALUOp: in std_logic_vector(2 downto 0);
Z: out std_logic_vector((C_data_width - 1) downto 0)
);
end ALU;
architecture beh of ALU is
signal R_A, R_B: std_logic_vector((C_data_width - 1) downto 0);
signal R_ALUOp: std_logic_vector(2 downto 0);
signal R_Z: std_logic_vector((C_data_width - 1) downto 0);
begin
Z <=
A * B when (ALUOp = "000") else --MUL
A + B when (ALUOp = "001") else --ADD
A nor B when (ALUOp = "010") else --NOR
A xor B when (ALUOp = "011") else --XOR
A and B when (ALUOp = "100") else --AND
A - B when (ALUOp = "101") else --SUB
shr(A,B) when (ALUOp = "110") else --SLR
A or B when (ALUOp = "111"); --OR
end beh;