CSE 201 Computer Logic Design * * * * * * * Verilog Modeling

Slides:



Advertisements
Similar presentations
Digital System Design-II (CSEB312)
Advertisements

VERILOG: Synthesis - Combinational Logic Combination logic function can be expressed as: logic_output(t) = f(logic_inputs(t)) Rules Avoid technology dependent.
CSE502: Computer Architecture SystemVerilog Adapted from slides by Peter Milder.
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Verilog Part 1 – Chapter.
Verilog Fundamentals Shubham Singh Junior Undergrad. Electrical Engineering.
2’s Complement 4-Bit Saturator
CPSC 321 Computer Architecture Andreas Klappenecker
CDA 3100 Recitation Week 11.
Verilog.
The Verilog Hardware Description Language
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Supplement on Verilog adder examples
Synchronous Sequential Logic
EE 361 Fall 2003University of Hawaii1 Hardware Design Tips EE 361 University of Hawaii.
Combinational Logic.
Table 7.1 Verilog Operators.
Verilog Intro: Part 1.
Hardware Description Language (HDL)
Combinational Logic with Verilog Materials taken from: Digital Design and Computer Architecture by David and Sarah Harris & The Essentials of Computer.
Anurag Dwivedi.  Verilog- Hardware Description Language  Modules  Combinational circuits  assign statement  Control statements  Sequential circuits.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part3: Verilog – Part 1.
CSE 201 Computer Logic Design * * * * * * * Verilog Modeling
Verilog. 2 Behavioral Description initial:  is executed once at the beginning. always:  is repeated until the end of simulation.
 HDLs – Verilog and Very High Speed Integrated Circuit (VHSIC) HDL  „ Widely used in logic design  „ Describe hardware  „ Document logic functions.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
ELEN 468 Advanced Logic Design
Verilog Intro: Part 2. Procedural Blocks There are two types of procedural blocks in Verilog. – initial for single-pass behavior : initial blocks execute.
University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Today’s Lecture Process model –initial & always statements Assignments –Continuous & procedural assignments Timing Control System tasks.
Engineering 100 Section 250 Combinational Logic -- Examples 9/13/2010.
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
ECE/CS 352 Digital Systems Fundamentals
Verilog Language Concepts
CS 3850 Lecture 3 The Verilog Language. 3.1 Lexical Conventions The lexical conventions are close to the programming language C++. Comments are designated.
Digital System 數位系統 Verilog HDL Ping-Liang Lai (賴秉樑)  
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
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.
Module 1.2 Introduction to Verilog
Behavioral Modelling - 1. Verilog Behavioral Modelling Behavioral Models represent functionality of the digital hardware. It describes how the circuit.
The Verilog Hardware Description Language. GUIDELINES How to write HDL code: How to write HDL code:
Brief Verilog.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL State Machines Anselmo Lastra.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Introduction to ASIC flow and Verilog HDL
Multiplexers Section Topics Multiplexers – Definition – Examples – Verilog Modeling.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Verilog Intro: Part 1. Hardware Description Languages A Hardware Description Language (HDL) is a language used to describe a digital system, for example,
1 University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
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.
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.
Hardware Description Languages: Verilog
TODAY’S OUTLINE Verilog Codings Concurrent and Sequential If-else
Reg and Wire:.
Verilog Introduction Fall
EMT 351/4 DIGITAL IC DESIGN Week # Synthesis of Sequential Logic 10.
Lecture 2 Supplement Verilog-01
Verilog-HDL-3 by Dr. Amin Danial Asham.
Hardware Description Languages: Verilog
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Behavioral Modeling in Verilog
Supplement on Verilog adder examples
Chapters 4 – Part3: Verilog – Part 1
The Verilog Hardware Description Language
The Verilog Hardware Description Language
COE 202 Introduction to Verilog
Presentation transcript:

CSE 201 Computer Logic Design * * * * * * * Verilog Modeling Basics CSULB -- CECS 201– Verilog Basics © 2013 -- R.W. Allison

Two Primary Ways of Modeling Logic Structural Behavioral DO NOT use “always” Use “always” block Outputs declared as “wire” Outputs declared as “reg” “Schematics using text” “Instantiate” other modules and interconnect them with wires and busses… Combinational Logic Sequential Logic … or, alternatively, use the “assign” statement along with the verilog operators for “and” (&), “or” (|), “not” (~) and xor (^). always @ (*) always @ (posedge clk, posedge reset) case ( {all inputs} ) if ( reset == 1’b1 ) //check for reset first // assign output(s) for reset condition // each row assigns output(s) // based on input combinations else //got a clock // assign output(s) based on decisions For example, assign F1 = (~W & X & ~Y) | (~X & ~Z); CSULB -- CECS 201– Verilog Basics © 2013 -- R.W. Allison

Fundamentals Verilog Module Definitions (structural) Module name (must begin with a letter or underscore) Port list (input and output names) module addsub4 ( M, A, B, Cin, Y, CB ); input [3:0] A, B; input M, Cin; output wire [3:0] Y; output wire CB; input/output declarations size specifier (default size is 1-bit scalar) type specifier (for outputs only, default type is wire) // structural logic of 4-bit add/sub // using 4 instances of 1-bit addsub addsub a0 ( M, A[0], B[0], Cin, Y[0], cb0), a1 ( M, A[1], B[1], cb0, Y[1], cb1), a2 ( M, A[2], B[2], cb1, Y[2], cb2), a3 ( M, A[3], B[3], cb2, Y[3], CB); single line comments endmodule CSULB -- CECS 201– Verilog Basics © 2013 -- R.W. Allison

Fundamentals Verilog Module Definitions (behavioral) Module name (must begin with a letter or underscore) Port list (input and output names) module addsub ( M, A, B, Cin, Y, CB ); input [3:0] A, B; input M, Cin; output reg [3:0] Y; output reg CB; input/output declarations size specifier (default size is 1-bit scalar) type specifier (for outputs only) event operator sensitivity list always @ ( M, A, B, Cin ) begin // behavioral logic of add/sub if ( M == 1’b0 ) {CB,Y} = A + B + Cin; else {CB,Y} = A - B - Cin; single line comment Note: Verilog is an “event driven” language, not a “sequential” language. concatenation operator As such, the most powerful operator in the verilog language is the “event” operator (@). end // end of always endmodule In practical use, the second most powerful operator is the concatenation operator ( { , } ). CSULB -- CECS 201– Verilog Basics © 2013 -- R.W. Allison

Structural Verilog Module Example (2-to-4 decoder) En Y3 Y2 Y1 Y0 decode_2to4 One could create four 3-variable K-maps to find the S.O.P expressions for the four outputs, but, by observation, each output only has one minterm in the truth table where it is “1.” En I1 I0 Y3 Y2 Y1 Y0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 1 1 0 1 0 0 1 0 1 1 0 0 1 0 0 1 1 1 1 0 0 0 Thus, Y3 = En & I1 & I0 Y2 = En & I1 & I0’ Y1 = En & I1’ & I0 Y2 = En & I1’ & I0’ CSULB -- CECS 201– Verilog Basics © 2013 -- R.W. Allison

Structural Verilog Module Example (2-to-4 decoder) Thus, Y3 = En & I1 & I0 Y2 = En & I1 & I0’ Y1 = En & I1’ & I0 Y2 = En & I1’ & I0’ Structural using “gates” module decoder_2to4 (En, I1, I0, Y3, Y2, Y1, Y0);   input En, I1, I0; output wire Y3, Y2, Y1, Y0; wire i1_n, i0_n; // interconnection wires for not gate outputs // Structural model of decoder using 4 3-input “and” gates not n1 (i1_n, I1), n0 (i0_n, I0); and ag3 (Y3, En, I1, I0), ag2 (Y2, En, I1, i0_n), ag1 (Y1, En, i1_n, I0), ag0 (Y0, En, i1_n, i0_n); endmodule CSULB -- CECS 201– Verilog Basics © 2013 -- R.W. Allison

Structural Verilog Module Example (2-to-4 decoder) Thus, Y3 = En & I1 & I0 Y2 = En & I1 & I0’ Y1 = En & I1’ & I0 Y2 = En & I1’ & I0’ Structural using “assign” module decoder_2to4 (En, I1, I0, Y3, Y2, Y1, Y0);   input En, I1, I0; output wire Y3, Y2, Y1, Y0; // Structural model of decoder using 4 3-input “assign” statement assign Y3 = (En & I1 & I0), Y2 = (En & I1 & ~I0), Y1 = (En & ~I1 & I0), Y0 = (En & ~I1 & ~I0); endmodule CSULB -- CECS 201– Verilog Basics © 2013 -- R.W. Allison

Behavioral Verilog Module Example (2-to-4 decoder) En Y3 Y2 Y1 Y0 decode_2to4 Having the truth table for ANY logic function, we can create a “behavioral” module using the verilog “case statement.” In essence, the “case statement” has exactly the same input/output relationships seen in a table; yet the table data must be placed in the case “template.” // behavioral logic of 2-to-4 decoder case ( {En, I1, I0} ) 3’b000: {Y3,Y2,Y1,Y0} = 4’b0000; 3’b001: {Y3,Y2,Y1,Y0} = 4’b0000; 3’b010: {Y3,Y2,Y1,Y0} = 4’b0000; 3’b011: {Y3,Y2,Y1,Y0} = 4’b0000; 3’b100: {Y3,Y2,Y1,Y0} = 4’b0001; 3’b101: {Y3,Y2,Y1,Y0} = 4’b0010; 3’b110: {Y3,Y2,Y1,Y0} = 4’b0100; 3’b111: {Y3,Y2,Y1,Y0} = 4’b1000; endcase En I1 I0 Y3 Y2 Y1 Y0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 1 1 0 1 0 0 1 0 1 1 0 0 1 0 0 1 1 1 1 0 0 0 Inputs Outputs CSULB -- CECS 201– Verilog Basics © 2013 -- R.W. Allison

Behavioral Verilog Module Example (2-to-4 decoder) The “case statement” must be placed within the verilog “always” block, the only procedural block used in behavioral modeling. The complete module is created by “packaging” the procedural block within the applicable verilog module declarations ... module decoder_2to4 ( En, I1, I0, Y3, Y2, Y1, Y0); input En, I1, I0; output reg Y3, Y2, Y1, Y0; endmodule // Although verilog allows for “free // formatting,” you are encouraged to // develop good coding style. case ( {En, I1, I0} ) 3’b000: {Y3,Y2,Y1,Y0} = 4’b0000; 3’b001: {Y3,Y2,Y1,Y0} = 4’b0000; 3’b010: {Y3,Y2,Y1,Y0} = 4’b0000; 3’b011: {Y3,Y2,Y1,Y0} = 4’b0000; 3’b100: {Y3,Y2,Y1,Y0} = 4’b0001; 3’b101: {Y3,Y2,Y1,Y0} = 4’b0010; 3’b110: {Y3,Y2,Y1,Y0} = 4’b0100; 3’b111: {Y3,Y2,Y1,Y0} = 4’b1000; endcase // behavioral logic of 2-to-4 decoder always @ (En, I1, I0) begin end // end of always block // “Programming styles commonly deal // with the visual appearance of source // code, with the goal of requiring less // human cognitive effort to extract // information about the program.”1 1 ref. http://en.wikipedia.org/wiki/Programming_style CSULB -- CECS 201– Verilog Basics © 2013 -- R.W. Allison