Last Lecture: Adder Examples

Similar documents
Chapter 4. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 4 <1>

Chapter 4 :: Topics. Introduction. SystemVerilog. Hardware description language (HDL): allows designer to specify logic function only.

Chapter 4. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 4 <1>

A Verilog Primer. An Overview of Verilog for Digital Design and Simulation

HDLs and SystemVerilog. Digital Computer Design

EECS 427 Lecture 14: Verilog HDL Reading: Many handouts/references. EECS 427 W07 Lecture 14 1

Last Lecture. Talked about combinational logic always statements. e.g., module ex2(input logic a, b, c, output logic f); logic t; // internal signal

VHDL Structural Modeling II

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

Digital Systems Design

In this lecture, we will go beyond the basic Verilog syntax and examine how flipflops and other clocked circuits are specified.

Lecture 32: SystemVerilog

Course Topics - Outline

Online Verilog Resources

Verilog Behavioral Modeling

SystemVerilog Lecture 3. Prof. Gerald E. Sobelman Dept. of Electrical and Computer Engineering University of Minnesota Minneapolis, MN USA

CSE140L: Components and Design Techniques for Digital Systems Lab

Synthesis of Language Constructs. 5/10/04 & 5/13/04 Hardware Description Languages and Synthesis

CSE140L: Components and Design

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

Verilog. What is Verilog? VHDL vs. Verilog. Hardware description language: Two major languages. Many EDA tools support HDL-based design

Design Using Verilog

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

Chapter 6: Hierarchical Structural Modeling

EN2911X: Reconfigurable Computing Topic 02: Hardware Definition Languages

Hardware Description Language VHDL (1) Introduction

EN164: Design of Computing Systems Lecture 06: Lab Foundations / Verilog 2

EN2911X: Reconfigurable Computing Lecture 05: Verilog (2)

Contents. Appendix D Verilog Summary Page 1 of 16

Chap 6 Introduction to HDL (d)

Course Topics - Outline

EEL 4783: HDL in Digital System Design

Lab #1. Topics. 3. Introduction to Verilog 2/8/ Programmable logic. 2. Design Flow. 3. Verilog --- A Hardware Description Language

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

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

Digital Design with FPGAs. By Neeraj Kulkarni

Digital Design (VIMIAA01) Introduction to the Verilog HDL

LECTURE 4: The VHDL N-bit Adder

14:332:231 DIGITAL LOGIC DESIGN. Hardware Description Languages

Computer Aided Design Basic Syntax Gate Level Modeling Behavioral Modeling. Verilog

Module 2.1 Gate-Level/Structural Modeling. UNIT 2: Modeling in Verilog

Step 1 in transitioning to behavioral modeling. But here 1-to-1 with our gate level model.

Verilog for High Performance

Digital Design using HDLs EE 4755 Midterm Examination

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

Synthesis vs. Compilation Descriptions mapped to hardware Verilog design patterns for best synthesis. Spring 2007 Lec #8 -- HW Synthesis 1

CSE241 VLSI Digital Circuits Winter Recitation 1: RTL Coding in Verilog

Chapter 3 Part 2 Combinational Logic Design

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

ECE 353 Lab 4. Verilog Review. Professor Daniel Holcomb UMass Amherst Fall 2017

EECS150 - Digital Design Lecture 10 Logic Synthesis

Under-Graduate Project Logic Design with Behavioral Models

a, b sum module add32 sum vector bus sum[31:0] sum[0] sum[31]. sum[7:0] sum sum overflow module add32_carry assign

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Course Details: Webpage

Sequential Logic Design

EECS150 - Digital Design Lecture 10 Logic Synthesis

EECS150 - Digital Design Lecture 4 - Verilog Introduction. Outline

2/14/2016. Hardware Synthesis. Midia Reshadi. CE Department. Entities, Architectures, and Coding.

Chapter 3 Arithmetic for Computers

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

(System)Verilog Tutorial Aleksandar Milenković

Digital Design using HDLs EE 4755 Midterm Examination

HDL for Combinational Circuits. ENEL211 Digital Technology

Verilog Dataflow Modeling

Chapter 6 Combinational-Circuit Building Blocks

Chapter 3 Arithmetic for Computers. ELEC 5200/ From P-H slides

EECS 470 Lab 1. Verilog: Hardware Description Language

Verilog for Synthesis Ing. Pullini Antonio

A Brief Introduction to Verilog Hardware Definition Language (HDL)

Chapter 2 Using Hardware Description Language Verilog. Overview

14:332:231 DIGITAL LOGIC DESIGN. Hardware Description Languages

Part I: Translating & Starting a Program: Compiler, Linker, Assembler, Loader. Lecture 4

Outline. EECS150 - Digital Design Lecture 5 - Verilog 2. Structural Model: 2-to1 mux. Structural Model - XOR. Verilog Basics Lots of Examples

EECS 470 Lab 1. Verilog: Hardware Description Language

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

CSE140L: Components and Design Techniques for Digital Systems Lab. Verilog HDL. Instructor: Mohsen Imani UC San Diego. Source: Eric Crabill, Xilinx

Contents. Appendix D VHDL Summary Page 1 of 23

ECE 353 Lab 4. Verilog Review. Professor Daniel Holcomb With material by Professor Moritz and Kundu UMass Amherst Fall 2016

The Verilog Language COMS W Prof. Stephen A. Edwards Fall 2002 Columbia University Department of Computer Science

Topics. Midterm Finish Chapter 7

Digital Design with SystemVerilog

Verilog 1 - Fundamentals

ECE 353 Lab 3 (Verilog Design Approach)

Binary Arithmetic Circuits

VeriLogger Tutorial: Basic Verilog Simulation

Engineering 303 Digital Logic Design Fall 2018

UC Berkeley College of Engineering, EECS Department CS61C: Combinational Logic Blocks

UC Berkeley College of Engineering, EECS Department CS61C: Combinational Logic Blocks

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

ECEN 468 Advanced Logic Design

Parallel versus serial execution

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017

ELCT 501: Digital System Design

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

Lecture 15: System Modeling and Verilog

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

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26)

Combinational Circuit Design

Transcription:

Last Lecture: Adder Examples module fulladder(input logic a, b, cin, output logic s, cout); logic p, g; // internal nodes assign p = a ^ b; assign g = a & b; assign s = p ^ cin; assign cout = g (p & cin); g cin s s Slide derived from slides by Harris & Harris from their book a b p un1_cout cout cout 1

Last Lecture: Adder Examples /* hierarchical 4-bit adder */ module h4ba(input logic [3:0] A, B, input logic carry_in, output logic [3:0] sum, output logic carry_out); logic carry_out_0, carry_out_1, carry_out_2; // internal signals fulladder fa0 (A[0], B[0], carry_in, sum[0], carry_out_0); fulladder fa1 (A[1], B[1], carry_out_0, sum[1], carry_out_1); fulladder fa2 (A[2], B[2], carry_out_1, sum[2], carry_out_2); fulladder fa3 (A[3], B[3], carry_out_2, sum[3], carry_out); each of these is an instantiation of full_adder 2

More Examples module ex1(input logic [3:0] X, Y, Z, input logic a, cin, output logic [3:0] R1, R2, R3, Q1, Q2, output logic [7:0] P1, P2, output logic t, cout); assign R1 = X (Y & ~Z); use of bitwise Boolean operators assign t = &X; example reduction operator assign R2 = (a == 1 b0)? X : Y; conditional operator assign P1 = 8 hff; example constants replication, same as {a, a, a, a} assign P2 = {4{a}, X[3:2], Y[1:0]}; example concatenation assign {cout, R3} = X + Y + cin; assign Q1 = X << 2; bit shift operator assign Q2 = {X[1], X[0], 1 b0, 1 b0}; equivalent bit shift 3

Parameterized Modules 2:1 mux: module pmux2 #(parameter width = 8) // name and default value (input logic [width-1:0] d0, d1, input logic s, output logic [width-1:0] y); assign y = s? d1 : d0; Instance with 8-bit bus width (uses default): pmux2 pmux2_8(d0, d1, s, out); Instance with 12-bit bus width: pmux2 #(12) pmux2_12 (d0, d1, s, out); Slide derived from slides by Harris & Harris from their book 4

Combinational logic using always module ex2(input logic a, b, c, output logic f); logic t; // internal signal always_comb begin t = a & b; f = t c; end should use = (called blocking assignment) in comb. logic always statements. RHS just takes output from the previous equation. The order of statements matters! takes output of t from previous equation 5

Combinational logic using always module ex3(input logic [3:0] d0, d1, input logic s, output logic [3:0] y); always_comb begin if (s) y = d1; else y = d0; end If-then-else translates into a 2:1 multiplexor Slide derived from slides by Harris & Harris from their book 6

Combinational logic using always /* behaviorial description of a 4-bit adder */ module p4ba(input logic [3:0] A, B, input logic carry_in, output logic [3:0] sum, output logic carry_out); logic [4:0] carry; // internal signal always_comb begin end carry[0] = carry_in; for (int i = 0; i < 4; i++) begin sum[i] = A[i] ^ B[i] ^ carry[i]; carry[i+1] = A[i] & B[i] end carry_out = carry[4]; entire always_comb block is called an always statement for combiantional logic A[i] & carry[i] B[i] & carry[i]; for loops must have a specified range. simply interpreted as replication. Note we can declare the loop control variable within the for loop Verilog calls the use of = inside an always statement as a blocking assignment. all it means is that the Verilog will parse the lines of code inside the always block in sequential order in the generation of logic. (will make more sense later when we discuss non-blocking assignments.) 7

Combinational logic using always 8

Combinational logic using case module sevenseg(input logic [3:0] data, output logic [6:0] segments); always_comb case (data) // abc_defg 0: segments = 7'b111_1110; 1: segments = 7'b011_0000; 2: segments = 7'b110_1101; 3: segments = 7'b111_1001; 4: segments = 7'b011_0011; 5: segments = 7'b101_1011; 6: segments = 7'b101_1111; 7: segments = 7'b111_0000; 8: segments = 7'b111_1111; 9: segments = 7'b111_0011; default: segments = 7'b000_0000; // required endcase case statement translates into a more complex multiplexor similar to if-then-else Slide derived from slides by Harris & Harris from their book 9

Combinational logic using case case statement implies combinational logic only if all possible input combinations described Remember to use default statement Otherwise, compiler will create an asynchronous latch to remember previous value: bad because this is not intended! Slide derived from slides by Harris & Harris from their book 10

Combinational logic using casez module priority_casez(input logic [3:0] a, output logic [3:0] y); always_comb casez(a) 4'b1???: y = 4'b1000; //? = don t care 4'b01??: y = 4'b0100; 4'b001?: y = 4'b0010; 4'b0001: y = 4'b0001; default: y = 4'b0000; endcase Slide derived from slides by Harris & Harris from their book 11

Nesting In general, for loop, if-then-else, and case statements can be nested. e.g., for ( ) if ( ) case ( ) endcase else Compiler will compile from the inner-most scope outwards: i.e., it will first produce multiplexor logic for case statement, then produce multiplexor logic for the if-then-else part, then replicate all that logic based on the number of iterations in the for loop. 12

Functions /* adder subtractor */ module add_sub(input logic op, input logic [3:0] A, B, input logic carry_in, output logic [3:0] sum, output logic carry_out); function logic [4:0] adder(input logic [3:0] x, y, input logic cin); logic [3:0] s; // internal signals logic c; c = cin; for (int i = 0; i < 4; i++) begin s[i] = x[i] ^ y[i] ^ c; c = (x[i] & y[i]) (c & x[i]) (c & y[i]); end adder = {c, s}; endfunction function is like a comb. always statement, but can be called (instantiated) later. always_comb if (op) // subtraction {carry_out, sum} = adder(a, ~B, 1); else {carry_out, sum} = adder(a, B, 0); 13