Lab 3: Standard Combinational Components

Similar documents
Verilog Module 1 Introduction and Combinational Logic

To design a 4-bit ALU To experimentally check the operation of the ALU

EE 231 Fall Lab 2: Decoders and Multiplexers. Introduction

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

EE 231 Fall EE 231 Lab 3

CSCB58 - Lab 3. Prelab /3 Part I (in-lab) /2 Part II (in-lab) /2 TOTAL /8

8-1. Fig. 8-1 ASM Chart Elements 2001 Prentice Hall, Inc. M. Morris Mano & Charles R. Kime LOGIC AND COMPUTER DESIGN FUNDAMENTALS, 2e, Updated.

Number Systems. Readings: , Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs

Lab 6: Integrated the Decoder with Muti-bit Counter and Programming a FPGA

Digital Design with FPGAs. By Neeraj Kulkarni


Laboratory Exercise 1

CCE 3202 Advanced Digital System Design

Contents. Chapter 9 Datapaths Page 1 of 28

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

EEL 4712 Digital Design Test 1 Spring Semester 2008

EET 1131 Lab #7 Arithmetic Circuits

Chapter 6 Combinational-Circuit Building Blocks

EXPERIMENT #8: BINARY ARITHMETIC OPERATIONS

EITF35 - Introduction to Structured VLSI Design (Fall ) 7. Assignment 3 - Arithmetic Logic Unit (ALU)

EE 231 Fall EE 231 Lab 3. Decoders and Multiplexers. Figure 1: 7-Segment Display. Memory: where the program is stored.

Lecture 38 VHDL Description: Addition of Two [5 5] Matrices

Laboratory 4 Design a Muti-bit Counter and Programming a FPGA

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

EN2911X: Reconfigurable Computing Lecture 05: Verilog (2)

ENEE245 Digital Circuits and Systems Lab Manual

Single-Cycle CPU VITO KLAUDIO CSC343 FALL 2015 PROF. IZIDOR GERTNER

ECE 3610 Microprocessing Systems Lab #1 Verilog Design of the TOC Using Quartus II

CS303 LOGIC DESIGN FINAL EXAM

ENEE245 Digital Circuits and Systems Lab Manual

Verilog Hardware Description Language ROOM: B405

yamin/

ELCT 501: Digital System Design

Engineering 303 Digital Logic Design Fall 2018

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

CS/EE Homework 7 Solutions

ECE2029: Introduction to Digital Circuit Design Lab 3 Implementing a 4-bit Four Function ALU

Laboratory Exercise 7

Control and Datapath 8

Laboratory 4 Design a Muti-bit Counter

CSC / EE Digital Systems Design. Summer Sample Project Proposal 01

MPLEMENTATION. Part 1: Implementation of the TOC on the DE2 Board using Verilog - Performed in Lab #1

IA Digital Electronics - Supervision I

Digital Systems Design

8-1. Fig. 8-1 ASM Chart Elements 2001 Prentice Hall, Inc. M. Morris Mano & Charles R. Kime LOGIC AND COMPUTER DESIGN FUNDAMENTALS, 2e, Updated.

Digital Circuit Design and Language. Datapath Design. Chang, Ik Joon Kyunghee University

Design a 4 bit-adder. Then design a 4-7 decoder to show the outputs. Output Sum(4 bits) Adder. Output carry(1 bit)

TSIU03, SYSTEM DESIGN LECTURE 2

Lab 2 EECE473 Computer Organization & Architecture University of Maine

Chapter 2 Basic Logic Circuits and VHDL Description

CPE 200L LABORATORY 4: INTRODUCTION TO DE2 BOARD UNIVERSITY OF NEVADA, LAS VEGAS GOALS: BACKGROUND:

The functional block diagram of 8085A is shown in fig.4.1.

LAB 4: Seven Seg, Full Adder, Ripple Adder, Heirarchical Design

Digital Design with SystemVerilog

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

BUILDING BLOCKS OF A BASIC MICROPROCESSOR. Part 1 PowerPoint Format of Lecture 3 of Book

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

Hardware Description Language VHDL (1) Introduction

ENEE 245 Lab 1 Report Rubrics

IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL

Advanced Electronics Lab.

Computer architecture Assignment 3

Combinational Logic Circuits

ENGIN 241 Digital Systems with Lab

Hardware Description Languages (HDLs) Verilog

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

Digital Systems Laboratory

CPEN 230L: Introduction to Digital Logic Laboratory Lab 7: Multiplexers, Decoders, and Seven Segment Displays

VHDL for Synthesis. Course Description. Course Duration. Goals

REGISTER TRANSFER LANGUAGE

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

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

ANADOLU UNIVERSITY. EEM Digital Systems II

Lab #12: ArithmeticLogic Unit

1. What is y-chart? ans: The y- chart consists of three domains:- behavioral, structural and geometrical.

University of California, Davis Department of Electrical and Computer Engineering. Lab 1: Implementing Combinational Logic in the MAX10 FPGA

Lab 7: RPN Calculator

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

Chapter 4. Combinational Logic

Experiment 8 Introduction to VHDL

Brief Introduction to Verilog HDL (Part 1)

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

HW1 Modeling Concepts

ECE 2300 Digital Logic & Computer Organization. More Sequential Logic Verilog

MCPU - A Minimal 8Bit CPU in a 32 Macrocell CPLD.

CCE 3202 Advanced Digital System Design

University of California, Davis Department of Electrical and Computer Engineering. EEC180B DIGITAL SYSTEMS Spring Quarter 2018

Contents. Appendix B HDL Entry Tutorial 2 Page 1 of 14

Control Unit: Binary Multiplier. Arturo Díaz-Pérez Departamento de Computación Laboratorio de Tecnologías de Información CINVESTAV-IPN

Figure 1: Verilog used to generate divider

Combinational Logic II

Chip Design with FPGA Design Tools

1 /10 2 /12 3 /16 4 /30 5 /12 6 /20

Area Efficient, Low Power Array Multiplier for Signed and Unsigned Number. Chapter 3

Register Transfer Level in Verilog: Part I

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering

ES611 FPGA Based System Design. Behavioral Model

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

Workshop on Digital Circuit Design in FPGA

Transcription:

Lab 3: Standard Combinational Components Purpose In this lab you will implement several combinational circuits on the DE1 development board to test and verify their operations. Introduction Using a high-level description language to describe the operation of a circuit. Converting from a binary number to a decimal number. There are several standard combinational components that are used very often in building larger digital systems. These components are used as building blocks for larger systems. They are: Adder Multiplexer ALU Decoder Encoder Comparator In this lab you will build some of them and verify their operations. These components will be used again in future labs, so save them in a library. For each component, create a symbol for it. To test it, open a new schematic drawing, add the symbol, and map the I/O pins to the symbol. 1. Multiplexer a) Implement and verify the operation of a 4-bit 2-to-1 multiplexer. This mux has two data inputs and one data output. The width of the data bus is 4-bits wide. Refer to Section 4.2 of the textbook (or Lab 1, question 6) for a discussion of multiplexers. b) Implement a 4-bit 4-to-1 multiplexer.

2. Arithmetic and Logic Unit (ALU) Instead of manually designing a digital logic circuit, you can describe its operation using a high-level language and then have Quartus automatically synthesize the netlist (circuit) for you. There are currently two industry standard hardware description languages (HDL), VHDL and Verilog. You can use either language in Quartus. Below is the code for an 8-operation ALU written in both Verilog and VHDL. Notice the similarities between this code and C++ code. The only difference between entering a schematic drawing and entering code is when you do a File New, you select Verilog file or VHDL file instead of Block Diagram/Schematic File. Enter either the Verilog code or the VHDL code into Quartus and save it using the name alu. Create a symbol for this component, also called alu. Test it out on the DE1 board to make sure that it works correctly. Verilog code for an 8-operation ALU: module alu ( input [2:0] S, input [n-1:0] A, B, output reg [n-1:0] F ); parameter n = 4; always @ (S or A or B) begin case (S) 0: F <= A; // pass A through 1: F <= A & B; // logical AND 2: F = A B; // logical OR 3: F = ~A; // logical NOT A 4: F = A + B; // add 5: F = A - B; // subtract 6: F = A + 1; // increment 7: F = A - 1; // decrement endcase end endmodule

VHDL code for an 8-operation ALU: LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL; -- needed for doing + and - ENTITY alu IS PORT ( S: IN STD_LOGIC_VECTOR(2 DOWNTO 0); -- select for operations A, B: IN STD_LOGIC_VECTOR(3 DOWNTO 0); -- input operands F: OUT STD_LOGIC_VECTOR(3 DOWNTO 0)); -- output END alu; ARCHITECTURE Behavioral OF alu IS BEGIN PROCESS(S, A, B) BEGIN CASE S IS WHEN "000" => -- pass A through F <= A; WHEN "001" => -- logical AND F <= A AND B; WHEN "010" => -- logical OR F <= A OR B; WHEN "011" => -- logical NOT A F <= NOT A; WHEN "100" => -- add F <= A + B; WHEN "101" => -- subtract F <= A - B; WHEN "110" => -- increment F <= A + 1; WHEN OTHERS => -- decrement F <= A - 1; END CASE; END PROCESS; END Behavioral;

3. 4-Bit Binary to 7-Segment Hex Digit Display Decoder A 4-bit binary to 7-segment hex digit display decoder is a circuit that takes a 4-bit binary number and outputs a (hexadecimal) decimal digit on a single 7-segment display. The input to the decoder is a 4-bit binary value. The output from the decoder is a 7-bit value for turning on or off each of the seven LEDs in a 7-segment HEX display. For example, if the input is 0011, then it will turn on the corresponding LED segments to display the digit 3, i.e. segments a, b, c, d and g as shown next. a f e g d b c Enter either the Verilog code or the VHDL code into Quartus and save it using the name BCD. Create a symbol for this component, also called BCD. Test it out on the DE1 board to make sure that it works correctly.

// Verilog version // BCD - 4-bit Binary to 7-segment hex digit // active low output // Copyright 2006 Enoch Hwang module BCD ( input [3:0] I, output reg [0:6] Segs ); always @ (I) begin case (I) // 0=on; 1=off 0: Segs = 7'b0000001; // 0 1: Segs = 7'b1001111; // 1 2: Segs = 7'b0010010; // 2 3: Segs = 7'b0000110; // 3 4: Segs = 7'b1001100; // 4 5: Segs = 7'b0100100; // 5 6: Segs = 7'b0100000; // 6 7: Segs = 7'b0001111; // 7 8: Segs = 7'b0000000; // 8 9: Segs = 7'b0001100; // 9 10: Segs = 7'b0001000; // A 11: Segs = 7'b1100000; // b 12: Segs = 7'b0110001; // C 13: Segs = 7'b1000010; // d 14: Segs = 7'b0110000; // E 15: Segs = 7'b0111000; // F default: Segs = 7'b1111111; endcase end // all off endmodule

-- VHDL Version -- BCD - 4-bit Binary to 7-segment hex digit -- active low output -- Copyright 2006 Enoch Hwang LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; ENTITY BCD IS PORT ( I: IN STD_LOGIC_VECTOR(3 DOWNTO 0); segs: OUT STD_LOGIC_VECTOR(0 TO 6)); END BCD; ARCHITECTURE Behavioral OF BCD IS BEGIN PROCESS(I) BEGIN CASE I IS -- 0=on; 1=off WHEN "0000" => segs <= "0000001"; -- 0 WHEN "0001" => Segs <= "1001111"; -- 1 WHEN "0010" => Segs <= "0010010"; -- 2 WHEN "0011" => Segs <= "0000110"; -- 3 WHEN "0100" => Segs <= "1001100"; -- 4 WHEN "0101" => Segs <= "0100100"; -- 5 WHEN "0110" => Segs <= "0100000"; -- 6 WHEN "0111" => Segs <= "0001111"; -- 7 WHEN "1000" => Segs <= "0000000"; -- 8 WHEN "1001" => Segs <= "0001100"; -- 9 WHEN "1010" => Segs <= "0001000"; -- A WHEN "1011" => Segs <= "1100000"; -- b WHEN "1100" => Segs <= "0110001"; -- C WHEN "1101" => Segs <= "1000010"; -- d WHEN "1110" => Segs <= "0110000"; -- E WHEN "1111" => Segs <= "0111000"; -- F WHEN OTHERS => Segs <= "1111111"; END CASE; END PROCESS; END Behavioral; -- all off

4. Complete ALU System Create a logic symbol for both the 4-bit adder and the 7-segment decoder circuits if you have not already done so. Create a new schematic file. You will use this file as the top level for your project. Insert the two block symbols (Adder and BCD) and connect them together as shown below. 4 4 3 s X Y 4-bit ALU F 4 I BCD Segs f e a g b c d Map the I/O signals as follows: y 3 -y 0 SW[3]-SW[0] x 3 -x 0 SW[7]-SW[4] s 2 s 1 -s 0 f 3 -f 0 Segs 0 -Segs 6 KEY[0] SW[9]-SW[8] LEDR[3]-LEDR[0] HEX0[0..6] Test out your system on the DE1. The output of the ALU will now be in decimal instead of binary. What happens when the result from the ALU has two decimal digits? Use the Verilog code below to solve this problem.

The code below will decode an 8-bit number to three 7-segment digits. // convert an 8-bit binary number n // to a 3-digit decimal number // and display it on three 7-segment LEDs // The signednumber parameter when set to 1 will interpret // the 8-bit binary number as two's complement module displaynumber #(parameter signednumber = 0) ( input [7:0] n, output reg [0:6] HEX3, HEX2, HEX1, HEX0 ); reg [7:0] n2; reg [3:0] hundreth, tenth, unit; // binary coded decimals // convert an 8-bit number n to its hundreth, tenth, and unit decimal digits always @ (n) begin if ((signednumber == 1) & (n[7] == 1'b1)) begin n2 = ~n + 1; // two's complement; flip bits and add a 1 HEX3 = ~7'b0000001; end else begin n2 = n; HEX3 = ~7'b0000000; end hundreth = n2/100; n2 = n2 - hundreth*100; tenth = n2/10; unit = n2%10; HEX2 = ~bcd(hundreth); HEX1 = ~bcd(tenth); HEX0 = ~bcd(unit); end // calculate the hundreth digit // calculate the tenth digit // calculate the unit digit // display hundreth digit on HEX2 // display tenth digit on HEX1 // display unit digit on HEX0 // function to convert BCD to 7-segment LED display function [0:6] bcd (input [3:0] n); case (n) 0: bcd = 7'b1111110; 1: bcd = 7'b0110000; 2: bcd = 7'b1101101; 3: bcd = 7'b1111001; 4: bcd = 7'b0110011; 5: bcd = 7'b1011011; 6: bcd = 7'b1011111; 7: bcd = 7'b1110000; 8: bcd = 7'b1111111; 9: bcd = 7'b1110011; default: bcd = 7'b0000000; endcase endfunction endmodule