--- Quote Start ---
take this example:
A = 1111101
B = 1111111
y = 0
count = 0 , A(0) = '1' hence result of A(0) *B = B (1111111), I called it temp
update sum: y = y+temp;
count <= count + 1;
count = 1 , A(1) = '0' hence result of A(1) *B = 0, I called it temp
update sum: y = y+temp&'0'; --shift temp by one bit
count <= count + 1;
count = 2 , A(2) = '1' hence result of A(2) *B = B, I called it temp
update sum: y = y+temp&'00'; --shift temp by two bits
count <= count + 1;
...
--- Quote End ---
I've been working in this project and I've get this:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.std_logic_unsigned.all;
use IEEE.numeric_std.all;
entity prueba2 is
port (
A : in std_logic_vector (7 downto 0);
B : in std_logic_vector (7 downto 0);
inicio : in std_logic;
clk : in std_logic;
reset: in std_logic;
q : out std_logic_vector (2 downto 0);
resultado : out std_logic_vector (15 downto 0)
);
end prueba2;
architecture behavioral of prueba2 is
begin
multi : process (A, clk, reset)
variable y : std_logic_vector (15 downto 0);
variable cuenta : std_logic_vector (2 downto 0);
variable temp : std_logic_vector (7 downto 0);
begin
if reset = '1' then y:= "0000000000000000";
else
if clk'event and clk = '1' and inicio = '1' then
cuenta := cuenta + 1;
end if;
q <= cuenta;
end if;
case cuenta is
when "000" =>
if A(0) = '1' then
temp := B;
else
temp := "00000000";
end if;
y := y + temp;
when "001" =>
if A(1) = '1' then
temp := B;
else
temp := "00000000";
end if;
y := y + temp&"0";
when "010" =>
if A(2) = '1' then
temp := B;
else
temp := "00000000";
end if;
y := y + temp&"00";
when "011" =>
if A(3) = '1' then
temp := B;
else
temp := "00000000";
end if;
y := y + temp&"000";
when "100" =>
if A(4) = '1' then
temp := B;
else
temp := "00000000";
end if;
y := y + temp&"0000";
when "101" =>
if A(5) = '1' then
temp := B;
else
temp := "00000000";
end if;
y := y + temp&"00000";
when "110" =>
if A(6) = '1' then
temp := B;
else
temp := "00000000";
end if;
y := y + temp&"000000";
when "111" =>
if A(7) = '1' then
temp := B;
else
temp := "00000000";
end if;
y := y + temp&"0000000";
end case;
resultado <= y;
end process;
end behavioral;
-------------------------------------------
But there is an error when I do y := y + temp&"0"; because expression has 17 elements, but must have 16 elements.
How can I correct this?