Supplement on Verilog combinational circuit examples

Slides:



Advertisements
Similar presentations
Verilog.
Advertisements

The Verilog Hardware Description Language
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Supplement on Verilog adder examples
Combinational Logic.
Chap. 6 Dataflow Modeling
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 07: Verilog (3/3) Prof. Sherief Reda Division of.
CPEN Digital System Design
Table 7.1 Verilog Operators.
Verilog Intro: Part 1.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part3: Verilog – Part 1.
 HDLs – Verilog and Very High Speed Integrated Circuit (VHSIC) HDL  „ Widely used in logic design  „ Describe hardware  „ Document logic functions.
Verilog - 1 Writing Hardware Programs in Abstract Verilog  Abstract Verilog is a language with special semantics  Allows fine-grained parallelism to.
First Steps in Verilog CPSC 321 Computer Architecture Andreas Klappenecker.
Logic Values 0:logic 0 / false 1:logic 1 / true X:unknown logic value Z:high-impedance.
2-to-1 Multiplexer: if Statement Discussion D7.1 Example 4.
Computer Organization Lecture Set – 03 Introduction to Verilog Huei-Yung Lin.
Quad 2-to-1 Multiplexer Discussion D7.4 Example 7.
Verilog Descriptions of Digital Systems. Electronic Lock // // Electronic combinational lock // module lock(seg7,key, valid_key, col, row, mclk, resetL)
Overview Logistics Last lecture Today HW5 due today
each of these is an instantiation of “full_adder”
Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 7: Design Example,
Module : TASKS, Functions and UDPs in Verilog. Functions Functions are declared with the keywords function and endfunction. Functions are used if all.
Chapter 6. Dataflow Modeling. Continuous Assignments The left hand side always be a scalar or vector net or a concatenation of scalar and vector nets.
Programmable Logic Architecture Verilog HDL FPGA Design Jason Tseng Week 5.
Verilog Intro: Part 2. Procedural Blocks There are two types of procedural blocks in Verilog. – initial for single-pass behavior: initial blocks execute.
Figure 6.1. A 2-to-1 multiplexer.
ECE 2372 Modern Digital System Design
ECE/CS 352 Digital Systems Fundamentals
Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-1 Ders – 4: Davranışsal Modelleme.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 7: Design Example, Modeling Flip-Flops Spring.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
M.Mohajjel. Structured Procedures Two basic structured procedure statements always initial All behavioral statements appear only inside these blocks Each.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 6: Procedural Modeling Spring 2009 W. Rhett.
Chapter 8: Combinational Logic Modules Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 8-1 Chapter 8: Combinational.
Verilog Intro: Part 1. Hardware Description Languages A Hardware Description Language (HDL) is a language used to describe a digital system, for example,
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.
Exp#5 & 6 Introduction to Verilog COE203 Digital Logic Laboratory Dr. Ahmad Almulhem KFUPM Spring 2009.
Overview Logistics Last lecture Today HW5 due today
Hardware Description Languages: Verilog
Supplement on Verilog FF circuit examples
Supplement on Verilog for Algorithm State Machine Chart
Figure 8.1. The general form of a sequential circuit.
TODAY’S OUTLINE Verilog Codings Concurrent and Sequential If-else
Reg and Wire:.
Supplement on Verilog adder examples
Supplement on Verilog Sequential circuit examples: FSM
Lecture 2 Supplement Verilog-01
TODAY’S OUTLINE Testbench Circuit Verilog Operators
Verilog-HDL-3 by Dr. Amin Danial Asham.
Hardware Description Languages: Verilog
Behavioral Modeling in Verilog
Logic Values 0:logic 0 / false 1:logic 1 / true X:unknown logic value
332:437 Lecture 10 Verilog Language Details
332:437 Lecture 10 Verilog Language Details
Logic Values 0:logic 0 / false 1:logic 1 / true X:unknown logic value
COE 202 Introduction to Verilog
Lecture 2: Continuation of SystemVerilog
Chapter 8: Combinational Logic Modules
332:437 Lecture 10 Verilog Language Details
Supplement on Verilog Sequential circuit examples: FSM
Logic Values 0:logic 0 / false 1:logic 1 / true X:unknown logic value
Supplement on Verilog adder examples
Chapters 4 – Part3: Verilog – Part 1
The Verilog Hardware Description Language
The Verilog Hardware Description Language
XOR Function Logic Symbol  Description  Truth Table 
Dr. Tassadaq Hussain Introduction to Verilog – Part-4 Expressing FSM in Verilog (contd) and FSM State Encoding Dr. Tassadaq Hussain.
Introduction to Verilog – Part-2 Procedural Statements
Presentation transcript:

Supplement on Verilog combinational circuit examples Based on Fundamentals of Digital Logic with Verilog Design By Brown/Vranesic 3rd. Chung-Ho Chen

Conditional Execution A MuX: Form 1 A = (x1< x2)? (B+1): (B); If x1 < x2, A = B+1, else A = B; module mux_2to1 (x0, x1, s, f); input x0, x1, s; output f; assign f = s ? x1 : x0; endmodule  A MuX: Form 2 module mux_2to1 (x0, x1, s, f); input x0, x1, s; output reg f; always @(x0, x1, s) f = s ? x1 : x0; endmodule  Continuous assignment always block

Conditional Execution A = (x1< x2)? (B+1): (B); If x1 < x2, A = B+1, else A = B; A MuX: Two conditional bits declared in vectored signal module mux_4to1 (x0, x1, x2, x3, S, f); input x0, x1, x2, w3; input [1:0] S; output f;   assign f = S[1] ? (S[0] ? x3 : x2) : (S[0] ? x1 : x0); endmodule  f s 1 x 00 01 2 3 10 11 First see if s1 is 1, if true, then if s0 is true: then f = x3

Conditional Execution using if else 2to1 MuX module mux_2to1 (x0, x1, s, f); input x0, x1, s; output reg f; always @(x0, x1, s) if (s==0) f = x0; else f = x1; endmodule module mux_2to1 (x0, x1, s, f); input x0, x1, s; output reg f; always @(x0, x1, s) f = s ? x1 : x0; endmodule 

Conditional Execution Using case module mux_4to1 (x, s, f); input [0:3] x; input [1:0] s; output reg f; always @(x, s) case (s) 0: f = x[0]; 1: f = x[1]; 2: f = x[2]; 3: f = x[3]; endcase endmodule module mux_2to1 (x0, x1, s, f); input x0, x1, s; output reg f; always @(x0, x1, s) if (s==0) f = x0; else f = x1; endmodule 2’b00

Signal states: 0, 1, z, or x High impedance state z: output behaves like an open circuit and not connected to any defined voltage value. Don’t care state x: does not matter whether a given logic variable has the value of 0 or 1.

Example of using casex d 1 U y z x U3 has the highest priority. module priority (U, Y, z); input [3:0] U; output reg [1:0] Y; output reg z; always @(U) begin z = 1; casex (U) 4'b1xxx: Y = 3; 4'b01xx: Y = 2; 4'b001x: Y = 1; 4'b0001: Y = 0; default: begin z = 0; Y = 2'bx; end endcase endmodule d 1 U y z x 2 3 U3 has the highest priority.

Verilog Operators A[2:0], B[2:0]; f, w is scalar & 1 x | ^ ~ ^ Bitwise AND Bitwise OR A[2:0], B[2:0]; f, w is scalar 1. f = A & B, (bitwise and) only the least significant bits are involved, ie, f = A[0] & B[0]; 2. f = !A; f = 1 only if all bits in A are 0, ie, f = ~(a2 +a1 +a0). f = A && B; f=(a2+a1+a0) . (b2+b1+b0) f =&A; f = a2.a1.a0. (reduction and) Concatenate and Replication: {3{A}}= {A,A,A} = a2a1a0a2a1a0a2a1a0 & 1 x | ^ ~ ^ Bitwise XOR Bitwise XNOR

Using Task in Verilog Task: circuit routine for replication 4 Inputs of 16to1 Task: circuit routine for replication Output of a task must be a variable. The task must be included in the module that calls it. A task can call another task and it may invoke a function.

Using Function in Verilog Function: circuit function for invocation Return a single value which is placed where the function is invoked. A function can call other function but cannot call a task. Input Return one of the inputs (W12-15)