Standard ICs FPGA (Field Programmable Gate Array) VHDL (Very-high-speed integrated circuits Hardware Description Language) 1
Standard ICs PLD: Programmable Logic Device CPLD: Complex PLD FPGA: Field Programmable Gate Array 2
x 1 x 2 x 3 Programmable connections P 1 OR plane P 2 P 3 P 4 Programmable Logic Array (PLA) AND plane f 1 f 2 3
Field-Programmable Gate Arrays (FPGA) An array of logic blocks (Logic Elements) Each logic block typically has a small number of inputs and one output. Large RAM blocks Embedded multipliers Interconnection wires and switches (routing channels) I/O blocks In-System Programming (ISP) with JTAG port Storage cells are volatile. 4
x 1 Lookup table Logic Elements of FPGA 0/1 x 2 0/1 0/1 0/1 f x 1 x 2 0 0 1 1 0 1 0 1 f 1 1 0 0 1 (a) Circuit for a two-input LUT (b) f 1 = x 1 x 2 + x 1 x 2 x 1 1 0 0 f 1 LUTs usually have 4 to 6 inputs (16 to 64 storage cells). 1 x 2 (c) Storage cell contents in the LUT A two-input lookup table 5
Select In 1 Flip-flop Out In 2 LUT D Q In 3 Clock Inclusion of a flip-flop with a LUT 6
x 3 f x 1 x 2 x 1 x 2 0 0 0 1 x 2 0 f 1 1 f 2 0 x 3 0 f 1 f 2 0 1 1 1 f A section of a programmed FPGA 7
Altera Cyclone II, EP2C20 on Altera DE1 18752 Logic Elements (LEs) Each LE has a four-input look-up table (LUT) 52 M4K Memory blocks (4 Kbits plus 512 parity bits) Total RAM bits: 239616 26 Embedded multipliers 4 Phase-Locked Loops (PLLs) User I/O pins: 315 8
Major steps of design with programmable devices 9
VHDL A hardware description language 10
Example VHDL code 11
Design Entity Entity Entity Declaration Architecture 12
LIBRARY ieee; USE ieee.std_logic_1164.all; std_logic_1164: a package containing the definition of STD_LOGIC Data type: STD_LOGIC Some of legal values of STD_LOGIC: 0, 1, Z, - Z: high-impedance state - : don t care 13
ENTITY Declaration ENTITY entity-name IS PORT ( [SIGNAL] signal_name{,signal_name}:[mode] type_name {; [SIGNAL] signal_name{,signal_name}:[mode] type_name} ) ; END entity_name ; Example ENTITY fulladd IS PORT ( Cin, x, y : IN STD_LOGIC ; s, Cout : OUT STD_LOGIC ) ; END fulladd ; 14
Modes of signals in entity ports Mode IN OUT INOUT BUFFER Purpose Input Output The signal only appears on the left of <=. Input and output Output The signal can appear both on the left and right sides of <=. 15
Architecture ARCHITECTURE architecture_name OF entity_name IS [SIGNAL declarations] [CONSTANT declarations] [TYPE declarations] [COMPONENT declarations] [ATTRIBUTE specifications] BEGIN {COMPONENT instantiation statement ;} {CONCURRENT ASSIGNMENT statement ;} {PROCESS statement ;} {GENERATE statement ;} END [architecture_name]; Declaration region Architecture body 16
Example: a 2-to-1 multiplexer MUX 2-1 17
Representation of numbers in VHDL code SIGNAL C: STD_LOGIC_VECTOR(1 TO 3); The data type STD_LOGIC_VECTOR represents a linear array of STD_LOGIC data objects. C is defined as a three-bit STD_LOGIC signal. Each bit of C can be referred to separately using names C(1), C(2), and C(3). The syntax (1 TO 3) specifies that the mostsignificant bit in C is C(1) and the least-significant bit is C(3). 18
SIGNAL X: STD_LOGIC_VECTOR(3 DOWNTO 0); X is a four-bit STD_LOGIC_VECTOR signal. The syntax (3 DOWNTO 0) specifies that the mostsignificant bit in X is X(3) and the least-significant bit is X(0). Signal Assignment Statements X(3) <= 1 ; X(2) <= 1 ; X(1) <= 0 ; X(0) <= 0 ; X <= 1100 ; Single quotes for one-bit signals Double quotes for multibit signals 19
Example: MUX 4-1 20
Conditional Signal Assignment LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY mux2to1 IS PORT ( w0, w1, s : IN STD_LOGIC ; f : OUT STD_LOGIC ) ; END mux2to1 ; ARCHITECTURE Behavior OF mux2to1 IS BEGIN f <= w0 WHEN s = '0' ELSE w1 ; END Behavior ; A 2-to-1 multiplexer using a conditional signal assignment 21
Example: MUX2_1x4 22
Select Signal Assignment LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY mux2to1 IS PORT ( w0, w1, s : IN STD_LOGIC ; f : OUT STD_LOGIC ) ; END mux2to1 ; ARCHITECTURE Behavior OF mux2to1 IS BEGIN WITH s SELECT f <= w0 WHEN '0', w1 WHEN OTHERS ; END Behavior ; VHDL code for a 2-to-1 multiplexer 23
Process Statement Sensitivity list When any signal in the sensitivity list changes value, statements are evaluated in sequential order. Sequential Assignment Statements: IF-THEN-ELSE statement CASE statement Assignments to signals are only visible when all the statements in the process have been evaluated. If there are multiple assignments to the same signal, only the last one has any visible effect. 24
Using a process statement to describe a 2-to-1 multiplexer, MUX 2-1 Sensitivity list 25
IF-THEN-ELSE statement 26
Example of CASE statement: MUX 4-1 27
CASE statement 28
Process statement for combinational circuits The sensitivity list must include all input signals. All values of each output signal must be defined (specified) for all combination of values of all input signals. 29
Process statement for sequential circuits The sensitivity list only includes some input signals which can trigger the sequential circuits. For example, clock and asynchronous reset. The values of each output signal may not be fully specified. For example, the output signal of a latch. 30
Example: Sequence detector 31
There are 3 processes in the entity Sdet1_mo. 32
The first process is a combinational circuit. 33
The second process is a combinational circuit. 34
The third process is a sequential circuit. 35
Example: TwoComp for computing 2 s complement of a binary number 36
Example: TwoComp 37
First process for a combinational circuit 38
Second process for a combinational circuit (Note that TwoComp is Mealy type.) 39
Third process for a sequential circuit 40
Synchronous reset 41
Asynchronous reset 42
Example: Sequence generator Sgen1 43
Example: Sgen1 Arithmetic package 44
Sgen1: Two combinational circuits 45
Convert an integer to an std_logic_vector 46
Sgen1: Process for a sequential circuit 47
Example: Shift register Shreg4_hvL 48
Example: Shreg4_hvL 49
Concatenate operator: & 50
Structure description Use a full adder as a component to construct a 4-bit adder 51
VHDL code for a full adder 52
53
COMPONENT instantiation statement: port map 54