Hi,
I played a bit with your algorithm and realised your output is serial.
Here is the code that corresponds to your algorithm. It worked as far as I tested but check various values of the range 0_15 on both A,B inputs.
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity mult1 is
port(
load : in std_logic;
clk : in std_logic;
A : in std_logic_vector(3 downto 0);
B : in std_logic_vector(3 downto 0);
ready : out std_logic;
R : out std_logic
);
end entity;
architecture rtl of mult1 is
signal shift_reg1 : std_logic_vector(3 downto 0) := "0000";
signal shift_reg2 : std_logic_vector(7 downto 0) := x"00";
signal reg1 : std_logic_vector(7 downto 0);
signal opA : std_logic_vector(3 downto 0);
signal count : integer range 0 to 7 := 0;
begin
R <= shift_reg2(0);
ready <= '1' when count = 5 else '0';
reg1(7 downto 3) <= std_logic_vector(resize(unsigned(OpA),5) + unsigned(shift_reg2(7 downto 4)));
reg1(2 downto 0) <= shift_reg2(3 downto 1);
process(load,clk)
begin
if load = '1' then
count <= 0;
shift_reg1 <= A; -- load input A into shift register
elsif rising_edge(clk) then
if count < 7 then
count <= count + 1;
end if;
shift_reg1 <= '0' & shift_reg1(3 downto 1); -- shift right
shift_reg2 <= reg1;
if shift_reg1(0) = '1' then
OpA <= B;
else
OpA <= "0000";
end if;
end if;
end process;
end rtl;