Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania 18042 ECE 313 - Computer Organization Lecture 12 - Introduction.

Slides:



Advertisements
Similar presentations
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Advertisements

Synchronous Sequential Logic
Combinational Logic.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 13 - A Verilog.
Table 7.1 Verilog Operators.
Verilog Intro: Part 1.
//HDL Example 6-1 // //Behavioral description of //Universal shift register // Fig. 6-7 and Table 6-3 module shftreg.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Verilog - 1 Writing Hardware Programs in Abstract Verilog  Abstract Verilog is a language with special semantics  Allows fine-grained parallelism to.
Spring 20067W. Rhett Davis with minor modifications by Dean Brock ECE 406 at UNASlide 1 ECE 406 Design of Complex Digital Systems Lecture 10: 9: State.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Senior Design I Lecture 2 - Verilog Fall.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Senior Design I Lecture 4 - Sequential Design.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE VLSI System Design Lecture 2 - Verilog Review.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE VLSI Circuit Design Lecture 18 - Verilog.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Senior Design I Lecture 3 - Combinational.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Senior Design I Lecture 4 - Verilog 2 (Sequential.
ECEN ECEN475 Introduction to VLSI System Design Verilog HDL.
ELEN 468 Advanced Logic Design
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Senior Design I Lecture 2 FPGAs & Verilog.
Advanced Verilog EECS 270 v10/23/06.
Computer Organization Lecture Set – 03 Introduction to Verilog Huei-Yung Lin.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 7 - Introduction.
University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Overview Logistics Last lecture Today HW5 due today
Verilog Basics Nattha Jindapetch November Agenda Logic design review Verilog HDL basics LABs.
1 Verilog Digital System Design Z. Navabi, 2006 Digital Design Flow  Digital Design Flow begins with specification of the design at various levels of.
Verilog Intro: Part 2. Procedural Blocks There are two types of procedural blocks in Verilog. – initial for single-pass behavior: initial blocks execute.
ECE 2372 Modern Digital System Design
Registers CPE 49 RMUTI KOTAT.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-1 Ders – 4: Davranışsal Modelleme.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Multi-Cycle Processor.
ECE 551 Digital System Design & Synthesis Fall 2011 Midterm Exam Overview.
ECE 551 Digital Design And Synthesis
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Slide 1 6. VHDL/Verilog Behavioral Description. Slide 2 Verilog for Synthesis: Behavioral description Instead of instantiating components, describe them.
ECE/CS 352 Digital System Fundamentals© 2001 C. Kime 1 ECE/CS 352 Digital Systems Fundamentals Spring 2001 Chapters 3 and 4: Verilog – Part 2 Charles R.
1 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
Verilog for Synthesis Ing. Pullini Antonio
ECE 445 – Computer Organization
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Verilog Part 3 – Chapter.
3/4/20031 ECE 551: Digital System Design * & Synthesis Lecture Set 3 3.1: Verilog - User-Defined Primitives (UDPs) (In separate file) 3.2: Verilog – Operators,
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 15 - Multi-Cycle.
1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities and architectural bodies behavioral,
Behavioral Modelling - 1. Verilog Behavioral Modelling Behavioral Models represent functionality of the digital hardware. It describes how the circuit.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
Multiplexers Section Topics Multiplexers – Definition – Examples – Verilog Modeling.
Introduction to Verilog
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 16 - Multi-Cycle.
Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-1 Chapter 6: Hierarchical.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 9: State Machines & Reset Behavior Spring.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part4: Verilog – Part 2.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Overview Logistics Last lecture Today HW5 due today
Hardware Description Languages: Verilog
Verilog Tutorial Fall
Supplement on Verilog FF circuit examples
Verilog Introduction Fall
Hardware Description Languages: Verilog
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
COE 202 Introduction to Verilog
Chapter 4: Behavioral Modeling
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
The Verilog Hardware Description Language
Lecture 7: Verilog Part II
Presentation transcript:

Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 12 - Introduction to Verilog II Fall 2006 Reading: Verilog Handout Sections 5-6 Portions of these slides are derived from: Textbook figures © 1998 Morgan Kaufmann Publishers all rights reserved Tod Amon's COD2e Slides © 1998 Morgan Kaufmann Publishers all rights reserved Dave Patterson’s CS 152 Slides - Fall 1997 © UCB Rob Rutenbar’s Slides - Fall 1999 CMU other sources as noted

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II2 Outline - Introduction to Verilog II  More about Combinational Logic   More about always blocks and comb. Logic  Parameterized modules  Symbolic Constants  Sequential Logic  Verilog Sequential Constructs  Simple Flip-Flops & Registers  Simple Sequential Circuits: Counters, Shift registers, etc.  Memories

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II3 Review - Verilog Module Declaration  Describes the external interface of a single module  Name  Ports - inputs and outputs  General Syntax: module modulename ( port1, port2,... ); port1 direction declaration; port2 direction declaration; reg declarations; module body - “parallel” statements endmodule // note no semicolon (;) here!

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II4 Review: Combinational Logic in Verilog  Combinational Logic in assign assign output = expression;  Combinational Logic specified in always begin out1 = expr1;... out2 = expr2;... end

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II5 Review - Comb. Modeling with assign  Used for simple logic functions module fulladder(a, b, cin, sum, cout); input a, b, cin; output sum, cout; assign sum = a ^ b ^ cin; assign cout = a & b | a & cin | b & cin; endmodule

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II6 Review - Comb. Modeling with always  Example: 4-input mux behavioral model module mux4(d0, d1, d2, d3, s, y); input d0, d1, d2, d3; input [1:0] s; output y; reg y; or d1 or d2 or d3 or s) case (s) 2'd0 : y = d0; 2'd1 : y = d1; 2'd2 : y = d2; 2'd3 : y = d3; default : y = 1'bx; endcase endmodule Blocking assignments (immediate update)

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II7 Parameterized Modules  Parameters - define values that can change  Declaration: module mod1(in1, in2, out1, out2); parameter N=default-value; input [N-1 : 0] in1, in2; output [N-1 : 0] out1; … endmodule  Instantiation: wire [7:0] w, x, y; wire z; mod1 #(8) my_mod1(w,x,y,z); Defines Parameter N Uses Parameter NSets Parameter N for instance my_mod1 Sizes must match instantiated value!

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II8 Parameterized Modules: Example  N-bit 2-1 multiplexer (parameterized bitwidth) module mux2( sel, a, b, y ); parameter bitwidth=32; input sel; input [bitwidth-1:0] a, b; output [bitwidth-1:0] y; assign y = sel ? b : a; endmodule  Instantiations mux2 #(16) my16bit_mux(s, a,b, c); mux2 #(5) my5bit_mux(s, d, e, f); mux2 #(32) my32bit_mux(s, g, h, i); mux2 myDefault32bit_mux(s, j, k, l); Defines Parameter bitwidth (default value: 32 ) Uses Parameter bitwidth to set input, output size 16-bit mux 5-bit mux 32-bit mux 32-bit mux (default)

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II9 Symbolic Constants with Parameters  Idea: use parameter to name “special constants” parameter RED_ALERT = 2’b11; parameter YELLOW_ALERT = 2’b01; parameter GREEN_ALERT = 2’b00;  Don’t change in module instances  Do this to make your code more understandable  For others reading your code  For yourself reading your code after some time has passed

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II10 Symbolic Constant Example  7-segment decoder from Verilog Handout (Part 1) module seven_seg_display_decoder(data, segments); input[3:0]data; output[6:0]segments; reg[6:0]segments; // Segment # abc_defg hex equivalent parameterBLANK= 7’b111_1111;// h7F parameterZERO= 7’b000_0001;// h01 parameterONE = 7’b100_1111;// h4F parameterTWO= 7’b001_0010;// h12 parameterTHREE= 7’b000_0110;// h06 parameterFOUR= 7’b100_1100;// h4C parameterFIVE= 7’b010_0100;// h24 parameterSIX= 7’b010_0000;// h20 parameterSEVEN= 7’b000_1111;// h0F parameterEIGHT= 7’b000_0000;// h00 parameterNINE= 7’b000_0100;// h04

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II11 Symbolic Constant Example  7-segment decoder from Verilog handout Part 2) case (data) 0: segments = ZERO; 1: segments = ONE; 2: segments = TWO; 3: segments = THREE; 4: segments = FOUR; 5: segments = FIVE; 6: segments = SIX; 7: segments = SEVEN; 8: segments = EIGHT; 9: segments = NINE; default: segments = BLANK; endcase endmodule

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II12 Symbolic Constants using `define  Like C/C++, Verilog has a preprocessor  `define - equivalent to #define in C/C++  Symbolic constant definition: `define ZERO 7’b0000_0001  Symbolic constant usage: preface with “`” segments = `ZERO;  Other preprocessor directives (not discussed here)  `ifdef  `else  `endif Used for conditional compilation

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II13 Outline - Introduction to Verilog II  More about Combinational Logic  More about always blocks and comb. Logic  Parameterized modules  Symbolic Constants  Sequential Logic   Verilog Sequential Constructs  Simple Flip-Flops & Registers  Simple Sequential Circuits: Counters, Shift registers, etc.  Memories

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II14 Sequential Design with Verilog  Describe edge-triggered behavior using:  always block with“edge event” clock-signal) clock-signal)  Nonblocking assignments ( <= clock-signal) begin output1 <= expression1;... output2 <= expression2;... end Non-Blocking Assignments Registered Outputs for positive edge-trigger for negative edge-trigger

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II15 Simple Examples: Flip-Flop, Register module flipflop(d, clk, q); input d; input clk; output q; reg q; clk) q <= d; endmodule module flop3(clk, d, q); input clk; input[3:0] d; output [3:0] q; reg[3:0] q; clk) q <= d; endmodule D CLK QD Q 44

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II16 Simple Example: Register with Reset  Synchronous - resets on clock edge if reset=1 module flopr(clk, reset, d, q); input clk; inputreset; input[3:0]d; output [3:0]q; reg[3:0] q; clk) if (reset) q <= 4’b0; else q <= d; endmodule D CLK Q 44 RESET

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II17 Simple Example: Register with Reset  Asynchronous - resets immediately if reset=1 module flopr(clk, reset, d, q); input clk; inputreset; input[3:0]d; output [3:0]q; reg[3:0] q; clk or posedge reset) if (reset) q <= 4’b0; else q <= d; endmodule D CLK Q 44 RESET

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II18 Another Example: Shift Register module shiftreg(clk, sin, q); input clk; inputsin; output [3:0]q; reg[3:0] q; clk) begin q[3] <= q[2]; q[2] <= q[1]; q[1] <= q[0]; q[0] <= sin; end endmodule

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II19 Another Example: 4-bit Counter  Basic Circuit: module counter(clk, Q); input clk; output [3:0] Q; reg [3:0] Q; // a signal that is assigned a value posedge clk ) begin Q <= Q + 1; end endmodule  Questions: How about carry?  Putting carry in this code would “register” carry  Result: carry delayed one clock cycle  Need to mix sequential & combinational logic

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II20 Combining Sequential and Combinational Outputs  General circuit - both registered and comb. outputs  Approach: multiple always blocks clock) or assign

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II21 Example: Adding carry to 4-bit Counter module counter(clk, Q, carry); input clk; output [3:0] Q; output carry; reg [3:0] Q; // a signal that is assigned a value assign carry = (Q == 4'b1111); posedge clk ) begin Q <= Q + 1; end endmodule

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II22 Refining the Counter: Synchronous Clear module counter(clk, clr, Q, carry); input clk, clr; output [3:0] Q; output carry; reg [3:0] Q; // a signal that is assigned a value assign carry = (Q == 4'b1111); posedge clk ) begin if (clr) Q <= 4'd0; else Q <= Q + 1; end endmodule Q changes on clk edge (usually preferred)

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II23 Refining the Counter: Asynchronous Clear module counter(clk, clr, Q, carry); input clk, clr; output [3:0] Q; output carry; reg [3:0] Q; // a signal that is assigned a value assign carry = (Q == 4'b1111); posedge clr or posedge clk ) begin if (clr) Q <= 4'd0; else Q <= Q + 1; end endmodule Q changes on clk edge or on reset

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II24 Memories  Model memories using an array of vectors module ram(addr, wrb, din, dout); input[5:0]addr; inputwrb; input[15:0]din; output[15:0]dout; reg[15:0]mem[63:0]; // the memory reg[15:0]dout; or wrb or din) // async. access if (~wrb) mem[addr] <= din; else dout <= mem[addr]; endmodule

ECE 313 Fall 2006Lecture 12 - Intro. to Verilog II25 Coming Up  Modeling the Single-Cycle MIPS in Verilog  Modeling basic datapath components  Modeling the datapath  Modeling the control unit  Project 2 Assignment