IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL

Similar documents
PLD (eg. PAL) Typically 8 logic elements Technology: AND-OR array. William Sandqvist

Chapter 6 Combinational-Circuit Building Blocks

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

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

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

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

Digital Systems Design

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

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

Introduction to VHDL #1

Lecture 3 Introduction to VHDL

Boolean Logic CS.352.F12

Declarations of Components and Entities are similar Components are virtual design entities entity OR_3 is

Introduction to VHDL #3

Chapter 2 Basic Logic Circuits and VHDL Description

FPGA: FIELD PROGRAMMABLE GATE ARRAY Verilog: a hardware description language. Reference: [1]

Hardware Description Language VHDL (1) Introduction

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

OUTLINE SYSTEM-ON-CHIP DESIGN. GETTING STARTED WITH VHDL September 3, 2018 GAJSKI S Y-CHART (1983) TOP-DOWN DESIGN (1)

C-Based Hardware Design

Synthesis of Combinational and Sequential Circuits with Verilog

Basic Language Concepts

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

VHDL for Complex Designs

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

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

Written exam for IE1204/5 Digital Design Thursday 29/

Experiment 8 Introduction to VHDL

Digital Design with FPGAs. By Neeraj Kulkarni

Concurrent Signal Assignment Statements (CSAs)

Lecture 12 VHDL Synthesis

ECE U530 Digital Hardware Synthesis. Course Accounts and Tools

VHDL for Synthesis. Course Description. Course Duration. Goals

ELCT 501: Digital System Design

COMBINATIONAL LOGIC CIRCUITS

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

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

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

Lattice VHDL Training

Contents. Chapter 3 Combinational Circuits Page 1 of 34

Part 4: VHDL for sequential circuits. Introduction to Modeling and Verification of Digital Systems. Memory elements. Sequential circuits

Lecture 4. VHDL Fundamentals. George Mason University

EE 8351 Digital Logic Circuits Ms.J.Jayaudhaya, ASP/EEE

TSIU03, SYSTEM DESIGN LECTURE 2

What is Verilog HDL? Lecture 1: Verilog HDL Introduction. Basic Design Methodology. What is VHDL? Requirements

Lab 3: Standard Combinational Components

EEL 4783: Hardware/Software Co-design with FPGAs

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

CHAPTER 9 MULTIPLEXERS, DECODERS, AND PROGRAMMABLE LOGIC DEVICES

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

VHDL. Chapter 1 Introduction to VHDL. Course Objectives Affected. Outline

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

ECE 545 Lecture 12. FPGA Resources. George Mason University

VHDL: A Crash Course

Control and Datapath 8

Mridula Allani Fall Fall

EITF35: Introduction to Structured VLSI Design

1. Mark the correct statement(s)

VHDL Structural Modeling II

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

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

CONTENTS CHAPTER 1: NUMBER SYSTEM. Foreword...(vii) Preface... (ix) Acknowledgement... (xi) About the Author...(xxiii)

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

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

VHDL for FPGA Design. by : Mohamed Samy

ENGIN 241 Digital Systems with Lab

SUBJECT CODE: IT T35 DIGITAL SYSTEM DESIGN YEAR / SEM : 2 / 3

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

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

Topics. Midterm Finish Chapter 7

Combinational Logic COMB. LOGIC BLOCK. A Combinational Logic Block is one where the outputs depend only on the current inputs

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

Lecture 1: Introduction Course arrangements Recap of basic digital design concepts EDA tool demonstration

CS8803: Advanced Digital Design for Embedded Hardware

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 1

structure syntax different levels of abstraction

Here is a list of lecture objectives. They are provided for you to reflect on what you are supposed to learn, rather than an introduction to this

CSE140L: Components and Design Techniques for Digital Systems Lab

EECS150 - Digital Design Lecture 10 Logic Synthesis

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District DEPARTMENT OF INFORMATION TECHNOLOGY CS 2202 DIGITAL PRINCIPLES AND SYSTEM DESIGN

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

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

Chap.3 3. Chap reduces the complexity required to represent the schematic diagram of a circuit Library

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

Writing VHDL for RTL Synthesis

Introduction to Verilog HDL. Verilog 1

Outline of this Introduction to VHDL

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

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

Computer-Aided Digital System Design VHDL

CprE 583 Reconfigurable Computing

Midterm Exam Thursday, October 24, :00--2:15PM (75 minutes)

CSE140L: Components and Design

VHDL Examples Mohamed Zaky

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

DIGITAL CIRCUIT LOGIC UNIT 9: MULTIPLEXERS, DECODERS, AND PROGRAMMABLE LOGIC DEVICES

Sequential VHDL. Katarzyna Radecka. DSD COEN 313

SECTION 1 FAMILIARIZATION WITH VHDL

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

Transcription:

IE24 Digital Design L7: Combinational circuits, Introduction to VHDL Elena Dubrova KTH / ICT / ES dubrova@kth.se

This lecture BV 38-339, 6-65, 28-29,34-365 IE24 Digital Design, HT 24 2

The multiplexer (MUX) The multiplexer can select which input you are going to connect to the output If S then X, else Y X Y Z S Z SX S Y IE24 Digital Design, Autumn 24 2

Implementation of functions using MUXes How can the following functions be implemented with a 2: multiplexer? Z = B (INV) Z = AB (AND) Z = A + B (OR) Z = A B (XOR) X Y Z S Z SX S Y IE24 Digital Design, Autumn 24 3

Inverter implemented with a MUX Specification: If input x = "" then result = "" If input = "" then result = "" x NOT Input x Z IE24 Digital Design, Autumn 24 4

AND implemented with a MUX Specification: x x x Z x IE24 Digital Design, Autumn 24 5

OR implemented with a Mux Specification: x x X Z X IE24 Digital Design, Autumn 24 6

XOR implemented with a Mux Specification: x x X X Z X IE24 Digital Design, Autumn 24 7

Hierarchy of MUXes X X X X Z X X X X Z S S S S IE24 Digital Design, Autumn 24 8

Implementation of larger functions with MUXes Choose any of the inputs as address inputs... z xy f = z x +x y+zy z z f... And minimize/implement function for each input. Draw new Karnaugh diagrams if necessary. x y An (n + )-input function can be implemented with a MUX that has n select inputs! IE24 Digital Design, Autumn 24 9

Mapping into MUXes: Shannon decomposition (BV 6..2) Any Boolean function f (x n,..., x, x ) can be partitioned as f(x n,..., x, x ) = x f (x n,..., x,) + x f (x n,..., x,) = x f (x n,..., x ) + x f (x n,..., x ) The function can then be implemented with a multiplexer x n f x n f x f x x x n f x x IE24 Digital Design, Autumn 24

Mapping to MUXes: Shannon decomposition Any Boolean function f (x n,..., x, x ) can be decomposed (recursively) as f(x n,...,x,x ) = x f (x n,..., x ) + x f (x n,..., x ) = x x f (x n,..., x 2 ) + x x f (x n,..., x 2 ) + x x f (x n,..., x 2 ) + x x f (x n,..., x 2 ) f f x f f f f f x f x IE24 Digital Design, Autumn 24

Proof Right-hand side: If x = then the right term is zero. Then f is equal to the left term. If x =, the left term is zero. Then f is equal to the right term. Left-hand side: if x =, then f is equal to f (x n,..., x,) (= left term on the right-hand side) if x = then f is equal to f (x n,..., x,) (= right term in the right-hand side) Left-hand side = Right-hand side IE24 Digital Design, Autumn 24 2

Mux circuits x yz XYZ Value z Address y But this is a memory (ROM, RAM...) Address x Address pins IE24 Digital Design, Autumn 24 3

Look-up tables (LUT) Programmable cell / / / f x 2 x / A LUT with n inputs can realize all combinational functions with up to n inputs Two-input LUT IE24 Digital Design, Autumn 24 4

Example: XOR gate Programmed Values f x 2 x Two-input LUT IE24 Digital Design, Autumn 24 5

A simple FPGA cell The simplest FPGA cell consists of a single table (e.g. Look-Up-Table - LUT), a D flipflop and a bypass MUX A B C D LUT D Q CLK M S RESET IE24 Digital Design, Autumn 24 6

One way to identify functions... f ( x f 3, x2, x, x) "" 6996 MSB LSB Bit # 5 Bit # Bit # The functions that are stored in a LUT are usually numbered after the number that is made up of the 's in the truth table / Karnaugh map. n inputs => 2 (2n) possible different Boolean functions IE24 Digital Design, Autumn 24 7

Lut function number f ( x f 3, x2, x, x) "" 6996 f 6996 x3 x2 x x Odd parity With a LUT, all functions are realized in the same way, so all of them have the same cost IE24 Digital Design, HT 24 9

Decoder Mostly used as address decoders Only one output is active when the 'enable' (En) signal is active The active output is selected by a a En a a y y y 2 y 3 - - a a En y 3 y 2 y y 2-to-4 decoder IE24 Digital Design, Autumn 24 8

The demultiplexer The demultiplexer has basically the same function as the decoder, but it is drawn differently The input f is connected to a selected output f a a y y y 2 y 3 - - f y 3 y 2 y y a a IE24 Digital Design, Autumn 24 9

Read-Only Memory Sel Sel / /... / / /... / Programable bits a a... a m-...... Decoder Sel 2 m - En / /... / d n- d n-2. d Three-state buffers IE24 Digital Design, Autumn 24 2

Encoders Encoder has the opposite function to a decoder, i.e. it translates 2 N bit input into an N-bit code. The information is greatly reduced Keyboard with 6 = 2 4 keys 2 n inputs w w 2 n - y y n - n outputs IE24 Digital Design, Autumn 24 2

Priority Encoder A Priority Encoder gives back the address of the input with the lowest (or highest) indices that are set to (or depending on what you are looking for) If all inputs are, the output z =, else z = w w w 2 w 3 z y y - - - - - - - - The output is welldefined even is several inputs are active at the same time IE24 Digital Design, Autumn 24 22

Code converters A code converter translates from one code to another. Typical examples are: Binary to BCD (Binary-Coded Decimal) Binary to Gray code 7-4-2- code BCD to seven-segment decoder w w w 2 w 3 a b c d e f g f e a g d b c A variant of the 7-4-2- code is used today to store the bar code IE24 Digital Design, Autumn 24 23

BCD-to-seven segment decoder IE24 Digital Design, Autumn 24 24 w a b w w 2 w 3 c d e f g c e w a w b c d w 2 w 3 e f g a g b f d BCD-to-7 segment decoder consists of 7 different combinatorial circuits, one for each segment To get optimal circuits, all 7 functions have to be minimized simultaneously so that common logic is shared

Gray code to binary code converer Wind direction Wind speed Wind direction indicators usually use Gray code to provide safe data registration IE24 Digital Design, HT 24 27

Disadvantage of binary codes Binary code, adjacent code words: -2 double change 3-4 triple change 5-6 double change 7-8 quadruple change! 9-A double change B-C quadruple change! D-E double change F- quadruple change! Can two bits change at exactly the same time? For safe data registration use Gray code For data processing use binary code IE24 Digital Design, HT 24 28

Gray code By changing the order of the codewords in a binary code, one construct codes in which no more than one bit is changing at a time Such codes are called Gray codes,,,,,,,,,,,,,, IE24 Digital Design, HT 24 29

Can solve Towers of Hanoi Gray code can be helpful for those who want to solve the game "Towers of Hanoi, constructed by the mathematician Edouard Lucas in 883 When the monks are done with their work the earth will go under - it will take 2 64 moves, so the whole thing will probably take a while... According to the legend, three monks move 64 golden discs, of different sizes, from one bar to another. The discs should be moved one by one, and they must always be placed so that a smaller disc ports on a larger disc IE24 Digital Design, HT 24 3

Conversion between binary and Gray Binary Gray: If Binary bit b n and bit b n- are different, the Gray code bit g n- ", else ". Gray Binary (most common transformation direction ): If Binary bit b n and Gray code bit g n- are different the Binary bit b n- is ", else ". IE24 Digital Design, HT 24 3

Logic for Gray to Binary conversion XOR-gate is if its inputs are different! 4 bit code converter Gray code to Binary code Gray/Bin IE24 Digital Design, HT 24 32

Introduction to VHDL VHDL is a language used to specify the hardware HDL - VHSIC Hardware Description Language VHSIC - Very High Speed Integrated Circuit Used mostly in Europe Verilog is another language used to specify the hardware Used mostly in the United States IE24 Digital Design, Autumn 24 25

Why VHDL? VHDL is used to verify that you have connected right by simulating the circuit describe the large structures in a simple way and then generate the circuit by synthesis allows for structured descriptions of a circuit VHDL increases the level of abstraction! IE24 Digital Design, Autumn 24 28

Types of VHDL code There are two types of VHDL code VHDL for synthesis: The code is used as an input to a synthesis tool which converts it into an implementation (for example FPGA or ASIC) VHDL modeling and simulation code is used to describe a system at an early stage. Since the code can be simulated so you can check whether the intended functionality is correct IE24 Digital Design, Autumn 24 29

Entity The primary abstraction level in VHDL is called Entity In a behavioral description, the entity defines responses to signals and inputs A behavioral model is the same thing as a "black box" The inside is not visible from the outside Entity's behavior is defined by the black box s functionality. Input Behavioral Entity Output IE24 Digital Design, Autumn 24 3

Entity (cont'd.) An entity describes a component's interface with the outside world PORT-declaration indicates if it is an input or an output An Entity is a symbol of a component. ENTITY xor_gate IS PORT (x, y: IN BIT; q: OUT BIT); END xor_gate; x y xor_gate q Use English names for variable names in the code! IE24 Digital Design, Autumn 24 32

VHDL Basics PORT declaration establishes interface between the component and the outside world A port declaration contains three things: The name of the port The direction of the port Port's datatype Example: ENTITY test IS PORT ( name : direction data_typ); END test; IE24 Digital Design, Autumn 24 33

The most common data types Scalars (single-variable signals) Bit ("", "") Std_logic ('U', '', ', 'X', 'Z', 'L', 'H', 'W', '-') Integer Real Time Vectors (many-variable signals) Bit_vector - vector of bits STD_LOGIC_VECTOR - vector of std_logic IE24 Digital Design, Autumn 24 34

Architecture A architecture describes the operation of a component An entity can have many architectures, but only one can be active at a time An architecture corresponds to the component diagram or behavior x y q Code for Simulation ARCHITECTURE behavior OF xor_gate IS BEGIN q <= a xor b after 5 ns; End behavior; IE24 Digital Design, Autumn 24 35

VHDL Example: 4/ MUX (/2) LIBRARY ieee; USE ieee.std_logic_64.all; ENTITY Multiplexer_4 IS PORT(ce_n: IN std_logic; -- Chip Enable (active low) data_in : IN std_logic_vector(3 DOWNTO ); sel: IN std_logic_vector( DOWNTO ); data_out : OUT std_logic); -- TriState Output END ENTITY Multiplexer_4; IE24 Digital Design, HT 24 4

VHDL Example: 4/ MUX (2/2) ARCHITECTURE RTL OF Multiplexer_4 IS BEGIN PROCESS(ce_n, data_in, sel) BEGIN IF ce_n = '' THEN ELSE data_out <= 'Z'; CASE sel is WHEN ""=> data_out <= data_in(); WHEN ""=> data_out <= data_in(); WHEN ""=> data_out <= data_in(2); WHEN ""=> data_out <= data_in(3); WHEN OTHERS => null; END CASE; END IF; END PROCESS; END ARCHITECTURE RTL; IE24 Digital Design, Autumn 24 37

More on VHDL The study matherial on synthesis shows a number VHDL constructions and the resulting hardware The following slides contain extra material The book gives many examples and detailed explanations of VHDL IE24 Digital Design, Autumn 24 38

Synthesis tool Quartus The course textbook contains a CD with the synthesis tool, Quartus You will use Quartus in Lab 3 IE24 Digital Design, Autumn 24 39

Summary Implementation of functions with MUXes Shannon decomposition Look-up tables, ROM Decoder, encoder, code converters Introduction to VHDL Next lecture: BV pp. 383-48, 469-47 IE24 Digital Design, HT 24 45

VHDL (Not part of the exam) IE24 Digital Design, Autumn 24 4

Signal declaration Signal-declaration is used inside architectures to declare internal (local) signals: signal a, b, c, d: bit; signal a, b, sum: bit_vector (3 downto ); Signal-assignment is used to describe the behavior: sum <= a + b; signal assignment without delay IE24 Digital Design, Autumn 24 4

VHDL description styles Structural similar to how to connect components Sequential similar to how to write desktop applications Data Flow Concurrent assignments IE24 Digital Design, Autumn 24 42

Sequential vs Parallel Code There are two types of code execution in VHDL: sequential and parallel Hardware can then be modeled in two different ways VHDL supports different levels of abstraction. Sequential code describes the hardware from a "programmer's" point of view and it is executed in the order which is defined The parallel code is executed regardless of the order. It is asynchronous. IE24 Digital Design, Autumn 24 43

Sequential style XOR gate x y q Process (x, y) begin if (x/= y) then q <= ''; else q <= ''; end if; end process; IE24 Digital Design, Autumn 24 44

Data flow style XOR gate x y q q <= a xor b; - Or in behavioral dataflow style q <= '' When a /= b else ""; IE24 Digital Design, Autumn 24 45

Structural style XOR gate x y q u: not_gate port map (x, xi); u2: not_gate port map (y, y); u3: and_gate port map (x, y, t3); u4: and_gate port map (y, x, t4); u5: or_gate port map (t3, t4, q); IE24 Digital Design, Autumn 24 46

Structural Code A component must be declared before it can be used ARCHITECTURE Test OF test_entity COMPONENT and_gate Port (in, in2: IN BIT; out: BIT OUT); END COMPONENT;... more statements... It is necessary, unless it is not in a library somewhere IE24 Digital Design, Autumn 24 47

Structural Code Component instantiation ring connects the component interface with the signals in the architecture ARCHITECTURE Test OF test_entity COMPONENT and_gate Port (in, in2: IN BIT; out: BIT OUT); END COMPONENT; SIGNAL S, S2, S3: BIT; BEGIN Gate: and_gate PORT MAP (S, S2, S3); END test; IE24 Digital Design, Autumn 24 48

Structural Code (cont'd.) Generate-statement couples many similar elements ENTITY adder IS GENERIC (N: integer) PORT (a, b: IN bit_vector (N- downto ); sum: OUT bit_vector (N- downto )); END adder; ARCHITECTURE OF structural adder IS COMPONENT full_adder PORT (a, b, cin: IN bit; cout, s: OUT bit); END COMPONENT; signal c: bit_vector (N-2 downto ); BEGIN G: for i in to N-2 Generate U: full_adder PORT MAP (a (i), b (i), c (i-), c (i), p (i)); end Generate; - G U: full_adder PORT MAP (a(), b(),, c(), p()); UN: full_adder PORT MAP (a(n-),b(n-),c(n-2),open, s(n-); END structural; IE24 Digital Design, Autumn 24 49

Test benches To test if your design works, you have to create a test bench. It has three functions: Generating stimuli for simulation Applying these stimuli to an entity to be tested Comparing the output values with expected values IE24 Digital Design, Autumn 24 5

The test bench stimuli ENTITY testbench IS END testbench; ARCHITECTURE xor_stimuli_ of testbench IS COMPONENT xor_gate PORT(x,y:IN bit;q:out bit); END COMPONENT; signal x,y,u,ut2,ut3:bit; BEGIN x <= not(x) after ns; y <= not(y) after 2 ns; U:xor_gate PORT MAP (x,y,ut); U2:xor_gate PORT MAP (x,y,ut2); U3:xor_gate PORT MAP (x,y,ut3); END example; IE24 Digital Design, Autumn 24 5

The test bench stimuli 2 ENTITY testbench IS END testbench; ARCHITECTURE xor_stimuli_2 of testbench IS COMPONENT xor_gate PORT(x,y:IN bit;q:out bit); END COMPONENT; signal x,u,u2,u3:bit; -- Endast en in-signal for U:xor_gate use entity work.xor_gate(behave); for U2:xor_gate use entity work.xor_gate(data_flow); for U3:xor_gate use entity work.xor_gate(structural); BEGIN x <= not(x) after ns; U:xor_gate PORT MAP (x,x,ut); U2:xor_gate PORT MAP (x,x,ut2); U3:xor_gate PORT MAP (x,x,ut3); END example; IE24 Digital Design, Autumn 24 52