prepared by P. Bakowski
VHDL entity declaration [syntax]
The basic descriptional element of VHDL is entity; each description must be composed from at least one entity. Each entity has a set of ports which constitute its interface to the outside world. In VHDL, an entity may be the top level module of the design or may be used as a component in a design.
The header may include specification of generic constants. Generics allow to determine some quantitative aspects of the structure (e.g. size of the bus) and behavior (e.g. number of counting steps) of the entity.
ports and signals
An entity port contains the list of items that must all be of class signal. Consequently, we are not required to write the word signal, it is assumed.
elements of entity declaration The declarative part of an entity may contain several kinds of items including:
The architecture is a module used to define how entity behaves or what it is composed of. The architecture description may be abstract implying the use of abstract objects; RTL (register transfer level) oriented implying the use of hardware related object types like registers or buses or structural implying the use of smaller hardware modules referred to as components. Depending on the character of the design or description, the components may be embraced at block or core level or be may be much more detailed and imply the creation of logic level structures (logic netlists). Each architecture body can describe a different implementation of the entity.
The potential composition of architecture module comprises:
architecture declarative part
The declarative part of the architecture may contain:
VHDL processes [syntax]
Behavioral architecture descriptions use extensively the algorithmic programming of the circuit/system functionalities. The behavioral architectures are mainly built from processes. All operations described in a process are executed sequentially (procedurally). Processes are activated through the events on signals generated outside or within the process (VHDL'93 provides an attribute called 'driving which can indicate if the signal is driven from within a process). The processes active at the same time execute concurrently.
basic process structure
A process is built from two parts: the declaration part and the statements part
A simple wait statement stops the execution of a process.
Any event on any signal listed frees the process.
The process above (and_process) will reactivate whenever there is an event on a or b or enable but only if enable is equal to `1', otherwise the process remain suspended.
The sensitivity list is a kind of wait operation specified in the header of process statement : Equivalent processes:
Some examples of conditional control in processes:
select_process: process begin
Example: The following is a well known model of RS flip-flop. The assertion is used to detect the forbidden state at the flip-flop inputs.
Processes and signal related attributes
As we have seen in the previous chapter concerning signals, VHDL provides a number of predefined signal related attributes. They allow to express different time related conditions and constraints.
Some attributes which define signals themselves :
What is the resulting waveform of the output (s) signal?
Another example:
The `stable attribute is a boolean signal whose value is TRUE when an event has not occurred on the signal for the given time; otherwise is FALSE. Detection of spikes:
'transaction attribute (signal- event result)
The `transaction attribute is a bit signal which toggles every time when a transaction has occurred on the signal. Note that the `transaction attribute produces events even if the value of the signal has not changed.
architecture accounting of nand_comp is
begin inst1:nand_gate port map(in1,in2,result); output<=result; account_process: -- counts the number of transactions on result signal
The `active attribute is a boolean signal which is TRUE when a transaction has occurred on the signal during the current simulation cycle. The `event attribute is a boolean signal which is TRUE when an event has occurred on the signal during the current simulation cycle.
The following excl_process is sensitive to two input signals but its behavior depends on whether or not each of the inputs has changed.
'last_active, 'last_event, 'last_value attributes (function - boolean result)
The `last_active attribute returns the amount of time that has elapsed since there was a transaction on the signal. The `last_event attribute returns the amount of time that has elapsed since there was an event on the signal. The `last_value attribute returns the value of the signal before the last event. Examples: The first example shows how `last_value attribute can be applied to detect the signal falling edge. The second example presents the use of 'event and 'last_event attributes to test the setup time.
architecture pfalling of sh_reg is begin shift_process: process variable reg: bit_vector(7 downto 0); begin
Several consecutive signal assignments may produce different effects depending on the value of signal and type of delays used in the process. When inertial signal assignment is made, all driver values in the queue past the current time are deleted. This is not the case of transport delays which maintains the previously (in time) assigned values.
More precise rule is given in the table below:
The VHDL architectures modules may contain concurrent procedure calls. A concurrent procedure is instantiated as a concurrent statement (e.g. signal assignment). Concurrent procedure is equivalent to a process with a sensitivity list extracted from all the actual signals whose mode in the formal parameter list is of in or inout. All elements associated to the formal parameters during the procedure instantiation must be visible in the architecture. There can be multiple occurrences of a concurrent procedure with different formal=>actual parameters association lists. This allows the reuse of the same procedure in different contexts. The concurrent procedure may be declared in a package, in the entity declarative part, or in the architecture declarative part. All classes of objects (signals, variables, constants and files) may be used as concurrent procedure parameters.
adder_proc(a,b,cin: in std_logic; s,cout: out std_logic); -- a,b,cin,s,cout : formal parameters
architecture con_proc of adder is begin adder_proc(in1,in2,in3,out1,out2); -- seen as concurrent procedure instantiation end con_proc;
architecture seq_proc2 of adder is