i know about shifting and also can make it by concatination using & ..but how can we know the variables as an example we have a and b so how we know that a need 2 shift and so... i need the algorithm for it
i programmed the fllowing code it is crrect but get wrong result
the fllowing code is shif multiplying
please if any one can tell me it get wrong result?
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity MUL is
Port ( clk : in STD_LOGIC;
-- i:in integer:=1;
result : out STD_LOGIC_vector(15 downto 0);
m : in STD_LOGIC_vector(7 downto 0);
n : in STD_LOGIC_vector(7 downto 0);
start:in std_logic);
end MUL;
architecture Behavioral of MUL is
signal count:integer:= 0;
signal n1,m1:std_logic_vector(7 downto 0);
signal result1:std_logic_vector(15 downto 0);
begin
process(clk)
begin
m1<=m;
n1<=n;
--result<=result1;
if (rising_edge(clk))then
if( start = '1' )then
result<="0000000000000000";
count <=0;
else
if (count /= 8 )then
if (m1(0)='1')then
result<=result1+n;
end if ;
n1 <=n(6 downto 0) & '0';
m1 <='0'& m (7 downto 1);
count <=count+1;
end if ;
end if;
end if ;
end process ;
entity division is
port ( a : in integer range 0 to 255;
b : in integer range 0 to 17;
quo : out integer range 0 to 17);
end division;
architecture structure of division is
begin
process(a,b)
variable var : integer range 0 to 255;
variable count,i : integer range 0 to 127;
begin
i:=0; var:=a;count:=0;
for i in 127 downto 0 loop
if (var>=b) then var :=var-b;count:=count+1;
else
quo<=count;exit;
end if;
end loop;
end process;
end structure;
entity division is
port ( a : in integer range 0 to 255;
b : in integer range 0 to 17;
quo : out integer range 0 to 17);
end division;
architecture structure of division is
begin
process(a,b)
begin
quo <= a / b;
end process;
entity division is
port ( a : In integer range 0 to 255;
b : In integer range 0 to 17;
quo : Out integer range 0 to 17);
end division;
architecture structure of division is
begin
process(a,b)
begin
quo <= a / b;
end process;