ELEN 468 Lecture 71 ELEN 468 Advanced Logic Design Lecture 7 System Tasks, Functions, Syntax and Behavioral Modeling I.

Slides:



Advertisements
Similar presentations
Verilog.
Advertisements

Simulation executable (simv)
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Supplement on Verilog adder examples
Synchronous Sequential Logic
ELEN 468 Lecture 61 ELEN 468 Advanced Logic Design Lecture 6 Delay Models.
ELEN 468 Lecture 21 ELEN 468 Advanced Logic Design Lecture 2 Hardware Modeling.
Verilog Modules for Common Digital Functions
Verilog Intro: Part 1.
Hardware Description Language (HDL)
Verilog. 2 Behavioral Description initial:  is executed once at the beginning. always:  is repeated until the end of simulation.
1 Brief Introduction to Verilog Weiping Shi. 2 What is Verilog? It is a hardware description language Originally designed to model and verify a design.
//HDL Example 6-1 // //Behavioral description of //Universal shift register // Fig. 6-7 and Table 6-3 module shftreg.
2/9/20031 ECE 551: Digital System Design & Synthesis Lecture Set 4 4.1: Verilog – Procedural Assignments &Scheduling Semantics 4.2: Verilog – More Behavioral.
ELEN 468 Lecture 151 ELEN 468 Advanced Logic Design Lecture 15 Synthesis of Language Construct I.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
Digital System Design by Verilog University of Maryland ENEE408C.
ELEN 468 Lecture 81 ELEN 468 Advanced Logic Design Lecture 8 Behavioral Descriptions II.
ELEN 468 Lecture 91 ELEN 468 Advanced Logic Design Lecture 9 Behavioral Descriptions III.
ENEE 408C Lab Capstone Project: Digital System Design Verilog Tutorial Class Web Site:
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
Silicon Programming--Intro. to HDLs1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities.
ECEN ECEN475 Introduction to VLSI System Design Verilog HDL.
Digital System Design Verilog ® HDL Useful Modeling Techniques Maziar Goudarzi.
Verilog Intro: Part 2. Procedural Blocks There are two types of procedural blocks in Verilog. – initial for single-pass behavior : initial blocks execute.
ELEN468 Lecture 31 ELEN 468 Advanced Logic Design Lecture 3 Simulation and Testbench.
Today’s Lecture Process model –initial & always statements Assignments –Continuous & procedural assignments Timing Control System tasks.
Overview Logistics Last lecture Today HW5 due today
ECE 2372 Modern Digital System Design
MODULE 1.3 VERILOG BASICS UNIT 1 : INTRODUCTION TO VERILOG TOPIC : System Tasks and Compiler directive.
Verilog Language Concepts
ECE 551 Digital System Design & Synthesis Fall 2011 Midterm Exam Overview.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Digital System Design Verilog ® HDL Parameters, and Generate Blocks Maziar Goudarzi.
1 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
Simulating a Verilog Description module bigtest;. calc1_top D1(out_data1, out_data2, out_data3, out_data4, out_resp1, out_resp2, out_resp3, out_resp4,
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
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,
1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities and architectural bodies behavioral,
3/4/20031 ECE 551: Digital System * Design & Synthesis Lecture Set 2 2.1: Verilog – The Basics 2.2: Verilog – Simulation and Testbenches.
Behavioral Modelling - 1. Verilog Behavioral Modelling Behavioral Models represent functionality of the digital hardware. It describes how the circuit.
1 Verilog Digital System Design Z. Navabi, 2006 Verilog Language Concepts.
The Verilog Hardware Description Language. GUIDELINES How to write HDL code: How to write HDL code:
ELEN 468 Lecture 131 ELEN 468 Advanced Logic Design Lecture 13 Synthesis of Combinational Logic II.
Verilog A Hardware Description Language (HDL ) is a machine readable and human readable language for describing hardware. Verilog and VHDL are HDLs.
M.Mohajjel. Structured Procedures Two basic structured procedure statements always initial All behavioral statements appear only inside these blocks Each.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
 A test bench is an HDL program used for applying stimulus to an HDL design in order to test it and observe its response during simulation.  In addition.
Verilog® HDL Behavioral Modeling (2)
ELEN 468 Lecture 171 ELEN 468 Advanced Logic Design Lecture 17 Midterm1 Review.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
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.
1 Lecture 3: Modeling Sequential Logic in Verilog HDL.
Structural Description
Overview Logistics Last lecture Today HW5 due today
Supplement on Verilog FF circuit examples
ELEN 468 Advanced Logic Design
Verilog Introduction Fall
‘if-else’ & ‘case’ Statements
Behavioral Modeling Structural modeling Behavioral modeling
Verilog HDL.
ELEN 468 Advanced Logic Design
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Useful Modeling Techniques
The Verilog Hardware Description Language
The Verilog Hardware Description Language
The Verilog Hardware Description Language
COE 202 Introduction to Verilog
Presentation transcript:

ELEN 468 Lecture 71 ELEN 468 Advanced Logic Design Lecture 7 System Tasks, Functions, Syntax and Behavioral Modeling I

ELEN 468 Lecture 72 System Tasks and Functions

ELEN 468 Lecture 73 Display Tasks $monitor $monitor(“%d %f %b %b”, $time, $realtime, x, y); Continuously display values $display, $displayb, $displayo, $displayh $display(“x = %b y = %b”, x, y); Display once only $write, $writeb, $writeo, $writeh $write(“x = %b y = %b”, x, y); Same as display, but no “\n”

ELEN 468 Lecture 74 Files $fopen, $fclose, $fdisplay module test_bench(); reg x; wire y; integer cd; assign y = ~x; initial begin cd = $fopen("test.dat"); #100 x = 0; $fdisplay(cd, "%b %b", x, y); $fclose(cd); end endmodule module test_bench(); reg x; wire y; integer cd; assign y = ~x; initial begin cd = $fopen("test.dat"); #100 x = 0; $fdisplay(cd, "%b %b", x, y); $fclose(cd); end endmodule channel descriptor

ELEN 468 Lecture 75 Read Memory parameter ram_file = “ram_data_file”; reg [15:0] RAM_1 [0:1023]; initial $readmemh(ram_file, RAM_1); // read input file as hexadecimal initial $readmemb(ram_file, RAM_1); // read input file as binary parameter ram_file = “ram_data_file”; reg [15:0] RAM_1 [0:1023]; initial $readmemh(ram_file, RAM_1); // read input file as hexadecimal initial $readmemb(ram_file, RAM_1); // read input file as binary

ELEN 468 Lecture 76 Simulation Control $finish and $finish(n) n = 0, print nothing n = 1, print simulation time and location n = 2, print simulation time, location and statistics $stop(n): interactive mode initial #200 $finish; initial #200 $finish; initial begin #20 x=0; y=0; $stop(0); initial begin #20 x=0; y=0; $stop(0);

ELEN 468 Lecture 77 Probability Distribution Generate different types of distributions integer seed, d; d = $dist_uniform(seed, 0, 9); d = $dist_exponential(seed, 3); d = $dist_normal(seed, 0, 5); integer seed, d; d = $dist_uniform(seed, 0, 9); d = $dist_exponential(seed, 3); d = $dist_normal(seed, 0, 5); range mean standard deviation

ELEN 468 Lecture 78 Compiler Directives `timescale `include `defaultnettype `define and `undef `ifdef, `else, `endif `include “testbench.v” `defaultnettype wor `define wait_state 3’b010 `undef wait_state `ifdef BEHAVIORAL y = x1 | x2; `else or ( y, x1, x2 ); `endif `include “testbench.v” `defaultnettype wor `define wait_state 3’b010 `undef wait_state `ifdef BEHAVIORAL y = x1 | x2; `else or ( y, x1, x2 ); `endif

ELEN 468 Lecture 79 Syntax

ELEN 468 Lecture 710 BNF Formal Syntax Notation BNF = Backus-Naur Form or Backus Normal Form ::= definition of syntax | alternative syntax […] appear once or not at all {…} appear any times, or not at all

ELEN 468 Lecture 711 Example of Verilog Syntax source_text ::= { description } description ::= module_declaration | udp_declaration module_declaration ::= module_keyword module_identifier [list_of_ports]; { module_item } endmodule module_keyword ::= module | macromodule

ELEN 468 Lecture 712 list_of_ports ::= ( port {, port} ) module_item ::= module_item_declaration | parameter_overwrite | continuous_assign | gate_instantiation | udp_instantiation | module_instantiation | specify_block | initial_construct | always_construct

ELEN 468 Lecture 713 continuous_assign ::= assign [drive_strength] [delay3] list_of_net_assignments; drive_strength ::= ( strength0, strength1) delay3 ::= #delay_value | #(delay_value [, delay_value [, delay_value]] ) list_of_net_assignments ::= net_assignment {, net_assignment } net_assignment ::= net1_value = expression

ELEN 468 Lecture 714 Behavioral Modeling I

ELEN 468 Lecture 715 Structural vs. Behavioral Descriptions module my_module(…); … assign …; // continuous assignment and (…); // instantiation of primitive adder_16 M(…); // instantiation of module begin … end initial begin … end endmodule Structural, no order Behavior, in order in each procedure

ELEN 468 Lecture 716 Behavioral Procedural Behavioral Descriptions In General Co-exists with gate instantiations Not all descriptions synthesize Not all synthesized descriptions are desirable Non-structural behaviors Continuous assignment initial always Within a module Multiple behaviors are allowed Nested behaviors are not allowed

ELEN 468 Lecture 717 Behavioral Statements initial | always single_statement; | begin block_of_statements; end initial | always single_statement; | begin block_of_statements; end initial Activated from t sim = 0 Executed once Initialize a simulation always Activated from t sim = 0 Executed cyclically Continue till simulation terminates

ELEN 468 Lecture 718 Example of Behavioral Statement module clock1 ( clk ); parameter half_cycle = 50; parameter max_time = 1000; output clk; reg clk; initial clk = 0; always begin #half_cycle clk = ~clk; end initial #max_time $finish; endmodule module clock1 ( clk ); parameter half_cycle = 50; parameter max_time = 1000; output clk; reg clk; initial clk = 0; always begin #half_cycle clk = ~clk; end initial #max_time $finish; endmodule clk t sim

ELEN 468 Lecture 719 Assignment Continuous assignment Values are assigned to net variables due to some input variable changes “assign …=… “ Procedural assignment Values are assigned to register variables when certain statement is executed in a behavior Procedural assignment, “=“ Procedural continuous assignment, “assign …=… [deassign] “ Non-blocking assignment, “<=“

ELEN 468 Lecture 720 Blocking and Non-blocking Assignment initial begin a = 1; b = 0; a = b; // a = 0; b = a; // b = 0; end initial begin a = 1; b = 0; a <= b; // a = 0; b <= a; // b = 1; end Blocking assignment “=“ Statement order matters A statement has to be executed before next statement Non-blocking assignment “<=“ Concurrent assignment If there are multiple non- blocking assignments to same variable in same behavior, latter overwrites previous

ELEN 468 Lecture 721 Procedural Continuous Assignment Continuous assignment establishes static binding for net variables Procedural continuous assignment (PCA) establishes dynamic binding for variables “assign … deassign” for register variables only “force … release” for both register and net variables

ELEN 468 Lecture 722 “assign … deassign” PCA Binding takes effect when PCA statement is executed Can be overridden by another PCA statement “deassign” is optional “assign” takes control, “deassign” release control module flop ( q, qbar, preset, clear, clock, data ); … assign qbar = ~q; initial q = 0; ( negedge clk ) q = data; ( clear or preset ) begin if ( !preset ) assign q = 1; else if ( !clear ) assign q = 0; else deassign q; end endmodule module flop ( q, qbar, preset, clear, clock, data ); … assign qbar = ~q; initial q = 0; ( negedge clk ) q = data; ( clear or preset ) begin if ( !preset ) assign q = 1; else if ( !clear ) assign q = 0; else deassign q; end endmodule

ELEN 468 Lecture 723 Example of assign module mux4_PCA(a, b, c, d, select, y_out); input a, b, c, d; input [1:0] select; output y_out; reg y_out; begin if (select == 0) assign y_out=a; else if (select == 1) assign y_out=b; else if (select == 2) assign y_out=c; else if (select == 3) assign y_out=d; else assign y_out=1’bx; end endmodule module mux4_PCA(a, b, c, d, select, y_out); input a, b, c, d; input [1:0] select; output y_out; reg y_out; begin if (select == 0) assign y_out=a; else if (select == 1) assign y_out=b; else if (select == 2) assign y_out=c; else if (select == 3) assign y_out=d; else assign y_out=1’bx; end endmodule y_out changes with a;

ELEN 468 Lecture 724 Alternative module mux4_PCA(a, b, c, d, select, y_out); input a, b, c, d; input [1:0] select; output y_out; reg y_out; or a or b or c or d) begin if (select == 0) y_out=a; else if (select == 1) y_out=b; else if (select == 2) y_out=c; else if (select == 3) y_out=d; else y_out=1’bx; end endmodule module mux4_PCA(a, b, c, d, select, y_out); input a, b, c, d; input [1:0] select; output y_out; reg y_out; or a or b or c or d) begin if (select == 0) y_out=a; else if (select == 1) y_out=b; else if (select == 2) y_out=c; else if (select == 3) y_out=d; else y_out=1’bx; end endmodule Value of ‘a’ is assigned to y_out at this time

ELEN 468 Lecture 725 “force … release” PCA force sig1 = 0; force sig2 = 1; Sig3 = 0; #9 sig3 = 1; … release sig1; release sig2; force sig1 = 0; force sig2 = 1; Sig3 = 0; #9 sig3 = 1; … release sig1; release sig2; Similar to “assign…deassign” Can be applied to net variables Often applied in testing modA modB sig1 sig2 sig3

ELEN 468 Lecture 726 Comparisons of Assignment mode Output of primitive Continuous assignment Procedural assignment assign … deassign PCA force … release PCA VariableNet Seq-reg NetRegister Net and register descriptionStructural Behavioral bindingStatic Dynamic, one shot Dynamic, continuous