Lattice VHDL Training

Similar documents
VHDL for FPGA Design. by : Mohamed Samy

Lecture 7. Standard ICs FPGA (Field Programmable Gate Array) VHDL (Very-high-speed integrated circuits. Hardware Description Language)

[VARIABLE declaration] BEGIN. sequential statements

Introduction to VHDL #3

Chapter 6 Combinational-Circuit Building Blocks

Digital Systems Design

Introduction to VHDL

Basic Language Concepts

UNIT I Introduction to VHDL VHDL: - V -VHSIC, H - Hardware, D - Description, L Language Fundamental section of a basic VHDL code Library :

Hardware Description Language VHDL (1) Introduction

Lecture 4. VHDL Fundamentals. George Mason University

VHDL 2 Combinational Logic Circuits. Reference: Roth/John Text: Chapter 2

310/ ICTP-INFN Advanced Tranining Course on FPGA and VHDL for Hardware Simulation and Synthesis 27 November - 22 December 2006

Advanced Training Course on FPGA Design and VHDL for Hardware Simulation and Synthesis. 26 October - 20 November, 2009

Lecture 4. VHDL Fundamentals. Required reading. Example: NAND Gate. Design Entity. Example VHDL Code. Design Entity

Lecture 12 VHDL Synthesis

Control and Datapath 8

Abi Farsoni, Department of Nuclear Engineering and Radiation Health Physics, Oregon State University

Introduction to VHDL #1

ELCT 501: Digital System Design

ECE 448 Lecture 4. Sequential-Circuit Building Blocks. Mixing Description Styles

ECE 545 Lecture 6. Behavioral Modeling of Sequential-Circuit Building Blocks. George Mason University

Menu. Introduction to VHDL EEL3701 EEL3701. Intro to VHDL

Lecture 1: VHDL Quick Start. Digital Systems Design. Fall 10, Dec 17 Lecture 1 1

JUNE, JULY 2013 Fundamentals of HDL (10EC45) PART A

Outline. CPE/EE 422/522 Advanced Logic Design L05. Review: General Model of Moore Sequential Machine. Review: Mealy Sequential Networks.

PROGRAMMABLE LOGIC DESIGN WITH VHDL

Introduction to VHDL. Yvonne Avilés Colaboration: Irvin Ortiz Flores Rapid System Prototyping Laboratory (RASP) University of Puerto Rico at Mayaguez

VHDL. Official Definition: VHSIC Hardware Description Language VHISC Very High Speed Integrated Circuit

ECE 545 Lecture 8. Data Flow Description of Combinational-Circuit Building Blocks. George Mason University

1 ST SUMMER SCHOOL: VHDL BOOTCAMP PISA, JULY 2013

VHDL for Complex Designs

Computer-Aided Digital System Design VHDL

COE 405, Term 062. Design & Modeling of Digital Systems. HW# 1 Solution. Due date: Wednesday, March. 14

CprE 583 Reconfigurable Computing

Hardware Description Languages. Modeling Complex Systems

Sequential Statement

Modeling Complex Behavior

IT T35 Digital system desigm y - ii /s - iii

!"#$%&&"'(')"*+"%,%-".#"'/"'.001$$"

Lecture 5: State Machines, Arrays, Loops. EE 3610 Digital Systems

CprE 583 Reconfigurable Computing

Synthesis of Language Constructs. 5/10/04 & 5/13/04 Hardware Description Languages and Synthesis

N-input EX-NOR gate. N-output inverter. N-input NOR gate

ECE 448 Lecture 3. Combinational-Circuit Building Blocks. Data Flow Modeling of Combinational Logic

VHDL Examples Mohamed Zaky

VHDL Basics. Mehdi Modarressi. Department of Electrical and Computer Engineering, University of Tehran. ECE381(CAD), Lecture 4:

VHDL for Synthesis. Course Description. Course Duration. Goals

Review. LIBRARY list of library names; USE library.package.object; ENTITY entity_name IS generic declarations PORT ( signal_name(s): mode signal_type;

Review of Digital Design with VHDL

Mridula Allani Fall Fall

Department of Electronics & Communication Engineering Lab Manual E-CAD Lab

Hardware Modeling. VHDL Basics. ECS Group, TU Wien

CS211 Digital Systems/Lab. Introduction to VHDL. Hyotaek Shim, Computer Architecture Laboratory

VHDL And Synthesis Review

ECE 545 Lecture 5. Data Flow Modeling in VHDL. George Mason University

EEL 4712 Digital Design Test 1 Spring Semester 2008

Two HDLs used today VHDL. Why VHDL? Introduction to Structured VLSI Design

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL

ECE 448 Lecture 3. Combinational-Circuit Building Blocks. Data Flow Modeling of Combinational Logic

VHDL Structural Modeling II

EE434 ASIC & Digital Systems

Summary of FPGA & VHDL

Introduction to VHDL. Main language concepts

5. VHDL - Introduction - 5. VHDL - Design flow - 5. VHDL - Entities and Architectures (1) - 5. VHDL - Entities and Architectures (2) -

Contents. Appendix D VHDL Summary Page 1 of 23

Pollard s Tutorial on Clocked Stuff in VHDL

Logic and Computer Design Fundamentals VHDL. Part 1 Chapter 4 Basics and Constructs

FPGA BASED SYSTEM DESIGN. Dr. Tayab Din Memon Lecture 9 & 10 : Combinational and Sequential Logic

In our case Dr. Johnson is setting the best practices

Lecture 3. VHDL Design Units and Methods. Entity, Architecture, and Components Examples of Combinational Logic Hands-on in the Laboratory

COE 405 Design Methodology Based on VHDL

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

SRI SUKHMANI INSTITUTE OF ENGINEERING AND TECHNOLOGY, DERA BASSI (MOHALI)

Lecture 4: Modeling in VHDL (Continued ) EE 3610 Digital Systems

VHDL. VHDL History. Why VHDL? Introduction to Structured VLSI Design. Very High Speed Integrated Circuit (VHSIC) Hardware Description Language

VHDL. ELEC 418 Advanced Digital Systems Dr. Ron Hayne. Images Courtesy of Cengage Learning

ECE U530 Digital Hardware Synthesis. Course Accounts and Tools

Design units can NOT be split across different files

CSCI Lab 3. VHDL Syntax. Due: Tuesday, week6 Submit to: \\fs2\csci250\lab-3\

The block diagram representation is given below: The output equation of a 2x1 multiplexer is given below:

Sequential Logic - Module 5

Subprograms, Packages, and Libraries

EEL 4712 Digital Design Test 1 Spring Semester 2007

Synthesis from VHDL. Krzysztof Kuchcinski Department of Computer Science Lund Institute of Technology Sweden

Multi-valued Logic. Standard Logic IEEE 1164 Type std_ulogic is ( U, uninitialized

Tutorial 4 HDL. Outline VHDL PROCESS. Modeling Combinational Logic. Structural Description Instantiation and Interconnection Hierarchy

VHDL. Chapter 7. Behavioral Modeling. Outline. Behavioral Modeling. Process Statement

Lecture 3. VHDL Design Units and Methods. Notes. Notes. Notes

Sequential VHDL. Katarzyna Radecka. DSD COEN 313

VHDL in 1h. Martin Schöberl

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 3

Contents. Chapter 9 Datapaths Page 1 of 28

VHDL: RTL Synthesis Basics. 1 of 59

3 Designing Digital Systems with Algorithmic State Machine Charts

VHDL is a hardware description language. The code describes the behavior or structure of an electronic circuit.

Verilog Design Principles

Overview. Ram vs Register. Register File. Introduction to Structured VLSI Design. Recap Operator Sharing FSMD Counters.

APPLICATION NOTE. A CPLD VHDL Introduction. Introduction. Overview. Entity. XAPP 105 January12, 1998 (Version 1.0) 0 4* Application Note

Transcription:

Lattice Part I February 2000 1

VHDL Basic Modeling Structure February 2000 2

VHDL Design Description VHDL language describes a digital system as a set of modular blocks. Each modular block is described by a pair of entity and architecture. entity counter... end counter; entity tff.. end tff; entity inv... end inv; entity dff.. end dff; architecture counter_design of counter.. end counter_design; architecture tff_design of tff is.. end tff; architecture inv_design of inv.. end inv_design; architecture dff_design of dff is.. end dff; Ripple Carry Counter T_FF0 T_FF1 T_FF2 T_FF3 DFF INV DFF INV DFF INV DFF INV February 2000 3

VHDL Design Descriptions VHDL design description consist of an ENTITY and ARCHITECTURE pair The ENTITY describes the design I/Os A[7:0] B[7:0] reset my_design O[7:0] clk The ARCHITECTURE describes the content of the design February 2000 4

The Entity - example VHDL description of the entity: ENTITY black_box is port ( rst : IN std_logic; clk : IN std_logic; d : IN std_logic_vector (7 downto 0); q : BUFFER std_logic_vector (7 downto 0); co : OUT std_logic ); END black_box; Black Box D[7:0] Rst CLK Q[7:0] CO Note: VHDL is NOT case sensitive! February 2000 5

The Entity - General Format for Port Declaration Entity only describes the circuit interface but not function ENTITY entity_name IEEE Standard is port ( for Physical Data Type (0, 1, x, Z ) One-Bit clk : IN std_logic; q : OUT std_logic_vector(0 to 7)); port_name : port_mode port_type Unique within Entity communication points Direction of the communication points Data type of the ports END entity_name; February 2000 6

PORT Modes IN oe oe OUT OUT (Tri-State) INOUT Buffer February 2000 7

PORT Types integer Boolean Useful as index holders for loops and constants. When used for I/O signals, usually reference counters Can take values of TRUE and FALSE std_logic Standard industry logic type, has values of 0, 1, X, and Z defined by IEEE std 1164. std_logic_vector A grouping of std_logic, standard industry logic type February 2000 8

PORT Types VHDL is a strongly typed language. You cannot assign one signal type to another signal type. ENTITY example is port (Q1 : OUT Integer; Q2 : OUT std_logic_vector( 3 downto 0)); END example; Architecture behavior of example is begin -- Q2 is declared in 4 bit std_logic_vector type Q1 <= 7; Q2 <= 1001 ; Q2 <= 9; end behavior; -- 7 : decimal integer; -- 1001 : 4 bit std_logic vector -- 9 : decimal integer February 2000 9

The Architecture body - General Format Entity entity_name is port ( ); End entity_name; Architecture must be associated with entity ARCHITECTURE architecture_name of entity_name is signal ai, bi : std_logic; Architecture declaration section: declare internal signals ( nets ) ai <= a; bi <= b; y <= (ai AND bi); z <= (ai OR bi); x <= 1 ; w <= 1010 ; a b 1 ai bi z y x END architecture_name; 1010 4 w February 2000 10

Entity / Architecture / Libraries - example Every design has an ENTITY/ARCHITECTURE pair LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_unsigned.all; ENTITY logic is PORT ( a,b : IN std_logic; z, x, y: OUT std_logic; w: OUT std_logic_vector (3 downto 0)); END logic; ARCHITECTURE behavior of logic is signal ai, bi : std_logic; ai <= a; bi <= b; y <= (ai AND bi); z <= (ai OR bi); x <= 1 ; w <= 1010 ; a b 1 1010 ai bi z y x 4 w END behavior; February 2000 11

Libraries VHDL Text Files Wrap VHDL Text Files into VHDL Package Package std_logic_1164 Package std_logic_unsigned Package textio Library Directories Structure ieee std_logic_1164 std_logic_unsigned std textio VHDL Compiler 1*&%$#-+ klo+@!&( 00-.l :?_ Compiled Machine Codes February 2000 12

Libraries Library is a place to keep precompiled packages so that they can be used in other VHDL designs LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_unsigned.all; ieee - symbolic name for IEEE standard library. Contains packages std_logic_1164, std_logic_unsigned, etc. std_logic_1164 - name of the VHDL package Package std_logic_1164 contains declaration of data type for std_logic and std_logic_vector. std_logic_unsigned - name of the VHDL package. Package std_logic_unsigned contains the declaration of operators, functions for std_logic and std_logic_vector arithmetic operations. February 2000 13

Libraries LIBRARY ieee; -- Makes Library ieee visible -- to the following VHDL design. USE ieee.std_logic_1164.all; -- Indicates design can use all -- declarations of Package -- std_loigc_1164 in library ieee. USE ieee.std_logic_unsigned.all; Library Directories Structure ieee std_logic_1164 Compiled Codes Package std_logic_1164 std_logic_unsigned ENTITY design is Port ( q : OUT std_logic; ) End design; architecture context of design is begin q <= a + b; End context; February 2000 14

VHDL Language Syntax & VHDL Design Methods February 2000 15

Concurrent Statement Instantiation Statement Structural Modeling Architecture structural_modeling of one_bit_half_adder is begin X1: XOR2 Port Map ( Z0 => sum, A0 => a, A1 => b ); A1: AND2 Port Map ( Z0 => cout, A0 => a, A1 => b ); -- A1: AND2 Port Map ( cout, a, b ); end structural_modeling; Library Symbol: AND2 a b A0 A1 X1 A1 Z0 sum cout A0 A1 Z0 Entity AND2 is Port ( Z0 : out std_logic; A0 : in std_logic; A1 : in std_logic ); END AND2; February 2000 16

Concurrent Statement Dataflow Modeling by boolean equations assignments conditional assignments (When-Else, With-Select-When) b sell a n1 n2 n3 x Architecture dataflow_modeling of example is signal n1, n2, n3 : std_logic; -- Declare Internal Nets begin x <= n2 OR n3; n2 <= b AND sell; n3 <= n1 AND a; n1 <= NOT sell; -- x <= (a AND (NOT sel1)) OR (b AND sel1); end example; February 2000 17

Concurrent Statement - Boolean Equation Assignment Boolean Equation Assignment Format x <= a AND b ; Left Operand Right Operands Operator The <= operation is also used to signify taking on the value of Concatenate Assignment c <= a(2 downto 0) & b(3 downto 0); c(6) <= a(2); c(5) <= a(1); c(4) <= a(0); c(3) <= b(3); c(2) <= b(2); c(1) <= b(1); c(0) <= b(0); February 2000 18

Standard VHDL Operators Logical Operators AND OR XOR NOT Boolean True or False Logic 1 or 0 ( ( a AND b ) = ( c OR d ) ) Relational Operators = Equal to /= Not equal to > Greater than < Less than >= Greater than or equal to <= Less than or equal to a, b, c, d : std_logic February 2000 19

Concurrent Conditional Assignment With-Select-When Example entity mux is port ( a, b, c, d:in std_logic; s: in std_logic_vector(1 downto 0); x: out std_logic ); end mux; a b c d s0 s1 x architecture archmux of mux is begin with s select x <= a when 00, -- x is assigned based on s b when 01, c when 10, d when 11 ; end archmux; February 2000 20

Concurrent conditional Assignment When-Else Same example of 4-to-1 mux architecture archmux of mux is begin x <= a when ( s = 00 ) else b when ( s = 01 ) else c when ( s = 10 ) else d; end archmux; a b c d s0 s1 x WITH-SELECT-WHEN must specify all mutually exclusive conditions WHEN-ELSE does not have to February 2000 21

With-Select-When vs. WHEN-ELSE with s select x <= a when 00, b when 01, c when 10, d when 11 ; Specify all mutual exclusive conditions Specify chose values based on data type of S x <= a when ( s = 00 ) else b when ( s = 01 ) else c when ( s = 10 ) else d; Specify Boolean conditions Don t have to specify all mutually exclusive conditions, the last one can be defaulted after ELSE keyword February 2000 22

Sequential Statements Process Statement Behavioral Modeling A PROCESS is used to describe sequential events and is included in the ARCHITECTURE of the design. An ARCHITECTURE can contain several PROCESS statements. PROCESS statements have 3 parts: Sensitivity list : includes signals used in the PROCESS process is active when a signal in sensitivity list changes value PROCESS : the description of behavior - END PROCESS statement: describes the beginning & ending of the PROCESS February 2000 23

Process - Sequential Statement Simple example of PROCESS mux: PROCESS (a, b, s) -- the sensitivity list if ( s = 0 ) then x <= a; else x <= b; end if; END PROCESS mux; -- define the process section a b s x Here the process mux is sensitive to signals a, b and s. Whenever signal a or b or s changes value, the statements inside the process will be evaluated February 2000 24

IF -THEN -ELSE It is a sequential statement and can only be used in PROCESS To select a specific execution path based on Boolean evaluation of a condition or set of conditions Cascaded If-Then-Else PROCESS (select, a, b, c, d) if (select = 00 ) then step <= a; elsif (select = 01 ) then step <= b; elsif (select = 10 ) then step <= c; else step <= d; end if; END PROCESS; a b c d sel0 sel1 step ELSIF allows multiple conditions in one statement Must have an END IF statement for every IF statement February 2000 25

IF -THEN -ELSE Nested If-Then-Else PROCESS (select, a, b, c, d) if (select = 00 ) then step <= a; else if (select = 01 ) then step <= b; else if (select = 10 ) then step <= c; else step <= d; end if; end if; end if; END PROCESS; a b c d sel0 sel1 step February 2000 26

CASE - WHEN It is a sequential statement and can only be used in PROCESS ARCHITECTURE archdesign OF design IS decode: PROCESS (a, b, c, option) CASE option IS WHEN "00" => output <= a; WHEN "01" => output <= b; WHEN "10" => output <= c; WHEN OTHERS => output <= '0'; END CASE; END PROCESS decode; END archdesign; OTHERS is all other possible value for signals of type std_logic February 2000 27

Data Objects -Signal, Constant, Variable SIGNAL used to declare internal signals; not external signals interconnects components may be assigned to an external signal ARCHITECTURE behavior of example is SIGNAL count: std_logic_vector (3 downto 0); SIGNAL flag: integer; SIGNAL mtag: integer range 0 to 15; SIGNAL stag: integer range 100 downto 0; --mtag is a 4-bit array; MSB is mtag(0); LSB is mtag(3) --stag is a 7-bit array; MSB is stag(6); LSB is stag(0) --always declared in ARCHITECTURE section February 2000 28

Data Objects SIGNAL in User-defined enumeration type represents state elements in a state-machine ARCHITECTURE behavior of example is TYPE states is (state0, state1, state2, state3); 00 01 10 11 SIGNAL memread: states; Pre-Defined Data Type SIGNAL q : std_logic_vector(0 to 3); SIGNAL a : integer; or User-defined enumeration data type --each state (state0, state1, etc) represents a distinct state. February 2000 29

Data Objects CONSTANT holds a specific value of a type that cannot be changed within the design description ARCHITECTURE behavior of example is CONSTANT width: integer := 8; -- width is a constant with integer type and has a value of 8 VARIABLE used to declare local values only within a given PROCESS. PROCESS (s) VARIABLE result: integer := 12; -- result is a VARIABLE with an intial value of 12. -- value of result may be modified within a PROCESS. variable assignment use := port/signal assignment use <= February 2000 30

Understand VHDL Synthesis and VHDL Design Application February 2000 31

REGISTERS in Behavioral VHDL 3 ways to describe a register PROCESS (clk) 0 clk IF (clk event and clk= 1 ) THEN -- rising edge of clk q <= d; END IF; END PROCESS; -- falling edge of clk => (clk event and clk = 0 ) 1 PROCESS (clk) IF RISING_EDGE (clk) THEN q <= d; END IF; END PROCESS; d clk q PROCESS -- no sensitivity list WAIT UNTIL clk event AND clk = '1'; q <= d; END PROCESS; February 2000 32

Synchronous/Asynchronous Reset Register ARCHITECTURE behavior of synchronous_reset_register is PROCESS (clk) END PROCESS; END behavior; IF (clk EVENT and clk = 1 ) then IF (rst = 1 ) then q <= 0 ; ELSE q <= d; END IF; END IF; ARCHITECTURE behavior of Asynchronous_reset_register is PROCESS (rst, clk) IF (rst = 1 ) then q <= 0 ; ELSIF (clk EVENT and clk = 1 ) then q <= d; END IF; END PROCESS; END behavior; February 2000 33

Synchronous Reset Counter Signal count represent hardware NET Output Port Q Entity counter is port (clock : IN std_logic; reset : IN std_logic; Q: OUT std_logic_vector(3 downto 0)); End counter; clock reset count Q Architecture behavior of counter is signal count : std_logic_vector(3 downto 0); begin upcount: PROCESS (clock) IF (clock EVENT AND clock = '1') THEN IF reset = '1' THEN count <= 0000 ; -- synchronous ELSE count <= count + 0001 ; END IF; END IF; END PROCESS upcount; Q <= count; End behavior; February 2000 34

Asynchronous Reset Counter count Buffer Mode Output Port count clock Entity counter is port (clock, reset : IN std_logic; reset count: buffer std_logic_vector(3 downto 0)); End counter; count count Architecture behavior of counter is begin upcount: PROCESS (clock, reset) End behavior; IF (reset = '1') THEN -- reset has a higher priority count <= 0000 ; -- asynchronous ELSIF (clock EVENT AND clock = '1') THEN count <= count + 0001 ; END IF; END PROCESS upcount; February 2000 35

LATCHES - in Behavioral VHDL ARCHITECTURE behavior of d_latch is PROCESS (enable) IF (enable = '1') then outa <= ina; END IF; END PROCESS; END behavior; ina enable outa ARCHITECTURE behavior of set_reset_latch is PROCESS (set, reset) IF (set = '1' AND reset = '0') then outa <= '1'; ELSIF (set = '0' AND reset = '1') then outa <= '0'; END IF; END PROCESS; END behavior; set reset outa February 2000 36

Synchronous/Asynchronous Reset Latch ARCHITECTURE behavior of synchronous_reset_d_latch is PROCESS (enable) IF (enable = 1 ) then IF ( rst = 1 ) then outa <= 0 ; ELSE outa <= ina; END IF; END IF; END PROCESS; END behavior; ARCHITECTURE behavior of asynchronous_reset_d_latch is PROCESS (enable, rst) END PROCESS; END behavior; IF (rst = 1 ) then outa <= '0 ; ELSIF (enable = 1 ) then outa <= ina; END IF; February 2000 37

Output Enables Entity design is port ( q : out std_logic_vector(0 to 6); ); End design; -- Tri-State Port declared as OUT ARCHITECTURE behavioral of design is q <= qint when (oe= 1') else "ZZZZZZZ" ; END behavioral; ARCHITECTURE behavioral of design is PROCESS (oe) if ( oe = 1 ) then q <= qint; else q <= ZZZZZZZ ; end if; END PROCESS; END behavioral; oe qint q February 2000 38

Bi-Directional Port Entity design is port(-- Bi-Directional Port declared as INOUT data:inout std_logic_vector(0 to 7);...); End design; ARCHITECTURE behavior OF design IS SIGNAL ext_input : std_logic; data <= count WHEN oe = 1' ELSE ZZZZZZZZ ; ext_input <= data; END behavior; ARCHITECTURE behavior OF design IS SIGNAL ext_input : std_logic; PROCESS (oe) IF (oe = 1 ) THEN data <= count; ELSE data <= ZZZZZZZZ ; END IF; END PROCESS; ext_input <= data; END behavior; oe count ext_input data February 2000 39

CPLD Optimization - Caution using If-Then-Else The following VHDL file does not specify the value of q when a1 is equal to 0, thus creating a Latch. The following VHDL file specifies the value of q when a1 is equal to 0, thus creating an AND gate PROCESS (a1, d) IF (a1 = 1 ) then q <= d; END if; END PROCESS; PROCESS (a1, d) IF (a1 = 1 ) then q <= d; ELSE q <= 0 ; END if; END PROCESS; d q a1 q a1 d February 2000 40

CPLD Optimization - Caution using Case-When This VHDL file generates unwanted latches because not all states are defined. signal sel:std_logic_vector(0 to 1); This VHDL file generates a multiplexer correctly because states 10 and 01 are defined. -- sel can choose either of 00, 01, 10, 11 PROCESS (sel,a,b) CASE sel IS WHEN 00 =>q<=a; WHEN 11 =>q<=b; END CASE; END PROCESS; PROCESS (sel,a,b) CASE sel IS WHEN 00 =>q<=a; WHEN 11 =>q<=b; WHEN OTHERS=>q<= 0 ; END CASE; END PROCESS; February 2000 41

CPLD Optimization - Use of Parentheses Example listing below generates a design that uses three cascaded adders and three logic levels. d PROCESS (a,b,c,d) sum<=a+b+c+d; END PROCESS; sum Example listing below, by inclusion of two sets of parentheses, generates two parallel adders whose outputs the circuit then adds. This design results in two logic levels. PROCESS (a,b,c,d) sum<=(a+b)+(c+d); END PROCESS; c d b a c b a sum February 2000 42

VHDL Hierarchical Design February 2000 43

Concept of Hierarchical Design Low-level Design ENTITY tff is port (d, clk, rst : in std_logic; q : out std_logic); end tff; ARCHITECTURE context of tff is begin D_FF: FD21 port map(d, q, clk, rst); NOT_Gate: INV port map(d, q); end context; High-Level Design ENTITY ripple_counter is port (cnt_en, clk, rst : in std_logic; q : out std_logic ); end ripple_counter; ARCHITECTURE structure of ripple_counter is tff0 : tff port map ( ); tff1 : tff port map ( ); tff2 : tff port map ( ); tff3 : tff port map ( ); end structure; T_FF0 Ripple Carry Counter T_FF1 T_FF2 T_FF3 February 2000 44

COMPONENT Top Level: Addmult component declaration: Add ENTITY addmult is Instantiation of component port( sig1,sig2: in std_logic_vector(0 to 3); result: out std_logic_vector(0 to 7)); end addmult; Low Level: Add ARCHITECTURE structure of addmult is SIGNAL s_add: std_logic_vector(0 to 7); Top level example COMPONENT add -- component declaration port(op1,op2: in std_logic_vector(0 to 3); ret: out std_logic_vector(0 to 7)); end component; --component instantiation --name of lower level component --key word connecting two levels add1: add port map(op1=>sig1, op2=>sig2, ret=>s_add); result <= s_add - 00000001 ; end structure; February 2000 45

COMPONENT (cont.) Top level design contains component declaration COMPONENT add port(op1,op2: in std_logic_vector(0 to 3); ret: out std_logic_vector(0 to 7)); end component; Lower level design of previous example ENTITY add is PORT(op1,op2: in std_logic_vector(0 to 3); ret: out std_logic_vector(0 to 7)); end add; ARCHITECTURE dataflow of add is ret <= op1 + op2; end dataflow; Component name identical to entity name in low-level design. port declaration in component and low-level entity are identical. Lower level design can be in a separate file or in the same file as the top-level design February 2000 46