Verification Guild
A Community of Verification Professionals

 Create an AccountHome | Calendar | Downloads | FAQ | Links | Site Admin | Your Account  

Login
Nickname

Password

Security Code: Security Code
Type Security Code
BACKWARD

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Modules
· Home
· Downloads
· FAQ
· Feedback
· Recommend Us
· Web Links
· Your Account

Advertising

Who's Online
There are currently, 47 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here

  
Verification Guild: Forums

 Forum FAQForum FAQ   SearchSearch   UsergroupsUsergroups   ProfileProfile  ProfileDigest    Log inLog in 

Common testbench mistakes in VHDL

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Verification Guild Forum Index -> Miscellaneous
View previous topic :: View next topic  
Author Message
Newsletter
Original Contribution


Joined: Dec 08, 2003
Posts: 1107

PostPosted: Mon Mar 20, 2000 12:00 am    Post subject: Common testbench mistakes in VHDL Reply with quote

(Originally from Issue 1.5, Item 6.0)

From: Ben Cohen Send e-mail

I thought I would share some common TB mistakes and solutions, to help
others, and to hear form others about their experiences. Janick, those
were also discussed in your Writing TB book.

As a VHDL consultant, I recently found the following errors that
caused the test engineer hours of frustration for the unexplainable
errors he was getting.

1. Mishandling of clock definition. Specifically, in a 50 MHz (20 ns
period design clocked ASIC, a derived 25 MHz signal is used in the
design as an enable signal.

The following is ERRONEOUS code defined in the TB:

Clk50_Proc: process
begin
Clk50 <= '0';
wait for 10 ns;
Clk 50 <= '1';
wait for 10 ns;
end process Clk50_Proc;

Clk25_Proc: process -- BAD code for a derived clock !!!
begin
Clk25 <= '0';
wait for 20 ns;
Clk 25 <= '1';
wait for 20 ns;
end process Clk25_Proc;

The problem here is that the 25 MHz clock is not modeled as a derived clock,
like the real system. Solution:

signal Clk50 : std_logic := '1'; -- to start at '1' for a full cycle
signal Clk25 : std_logic := '1';
...
Clk50 <= not Clk50 after 10 ns; -- concurrent signal assignment

Clk25_Proc: process -- derived clock
begin
wait until Clk50 = '1';
Clk25 <= not Clk25 after 1 ns;
-- 'after' not really needed, but
-- emphasizes that this is a derived signal.
-- Also helps in debug
end process Clk25_Proc;

2. Mishandling of assignments of stimulus vectors

-- BAD design. Data changes at same edge as rising edge of clock.
-- No setup time -- will cause all kinds of errors!!!!
XY_Proc: process
begin
wait for 40 ns;
Data <= "1010";
wait for 100 ns;
DATA <= "0000";
--....
end process XY_Proc;

SOLUTION: Make assignments synchronous to the clock.

-- in declaration section or in a package:
procedure WaitNclk(Signal Clk : Std_Logic;
constant NumbClk : Positive) is
begin
for I in 1 to NumbClk loop
wait until Clk = '1';
end loop
end WaitNClk;
-- ....
-- In TB architecture
XY_Proc: process
begin
WaitNClk(Clk50, 40 ns/20 ns);
Data <= "1010" after 1 ns; -- after is optional, but preferred
WaitNClk(Clk50, 5); -- wait for 100 ns;
DATA <= "0000"; -- no after shown here
--....
end process XY_Proc;
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Verification Guild Forum Index -> Miscellaneous All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Verification Guild © 2006 Janick Bergeron
Web site engine's code is Copyright © 2003 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.085 Seconds