Combinational Verilog Intro. EECS 270 Labs

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

Spiral 1 / Unit 4 Verilog HDL. Digital Circuit Design Steps. Digital Circuit Design OVERVIEW. Mark Redekopp. Description. Verification.

Design Using Verilog

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

ECEN 468 Advanced Digital System Design

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

Engineering 303 Digital Logic Design Fall 2018

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

Speaker: Shao-Wei Feng Adviser: Prof. An-Yeu Wu Date: 2010/09/28

Verilog Module 1 Introduction and Combinational Logic

Experiment 7 Arithmetic Circuits Design and Implementation

ECE 353 Lab 3 (Verilog Design Approach)

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

Introduction to Verilog design. Design flow (from the book)

Digital Design with FPGAs. By Neeraj Kulkarni

Combinational Logic Design with Verilog. ECE 152A Winter 2012

Lab 4: Arithmetic Logic Unit (ALU)

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

Lecture #2: Verilog HDL

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

EN2911X: Reconfigurable Computing Topic 02: Hardware Definition Languages

Hardware description languages

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

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

Introduction to Verilog design. Design flow (from the book) Hierarchical Design. Lecture 2

Physics 364, Fall 2012, reading due your answers to before the end of Wednesday s lab.

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

ENEE245 Digital Circuits and Systems Lab Manual

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

EN2911X: Reconfigurable Computing Lecture 05: Verilog (2)

Introduction to Verilog

EMT1250 LABORATORY EXPERIMENT. EXPERIMENT # 10: Implementing Binary Adders. Name: Date:

EET 1131 Lab #7 Arithmetic Circuits

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

Federal Urdu University of Arts, Science and Technology, Islamabad VLSI SYSTEM DESIGN. Prepared By: Engr. Yousaf Hameed.

ENEE245 Digital Circuits and Systems Lab Manual

Physics 364, Fall 2014, reading due your answers to by 11pm on Sunday

Hardware Description Languages: Verilog. Quick History of HDLs. Verilog/VHDL. Design Methodology. Verilog Introduction. Verilog.

Hardware Description Languages: Verilog

Introduction to Verilog/System Verilog

DIGITAL SYSTEM DESIGN

Department of Computer Science and Electrical Engineering. Intro to Verilog II

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

Verilog. Reminder: Lab #1 due tonight! Fall 2008 Lecture 3

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

Laboratory Exercise 1

271/469 Verilog Tutorial

Microcomputers. Outline. Number Systems and Digital Logic Review

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

Design of Digital Circuits Lecture 6: Combinational Logic, Hardware Description Lang. & Verilog. Prof. Onur Mutlu ETH Zurich Spring March 2018

L3: Introduction to Verilog (Combinational Logic)

LAB K Basic Verilog Programming

Lecture 2: Data Types, Modeling Combinational Logic in Verilog HDL. Variables and Logic Value Set. Data Types. Why use an HDL?

ECEN 468 Advanced Logic Design

L3: Introduction to Verilog (Combinational Logic)

Chap 3. Modeling structure & basic concept of Verilog HDL

! ISP (circa 1977) - research project at CMU " Simulation, but no synthesis

Lab 3: Standard Combinational Components

Lab 2 EECE473 Computer Organization & Architecture University of Maine

Workshop on Digital Circuit Design in FPGA

ECE 152A LABORATORY 2

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

ENGN1640: Design of Computing Systems Topic 02: Lab Foundations

1. Mark the correct statement(s)

ECE 4514 Digital Design II. Spring Lecture 7: Dataflow Modeling

HDLs and SystemVerilog. Digital Computer Design

Advanced Digital Design with the Verilog HDL

Software Engineering 2DA4. Slides 2: Introduction to Logic Circuits

SWITCHING THEORY AND LOGIC CIRCUITS

Tutorial on Verilog HDL

ECE2029: Introduction to Digital Circuit Design. Lab 2 Implementing Combinational Functional Blocks

Advanced Digital Design Using FPGA. Dr. Shahrokh Abadi

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

Verilog HDL Introduction

EE292: Fundamentals of ECE

ECE468 Computer Organization & Architecture. The Design Process & ALU Design

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

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

Hardware description language (HDL)

This Lecture. Some components (useful for the homework) Verilog HDL (will continue next lecture)

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

VERILOG 2: LANGUAGE BASICS

N-input EX-NOR gate. N-output inverter. N-input NOR gate

Chapter 3: Dataflow Modeling

ECE Digital System Design & Synthesis Exercise 1 - Logic Values, Data Types & Operators - With Answers

Veriolog Overview. CS/EE 3710 Fall 2010

ENGIN 241 Digital Systems with Lab

ENGN1640: Design of Computing Systems Topic 02: Design/Lab Foundations

Arithmetic Operators There are two types of operators: binary and unary Binary operators:

EE 231 Fall Lab 1: Introduction to Verilog HDL and Altera IDE

Contents. Appendix D Verilog Summary Page 1 of 16

Topics. Midterm Finish Chapter 7

Combinational Logic II

Systems Programming. Lecture 2 Review of Computer Architecture I

This podcast will demonstrate a logical approach as to how a computer adds through logical gates.

Combinational Circuits

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

Release 0.8. Multi-Purpose Light Unit Technical Reference Manual

1. Prove that if you have tri-state buffers and inverters, you can build any combinational logic circuit. [4]

Transcription:

Combinational Verilog Intro EECS 270 Labs

From Schematics to Verilog https://www.engineersgarage.com/articles/field-programmabl e-gate-arrays-fpga https://www.altera.com/content/dam/altera-www/global/en _US/pdfs/literature/wp/wp-01003.pdf

Schematics to Verilog cont. a1 module add_half (a, b, s, cout); input a, b; output s, cout; wire s, cout; assign s = a ^ b;assign cout = a & b; endmodule // end of half adder module module add_full (a, b, cin, s, cout); input a, b, cin; output s, cout; wire s, cout; assign s = a ^ b ^ cin; assign cout = (a & b) (a & cin) (b & cin); endmodule // end of full adder module module add_2bit (a, b, s, cout); input [1:0] a, b; output [1:0] s; output cout; wire [1:0] s; wire cout; // Both a and b are 2 bit inputs // s[1] = MSB of s, s[0] = LSB of s wire c0; add_half a1(a[0], b[0], s[0], c0); // intermediate carry between adders add_full a2(a[1], b[1], c0, s[1], cout); endmodule a2

Verilog Modular Structure Module Definition: module <module name> (<input list>, <output list>); input <name>, output endmodule Input list and output list (in that order) are comma-separated list of variable names (identifiers) Can define multi-bit signals with type[n:0] name representing a n+1 bit input/output Module Instantiations: <module name> <instance name> (<parameter list>);

Verilog Literals <size><base format><number> Size: In decimal, the number of bits of <number> Base Format Options: b binary d decimal o octal h hexadecimal Examples: 549 'h8ff 'o765 4'b11 // 4-bit binary number 0011 5'd3 // 5-bit decimal number

Macros `define <MACRO_NAME> <literal> a = b & `<MACRO_NAME>; Don t forget the `, same key as tilda on the keyboard. Example: `define FORWARD 7 b0111000; hex[6:0] = `FORWARD;

Behavioral Verilog Operators & Bitwise AND Bitwise OR ~ Bitwise Negation (eg. ~A, ~(A & B), (~A B) ^ Bitwise XOR << n Left shift by n >> n Right shift by n {} Concatenation {a,b,c} puts a, b, and c after one another into a single value {n{m}} makes a single value that is n copies of m, one after the other cond? iftrue : iffalse Ternary (Conditional Operator) assign mux_out = (sel == 1)? in1 : in0; If sel equals 1, mux_out = in1, else mux_out = in0;

Structural Verilog Specifically indicates which gates to instantiate AND, OR, XOR, NOT, NAND, NOR <gate type> <instance name> (<output name> <input list>); If output name is a multi-bit signal, multiple instances of the gate will be made Input bit widths must match output bit widths module add_half (a, b, s, cout); input a, b;output s, cout;wire s, cout; xor x1 (s, a, b); and a1 (cout, a, b); endmodule // end of half adder module module add_full (a, b, cin, s, cout); input a, b, cin; output s, cout; wire s, cout; wire ab, ac, bc; // Intermediate AND gate outputs xor x2 (s, a, b, cin); and a2 (ab, a, b); and a3 (ac, a, cin); and a4 (bc, b, cin); or o1 (cout, ab, bc, ac); endmodule // end of full adder module

Behavioral vs Structural Verilog A LUT ( Look Up Table) as a truth table Behavioral Verilog takes advantage of LUTs that condense boolean logic to single logic blocks Structural Verilog instantiates individual gates in ea. Logic block https://slideplayer.com/slide/10706337/ University of Florida ECE Department Reconfigurable Architectures

Lab 3 Intro EECS 270 Labs

Robbie Goal: Drive to a beacon by controlling two wheels Robbie can go straight, right, or left Inputs to Robbie: Sensors on Front, Right and Left Sensor outputs 1 if detects beacon Outputs from Robbie: Right and Left Wheel Motion Each wheel can either go forward (F), or stop (S). Schematic & Verilog Versions, use separate Quartus Projects!

Robbie s Rules (Logic) Go straight if Forward beacon sensor or Right and Left sensors are 1 Go right if: Go left if: Stop if: Forward and Right sensors but not Left sensor Right sensor only Forward and Left sensors but not Right sensor Left sensor only Forward, Right, and Left None (All sensors drive low)

Controlling Robbie Action Left Wheel Right Wheel Straight Forward Forward Right Forward Stop Left Stop Forward Stop Stop Stop

Schematic and Verilog Implementations Sensors: Wheels SW[2] : Left SW[1] : Forward SW[0] : Right LEDR[1] (ON/OFF): Left Wheel Forward/Stopped LEDR[0] (ON/OFF): Right Wheel Forward/Stopped Sensors: Wheels SW[2] : Left SW[1] : Forward SW[0] : Right HEX1 -> F/S: Left Wheel Forward/Stopped HEX0 -> F/S: Right Wheel Forward/Stopped (HEX are active low!)

Robbie Verilog Top-level module name must be same as your project name Inputs: Left sensor, forward sensor, right sensor Outputs: [6:0] left wheel drive [6:0] right wheel drive HEX submodules will take a single control bit input (Forward or Stopped) and write to the hex displays Every time you instantiate a new submodule it must have a new instance name E.g. outputsf osf1(<input_parameter_list>,<output_params_list>); outputsf osf2(<input_parameter_list>,<output_params_list>);

Quick aside on bit sets/bit strings/busses [n-1:0] a_name = n hfa800f LSB: a_name[0] MSB: a_name[n-1] = 1 output [6:0] lwd, rwd assign lwd = 7 h11 lwd[0] = 1 lwd[4] = 1 lwd[6:5], lwd[3:1] are 0 [0] [1] [2] n n [n-1]

Robbie Verilog Top level module name = verilog file name = quartus project name Submodules can be in the same verilog file. FPGA pin assignments ( QSF file ) are made to the top-level-module s inputs and output names E.g. set_location_assignment PIN_H21 -to LEDG[4] Replace LEDG[4] with the output name you used in top level module

Renee (no schematic, only verilog) Goal: Drive to the beacon, responding to obstacles Inputs: Beacon Sensors [2:0] 2 sensors, front-left, front-right 3-bit unsigned number: signal strength, higher = closer Bumper Sensors (Active Low) 4 sensors, front, back, right, left Outputs: Wheels Forward (F), Backwards (r), Stop (S) Left Bumper Left Beacon Sensor Front Bumper Renee Back Bumper Right Beacon Sensor Right Bumper

Renee s Rules (Logic) First priority is dealing w/obstacles, then head to beacon (Robbie beacon logic) Go forward if Back bumper sensor only is active Right and Left beacon sensors are both not 0 and are both equal strength Go reverse if Go right if: Go left if: Front bumper sensor only is active Left and Back bumpers only are active Right and Back bumpers only are active Go left-back if Right and Front bumpers only are active Right bumper only is active Go right-back if Stop if: Left and Front bumpers only are active Left bumper only is active Right and Left beacon sensors are both 0 Right and Left bumpers are active Top and Bottom bumpers are active

Controlling Renee Action Left Wheel Right Wheel Forward Forward Forward Left Stop Forward Right Forward Stop Stop Stop Stop Left Back Stop Reverse Right Back Reverse Stop Reverse Stop Reverse

Verilog Implementation Beacon Sensors: SW[6:4] : Left SW[2:0] : Right Note: SW[3] unused Bumper Sensors: Key3 : Left Key0 : Right Key2: Front Key1 : Back Note: Buttons are Active low, collision occurs if key is pressed (like an actual bumper) Wheels HEX1 -> F/S/r: Left Wheel Forward/Stopped/reverse HEX0 -> F/S/r: Right Wheel Forward/Stopped/reverse Note: r is displayed as segments 4 & 6 on the hex.

Renee Verilog Notes Top level module name = verilog file name = quartus project name renee renee.v renee.qpf module renee(ls,rs,fb,rb,lb,bb,lwd,rwd); input [2:0] ls,rs; //Beacon sensors input fb, rb, lb, bb; //Bumper sensors output [6:0]lwd,rwd; //wheel outputs

Renee Verilog Hints Don t try to write a truth table for Renee, think about the logic description in english and how ifs may translate to ands, ors, etc. in verilog Make intermediate results, be ~modular~ Ideas: Modules to represent sensor/ bumper driven modes? Module to compare the sensor values? Module to determine where beacon is? Use a submodule to manage hex, like Robbie s but with edits for reverse No conditionals allowed in this lab (if, else) Declare hex outputs as sets in Verilog (i.e. output [6:0] lwd) so they can be displayed as a bus on the simulation waveform.

In-Lab and Post-Lab Deliverables In-Lab Demo Part 1: Robbie Verilog running on DE2 board In-Lab Demo Part 2: Renee running on DE2 board (Signed separate from part 1), due the week after demo part 1 Post Lab: Robbie functional sim waveform and testbench Post Lab: Renee functional sim waveform and testbench for given test cases For both sims display wheels as a bus ( see bottom for what this should look like ) Post Lab: Verilog code for Robbie and Renee Post Lab: Questions in Post Lab Post Lab is due the week after Demo Part 2. Example of what a simulation displaying the output as a bus looks like. You will achieve this by labeling the output as a bus in the testbench (using [6:0] instead of listing each segment of the display)