nageshnaik
Newbie level 2
- Joined
- Mar 23, 2014
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 33
i want to make a loop that repeats itself a variable number of times according to the input. i have worked out a code for it. This code compiles well but a output i get zero as answer. Can anyone help me rectify this issue.
i am giving both the uut and tb. Please help me rectify the issue.
UUT:
Testbench:
Thank you in advance.
i am giving both the uut and tb. Please help me rectify the issue.
UUT:
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; use ieee.numeric_std.all; entity loopagain is Port ( a : in STD_LOGIC_VECTOR (15 downto 0); b : in STD_LOGIC_VECTOR (15 downto 0); y : out STD_LOGIC_VECTOR (15 downto 0)); end loopagain; architecture Behavioral of loopagain is signal sh1 :std_logic_vector(15 downto 0) := (others => '0'); signal s1 : bit_vector(15 downto 0); signal k : bit_vector(15 downto 0); signal lp : std_logic_vector(15 downto 0) := (others => '0'); begin process (a,b) begin lp <= b; s1 <= TO_BITVECTOR(a); while (lp > 0) loop k <= s1 sll 1; s1 <= k; lp <= lp - "0000000000000001"; end loop; sh1 <= to_stdlogicvector(k) ; y <= sh1; end process; end Behavioral;
Testbench:
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 LIBRARY ieee; USE ieee.std_logic_1164.ALL; USE ieee.std_logic_unsigned.all; USE ieee.numeric_std.ALL; ENTITY loopagaintb IS END loopagaintb; ARCHITECTURE behavior OF loopagaintb IS -- Component Declaration for the Unit Under Test (UUT) COMPONENT loopagain PORT( a : IN std_logic_vector(15 downto 0); b : IN std_logic_vector(15 downto 0); y : OUT std_logic_vector(15 downto 0) ); END COMPONENT; --Inputs signal a : std_logic_vector(15 downto 0) := (others => '0'); signal b : std_logic_vector(15 downto 0) := (others => '0'); --Outputs signal y : std_logic_vector(15 downto 0); BEGIN -- Instantiate the Unit Under Test (UUT) uut: loopagain PORT MAP ( a => a, b => b, y => y ); -- No clocks detected in port list. Replace <clock> below with -- appropriate port name -- Stimulus process stim_proc: process begin -- hold reset state for 100ms. wait for 100ns; a <= "0000000000000011"; b <= "0000000000000001"; -- insert stimulus here wait; end process; END;
Thank you in advance.
Last edited by a moderator: