How to do this in the VHDL testbench

Status
Not open for further replies.

pastro

Junior Member level 3
Joined
Aug 20, 2010
Messages
25
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,538
Hello,

I need to write a VHDL testbench for simulating an FPGA circuit. In the testbench, I want to make an 8 bit waveform (called TB_COUNT) start counting up from zero at 120 ns, and increment by 1 count every 40 ns.

In the past, I've written something like what follows, where TB_COUNT is defined:
signal TB_COUNT : std_logic_vector (7 downto 0) := "00000000";

TB_COUNT <= "00000000" after 120 ns,
"00000001" after 160 ns,
etc


However, I need TB_COUNT to increment 1000x's, so this brute force approach is impractical. So, how do I perform this task elegantly?
 

You can use something like

Code:
  process 
    begin
     wait for 120 ns;
     for i in 0 to 1000000 loop  
     -- loop      -- you can also use this without the loop counter
      TB_COUNT <=TB_COUNT+1;
      wait for 40 ns;     
     end loop;
     wait;   
    end process;

Alex
 
Last edited:
Reactions: pastro

    pastro

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…