EmbDev.net

Forum: FPGA, VHDL & Verilog vhdl test bench


von Rockyy S. (rockyy)


Attached files:

Rate this post
useful
not useful
1
 library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
4
entity test1 is
5
    Port ( clk : in  STD_LOGIC;
6
           input1 : in  STD_LOGIC;
7
           input2 : in  STD_LOGIC;
8
           output : out  STD_LOGIC);
9
end test1;
10
11
architecture Behavioral of test1 is
12
  process(clk)
13
begin
14
      if (clk'event and clk='1') then
15
        output <= input1 and input2;
16
        end if;
17
end process;
18
19
end Behavioral;

For the above Program I have created a VHDL test bench like below
1
LIBRARY ieee;
2
USE ieee.std_logic_1164.ALL;
3
 
4
-- Uncomment the following library declaration if using
5
-- arithmetic functions with Signed or Unsigned values
6
--USE ieee.numeric_std.ALL;
7
 
8
ENTITY test IS
9
END test;
10
 
11
ARCHITECTURE behavior OF test IS 
12
 
13
    -- Component Declaration for the Unit Under Test (UUT)
14
 
15
    COMPONENT test1
16
    PORT(
17
         clk : IN  std_logic;
18
         input1 : IN  std_logic;
19
         input2 : IN  std_logic;
20
         output : OUT  std_logic
21
        );
22
    END COMPONENT;
23
    
24
25
   --Inputs
26
   signal clk : std_logic := '0';
27
   signal input1 : std_logic := '0';
28
   signal input2 : std_logic := '0';
29
30
     --Outputs
31
   signal output : std_logic;
32
33
   -- Clock period definitions
34
   constant clk_period : time := 1 ns;
35
 
36
BEGIN
37
 
38
    -- Instantiate the Unit Under Test (UUT)
39
   uut: test1 PORT MAP (
40
          clk => clk,
41
          input1 => input1,
42
          input2 => input2,
43
          output => output
44
        );
45
46
   -- Clock process definitions
47
   clk_process :process
48
   begin
49
        clk <= '0';
50
        wait for clk_period/2;
51
        clk <= '1';
52
        wait for clk_period/2;
53
   end process;
54
 
55
56
   -- Stimulus process
57
   stim_proc: process
58
   begin        
59
      -- hold reset state for 100 ns.
60
      wait for 10 ns;     
61
        input1 <= '0';
62
        input2 <= '0';
63
        
64
        wait for 20 ns;
65
        input1 <= '0';
66
        input2 <= '1';
67
        
68
        wait for 30 ns;
69
        input1 <= '1';
70
        input2 <= '0';
71
        
72
        wait for 40 ns;
73
        input1 <= '1';
74
        input2 <= '1';
75
76
    
77
   end process;
78
79
END;

but after simulating the behavioural Model i am getting the value of
clk = U
input1 = U
input2 = U
output = U

I am very new to VHDL,Can any one let me know why I am getting U as 
value and not getting the Signal.Check the attach file for the output.

von Bitflüsterer (Guest)


Rate this post
useful
not useful
Declare your testbench, i.e. entity "test" as top level. Not "test1", 
which is the DUT (device under test) itself.
Another possibility is, that you marked the test1 entity when starting 
the simulator. Mark the testbench test instead, when starting 
simulation.

von Rockyy S. (rockyy)


Rate this post
useful
not useful
Thanks for the information its working

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.