Multiplexers Two Types + Verilog

Similar documents
Finite State Machine Design A Vending Machine

Introduction to Digital Design Using Digilent FPGA Boards Block Diagram / Verilog Examples

Sequential Logic: Clocks, Registers, etc.

Lab 1: Introduction to Xilinx ISE Tutorial

ELEC EXPERIMENT 1 Basic Digital Logic Circuits

Digital Circuit Design Using Xilinx ISE Tools

Lab 1: Full Adder 0.0

Lab 17: Building a 4-Digit 7-Segment LED Decoder

Modeling Registers and Counters

A New Paradigm for Synchronous State Machine Design in Verilog

Gates, Circuits, and Boolean Algebra

Technical Aspects of Creating and Assessing a Learning Environment in Digital Electronics for High School Students

VHDL Test Bench Tutorial

ECE410 Design Project Spring 2008 Design and Characterization of a CMOS 8-bit Microprocessor Data Path

Modeling Latches and Flip-flops

EGR 278 Digital Logic Lab File: N278L3A Lab # 3 Open-Collector and Driver Gates

ECE 451 Verilog Exercises. Sept 14, James Barnes

LAB #3 VHDL RECOGNITION AND GAL IC PROGRAMMING USING ALL-11 UNIVERSAL PROGRAMMER

FORDHAM UNIVERSITY CISC Dept. of Computer and Info. Science Spring, Lab 2. The Full-Adder

LAB #4 Sequential Logic, Latches, Flip-Flops, Shift Registers, and Counters

Introduction to Digital System Design

Life Cycle of a Memory Request. Ring Example: 2 requests for lock 17

Basic Logic Gates Richard E. Haskell

CHAPTER 11: Flip Flops

EXPERIMENT 8. Flip-Flops and Sequential Circuits

RAPID PROTOTYPING OF DIGITAL SYSTEMS Second Edition

An Integer Square Root Algorithm

Module 4 : Propagation Delays in MOS Lecture 22 : Logical Effort Calculation of few Basic Logic Circuits

Objectives: Part 1: Build a simple power supply. CS99S Laboratory 1

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Electronic Circuits Spring 2007

Measuring Electric Phenomena: the Ammeter and Voltmeter

No serious hazards are involved in this laboratory experiment, but be careful to connect the components with the proper polarity to avoid damage.

Digital Electronics Detailed Outline

Lecture 5: Gate Logic Logic Optimization

9/14/ :38

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

Using Op Amps As Comparators

After opening the Programs> Xilinx ISE 8.1i > Project Navigator, you will come to this screen as start-up.

CHAPTER 3 Boolean Algebra and Digital Logic

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180B Lab 7: MISP Processor Design Spring 1995

Lab #5: Design Example: Keypad Scanner and Encoder - Part 1 (120 pts)

The 104 Duke_ACC Machine

EE 209 Lab 1 Sound the Alarm

EXPERIMENT 4. Parallel Adders, Subtractors, and Complementors

Digital Systems Design! Lecture 1 - Introduction!!

RUTGERS UNIVERSITY Department of Electrical and Computer Engineering 14:332:233 DIGITAL LOGIC DESIGN LABORATORY

A Verilog HDL Test Bench Primer Application Note

PCB Project (*.PrjPcb)

1. True or False? A voltage level in the range 0 to 2 volts is interpreted as a binary 1.

Laboratory 4: Feedback and Compensation

LAB 7 MOSFET CHARACTERISTICS AND APPLICATIONS

Massachusetts Institute of Technology

Cornerstone Electronics Technology and Robotics I Week 15 Voltage Comparators Tutorial

Chapter 2 Logic Gates and Introduction to Computer Architecture

A First Course in Digital Design Using VHDL and Programmable Logic

Cadence Verilog Tutorial Windows Vista with Cygwin X Emulation

More Verilog. 8-bit Register with Synchronous Reset. Shift Register Example. N-bit Register with Asynchronous Reset.

Conversion Between Analog and Digital Signals

NEW adder cells are useful for designing larger circuits despite increase in transistor count by four per cell.

Verification & Design Techniques Used in a Graduate Level VHDL Course

Xilinx ISE. <Release Version: 10.1i> Tutorial. Department of Electrical and Computer Engineering State University of New York New Paltz

Digital Multiplexer and Demultiplexer. Features. General Description. Input/Output Connections. When to Use a Multiplexer. Multiplexer 1.

LAB4: Audio Synthesizer

Counters and Decoders

ASYNCHRONOUS COUNTERS

Systems I: Computer Organization and Architecture

case Statement //8-wide, 4:1 multiplexer module case1 ( input [7:0] a_in, b_in, c_in, d_in, input [1:0] sel, output logic [7:0] d_out);

Adder.PPT(10/1/2009) 5.1. Lecture 13. Adder Circuits

Sequential Logic Design Principles.Latches and Flip-Flops

Getting the Most Out of Synthesis

ESP-CV Custom Design Formal Equivalence Checking Based on Symbolic Simulation

7a. System-on-chip design and prototyping platforms

Lab 11 Digital Dice. Figure Digital Dice Circuit on NI ELVIS II Workstation

SDLC Controller. Documentation. Design File Formats. Verification

DIGITAL DESIGN FLOW OPTIONS

PLL frequency synthesizer

Final Project: Enhanced Music Synthesizer and Display Introduction

CSE140 Homework #7 - Solution

Quartus II Introduction Using VHDL Design

Implementation of Web-Server Using Altera DE2-70 FPGA Development Kit

Active Learning in the Introduction to Digital Logic Design Laboratory Course

3-Digit Counter and Display

Programming Logic controllers

The components. E3: Digital electronics. Goals:

Understanding Logic Design

7. Latches and Flip-Flops

Digital Systems. Role of the Digital Engineer

Manchester Encoder-Decoder for Xilinx CPLDs

Op-Amp Simulation EE/CS 5720/6720. Read Chapter 5 in Johns & Martin before you begin this assignment.

Combinational-Circuit Building Blocks

PROGRAMMABLE ANALOG INTEGRATED CIRCUIT FOR USE IN REMOTELY OPERATED LABORATORIES

Experiment # 9. Clock generator circuits & Counters. Eng. Waleed Y. Mousa

Programming A PLC. Standard Instructions

Gates & Boolean Algebra. Boolean Operators. Combinational Logic. Introduction

Digital Fundamentals. Lab 8 Asynchronous Counter Applications

Two's Complement Adder/Subtractor Lab L03

6.004 Computation Structures Spring 2009

University of St. Thomas ENGR Digital Design 4 Credit Course Monday, Wednesday, Friday from 1:35 p.m. to 2:40 p.m. Lecture: Room OWS LL54

INTRODUCTION TO DIGITAL SYSTEMS. IMPLEMENTATION: MODULES (ICs) AND NETWORKS IMPLEMENTATION OF ALGORITHMS IN HARDWARE

Transcription:

Multiplexers Two Types + Verilog ENEE 245: Digital Circuits and ystems Laboratory Lab 7 Objectives The objectives of this laboratory are the following: To become familiar with continuous ments and procedural programming in Verilog To design various multiplexer configurations in Verilog To implement a 4-bit wide 4:1multiplexer in the Nexys2 FPGA prototyping board To implement an analog MUX on breadboard A multiplexer is a device that selects one of several input signals and forwards the selected input to the output. Typical multiplexers come in 2:1, 4:1, 8:1, and 16:1 forms. A multiplexer of 2n inputs has n select lines. A TTL series 8:1 MUX is 74151. It has three select lines 2, 1, 0. Each of the 8 possible combinations of 2, 1, 0 selects In this lab, you will design a several MUXes using Verilog, on a Nexys2 board (from Digilent), which contains a partan 3E FPGA (from Xilinx). Multiplexers The MUX is generally shown as follows, as a high-level abstraction: It selects between multiple input signals, but though the picture above suggests that the chosen signal is passed from input to output, that depends on the implementation of the MUX. There is a difference between passing an input signal to the output, and the value of the input signal to the output. In general, there are two main MUX designs. The first is a digital MUX it passes on either 1 or 0 depending on the logic values given to it; the second is an analog MUX it passes on the desired signals themselves. Now that you have been exposed to analog signals as they appear in the digital world, this should make sense. 1

ENEE 245: Digital Circuits & ystems Lab Lab 7 Digital MUXes of various flavors AND gates feeding into an n-way OR gate NAND gates feeding into an n-way NAND gate (note the left-most NAND could be a simple inverter) D0 D0 D1 D1 Y Y D0 0 U.. Patent Nov. 16, 2004 heet 2 6f 13 U D1 6,819,602 1 B2 Y A CMO inverting MUX (a non-inverting MUX requires an additional inverter at the output) Analog MUX using transmission gates FIG. 3A 0088 ' 212 CNTB VREF V T 211 r _ CNT CNT and CNTB are the select/select-bar signals to enable only one transmission gate FIG. 38 2

An even cheaper analog MUX using simple pass transistors These are all MUXes. The digital ones on the top imply a CMO implementation, in which case each AND/NAND/OR/NOR would be at least four transistors (the non-inverting ones would require six), and each inverter would be two transistors. o the top design would require 20 transistors, and the second one would require 16 (could be reduced to 14 if an inverter were used on the select signal). The third one down, the inverting implementation, reduces the transistor count to 8, or 10 if a non-inverting MUX is desired. o it should be extremely clear why the analog ones are the most commonly used in industrial designs: they are much smaller the transmission-gate implementation requires six transistors (which includes an inverter to get the CNTB signal), and the last implementation only requires two. Note that the analog implementations are bi-directional the selected signal can pass both ways, as the pass transistors are all agnostic about signal direction, whereas the information is strictly one-way in CMO designs. Verilog Implementation The most important thing in writing behavioral Verilog is to ensure that what you want is what the software actually delivers to you. This is called writing synthesizable code, and when generating MUXes, the thing to keep in mind is that you ensure every possible value for the select signal is accounted for. If you fail to do this, the synthesis software will create odd little state machines to try to account for any values you neglected to mention. The following are all reasonable implementations: wire in0, in1, sel, out; out = (~sel & in0) (sel & in1); wire in0, in1, sel, out; out = (sel)? in1 : in0; wire in0, in1, sel, out; wire [1:0] d = {in0, in1}; out = d[sel]; wire in0, in1, sel, out; out = (sel==1 b0)? in0 : 1 bz, out = (sel==1 b1)? in1 : 1 bz; The main issue is when you go to larger numbers of inputs. In the case of, say, a 4-way MUX that selects between four inputs, you get the following Verilog code using the ternary operator: Example of what NOT to do: wire in0, in1, in2, in3, out; wire [1:0] sel; out = (sel==2 b00)? in0 : (sel==2 b01)? in1 : (sel==2 b10)? in2 : in3 ; 3

What this actually produces is a priority encoder, just like it would if you use a long list of if-thenelse statements. o, while it might be functionally equivalent, it is in fact a bit more expensive in both resources (die area, gates, power) and time. The following tri-state buffer implementation is a better solution (similar to the transmission-gate implementations above): wire in0, in1, in2, in3, out; wire [1:0] sel; out = (sel==2 b0)? in0 : 1 bz, out = (sel==2 b1)? in1 : 1 bz, out = (sel==2 b2)? in2 : 1 bz, out = (sel==2 b3)? in3 : 1 bz; Note that this scales to wide data widths. For instance, the following is a 4-way MUX for selecting between four different 64-bit data values: wire [63:0] in0, in1, in2, in3, out; wire [1:0] sel; out = (sel==2 d0)? in0 : 1 bz, out = (sel==2 d1)? in1 : 1 bz, out = (sel==2 d2)? in2 : 1 bz, out = (sel==2 d3)? in3 : 1 bz; Another good option is the case statement, which is extremely useful in module format: module (in0, in1, in2, in3, in4, in5, in6, in7, sel, out); input [63:0] in0, in1, in2, in3, in4, in5, in6, in7; input [2:0] sel; output [63:0] out; always @(in0 or in1 or in2 or in3 or in4 or in5 or in6 or in7 or sel) case (sel) 3 b000 : out = in0; 3 b001 : out = in1; 3 b010 : out = in2; 3 b011 : out = in3; 3 b100 : out = in4; 3 b101 : out = in5; 3 b110 : out = in6; 3 b111 : out = in7; endcase endmodule Here is the corresponding tri-state buffer implementation: module (in0, in1, in2, in3, in4, in5, in6, in7, sel, out); input [63:0] in0, in1, in2, in3, in4, in5, in6, in7; input [2:0] sel; output [63:0] out; out = (sel==3 d0)? in0 : 1 bz, out = (sel==3 d1)? in1 : 1 bz, out = (sel==3 d2)? in2 : 1 bz, out = (sel==3 d3)? in3 : 1 bz; out = (sel==3 d4)? in4 : 1 bz, out = (sel==3 d5)? in5 : 1 bz, out = (sel==3 d6)? in6 : 1 bz, out = (sel==3 d7)? in7 : 1 bz; endmodule Note that it is very important, when using the case statement, that you have a line for every possible value of the select signal. If you, the designer, happen to know that, for instance, only 6 out of 8 4

possible bit patterns will be used by the hardware while running, you would be tempted to write code accounting for only those six possibilities, leaving the other two out entirely. Verilog, however, does not know that only six are possible, and it will try to account for the missing two values by inserting a lot of inefficient circuitry that you might find puzzling to debug. In your case statement, you should have a default for all unexpected values, for instance, as in the following code, which assumes that select values 6 and 7 will never happen: always @(in0 or in1 or in2 or in3 or in4 or in5 or sel) case (sel) 3 b000 : out = in0; 3 b001 : out = in1; 3 b010 : out = in2; 3 b011 : out = in3; 3 b100 : out = in4; 3 b101 : out = in5; default : out = 64 bz; endcase When using the tri-state buffer implementation, which requires a separate comparator for each possible input, it is not necessary to account for any unused bit patterns. Pre-Lab Preparation Please make sure to complete the prelab before you attend your lab section. The lab will be long and frustrating if you do not do the prelab ahead of time. In this lab, you will use Verilog to implement several multiplexer configurations on the Xilinx partan 3E FPGA. The Verilog used to describe the multiplexers will be in structural as well as procedural. Part 1 2:1 Multiplexer 1. Create a top-level design called mux21_top that connects inputs a and b to the rightmost two slide switches of Nexys2, connects input s to btn[0] of Nexys2, and connects output y to ld[0]. 2. Perform a functional simulation of your design. 3. Create a symbol for the multiplexer. Part 2 4-Bit Wide 2:1 MUX Using if tatement 1. Create an N-bit wide 2:1 MUX using the parameter statement. Create a symbol for it. 2. Create a 4-bit wide 2:1 MUX by instantiating the N-bit wide MUX designed above. 3. Functional imulation. Perform a functional simulation of the circuit to verify that it is working correctly. 4. Create ymbol. Create a symbol for the multiplexer to use in the graphical editor. This creates a symbol file that is a Graphic File and can be viewed and edited by opening it. Part 3 4-Bit Wide 4:1 MUX 1. Design a 4-bit wide 4:1 multiplexer from three 4-bit wide 2:1 multiplexers. 2. Perform a functional simulation of the circuit. Paste the results in your prelab report. 3. Create a symbol for the 4-bit wide 4:1 MUX to use in the graphical editor. 4. Design a 4:1 multiplexer using the Verilog case statement. 5. imulate the design. Paste the results in your prelab report. 5

6. Bring your Verilog codes in a flash drive. Pre-Lab Report In your prelab report, include circuit schematics, Verilog programs, and simulation results for all multiplexers discussed above. Incorrect or incomplete designs and Verilog programs will not receive full credit. If you have any problems with Verilog syntax and other pre-lab related issues, please resolve them before coming to the lab. Your TA may not be able to help you with these issues during the lab session. In-Lab Procedure Bring flash drives to store your data. Ask the TA questions regarding any procedures about which you are uncertain. et your 4-bit 4:1 MUX Verilog file (the hierarchical one built from three 2:1 multiplexers) as the top module of your design and implement the complete design (synthesize, map, and Place & Route) using the Xilinx IE tools. Program the FPGA using the bit-stream file which is generated in the process. For checkoff, you will show the TA the following: 1. how the multiplexer working on the board. 2. Demonstrate at least one selection operation from the patterns you have used in the test bench. how that your simulation results above match the observed waveforms on the DLA. Post-Lab Report Write up your code, schematics, and lab procedures. Demonstrate the correctness of your designs through your DLA output and note any differences between what you simulated and how the circuits behaved in the lab. Along with your post-lab report, submit the observed waveforms (in separate sheets) for the 4-bit wide 4:1 multiplexer. 6