VHDL testbench

Guest #2005657
Hello experts,

I am stuck in doing a VHDL testbench. My VHDL code works just fine, but 
the problem now is that I cannot make the right testbench.

* the first problem is the clock, I made two seperated processes, one 
for clock and the other one for setting different valuse for the input.
The clock process does not work !! the simulation does not show any 
change in the clock signal.

* Same problem for reset, I put the reset signal in the second process, 
and it doesn't work propely.

* regarding setting the values, for the input I used for loop as follows

for j in 0 to 7 loop
       X(i) <= '1' ;
       wait for 10 ns;
 end loop;

and this also doesn't work properly.

any help is truley appreciated.
Guest #2005708
1
 for j in 0 to 7 loop
2
       X(i) <= '1' ;     --- should this be a X(j) or am I missing some code?
3
       wait for 10 ns;
4
 end loop;

> any help is truley appreciated.
Pls show your code...

> The clock process does not work !! the simulation does not show any
> change in the clock signal.
Do you simulate the testbench or your VHDL-Module?
Guest #2246480
Okay I can't help you with a book I only know german vhdl books but this 
link seems to be good:
http://www.seas.upenn.edu/~ese171/vhdl/vhdl_primer.html

And for your problem with the clock an reset signal. When I write a 
Testbench I do it like this:
1
ARCHITECTURE DUT_tb_BEHAV OF DUT_tb IS
2

3
CONSTANT PERIOD  : TIME := 500ns;  -- initiate the time value for the system clock
4

5
BEGIN
6

7
  -- Creating the system clock cycles
8
  PROCESS 
9
  BEGIN
10
    clock <= '0'; WAIT FOR PERIOD/2;
11
    clock <= '1'; WAIT FOR PERIOD/2;
12
  END PROCESS;
13

14
  -- Creating the asynchronous clear signal
15
  PROCESS
16
  BEGIN
17
    resetn <= '0'; WAIT FOR PERIOD*2;
18
    resetn <= '1'; WAIT;
19
  END PROCESS;
20

21
END ARCHITECTURE;

Greetings Phil
Guest #2246544
I use the following one-liners for signal generation:
1
    constant tb_clk_period     : time := (1 sec / 50_000_000);
2

3
    signal   tb_CLK            : std_logic := '0';
4
    signal   tb_RESET          : std_logic;
5

6
[...]
7

8
    tb_CLK   <= not tb_CLK after tb_clk_period / 2;
9
    tb_RESET <= '1', '0'   after 10 * tb_clk_period;

Duke
Guest #2246778
Hi QTX,

"tb_CLK   <= not tb_CLK after tb_clk_period / 2;" will not generate a 
periodic clock, it'll generate a rising edge after tb_clk_period / 2.

Use a Process instead and it'll work.
Guest #2246802
@wollibk:
> "tb_CLK   <= not tb_CLK after tb_clk_period / 2;" will not generate a
> periodic clock, it'll generate a rising edge after tb_clk_period / 2.
Check at your simulator first, before post nonsense...

Duke
Moderator (Company: Titel) #2724478
Pls. do not attach your question to any old thread. Instead start a new 
thread with your question...

And then show what you have, and ask a specific question concerning your 
problem. This forum here is not for stupidly solving homework...

Reply

A question of your own? This thread is over 15 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.