VLSI Design With VHDL Modeling For Synthesis
VLSI Design With VHDL Modeling For Synthesis
Prof. Jing-Yang Jou National Chiao Tung University Department of Electronics Engineering E-mail: jyjou@faculty.nctu.edu.tw Tel: (03)5731850 Fax: (03)5710580 Home Page: http://eda.ee.nctu.edu.tw/jyjou
7-1
History
VHSIC Hardware Description Language
Very High Speed Integrated Circuits
Requirements generated in 1981 from VHSIC program Version 7.2 in 1985 (IBM, Texas Instruments, Intermetrices) Proposed IEEE standard 1986 IEEE standard 1076 adopted in December 1987 IEEE standard 1076-1993 finalized in 1993
7-2
What is VHDL ?
A Formal Hardware Description Language Can express digital systems in different domains
Behavior Structure
7-3
VHDL
A simulation language A synthesis language
RT-level synthesis
A test-synthesis language
BSDL
7-4
Description Styles
Behavioral style
Adding two binary number
Structural style
Interconnection of gates
7-5
Synthesis Subset
structure
7-6
Books
A VHDL Primer, (Revised Edition) J. Bhasker, ISBN 013184478, Prentice Hall, 1994 Digital Systems Design Using VHDL, Charles H. Roth, Jr., ISBN 0-534-95099-X, PWS Publishing Company HDL Chip Design, Douglas J. Smith, ISBN 0-96519343-8, Doone Publications Web: http://www.doone.com Digital Design and Modeling with VHDL and Synthesis, K. C. Chang, ISBN 0-8186-7716-3, IEEE Computer Society Press
7-7
Design Entity
Primary hardware unit in VHDL (a component) Has well-defined inputs and outputs Performs a well-defined function Can represent an entire system, a board, a chip, a logic gate, etc. Consists of an interface (entity declaration) together with a corresponding behavior (architecture body)
7-8
7-9
Different Architectures
architecture DATA_FLOW of COMPARE is begin C<=not(A xor B) end DATA_FLOW architecture BEHAVIORAL of COMPARE is begin process(A, B) begin if(A = B) then C <= 1; else C <= 0; end if; end process; end;
7-10
Entity Declaration
Specifies the interface of entity to outside environment.
entity DECODER2x4 is port (A, B, ENABLE: in BIT; Z: out BIT_VECTOR(0 to 3)); end DECODER2x4;
7-11
Entity Declaration
entity FullAdder is port (A, B, CIN: in bit; SUM, COUT: out bit); end FullAdder; Format: entity ent_name is [generic (generic_list);] [port (port_list);] {common_declarations} end [ent_name];
7-12
Ports
Provide channels for communication between the design entity and its environment Mode is in, out, inout, or buffer Buffer:
- Same as inout - Can be updated by at most one source
7-13
Architecture Body
Specifies relationship between inputs and outputs Structure, data-flow, behavioral or mixed
Syntax: architecture arch_name of entity_name is {declarations} -- Declarations of items that are available -- for use within the block begin {statements} -- All are concurrent statements that execute -- asynchronously with respect to each other end [arch_name];
7-14
Description Styles
Structural: Set of interconnected components
Structure explicit May be hierarchical
7-16
concurrent behavior
7-17
Data Type
A data type is characterized by a set of values and a set of operations Subtype: subset of a type; a type with constraint
7-18
Predefined Types
bit Boolean integer real character time 0 or 1 False or True -(231-1) to + (231-1) -1.0E38 to + 1.0E38 d, 7 integer ns (ps, ms, sec, min, hr)
7-19
Subtypes
Subset of a primary type, type with a constraint
Used for range checking A value belongs to a subtype if it belongs to the type and satisfies the constraint
7-20
Type Declaration
Enumeration type: User-defined values
type MVL is (0, 1, X, U, Z); type INSTR is (LOAD, STORE, ADD, SUB, MUL, DIV); subtype ARITH_INSTR is INSTR range ADD to DIV; signal CLOCK: MVL;
7-21
Type Declaration
Physical type: Represents measurement of some quantity
type CAPACITANCE is range 0 to 1E8 units pf; -- base unit uf = 1000 pf; mf = 1000 uf; end units;
An example of usage:
variable K: CAPACITANCE; K := 5 mf;
7-22
Type Declaration
Array type:
Constrained array type
type ADDR_WORD is array (0 to 63) of BIT;
7-23
Literals
Integer: 56, 2E2, 54_3, 0
2#101_101#, 16#FA#
Character: A, Enumeration: literal of enumeration types String: <--->, YOU, This is an example Bit-string: B | O | X | bit_value
XFF0, B1101, O327
7-24
Data Objects
7-25
Object Declaration
Declare an object, its type, its class, and optionally to assign it a value Constant declarations:
constant CYCLE_TIME: TIME := 100 ns; constant NULL_OP_CODE: BIT_VECTOR := O052;
Variable declarations:
variable INDEX: INTEGER range 0 to 99 := 20; variable MEM: BIT;
Signal declarations:
signal RW: BIT := 1;
7-27
VHDL
Identifier
Case insensitive Contains letters, numbers and underscore _ Start with a letter Cannot end with _ C123 ab_12
7-28
Reserved Words
abs access after alias all and architecture array assert attribute begin block body buffer bus case component configuration constant disconnect downto else elsif end entity exit file for function generate generic guarded if in inout is label library linkage loop
7-29
Reserved Words
map mod nand new next nor not null of on open or others out package port procedure process range record register rem report return select severity signal subtype then to transport type units until use variable wait when while with xor
7-30
Arrays
type SHORT_WORD is array (15 downto 0) of bits; signal DATA_WORD: SHORT_WORD; variable ALT_WORD: SHORT_WORD:= 0101010101010101; variable ONE_WORD: SHORT_WORD:= (other=>1); type intvec is array (nature range <>) of integer; signal intvec5: intvec (1 to 5):= (3,2,6,8,1);
7-31
Arrays
Type matrix3x3 is array (1 to 3, 1 to 3) of integer; variable matrixA: matrix3x3:= ((1, 2, 3), (4, 5 ,6), (7, 8, 9)); matrixA: 1 2 3 4 5 6 7 8 9 matrixA(3,2) is 8
7-32
Array Objects
type optype is (add, sub, div, mul); type timing is array (optype range <>, optype range <>) of TIME: constant ALUtiming: timing:=
7-33
Array Objects
--named notation
type oparray is array (optype <>) of NATURAL; signal OpCode: oparray; OpCodes<= (add=>1, sub=>2, div=>3, mul=>4);
--mixed notation
type matrix is array (INTEGER range <>, INTEGER range <>) of integer; signal DiagMatrix: matrix (5 to 8, 6 to 9);
DiagMatrix <= ((6 =>1, others =>0), (7 =>1, others =>0), (8 =>1, others =>0), (9 =>1, others =>0);
7-34
Aggregates
Array
variable OP_CODES:BIT_VECTOR(1 to 5); OP_CODES:= 01000;
A string literal is assigned
OP_CODES:= (others=>0);
All values set to 0
7-35
Aggregates
Record
type PIN_TYPE is range 0 to 10; type MODULE is record SIZE: INTEGER range 20 to 200; CRITICAL_DLY: TIME; NO_INPUTS: PIN_TYPE; NO_OUTPUTS:PIN_TYPE; end record variable NAND_COMP: MODULE; NAND_COMP:= (50, 20 ns, 3, 2);
7-36
Logical Operators
not, or, nor, and, nand, xor:
Apply to BIT/BOOLEAN, 1-D of BIT/BOOLEAN Operands must be of the same type and same length Operation is performed on matching elements of the arrays Equal precedence executed from left to right
7-37
Logical Operators
Example:
entity BITWISE is port (A: in bit_vector(6 downto 0); B: in bit_vector(6 downto 0); Y: out bit_vector(6 downto 0); Z: out bit_vector(6 downto 0)); end entity BITWISE;
7-38
Logical Operators
architecture Behavior of BITWISE is begin process(A, B) begin Y(0) <= A(0) and B(0); --Binary AND Y(1) <= A(1) or B(1); --Binary OR Y(2) <= A(2) nand B(2); --Binary NAND Y(3) <= A(3) nor B(3); --Binary NOR Y(4) <= A(4) xor B(4); --Binary XOR Y(5) <= A(5) xnor B(5); --Binary XNOR Y(6) <= not A(6); --Unary negation Z <= A nor B; --Vector operation end process; end architecture Behavior;
7-39
Relational Operators
=, /=,<, <=, >, >=:
Apply to any types Result is BOOLEAN Operands of the same type, different lengths are OK
7-40
Relational Operators
Example:
entity COMPARISON is port (A, B, C: in bit_vector(2 downto 0); D, E, F: in bit_vector(3 downto 0); Y: out bit); end entity COMPARISON;
7-41
Relational Operators
architecture Behavior of COMPARISON is begin process(A, B, C, D, E, F) begin if ((A=B) and ((C>D) or not (E<=F))) then Y<=1; else Y<=0; end if; end process; end architecture Behavior;
7-42
Arithmetic Operators
+, -, *, /, **, mod, rem, abs:
Apply to numeric types (Integer, Real) Some synthesis support
7-43
Arithmetic Operators
Example
entity ARITHMETIC is port (A, B: in integer range 7 downto 0; Y1: out integer range 15 downto 0; Y3: out integer range 63 downto 0; Y2, Y4, Y5: out integer range 7 downto 0); end entity ARITHMETIC;
7-44
Arithmetic Operators
architecture Behavior of ARITHMETIC is begin process (A, B) begin Y1 <= A + B; -- Addition Y2 <= A - B; -- Subtraction Y3 <= A * B; -- Multiplication Y4 <= A / B; -- Division Y5 <= A mod B; -- Modulus of A divided by B end process; end architecture Behavior;
7-45
SLA
Fill in right most bit
SRA
Sign extension
ROL, ROR
7-46
7-47
7-48
VHDL Operators
1. Binary logic operators
and or nand nor xor xnor
bit, Boolean, bit_vector, Boolean_vector
2. Relational operators
= /= < <= > >=
Result is Boolean = and /=: any type Others: numeric or enumerated type
7-50
VHDL Operators
3. Shift operators
sll srl sla sra rol ror
Applied to bit_vector and Boolean_vector
4. Adding operators
+ & (concatenation)
+ and : any numeric types &: vectors
7-51
VHDL Operators
6. Multiplying operators
/ mod rem
and /: integer and real mod and rem: integer
7. Miscellaneous operator
not abs
: raise integer or real to integer power abs: absolute value of a numeric operand
7-52
Precedence
Class 7 is the highest Left to right for the same class Use () to change the order
7-53
Precedence
(A & not B or C ror 2 and D)=110010 The operator order is: not, &, ror, or, and,=
A=110, B=111, C=011000, D=111011 Not B=000 A & not B=110000 C ror 2=000110 (A & not B) or (C ror 2)=110110 (A & not B) or (c ror 2) and D =110010 [A & not B or C ror 2 and D)=110010:]=True
7-54