Unit 1g

Testing the ALU

VHDL Test Benches

As an alternative to creating long macro files for complicated simulations and wading through wave outputs that can become difficult to read, VHDL offers an alternative method of driving and verifying your simulation: the Test Bench. A VHDL Test Bench is a VHDL Entity/Architecture which becomes the new top-level of your design. In it is instantiated one instance of your actual design entity as a component plus one or more processes which drive the inputs of the component and, possibly, examine the outputs.

VHDL contains a special statement, called ASSERT, which is used in test benches to verify simulations. An ASSERT statement tests a condition and, if the result is false, it outputs a message to the simulator and may even be able to abort the simulation. The syntax of the ASSERT statement is:

	ASSERT condition 
	  REPORT string 
	  SEVERITY severity_level;

The condition is a Boolean statement to be evaluated. The string is a text string which will be output if the condition evaluates to false. The severity_level may be note, warning, error, or failure. An assertion of severity failure is intended to abort the simulation, but not all simulators will support this.

In Renoir, you can use the Design Manager to automatically generate a skeleton test-bench. This will create a new Block Diagram with an instance of the design unit to be tested and a sub-block with ports defined to drive and examine the design units inputs and outputs. In general, due to the sequential nature of testing, we will be creating a Flowchart view to describe the behavior of this sub-block.

Creating the ALU Test Bench