Verilog Wiring Tips EE371 Omid Azizi.

Slides:



Advertisements
Similar presentations
UNIT 8: Synthesis Basics
Advertisements

Verilog Fundamentals Shubham Singh Junior Undergrad. Electrical Engineering.
CDA 3100 Recitation Week 11.
The Verilog Hardware Description Language
Supplement on Verilog adder examples
EE 361 Fall 2003University of Hawaii1 Hardware Design Tips EE 361 University of Hawaii.
Anurag Dwivedi.  Verilog- Hardware Description Language  Modules  Combinational circuits  assign statement  Control statements  Sequential circuits.
CSE 201 Computer Logic Design * * * * * * * Verilog Modeling
[M2] Traffic Control Group 2 Chun Han Chen Timothy Kwan Tom Bolds Shang Yi Lin Manager Randal Hong Wed. Oct. 22 Overall Project Objective : Dynamic Control.
CS 61C L24 Verilog I (1) Garcia, Fall 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures.
2-to-1 Multiplexer: if Statement Discussion D7.1 Example 4.
Module 2.1 Gate-Level/Structural Modeling UNIT 2: Modeling in Verilog.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
February 6, 2009http://csg.csail.mit.edu/6.375/L02-1 Verilog 1 - Fundamentals Complex Digital Systems Arvind February 6, 2009 FA module adder( input.
Introduction to ASIC flow and Verilog HDL
Slide 1 3.VHDL/Verilog Description Elements. Slide 2 To create a digital component, we start with…? The component’s interface signals Defined in MODULE.
Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-1 Chapter 6: Hierarchical.
Figure Implementation of an FSM in a CPLD..
Introduction to FPGAs Getting Started with Xilinx.
1 A hardware description language is a computer language that is used to describe hardware. Two HDLs are widely used Verilog HDL VHDL (Very High Speed.
Maj Jeffrey Falkinburg Room 2E46E
Overview Logistics Last lecture Today HW5 due today
Lab 4 HW/SW Compression and Decompression of Captured Image
EE694v - Verification - Lect 12
Hardware Description Language
EECE6017C - Lab 0 Introduction to Altera tools and Basic Digital Logic
Adapted from Krste Asanovic
TODAY’S OUTLINE Introduction to Verilog Verilog coding format
TODAY’S OUTLINE Verilog Codings Concurrent and Sequential If-else
4.VHDL/Verilog Hierarchical Description
Reg and Wire:.
Introduction to Verilog
Topics Modeling with hardware description languages (HDLs).
Supplement on Verilog Sequential circuit examples: FSM
Lecture 2 Supplement Verilog-01
TODAY’S OUTLINE Testbench Circuit Verilog Operators
Chapter 3 Top Level View of Computer Function and Interconnection
EET 2261 Unit 11 Controlling LCD and Keypad
Topics Modeling with hardware description languages (HDLs).
Introduction to Verilog
Hardware Description Language
Combinatorial Logic Design Practices
UNIT 2: Data Flow description
EET 2261 Unit 11 Controlling LCD and Keypad
Hardware Description Language
Introduction to Verilog
Lecture 8 Logistics Last lecture Last last lecture Today
Verilog.
Registers and Counters
Fundamentals of Data Representation
22 October 3 classes before 2nd exam! Control 1/16/2019
Hardware Description Language
Supplement on Verilog Sequential circuit examples: FSM
UCSD ECE 111 Prof. Farinaz Koushanfar Fall 2017
Introduction to Verilog
Hardware Description Language
ECE 352 Digital System Fundamentals
Division and Modulo 15 Q A = Dividend B = Divisor Q = Quotient = A/B
Supplement on Verilog adder examples
Delivery, Forwarding, and Routing of IP Packets
Introduction to Verilog
Foundations for Datapath Design
Hardware Description Language
Introduction to Verilog
Description and Analysis of MULTIPLIERS using LAVA
332:437 Lecture 9 Verilog Example
332:437 Lecture 9 Verilog Example
ECE 352 Digital System Fundamentals
EE 194/BIO 196: Modeling biological systems
Combination Logic & FPGAs.
Presentation transcript:

Verilog Wiring Tips EE371 Omid Azizi

The Problem: A Wiring Mess Goal: We want to wire up the following structure - Its a made-up example, but similar to a multiplier array - Whoa! A lot of work (even for 4 bit by 4 bit) A[3:0] B[3:0]

Wiring a Row Lets break this down - take only one row A[3:0] B[0] METHOD 1 - MANUAL module row(A, B, R) input [3:0] A; input B; output [3:0] R; block b1 (A[3], B, R[3]); block b2 (A[2], B, R[2]); block b3 (A[1], B, R[1]); block b4 (A[0], B, R[0]); endmodule METHOD 2 - VERILOG module row(A, B, R) input [3:0] A; input B; output [3:0] R; block b [3:0] (A, B, R); endmodule

Wiring a Row What happened? We instantiated all 4 blocks at once But how did the connections (wiring) work? B R[3:0] METHOD 2 - VERILOG module row(A, B, R) input [3:0] A; input B; output [3:0] R; block b [3:0] (A, B, R); endmodule Instantiate 4 blocks

Automatic Connections CASE 1: input port expects N-bit wire and you provide N-bit wire Then, same signal goes to all blocks B R[3:0] METHOD 2 - VERILOG module row(A, B, R) input [3:0] A; input B; output [3:0] R; block b [3:0] (A, B, R); endmodule signal B is 1-bit block expects 1-bit input So, B is connected to all blocks (as in diagram)

Automatic Connections CASE 2: input port expects N-bit wire and you provide (M*N)-bit wire (M is number of blocks) Then, block 0 gets first N signals, block 1 gets next N signals, etc... B[0] works for R too R[3:0] METHOD 2 - VERILOG module row(A, B, R) input [3:0] A; input B; output [3:0] R; block b [3:0] (A, B, R); endmodule signal A is 4-bit block expects 1-bit input Bits are stripped off from A as connections are made. So block 0 gets A[0], block 1 gets A[1], ...

Automatic Connections CASE 3: neither case 1 nor 2 apply Then, Error! B[0] R[3:0] METHOD 2 - VERILOG module row(A, B, R) input [6:0] A; input B; output [3:0] R; block b [3:0] (A, B, R); endmodule assume signal A was 6-bit block still expects 1-bit input Then Verilog wouldn’t know how to distribute A to the blocks...error!

Automatic Connections What if you want to send a signal that is not a bus? Then, make it a bus! B[0] R[3:0] module row(A, S, B, R) input [2:0] A; input S; input B; output [3:0] R; wire [3:0] A2 = {S,A}; block b [3:0] (A2, B, R); endmodule Make a 4-bit wire so connections are made automatically

Automatic Connections What you have learned up to now is very simple, but can save you a lot of time - You have to make a 32x32 multiplier... - a lot of instantiations and a lot wires

Taking the example further We know how to make a row, now we have to make an array A[3:0] R1[3:0] R2[3:0] B[3:0] R3[3:0] R4[3:0]

A First Try module row(A, B, Rin, Rout) input [3:0] A; input B; input [3:0] Rin; output [3:0] Rout; block b [3:0] (A, B, Rin, Rout); endmodule module array(A, B, R) input [3:0] B; output [3:0] R; row array_row [3:0] (A, B, Rin, Rout); assign R = Rout; essentially same row as before, except now we also take the result of the previous row (Rin). Is it this easy now? What is wrong?

A First Try module row(A, B, Rin, Rout) input [3:0] A; input B; input [3:0] Rin; output [3:0] Rout; block b [3:0] (A, B, Rin, Rout); endmodule module array(A, B, R) input [3:0] B; output [3:0] R; row array_row [3:0] (A, B, Rin, Rout); assign R = Rout; A and B are hooked up correctly. All of A goes to each row (case 1). B gets distributed (case 2).

A First Try module row(A, B, Rin, Rout) input [3:0] A; input B; input [3:0] Rin; output [3:0] Rout; block b [3:0] (A, B, Rin, Rout); endmodule module array(A, B, R) input [3:0] B; output [3:0] R; row array_row [3:0] (A, B, Rin, Rout); assign R = Rout; The R connections don’t make any sense at all. We want connections between array_rows. This is something new. Its not obvious how to do this. Could just give up and instantiate all rows manually, or...

A Trick module array(A, B, R) input [3:0] A; input [3:0] B; output [3:0] R; wire [15:0] Rin; wire [15:0] Rout; // Make Rin of one row // come from Rout of previous row // This is done with a subtle shift assign Rin[3:0] = 4’b0000; assign Rin[15:4] = Rout[11:0]; row array_row [3:0] (A, B, Rin, Rout); assign R = Rout[15:12]; endmodule Rin of first row is just zeros. Make a relationship between Rin and Rout. Rin of one row is Rout of previous row. Output is Rout of last row

A Trick This works. And code is short. module array(A, B, R) input [3:0] A; input [3:0] B; output [3:0] R; wire [15:0] Rin; wire [15:0] Rout; // Make Rin of one row // come from Rout of previous row // This is done with a subtle shift assign Rin[3:0] = 4’b0000; assign Rin[15:4] = Rout[11:0]; row array_row [3:0] (A, B, Rin, Rout); assign R = Rout[15:12]; endmodule This works. And code is short. What if we wanted to make a 64x64-bit array? - code is just as short!

Some Final Words The Verilog 2001 standard has generate statements (like VHDL): generate genvar i; for (i=0; i <= 3; i=i+1) begin : u row array_row (A, B, R[i*4+3:i*4], R[(i+1)*4+3:(i+1)*4]); end endgenerate Think of it as a preprocessor that does automatic instantiations. Support for generate statements may be limited since its a newer standard But with generate support, everything you just learned almost becomes unnecessary!