Introduction to VHDL
Designer writes a logic circuit description in VHDL source code VHDL compiler translates this code into a logic circuit Representation of digital signals in VHDL
Logic signals in VHDL are represented as a data object VHDL includes a data type called BIT BIT objects can assume only two values: 0 and 1
: IN : OUT
BIT; BIT);
Type of the port
: IN : OUT
BIT; BIT);
ARCHITECTURE LogicFunc OF example1 IS BEGIN f <= (x1 AND x2) OR (NOT x2 AND x3); END LogicFunc;
x3
ARCHITECTURE LogicFunc OF example1 IS BEGIN f <= (x1 AND x2) OR (NOT x2 AND x3); END LogicFunc;
Electrical & Computer Engineering Dr. D. J. Jackson Lecture 3-6
VHDL does not assume any precedence of logic operators. Use parentheses in expressions to determine precedence In VHDL, a logic expression is called a simple assignment statement. There are other types that will be introduced that are useful for more complex circuits.
Assignment statements
VHDL provides several types of statements that can be used to assign logic values to signals
Simple assignment statements
Used previously, for logic or arithmetic expressions
Selected signal assignments Conditional signal assignments Generate statements If-then-else statements Case statements
We must declare the library where the data type exists, and declare that we will use the data type
LIBRARY USE ieee; ieee.std_logic_1164.all;
ARCHITECTURE Behavior OF mux4to1 IS BEGIN WITH s SELECT f <= w(0) WHEN "00", w(1) WHEN "01", w(2) WHEN "10", w(3) WHEN OTHERS; END Behavior;
Electrical & Computer Engineering Dr. D. J. Jackson Lecture 3-11
ARCHITECTURE Behavior OF priority IS BEGIN y <= "11" WHEN w(3) = '1' ELSE "10" WHEN w(2) = '1' ELSE "01" WHEN w(1) = '1' ELSE "00"; z <= '0 WHEN w = "0000" ELSE '1'; END Behavior;
Electrical & Computer Engineering Dr. D. J. Jackson Lecture 3-14
ARCHITECTURE LogicFunc OF fulladd IS BEGIN s <= x XOR y XOR Cin ; Cout <= (x AND y) OR (Cin AND x) OR (Cin AND y) ; END LogicFunc ; LIBRARY ieee ; USE ieee.std_logic_1164.all ; PACKAGE fulladd_package IS COMPONENT fulladd PORT ( Cin, x, y : IN s, Cout : OUT END COMPONENT ; END fulladd_package ;
Electrical & Computer Engineering
STD_LOGIC ; STD_LOGIC ) ;
ARCHITECTURE Structure OF adder4 IS SIGNAL C : STD_LOGIC_VECTOR(1 TO 3) ; BEGIN stage0: fulladd PORT MAP ( Cin, X(0), Y(0), S(0), C(1) ) ; stage1: fulladd PORT MAP ( C(1), X(1), Y(1), S(1), C(2) ) ; stage2: fulladd PORT MAP ( C(2), X(2), Y(2), S(2), C(3) ) ; stage3: fulladd PORT MAP ( C(3), X(3), Y(3), S(3), Cout ) ; END Structure ;
Generate statements
Whenever we write structural VHDL code, we often create instances of a particular component
A multi-stage ripple carry adder made from a number of single-bit full adders might be an example
If we need to create a large number of instances of a component, a more compact form is desired VHDL provides a feature called the FOR GENERATE statement
This statement provides a loop structure for describing regularly structured hierarchical code
Process statement
We have introduced several types of assignment statements
All have the property that the order in which they appear in VHDL code does not affect the meaning of the code
Because of this property, these statements are called concurrent assignment statements VHDL provides a second category of statements, sequential assignment statements, for which the ordering of the statements may affect the meaning of the code
If-then-else and case statements are sequential
VHDL requires that sequential assignment statements be placed inside another statement, the process statement
Process statement
The process statement, or simply process, begins with the PROCESS keyword, followed by a parenthesized list of signals called the sensitivity list
This list includes, at most, all the signals used inside the process Generally the list includes all signals that can be used to activate the process
Statements inside the process are evaluated in sequential order Assignments made inside the process are not visible outside the process until all statements in the process have been evaluated
If there are multiple assignments to the same signal inside a process, only the last one has any visible effect
Electrical & Computer Engineering Dr. D. J. Jackson Lecture 3-21
A B
AeqB
A B
AeqB
Case statement
A case statement is similar to a selected assignment statement in that the case statement has a selection signal and includes WHEN clauses for various valuations of the selection signal
Begins with a CASE keyword Each WHEN clause specifies the statements that should be evaluated when the selection signal has a specified value The case statement must include a when clause for all valuations of the selection signal
Use the OTHERS keyword