Digital Systems Design

Similar documents
Chapter 6 Combinational-Circuit Building Blocks

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

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

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

ELCT 501: Digital System Design

Hardware Description Language VHDL (1) Introduction

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

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

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

Arithmetic Circuits. Nurul Hazlina Adder 2. Multiplier 3. Arithmetic Logic Unit (ALU) 4. HDL for Arithmetic Circuit

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

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 2

Very High Speed Integrated Circuit Har dware Description Language

Introduction to VHDL #1

Contents. Appendix D VHDL Summary Page 1 of 23

Introduction to VHDL #3

VHDL for FPGA Design. by : Mohamed Samy

Concurrent Signal Assignment Statements (CSAs)

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

ENGIN 241 Digital Systems with Lab

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 3

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

ELE432. ADVANCED DIGITAL DESIGN HACETTEPE UNIVERSITY Designing with VHDL

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

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 3

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

Lecture 4. VHDL Fundamentals. George Mason University

Lattice VHDL Training

Digital Systems Design

Digital Systems Design

VHDL Structural Modeling II

Basic Language Concepts

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

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

COE 405 Design Methodology Based on VHDL

VHDL Examples Mohamed Zaky

ACS College of Engineering. Department of Biomedical Engineering. Logic Design Lab pre lab questions ( ) Cycle-1

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

Introduction to VHDL. Main language concepts

The VHDL Hardware Description Language

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

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

Chapter 2 Basic Logic Circuits and VHDL Description

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

IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL

Design Using Verilog

Experiment 8 Introduction to VHDL

Computer-Aided Digital System Design VHDL

Writing VHDL for RTL Synthesis

What Is VHDL? VHSIC (Very High Speed Integrated Circuit) Hardware Description Language IEEE 1076 standard (1987, 1993)

DOD, VHSIC ~1986, IEEE stnd 1987 Widely used (competition Verilog) Commercial VHDL Simulators, Synthesizers, Analyzers,etc Student texts with CDROMs

Lecture 12 VHDL Synthesis

1. Defining and capturing the design of a system. 2. Cost Limitations (low profit margin must sell millions)

Review of Digital Design with VHDL

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

Digital Design Using VHDL Using Xilinx s Tool for Synthesis and ModelSim for Verification

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

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

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

Lab # 2. Sequential Statements

LECTURE 4: The VHDL N-bit Adder

CCE 3202 Advanced Digital System Design

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

VHDL for Complex Designs

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

CprE 583 Reconfigurable Computing

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

Control and Datapath 8

Introduction to VHDL #2

Mridula Allani Fall Fall

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

Introduction to VHDL

Embedded Systems CS - ES

ECE 545 Lecture 12. FPGA Resources. George Mason University

Lecture 3 Introduction to VHDL

EECE-4740/5740 Advanced VHDL and FPGA Design. Lecture 3 Concurrent and sequential statements

C-Based Hardware Design

ECE 545 Lecture 7. Modeling of Circuits with a Regular Structure. Aliases, Attributes, Packages. Mixing Design Styles. George Mason University

Menu. Introduction to VHDL EEL3701 EEL3701. Intro to VHDL

Constructing VHDL Models with CSA

EE261: Intro to Digital Design

EEL 4783: Hardware/Software Co-design with FPGAs

VHDL Objects. Lecture 8: VHDL (2) Variables. VHDL Objects - Constant. Files. EE3109 Gopi K. Manne Fall 2007

ECE 545 Lecture 9. Modeling of Circuits with a Regular Structure. Aliases, Attributes, Packages. George Mason University

Solutions - Homework 2 (Due date: October 9:30 am) Presentation and clarity are very important!

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

Department of Technical Education DIPLOMA COURSE IN ELECTRONICS AND COMMUNICATION ENGINEERING. Fifth Semester. Subject: VHDL Programming

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

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

Lab 3: Standard Combinational Components

CprE 583 Reconfigurable Computing

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

ECE U530 Digital Hardware Synthesis. Course Accounts and Tools

Hardware Description Languages. Modeling Complex Systems

5. 0 VHDL OPERATORS. The above classes are arranged in increasing priority when parentheses are not used.

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 6 Combinational and sequential circuits

Advanced Electronics Lab.

Modeling Complex Behavior

Transcription:

Digital Systems Design Review of Combinatorial Circuit Building Blocks: VHDL for Combinational Circuits Dr. D. J. Jackson Lecture 2-1 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 Dr. D. J. Jackson Lecture 2-2 1

Writing simple VHDL code First step in writing VHDL code is to declare the input and output signals Done using a construct called an entity Name of the entity Input and output signals (ports) defined entity example1 is port (x1,x2,x3 : in bit; f : out bit); end example1; Mode of the port IN (input) OUT (output) Type of the port Dr. D. J. Jackson Lecture 2-3 Writing simple VHDL code Name of the entity Input and output signals (ports) defined entity example1 is port (x1,x2,x3 : in bit; f : out bit); end example1; Mode of the port IN (input) OUT (output) Type of the port x1 x2 x3 f Dr. D. J. Jackson Lecture 2-4 2

Writing simple VHDL code The entity specifies the inputs and outputs for a circuit, but does not describe the circuit function Circuit functionality is specified using a VHDL construct called an architecture Architecture name Entity used by logicfunc architecture logicfunc of example1 is f <= (x1 and x2) or (not x2 and x3); end logicfunc; VHDL statement that describes the circuit functionality Dr. D. J. Jackson Lecture 2-5 Complete VHDL code example x1 x2 f entity example1 is port (x1,x2,x3 : in bit; x3 f : out bit); end example1; architecture logicfunc of example1 is f <= (x1 and x2) or (not x2 and x3); end logicfunc; Dr. D. J. Jackson Lecture 2-6 3

Boolean operators in VHDL VHDL has built-in support for the following operators and logical AND or logical OR not logical NOT nand, nor, xor, xnor Assignment operator <= A variable (usually an output, mode OUT) should be assigned the result of the logic expression on the right hand side of the operator VHDL does not assume any precedence of logic operators. Use parentheses in expressions to determine precedence Exception to this is NOT logical operator 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. Dr. D. J. Jackson Lecture 2-7 Assignment statements VHDL provides several types of statements that can be used to assign logic values to signals Simple assignment statements Used for simple logic or arithmetic expressions Selected signal assignments Conditional signal assignments Generate statements If-then-else statements Case statements Dr. D. J. Jackson Lecture 2-8 4

Selected signal assignment A selected signal assignment allows a signal to be assigned one of several values, based on a selection criterion Keyword WITH specifies that s is used for the selection criterion Two WHEN clauses state that f=w 0 when s=0 and f=w 1 otherwise The keyword OTHERS must be used architecture behavior of mux2to1 is with s select f <= w0 when '0', w1 when others; Dr. D. J. Jackson Lecture 2-9 Design using VHDL In VHDL, a logic signal is represented as a data object We used a bit data type before that could only take on the values 0 and 1 Another data type, std_logic, is actually preferable because it can assume several different values [0, 1, Z (high impedance), - (don t care), etc] The std_logic_vector data type can be used for multi-bit values We must declare the library where the data type exists, and declare that we will use the data type library ieee; use ieee.std_logic_1164.all; Dr. D. J. Jackson Lecture 2-10 5

4-to-1 multiplexer VHDL code library ieee; use ieee.std_logic_1164.all; entity mux4to1 is port ( w : in std_logic_vector(3 downto 0); s : in std_logic_vector(1 downto 0); f : out std_logic); end mux4to1; architecture behavior of mux4to1 is with s select f <= w(0) when "00", w(1) when "01", w(2) when "10", w(3) when others; Dr. D. J. Jackson Lecture 2-11 2-to-4 binary decoder VHDL code entity dec2to4 is port ( w : in std_logic_vector(1 downto 0); en : in std_logic; y : out std_logic_vector(0 to 3)); end dec2to4; architecture behavior of dec2to4 is signal enw : std_logic_vector(2 downto 0); enw <= en & w; -- & is the vhdl concatenate operator with enw select y <= "1000" when "100", "0100" when "101", "0010" when "110", "0001" when "111", "0000" when others; Dr. D. J. Jackson Lecture 2-12 6

Conditional signal assignment Similar to the selected signal assignment, a conditional signal assignment allows a signal to be set to one of several values Uses when and else keyword to define the condition and actions entity mux2to1 is port (w0, w1, s : in std_logic; f : out std_logic); end mux2to1; architecture behavior of mux2to1 is f <= w0 when s = '0' else w1; Dr. D. J. Jackson Lecture 2-13 Priority encoder VHDL code entity priority is port ( w : in std_logic_vector(3 downto 0); y : out std_logic_vector(1 downto 0); z : out std_logic); end priority; architecture behavior of priority is 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'; Dr. D. J. Jackson Lecture 2-14 7

Behavioral Versus Structural VHDL The previous VHDL code examples are termed behavioral VHDL because they describe the behavior of a circuit without describing exactly how it is implemented in hardware. Another VHDL coding style is structural. For structural VHDL, the user typically describes the structure of a design by interconnecting several simpler designs from a library The library components may be user-defined or provided by the CAD tool vendor. Dr. D. J. Jackson Lecture 2-15 Single Bit Full Adder and Package Definition library ieee ; use ieee.std_logic_1164.all ; entity fulladd is port ( cin, x, y : in std_logic; s, cout : out std_logic); end fulladd ; architecture logicfunc of fulladd is s <= x xor y xor cin; cout <= (x and y) or (cin and x) or (cin and y); end logicfunc; Dr. D. J. Jackson Lecture 2-16 8

Single Bit Full Adder and Package Definition library ieee; use ieee.std_logic_1164.all; package fulladd_package is component fulladd port ( cin, x, y : in std_logic; s, cout : out std_logic); end component; end fulladd_package; Dr. D. J. Jackson Lecture 2-17 4-bit ripple carry adder library ieee; use ieee.std_logic_1164.all; use work.fulladd_package.all; entity adder4 is port ( cin : in std_logic; x, y : in std_logic_vector(3 downto 0); s : out std_logic_vector(3 downto 0); cout : out std_logic); end adder4; architecture structure of adder4 is signal c : std_logic_vector(1 to 3); 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; Dr. D. J. Jackson Lecture 2-18 9

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 Dr. D. J. Jackson Lecture 2-19 4-bit ripple carry adder library ieee; use ieee.std_logic_1164.all; use work.fulladd_package.all; entity adder4 is port ( cin : in std_logic; x, y : in std_logic_vector(3 downto 0); s : out std_logic_vector(3 downto 0); cout : out std_logic); end adder4; architecture structure of adder4 is signal c : std_logic_vector(0 to 4); c(0) <= cin; cout <= c(4); g1: for i in 0 to 3 generate stages: fulladd port map (c(i), x(i), y(i), s(i), c(i+1)); end generate; end structure; Dr. D. J. Jackson Lecture 2-20 10

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 Dr. D. J. Jackson Lecture 2-21 Process statement The process statement, or simply process, s with the PROCESS keyword, followed by a parenthesized list of signals called the sensitivity list This list includes, at most, all the (input) signals used inside the process There may be no signals in the sensitivity list (i.e. the list may not exist) Generally the list includes all signals that can be used to activate the process Statements inside the process are evaluated in sequential order This is true from a simulation standpoint From a synthesized hardware point-of-view, multiple assignments to a single signal (variable) generally implies multiplexing of the assignments to produce a single output 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 Dr. D. J. Jackson Lecture 2-22 11

2-to-1 MUX as a PROCESS architecture behavior of mux2to1 is process (w0,w1,s) if s = '0' then f <= w0; else f <= w1; end if; end process; Sensitivity list, Whenever a list entry changes, the process is reevaluated (activated) IF-THEN-ELSE statement to implement the MUX function Dr. D. J. Jackson Lecture 2-23 Priority encoder (IF-THEN-ELSE) architecture behavior of priority is process (w) if w(3) = '1' then y <= "11"; elsif w(2) = '1' then y <= "10"; elsif w(1) = '1' then y <= "01"; else y <= "00"; end if; end process; z <= '0' when w = "0000" else '1'; Dr. D. J. Jackson Lecture 2-24 12

Priority encoder (alternative) architecture behavior of priority is process (w) y <= "00"; if w(1) = '1' then y <= "01" ; end if; if w(2) = '1' then y <= "10" ; end if; if w(3) = '1' then y <= "11" ; end if; z <= '1'; if w = "0000" then z <= '0' ; end if; end process; Dr. D. J. Jackson Lecture 2-25 Implied memory in a PROCESS architecture behavior of c1 is process (a, b) aeqb <= '0'; if a = b then aeqb <= '1'; end if; end process; architecture behavior of c1 is process (a, b) if a = b then aeqb <= '1'; end if; end process; A B AeqB A B AeqB Dr. D. J. Jackson Lecture 2-26 13

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 Dr. D. J. Jackson Lecture 2-27 2-to-1 MUX with CASE architecture behavior of mux2to1 is process (w0,w1,s) case s is when '0' => f <= w0; when others => f <= w1; end case; end process; Dr. D. J. Jackson Lecture 2-28 14

2-to-4 binary decoder with CASE architecture behavior of dec2to4 is process (w, en) if en = '1' then case w is when "00" => y <= "1000"; when "01" => y <= "0100"; when "10" => y <= "0010"; when others => y <= "0001"; end case ; else y <= "0000"; end if; end process; Dr. D. J. Jackson Lecture 2-29 15