Experiment 4 Decoder Encoder Design using VHDL

Similar documents
Acknowledgment. DLD Lab. This set of slides on VHDL are due to Brown and Vranesic.

DESIGN AND IMPLEMENTATION OF ENCODERS AND DECODERS. To design and implement encoders and decoders using logic gates.

COMBINATIONAL LOGIC CIRCUITS. Dr. Mudathir A. Fagiri

Problem Set 6 Solutions

Digital Logic Design ENEE x. Lecture 14

Assignment # 3 - CSI 2111(Solutions)

Review for Test 1 : Ch1 5

Chapter 3 Ctd: Combinational Functions and Circuits

Written reexam with solutions for IE1204/5 Digital Design Monday 14/

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences

Table of Content. Chapter 11 Dedicated Microprocessors Page 1 of 25

Z = F(X) Combinational circuit. A combinational circuit can be specified either by a truth table. Truth Table

Dr. Nicola Nicolici COE/EE2DI4 Midterm Test #2 Nov 22, 2006

Written exam for IE1204/5 Digital Design with solutions Thursday 29/

7 Multipliers and their VHDL representation

COMBINATIONAL LOGIC FUNCTIONS

Luleå Tekniska Universitet Kurskod SMD098 Tentamensdatum

Shannon decomposition

CSE 140L Spring 2010 Lab 1 Assignment Due beginning of the class on 14 th April

Systems I: Computer Organization and Architecture

Shannon decomposition

ECE223. R eouven Elbaz Office room: DC3576

UNIVERSITY OF CALIFORNIA, RIVERSIDE

ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN. Week 2 Dr. Srinivas Shakkottai Dept. of Electrical and Computer Engineering

Chapter 4: Combinational Logic Solutions to Problems: [1, 5, 9, 12, 19, 23, 30, 33]

STEADY CODES WITH HAMMING- DISTANCES 1 AND 2 DGT D = 1 C 2 D = 2 C 1 C Digital Circuits. Hamburg. Prof. Dr. F.

CSCI 220: Computer Architecture-I Instructor: Pranava K. Jha. BCD Codes

CprE 281: Digital Logic

Logic. Combinational. inputs. outputs. the result. system can

ECE 448 Lecture 6. Finite State Machines. State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL Code. George Mason University

CHAPTER * 2-2.* Pearson Education Limited Problem Solutions, Global Edition Chapter 2. Verification of DeMorgan s Theorem

Written exam with solutions IE1204/5 Digital Design Friday 13/

Preparation of Examination Questions and Exercises: Solutions

COE 328 Final Exam 2008

CprE 281: Digital Logic

Number System. Decimal to binary Binary to Decimal Binary to octal Binary to hexadecimal Hexadecimal to binary Octal to binary

Combinational Logic. By : Ali Mustafa

MODULAR CIRCUITS CHAPTER 7

ECE 545 Digital System Design with VHDL Lecture 1A. Digital Logic Refresher Part A Combinational Logic Building Blocks

Chapter 3 Combinational Logic Design

Slides for Lecture 19

control in out in out Figure 1. Binary switch: (a) opened or off; (b) closed or on.

Unit 3 Session - 9 Data-Processing Circuits

Combinational Logic Design Combinational Functions and Circuits

Pin Details of Digital Logic Gates:

Chapter 4. Combinational: Circuits with logic gates whose outputs depend on the present combination of the inputs. elements. Dr.

Combinational Logic. Lan-Da Van ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C.

CHAPTER1: Digital Logic Circuits Combination Circuits

Why digital? Overview. Number Systems. Binary to Decimal conversion

Logic Simplification. Boolean Simplification Example. Applying Boolean Identities F = A B C + A B C + A BC + ABC. Karnaugh Maps 2/10/2009 COMP370 1

Review: Additional Boolean operations

Week No. 06: Numbering Systems

Lecture 6: Gate Level Minimization Syed M. Mahmud, Ph.D ECE Department Wayne State University

Combinational Logic. Mantıksal Tasarım BBM231. section instructor: Ufuk Çelikcan

Midterm Examination # 1 Wednesday, February 25, Duration of examination: 75 minutes

The Design Procedure. Output Equation Determination - Derive output equations from the state table

EECE 202 (Network I) & EECE 208 (Lab)

ECE 407 Computer Aided Design for Electronic Systems. Simulation. Instructor: Maria K. Michael. Overview

DE58/DC58 LOGIC DESIGN DEC 2014

211: Computer Architecture Summer 2016

ECE 545 Digital System Design with VHDL Lecture 1. Digital Logic Refresher Part A Combinational Logic Building Blocks

Chapter 9. Counters and Shift Registers. Counters and Shift Registers

Written exam with solutions IE Digital Design Friday 21/

Written exam with solutions IE1204/5 Digital Design Monday 23/

VHDL Implementation of Reversible Full Adder using PERES Gate

Combinational Logic. Lan-Da Van ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C.

EXAMINATION in Hardware Description and Verification

CS 226: Digital Logic Design

Unit 16 Problem Solutions

Contents. Chapter 3 Combinational Circuits Page 1 of 36

Boolean Algebra, Gates and Circuits

ECE 3401 Lecture 23. Pipeline Design. State Table for 2-Cycle Instructions. Control Unit. ISA: Instruction Specifications (for reference)

Department of Electrical & Electronics EE-333 DIGITAL SYSTEMS

LOGIC GATES. Basic Experiment and Design of Electronics. Ho Kyung Kim, Ph.D.

Lecture 2 Review on Digital Logic (Part 1)

CprE 281: Digital Logic


Cs302 Quiz for MID TERM Exam Solved

LECTURE 2: Delay models, std_ulogic and. EECS 316 CAD Computer Aided Design. with-select-when. Chris Papachristou Case Western Reserve University

ELECTRONICS & COMMUNICATION ENGINEERING PROFESSIONAL ETHICS AND HUMAN VALUES

Philadelphia University Student Name: Student Number:

Digital Control of Electric Drives

Vidyalankar. S.E. Sem. III [EXTC] Digital System Design. Q.1 Solve following : [20] Q.1(a) Explain the following decimals in gray code form

CE Optimized State Machines

And Inverter Graphs. and and nand. inverter or nor xor

Schedule. ECEN 301 Discussion #25 Final Review 1. Date Day Class No. 1 Dec Mon 25 Final Review. Title Chapters HW Due date. Lab Due date.

4 Switching Algebra 4.1 Axioms; Signals and Switching Algebra

UNIT II COMBINATIONAL CIRCUITS:

Introduction to Karnaugh Maps

Computer Science Final Examination Friday December 14 th 2001

14:332:231 DIGITAL LOGIC DESIGN

University of Guelph School of Engineering ENG 2410 Digital Design Fall There are 7 questions, answer all questions.

Philadelphia University Student Name: Student Number:

University of Florida EEL 3701 Summer 2015 Dr. Eric. M. Schwartz Department of Electrical & Computer Engineering Tuesday, 30 June 2015

Logic Design Combinational Circuits. Digital Computer Design

Introduction to Digital Logic Missouri S&T University CPE 2210 Combinatorial Circuit Analysis and Synthesis

Numbering Systems. Contents: Binary & Decimal. Converting From: B D, D B. Arithmetic operation on Binary.

Contents. Chapter 2 Digital Circuits Page 1 of 30

Digital Logic (2) Boolean Algebra

Save from: cs. Logic design 1 st Class أستاذ المادة: د. عماد

Transcription:

Objective: Experiment 4 Decoder Encoder Design using VHDL To learn how to write VHDL code To Learn how to do functional simulation To do study of the synthesis done by VHDL and the theoretical desin obtained using algebraic solution. Requirement: A computer system installed with XILINX VHDL Theory: A decoder generally decodes a binary value into a non-binary one by setting exactly one of itsn outputs to logic 1. If a binary decoder receives n inputs (usually grouped as a single binary or Boolean number) it activates one and only one of its 2 n outputs based on that input with all other outputs deactivated. The truth table of a decoder is shown below: S1 S0 O0 O1 O2 O3 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 1 1 0 0 0 1 As seen in the truth table only one of the output line is active depending on the input line combination. The logic equations for a decoder can be written as: O0 : S 1 S 0 1 when S 1 =0 and S 0 =0 O1 : S 1 S 0 1 when S 1 =0 and S 0 =1 O2 `: S 1 S 0 1 when S 1 =1 and S 0 =0 O3 : S 1 S 0 1 when S 1 =1 and S 0 =1 Now using the above expressions we can write the VHDL code for any size of decode. Here we implement a 1: 2 decoder with and without enable input. Then use thse as building block for constructing larger size deciders.

Synthesis 1 Decoder without enable library IEEE; use IEEE.STD_LOGIC_1164.ALL; entitydecod is Port ( sel : in STD_LOGIC; o1 : out STD_LOGIC; o2 : out STD_LOGIC); enddecod; architecture Behavioral of decod is o2 <= '1' when sel='1' else '0' when sel='0'; withsel select o1 <= '1' when '0', '0' when '1', 'Z' when others; 2 Decoder with enable input library IEEE; use IEEE.STD_LOGIC_1164.ALL; entitydecoder_with_enable is Port ( sel : in STD_LOGIC; en : in STD_LOGIC; o1 : out STD_LOGIC;

o2 : out STD_LOGIC); enddecoder_with_enable; architecture Behavioral of decoder_with_enable is o1 <= '1' when sel='0' and en='1' else '0'; o2 <= '1' when sel='1' and en='1' else '0'; 3A 2:4 Decoder using 1:2 Decoder in structure modelling library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity decoder2to4_structure is Port ( I : in STD_LOGIC_VECTOR (1 downto 0);

end decoder2to4_structure; o : out STD_LOGIC_VECTOR (3 downto 0)); architecture Behavioral of decoder2to4_structure is signal w1, w2: std_logic; RTL View: x1: entity work.decod PORT MAP (sel=>i(1), o1=> w1,o2=> w2); x2: entity work.decoder_with_enable PORT MAP (sel=>i(0), en=> w1, o1=> o(0), o2=> o(1)); x3: entity work.decoder_with_enable PORT MAP (sel=>i(0), en=> w2,o1=> o(2), o2 => o(3)); The snapshot shows the top level design of 1 2:4 decoder wit I(1:0) being the inputs and o(3:0) being the outputs. Simulation

2. ENCODER An encoder accepts an active level on one of its inputs, representing digit, such as a decimal or octal digits, and converts it to a coded output such as BCD or binary. Encoders can also be devised to encode various symbols and alphabetic characters. The process of converting from familiar symbols or numbers to a coded format is called encoding. An encoder has a number of input lines, only one of which input is activated at a given time and produces an N-bit output code,depending on which input is activated. The functional table for a 4 line to 2 line encoder is shown below: Inputs Output K0 K1 K2 K3 Yo Y1 1 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 1 0 0 0 0 1 1 1 The Boolean equations for coded outputs are: Y0= k2+k3 Y1= K1 + K3

Priority Encoder A priority Encoder encodes one of the many inputs but only the key having the highest priority is encoded first. If highest priority key is not pressed then the next lower priority key is encoded and so on. The functional table is given below, In the table Y0Y1 are the encoded output, output V is an indicator of a valid key press and is high when one of the valid key is pressed: K0 K1 K2 K3 Y0 Y1 V 0 0 0 0 x x 0 1 0 0 0 0 0 1 x 1 0 0 0 1 1 x x 1 0 1 0 1 x x x 1 1 1 1 The first row in table shows none of the key pressed, so the output (Y0, Y1) are don t care, and V output is zero indicating none of the valid key pressed. The other rows shows only one input is active and the least numbered keys are don t cared, and a valid key press entry V is raised and corresponding binary output obtained at Y1, Y1. The Boolean equations are: The equation for V is: V = K0 + K1 + K2 + K3 The logic diagram for the 4 to 2 priority encoder is shown in figure below:

VHDL Code for 4:2 priority encoder library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity PRIORITY_ENCODER is Port ( K : in STD_LOGIC_VECTOR (3 downto 0); Y : out STD_LOGIC_VECTOR (1 downto 0); V : out STD_LOGIC); end PRIORITY_ENCODER; architecture Behavioral of PRIORITY_ENCODER is Y(0) <= K(2) OR K(3); Y(1) <= (K(3) OR (K(1) AND (not K(2)))); V <= K(0) OR K(1) OR K(2) OR K(3); Schematic View

Simulation: Structural Modelling of 4:2 Priority Encoder entity or_4ip is Port ( i : in STD_LOGIC_VECTOR (3 downto 0); o : out STD_LOGIC); end or_4ip; architecture Behavioral of or_4ip is o <= i(0) or i(1) or i(2) or i(3); entity OR_GATE is Port ( i1 : in STD_LOGIC;

i2 : in STD_LOGIC; o : out STD_LOGIC); end OR_GATE; architecture Behavioral of OR_GATE is o <= i1 or i2; entity NO_GATE is Port ( i : in STD_LOGIC; o : out STD_LOGIC); end NO_GATE; architecture Behavioral of NO_GATE is o <= not i; library IEEE; use IEEE.STD_LOGIC_1164.ALL; librarymy_logics_lib; usemy_logics_lib.all; entityencoder_structure is Port ( k : in STD_LOGIC_VECTOR (3 downto 0); o : out STD_LOGIC_VECTOR (1 downto 0);

v : out STD_LOGIC); endencoder_structure; architecture Behavioral of encoder_structure is signal w1, w2: std_logic; x1: entity work.or_gate port map (i1=>k(3), i2 => w1, o => o(1)); x2: entity work.no_gate port map (i=> k(2), o => w2); x3: entity work.and_gate port map (i1=>k(1), i2 => w2, o => w1); x4: entity work.or_gate port map (i1=>k(2), i2 => k(3), o => o(0)) ; x5: entity work.or_4ip port map (i(0)=> k(0), i(1)=> k(1), i(2) => k(2), i(3) => k(3), o => v);