sarjumaharaj
Junior Member level 1
- Joined
- Mar 2, 2014
- Messages
- 16
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 148
hey,
I'm designing shift and add multiplier using controller datapath method. Here is the design of the circuit Shift And ADD DESIGN. I'm Making the Q from the design. Basically it's a register which stores the multiplier and shifts the value to the right when a value from product is shifted through the datapath.
I made the design in vhdl and it seems to be working but there is a slight problem. In the tb each clock cycle i made of 100 ns. So within the hunderd nanosecond the product does over 20 shifts due to which my value of multiplier (value stored in Q) becomes erroneous.
I tried adding the shift in the process so each time the value of shift is changed the process is initiated but still the output constantly changes over the period of 100ns and becomes wrong. Does any one know how to fix it.
Here is the code:
TEST BENCH INPUT
I'm designing shift and add multiplier using controller datapath method. Here is the design of the circuit Shift And ADD DESIGN. I'm Making the Q from the design. Basically it's a register which stores the multiplier and shifts the value to the right when a value from product is shifted through the datapath.
I made the design in vhdl and it seems to be working but there is a slight problem. In the tb each clock cycle i made of 100 ns. So within the hunderd nanosecond the product does over 20 shifts due to which my value of multiplier (value stored in Q) becomes erroneous.
I tried adding the shift in the process so each time the value of shift is changed the process is initiated but still the output constantly changes over the period of 100ns and becomes wrong. Does any one know how to fix it.
Here is the code:
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity q_multiplier is
port ( a0 , clk, shift , ini : in std_logic ;
mul: in std_logic_vector ( 4 downto 1);
q0 : out std_logic ;
temp_out : out std_logic_vector (4 downto 1)
);
end q_multiplier ;
architecture Behavioral of q_multiplier is
signal temp : std_logic_vector (4 downto 1);
signal temp_ini : std_logic ;
signal temp_shift : std_logic ;
begin
process (clk ,shift ,ini)
begin
temp_ini <= ini ;
temp_shift <= shift ;
if (clk = '1' and rising_edge(clk)) then
if ( temp_ini = '1') then
temp <= mul;
end if ;
if ( temp_shift = '1' ) then
for i in 3 downto 1 loop
temp(4-i) <= temp(5- i);
end loop ;
temp(4) <= a0;
end if ;
temp_out <= temp;
q0 <= temp(4);
end if ;
end process ;
end Behavioral;
--
TEST BENCH INPUT
Code:
wait for 100 ns;
a0 <= '1';
shift <='0';
ini <= '1' ;
mul<= "1010";
wait for 100 ns;
a0 <= '1';
shift <='1';
ini <= '0' ;
mul<= "1010";
wait for 100 ns;
a0 <= '1';
shift <='0';
Here are 2 pictures of the waverform. Second one is just zoomed in
[ATTACH=CONFIG]103037._xfImport[/ATTACH][ATTACH=CONFIG]103038._xfImport[/ATTACH]