Cutey
Member level 2
Hi people
how to calculate X^y in VHDL, actually i have a program in vhdl to multiply two number using shift adder and I want to modify it to power of y.
here is my code multiply m by n, and I need to insert loop operation to work as multiply m by m for n time.....
rchitecture Behavioral of MUL is
signal count:integer:= 0;
signal n1,m1,nn:std_logic_vector(31 downto 0);
signal result1:std_logic_vector(63 downto 0);
begin
process(clk)
begin
if (rising_edge(clk))then
if( start = '1' )then
result<="0000000000000000000000000000000000000000000000000000000000000000";
result1<="0000000000000000000000000000000000000000000000000000000000000000";
count <=0;
else
if (count /= 32 )then
if (m1(0)='1')then
result1<=result1+n1;
end if ;
n1 <=n1(30 downto 0) & '0';
m1 <='0'& m1 (31 downto 1);
count <=count+1;
end if ;
end if;
end if ;
-- end loop;
result<=result1;
how to calculate X^y in VHDL, actually i have a program in vhdl to multiply two number using shift adder and I want to modify it to power of y.
here is my code multiply m by n, and I need to insert loop operation to work as multiply m by m for n time.....
rchitecture Behavioral of MUL is
signal count:integer:= 0;
signal n1,m1,nn:std_logic_vector(31 downto 0);
signal result1:std_logic_vector(63 downto 0);
begin
process(clk)
begin
if (rising_edge(clk))then
if( start = '1' )then
result<="0000000000000000000000000000000000000000000000000000000000000000";
result1<="0000000000000000000000000000000000000000000000000000000000000000";
count <=0;
else
if (count /= 32 )then
if (m1(0)='1')then
result1<=result1+n1;
end if ;
n1 <=n1(30 downto 0) & '0';
m1 <='0'& m1 (31 downto 1);
count <=count+1;
end if ;
end if;
end if ;
-- end loop;
result<=result1;
Last edited: