First Steps in Verilog CPSC 321 Computer Architecture Andreas Klappenecker.

Slides:



Advertisements
Similar presentations
VERILOG: Synthesis - Combinational Logic Combination logic function can be expressed as: logic_output(t) = f(logic_inputs(t)) Rules Avoid technology dependent.
Advertisements

CPSC 321 Computer Architecture Andreas Klappenecker
//HDL Example 4-10 // //Gate-level description of circuit of Fig. 4-2 module analysis (A,B,C,F1,F2); input.
Verilog.
Simulation executable (simv)
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Supplement on Verilog adder examples
Combinational Logic.
CPEN Digital System Design
Verilog Intro: Part 1.
Hardware Description Language (HDL)
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part3: Verilog – Part 1.
CSE 201 Computer Logic Design * * * * * * * Verilog Modeling
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
 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.
Verilog II CPSC 321 Andreas Klappenecker Today’s Menu Verilog, Verilog.
The Multicycle Processor II CPSC 321 Andreas Klappenecker.
The Design Process CPSC 321 Computer Architecture Andreas Klappenecker.
ENEE 408C Lab Capstone Project: Digital System Design Verilog Tutorial Class Web Site:
2-to-1 Multiplexer: if Statement Discussion D7.1 Example 4.
Computer Organization Lecture Set – 03 Introduction to Verilog Huei-Yung Lin.
Digital System Design EEE344 Lecture 3 Introduction to Verilog HDL Prepared by: Engr. Qazi Zia, Assistant Professor EED, COMSATS Attock1.
Lecture 7 Verilog Additional references Structural constructs
each of these is an instantiation of “full_adder”
Verilog Basics Nattha Jindapetch November Agenda Logic design review Verilog HDL basics LABs.
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.
Combinational Circuits
ECE 2372 Modern Digital System Design
ECE/CS 352 Digital Systems Fundamentals
Workshop Topics - Outline
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.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities and architectural bodies behavioral,
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
Introduction to Verilog. Data Types A wire specifies a combinational signal. – Think of it as an actual wire. A reg (register) holds a value. – A reg.
Multiplexers Section Topics Multiplexers – Definition – Examples – Verilog Modeling.
Introduction to Verilog
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Chapter 3: Dataflow Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 3-1 Chapter 3: Dataflow Modeling.
Verilog Intro: Part 1. Hardware Description Languages A Hardware Description Language (HDL) is a language used to describe a digital system, for example,
Introduction to Verilog. Structure of a Verilog Program A Verilog program is structured as a set of modules, which may represent anything from a collection.
Exp#5 & 6 Introduction to Verilog COE203 Digital Logic Laboratory Dr. Ahmad Almulhem KFUPM Spring 2009.
Structural Description
Overview Logistics Last lecture Today HW5 due today
Hardware Description Languages: Verilog
Reg and Wire:.
Introduction to Verilog
Discussion 2: More to discuss
Verilog Introduction Fall
Supplement on Verilog adder examples
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]
Introduction to Verilog
Behavioral Modeling in Verilog
Chapter 3: Dataflow Modeling
Combinatorial Logic Design Practices
Logic Values 0:logic 0 / false 1:logic 1 / true X:unknown logic value
Introduction to Verilog
Supplement on Verilog adder examples
Introduction to Verilog
Introduction to Verilog
Supplement on Verilog combinational circuit examples
Introduction to Verilog – Part-2 Procedural Statements
COE 202 Introduction to Verilog
Presentation transcript:

First Steps in Verilog CPSC 321 Computer Architecture Andreas Klappenecker

Verilog Simulators vcs from Synopsis powerful debugging tools Icarus Verilog compiler, free Veriwell simulator, free

Information about Verilog Short manual by Chauhan and Blair Verilog Quick Reference Guide by Sutherland HDL Appendix A in Fundamentals of Digital Logic by Brown and Vranesic Quick Reference for Verilog HDL by Rajeev Madhavan

Hello World module top; initial $display("Hello, world!"); endmodule initial statements are executed once by the simulator

Verilog Simulator The Verilog simulator is event driven Different styles of Verilog structural dataflow behavioral We will see examples of each type

Nets A net represents a node in the circuit The wire type connects an output of one element to an input of another element wire abar; not(abar, a); nand(b, abar,abar);

Vector wires Range [msb: lsb] wire [3:0] S; S = 4’b0011 The result of this assignment is S[3] = 0, S[2] = 0, S[1] = 1, S[0] = 1 wire [1:2] A; A = S[2:1]; means A[1] = S[2], A[2] = S[1]

Variables Variables come in two flavors reg integers reg can model combinatorial or sequential parts of the circuits reg does not necessarily denote a register! Integers often used as loop control variables useful for describing the behavior of a module

Simple Example module testgate; reg b, c; // variables wire a, d, e; // nets and (d, b, c); // gates or (e, d, c); // nand(a, e, b); // initial begin // simulated once b=1; c=0; // blocking assignments #10 $display("a = %b", a); end endmodule What value will be printed?

Operators 1’s complement ~A 2’s complement -A bitwise AND A&B reduction &A produces AND of all bits in A Concatenate {a,b,c} | {a,b,c} = a | b | c Replication operators 2{A} = {A,A} {2{A},3{B}} = {A,A,B,B,B}

Continuous assignments Single bit assignments assign s = x ^ y ^ cin; assign cout = (x & y) | (cin & x) | (cin &y ) Multibit assignments wire [1:3] a,b,c; … assign c = a & b;

Full Adder module fulladd(cin, x, y, s, cout) input cin, x, y; output s, cout; assign s = x ^ y ^ cin; assign cout = (x & y) | (cin & x) | (cin & y); endmodule

Always Blocks An always block contains one or more procedural statements list) or y) begin s = x ^ y; c = x & y; end

Mux: Structural Verilog module mux(f, a,b,sel); input a,b,sel; output f; wire f1, f2; not(nsel, sel); and(f1, a,nsel); and(f2, b, sel); or (f, f1, f2); endmodule b a sel f

Mux: Dataflow Model module mux2(f, a,b,sel); output f; input a,b,sel; assign f = (a & ~sel) | (b & sel); endmodule

Mux: Behavioral Model module mux2(f, a,b,sel); output f; input a,b,sel; reg f; or b or sel) if (sel==1) f = b; else f = a; endmodule

Sign extension and addition module adder_sign(x,y,s,s2s); input [3:0] x,y; output [7:0] s, ss; assign s = x + y, ss = {{4{x[3]}},x}+{{4{y[3]},y} endmodule x = 0011, y = 1101 s = = ss = = = =

Demux Example 2-to-4 demultiplexer with active low enableabz[3]z[2]z[1]z[0] 0xx

Demux: Structural Model // 2-to-4 demultiplexer with active-low outputs module demux1(z,a,b,enable); input a,b,enable; output [3:0] z; wire abar,bbar; // local signals not v0(abar,a), v1(bbar,b); nand n0(z[0],enable,abar,bbar); nand n1(z[1],enable,a,bbar); nand n2(z[2],enable,abar,b); nand n3(z[3],enable,a,b); endmodule

Demux: Dataflow model // 2-to-4 demux with active-low outputs // dataflow model module demux2(z,a,b,enable); input a,b,enable; output [3:0] z; assign z[0] = | {~enable,a,b}; assign z[1] = ~(enable & a & ~b); assign z[2] = ~(enable & ~a & b); assign z[3] = enable ? ~(a & b) : 1'b1; endmodule

Demux: Behavioral Model // 2-to-4 demultiplexer with active-low outputs module demux3(z,a,b,enable); input a,b,enable; output [3:0] z; reg z; // not really a register! or b or enable) case ({enable,a,b}) default: z = 4'b1111; 3'b100: z = 4'b1110; 3'b110: z = 4'b1101; 3'b101: z = 4'b1011; 3'b111: z = 4'b0111; endcase endmodule