I am new in VHDL. I wrote a code of decrement counter in which counter picks integer from the array and counts it down to zero and increments the check output. I want you guys to verify if the code is logically correct. If yes then how can i test it using the test bench.
Why would you expect someone else to do your work? You can obviously write VHDL code, a testbench is simply more VHDL code. What exactly do you need help with in writing? All you do in the testbench is
- Instantiate your entity that is to be tested
- Write models for each of the input signals
- Write code that checks the outputs
In a testbench you are not constrained by synthesis rules so you are free to write things like this...
...
wait until rising_edge(clk);
assert check = '0' report "OOPS! Check is not correct" severity ERROR;
wait until rising_edge(clk);
wait until rising_edge(clk);
wait until rising_edge(clk);
assert check = '1' report "OOPS! Check is not correct" severity ERROR;
wait; -- All done, wait forever
...
You'll also want to break up your 'if' statement. For synthesizable code the if needs to be looking for nothing more than simply the rising (or falling...but not both) edge of the clock. Any other checking needs to be embedded within another if statement like this...
...
Code:
if rising_edge(clk) then
if (a > 5) then
...
end if;
end if;
Kevin Jennings