1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.

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

Chapter 15:Introduction to Verilog Testbenches Objectives In this section,you will learn about designing a testbench: Creating clocks Including files Strategic.
Simulation executable (simv)
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
CSCI 660 EEGN-CSCI 660 Introduction to VLSI Design Lecture 7 Khurram Kazi.
Synchronous Sequential Logic
Combinational Logic.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 07: Verilog (3/3) Prof. Sherief Reda Division of.
Table 7.1 Verilog Operators.
Verilog Intro: Part 1.
Hardware Description Language (HDL)
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Lecture 12 Latches Section , Block Diagram of Sequential Circuit gates New output is dependent on the inputs and the preceding values.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
Programming in Verilog CPSC 321 Computer Architecture Andreas Klappenecker.
Digital System Design by Verilog University of Maryland ENEE408C.
ELEN 468 Lecture 91 ELEN 468 Advanced Logic Design Lecture 9 Behavioral Descriptions III.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
ELEN 468 Lecture 161 ELEN 468 Advanced Logic Design Lecture 16 Synthesis of Language Construct II.
Silicon Programming--Intro. to HDLs1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities.
CSE241 R1 Verilog.1Kahng & Cichy, UCSD ©2003 CSE241 VLSI Digital Circuits Winter 2003 Recitation 1: Verilog Introduction.
Digital System Design Verilog ® HDL Useful Modeling Techniques Maziar Goudarzi.
Digital System Design Verilog ® HDL Behavioral Modeling (1) Maziar Goudarzi.
Digital System Design EEE344 Lecture 3 Introduction to Verilog HDL Prepared by: Engr. Qazi Zia, Assistant Professor EED, COMSATS Attock1.
Today’s Lecture Process model –initial & always statements Assignments –Continuous & procedural assignments Timing Control System tasks.
Overview Logistics Last lecture Today HW5 due today
RTL Coding tips Lecture 7,8 Prepared by: Engr. Qazi Zia, Assistant Professor EED, COMSATS Attock.
Introduction to VHDL (part 2)
CIS Computer Programming Logic
Introduction to FPGA AVI SINGH. Prerequisites Digital Circuit Design - Logic Gates, FlipFlops, Counters, Mux-Demux Familiarity with a procedural programming.
ECE 2372 Modern Digital System Design
Workshop Topics - Outline
MODULE 1.3 VERILOG BASICS UNIT 1 : INTRODUCTION TO VERILOG TOPIC : System Tasks and Compiler directive.
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.
Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-1 Ders – 4: Davranışsal Modelleme.
ECE 551 Digital System Design & Synthesis Fall 2011 Midterm Exam Overview.
CS 3850 Lecture 3 The Verilog Language. 3.1 Lexical Conventions The lexical conventions are close to the programming language C++. Comments are designated.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
1 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
Workshop Topics - Outline
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
System Tasks for File Output & Strobing 1. Introduction There are tasks and functions that are used to generate input and output during simulation. Their.
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 Behavioral Modeling Maziar Goudarzi.
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,
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.
M.Mohajjel. Structured Procedures Two basic structured procedure statements always initial All behavioral statements appear only inside these blocks Each.
Verilog® HDL Behavioral Modeling (2)
55:032 - Intro. to Digital DesignPage 1 VHDL and Processes Defining Sequential Circuit Behavior.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
TOPIC : SEQUENTIAL AND PARALLEL BLOCKS Module 2.3 : Behavioral modeling in verilog.
Structural Description
Overview Logistics Last lecture Today HW5 due today
Supplement on Verilog FF circuit examples
Discussion 2: More to discuss
EMT 351/4 DIGITAL IC DESIGN Week # Synthesis of Sequential Logic 10.
‘if-else’ & ‘case’ Statements
Verilog-HDL-3 by Dr. Amin Danial Asham.
Arrays, For loop While loop Do while loop
Chapter 4: Behavioral Modeling
Test Fixture (Testbench)
Introduction to Digital System and Microprocessor Design
ECE 551: Digital System Design & Synthesis
Introduction to Verilog – Part-2 Procedural Statements
Presentation transcript:

1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System Workshop 5 - Data types A Workshop 6 - Data types B Workshop 7 - Operators Workshop 8 - Signed arithmetic Workshop 9 - Behavioral modeling A Workshop 10 - Behavioral modeling B Workshop 11 - Behavioral modeling C Workshop 12 - Data flow modeling Workshop 13 - Coding Styles

2 Loop Statements There are four types of loop statements: - while - for - repeat - forever The syntax for those loops is very similar to the syntax of loops in C programming All loop statements can appear only inside an initial or always blocks Loops may contain delay expressions

3 while loop The while loop executes until the while-expression is not true. If the loop is entered when the while-expression is not true, the loop is not executed at all. Syntax: ::= while ( ) The while statement should not be used to wait for a change in a value generated external to its always statement. The while-expression can have multiple conditions using operators Multiple statements should be grouped by begin-end

4 while loop example - counter module count_mod ; integer count ; initial begin count = 0 ; while (count < 128) // Execute loop till count is 127. Exit at count 128 begin $display ("Count = %d", count) ; / / $display System Task. Display string on STD output count = count + 1 ; end endmodule

5 A riddle How many times does the following while loop say Hello? initial begin a = 5 ; c = 0 ; while (a != c) begin $display("Hello") ; c = c + 1 ; end 5 times !!!

6 for loop The for loop contains three parts: - An initial condition - A check to see if the termination condition is true - A procedural assignment to change value of the control variable Initialization condition and the incremental procedural assignment are included in the for loop and do not need to be specified separately. Provides more compact loop structure than the while loop Can be executed at compile time. Used often in Test Benches Example: module counter ; integer count ; initial for (count = 0 ; count < 128 ; count = count + 1) $display("Count = %d", count) ; endmodule

7 for loop example – memory initialization Can be executed also within an always block. Example: memory load module mem_load ; reg[7:0] mem[0:15] ; // 16 bytes memory integer I, seed ; reg clk = 1’b0 ; always begin for (i = 0 ; i < 16 ; i = i + clk) // timed, clock synchronized load mem[i] = $random(seed) ; /*returns random 32bit signed integer. seed value (reg, integer or time variable) is optional */ end always #1 clk = ~clk ; initial #33 $finish ; endmodule

8 repeat loop The repeat loop is executed the given number of times. Cannot be used to loop on a general logic expression. The while loop is used for that purpose Must contain a number – constant, variable, signal value Syntax: repeat ( ) The value of the loop count is determined once at the beginning of the execution of the loop. Example: initial // Generate random data stimuli in Test Bench begin /* If number is a variable or a signal value, it is evaluated repeat (30) only when loop starts, not during loop execution */ (posedge clock) #1 data_in = $random ; // or $random(seed) end

9 forever Loop The forever loop does not contain any expression and executes forever until the $finish task is encountered Syntax: ::= forever A forever loop can be exited by the use of the disable statement. Example: // clock generation for Test Bench reg clock ; initial begin clock = 1'b0 ; forever #5 clock = ~clock ; // clock cycle time = 10 end initial #1000 $finish ;

10 Exiting Loops on Exceptional Conditions Any of the loop statements may be exited through use of the disable statement A disable statement terminates any named begin-end block and execution then begins with the statement following the block begin-end blocks may be named by placing the name of the block after a colon following the begin keyword: begin : break for (i = 0 ; i < n ; i = i + 1) begin : continue if (a == 0) disable continue ; // proceed with i = i if (a == b) disable break ; // exit for loop... end

11 Block types - Sequential and Parallel There are two Block types: Sequential and Parallel Block statements are used to group multiple statements to act together as one If a Sequential Block contains more than one statement, keywords begin and end are used to group the statements If a Parallel Block contains more than one statement, keywords fork and join are used to group the statements Fundamental difference between sequential and parallel blocks:  Statements in a Sequential Block are processed in the order they are specified  Statements in a Parallel Block are executed concurrently

12 Sequential Blocks Statements in a Sequential Block are processed in the order they are specified A statement is executed only after its preceding statement completes execution (except for non-blocking assignments) If delay or event control is specified it is relative to the simulation time, i.e. execution of the previous statement Example: // x =1, y=2, z=3 begin x = y * z ; // x = 6 y = x + 2 ;// y = 8 z = y – 1 ;// z = 7 end begin x = y * z ; // x completes at simulation time 0 #4 y = x + 2 ; // y completes at simulation time 4 #8 z = y – 1 ; // z completes at simulation time 12 end

13 Parallel Blocks All statements (or blocks) between a fork/join pair begin execution simultaneously upon execution flow hitting the fork Execution continues after the join upon completion of the longest running statement or block between the fork and join Makes the blocking assignments to become unblocking Order of statements is controlled by the delay or event control assigned to each statement If delay or event control is specified, it is relative to the time the block was entered fork - splitting a single flow into independent flows join - joining independent flows back into a single flow

14 Example - Parallel Block reg x, y ; reg [1:0] z, w ; initial fork x = 1'b0 ; // x completes at simulation time 0 #5 y = 1'b1 ; // y completes at simulation time 5 #10 z = {x, y} ; // z completes at simulation time 10 #20 w = {y, x} ; // w completes at simulation time 20 join

15 Frequently used System Tasks and Functions Standard tasks for routine operations. Used to generate input & output during simulation. Format: $ Synthesis tools parse and ignore system functions, hence they can be included even in synthesizable models. System tasks are always written inside procedures. Verilog output normally goes to the standard output and to the ‘verilog.log’ file. $display(“..”, arg2, arg3,.);$monitor($time, “..”, arg2, arg3,.); (similar to “printf” in C programming) $readmemh, $readmemb (" ",,, ) ; initialize the content of a memory array from a specified text file. text file must be in Hex format or Binary format. $finish ; terminates simulation when encountered

16 Exercise 3 Implement a multiplier with add and shift operators, using for loop. Make operands and result parametric. Start with 8bits operands. Load operands with load signal Read result when flag valid_data is on. Use positive clk edge event to synchronize add-shift iterations. Write a Test Bench for the multiplier. Design the same module using repeat loop.