• No results found

Chapter 7: Advanced Modeling Techniques

N/A
N/A
Protected

Academic year: 2021

Share "Chapter 7: Advanced Modeling Techniques"

Copied!
42
0
0

Loading.... (view fulltext now)

Full text

(1)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-1

Chapter 7: Advanced Modeling

Techniques

Department of Electronic Engineering

National Taiwan University of Science and Technology

(2)

Chapter 7: Advanced Modeling Techniques

Syllabus

™

Objectives

™

Blocks

™

Procedural continuous assignments

(3)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-3

Objectives

After completing this chapter, you will be able to:

™ Describe the features of sequential blocks

™ Describe the features of parallel blocks

™ Describe the features of nested blocks

™ Describe the features of procedural continuous assignments

™ Describe how to model a module delay

™ Describe the features of specify blocks

(4)

Chapter 7: Advanced Modeling Techniques

Syllabus

™

Objectives

™

Blocks

ƒ Sequential blocks ƒ Parallel blocks ƒ Special blocks

ƒ The disable statement

™

Procedural continuous assignments

(5)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-5

Sequential Blocks

initial begin x = 1’b1; // at time 0 #12 y = 1’b1; // at time 12 #20 z = 1’b0; // at time 32 end initial begin x = 1'b0; // at time 0 #20 w = 1'b1; // at time 20 #12 y <= 1'b1; // at time 32 #10 z <= 1'b0; // at time 42 #25 x = 1'b1; w = 1'b0; // at time 67 end

(6)

Chapter 7: Advanced Modeling Techniques

Syllabus

™

Objectives

™

Blocks

ƒ Sequential blocks ƒ Parallel blocks ƒ Special blocks

ƒ The disable statement

™

Procedural continuous assignments

(7)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-7

Parallel Blocks

initial fork x = 1’b0; // at time 0 #12 y = 1’b1; // at time 12 #20 z = 1’b1; // at time 20 join initial fork x <= 1’b0; // at time 0 #12 y <= 1’b1; // at time 12 #20 z <= 1’b1; // at time 20 join

(8)

Chapter 7: Advanced Modeling Techniques

Syllabus

™

Objectives

™

Blocks

ƒ Sequential blocks ƒ Parallel blocks ƒ Special blocks

ƒ The disable statement

™

Procedural continuous assignments

(9)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-9

Types of Special Blocks

™

Nested blocks

(10)

Chapter 7: Advanced Modeling Techniques

Nested Blocks

initial begin

x = 1'b0; // at time 0

fork // parallel block -- enter at time 0

#12 y <= 1'b1; // at time 12

#20 z <= 1'b0; // at time 20

join // leave at time 20

#25 x = 1'b1; // at time 45

(11)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-11

Named Blocks

initial begin: test // test is the block name

reg x, y, z; // local variables x = 1’b0;

#12 y = 1’b1; // at time 12 #10 z = 1’b1; // at time 22 end

(12)

Chapter 7: Advanced Modeling Techniques

Syllabus

™

Objectives

™

Blocks

ƒ Sequential blocks ƒ Parallel blocks ƒ Special blocks

ƒ The disable statement

™

Procedural continuous assignments

(13)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-13

The disable statement

initial begin: test

while (i < 10) begin

if (flag) disable test; i = i + 1;

end end

(14)

Chapter 7: Advanced Modeling Techniques

Syllabus

™

Objectives

™

Blocks

™

Procedural continuous assignments

ƒ assign and deassign assignments

ƒ force and release assignments

(15)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-15

assign and deassign Constructs

™

They

ƒ assign values to variables

™

Their LHS

ƒ can be a variable or a concatenation of variables

™

They override

ƒ the effect of regular procedural assignments

™

They

(16)

Chapter 7: Advanced Modeling Techniques

assign and deassign Constructs

// negative edge triggered D flip flop with asynchronous reset

module edge_dff(input clk, reset, d, output reg q, qbar); always @(negedge clk) begin

q <= d; qbar <= ~d; end

always @(reset) // override the regular assignments

if (reset) begin

assign q = 1'b0;

assign qbar = 1'b1;

end else begin // release q and qbar deassign q;

(17)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-17

Syllabus

™

Objectives

™

Blocks

™

Procedural continuous assignments

ƒ assign and deassign assignments

ƒ force and release assignments

(18)

Chapter 7: Advanced Modeling Techniques

force and release Constructs

™

They

ƒ assign values to nets or variables

™

Their LHS

ƒ can be a variable or a net

™

They override

ƒ the effect of regular procedural assignments

ƒ the effect of assign and deassign construct

(19)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-19

Syllabus

™

Objectives

™

Blocks

™

Procedural continuous assignments

™

Delay models and timing checks

ƒ Delay models

ƒ Specify blocks

(20)

Chapter 7: Advanced Modeling Techniques

Types of Delay Models

™ Distributed delays

™ Lumped delays

(21)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-21

Distributed Delay Model

module M (input x, y, z, output f); wire a, b, c;

and #5 a1 (a, x, y); not #2 n1 (c, x); and #5 a2 (b, c, z); or #3 o1 (f, a, b); endmodule

module M (input x, y, z , output f); wire a, b, c; assign #5 a = x & y; assign #2 c = ~x assign #5 b = c & z assign #3 f = a | b; endmodule

(22)

Chapter 7: Advanced Modeling Techniques

Lumped Delay Model

module M (input x, y, z , output f); wire a, b, c;

and a1 (a, x, y);

module M (input x, y, z , output f); wire a, b, c;

(23)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-23

(24)

Chapter 7: Advanced Modeling Techniques

Syllabus

™

Objectives

™

Blocks

™

Procedural continuous assignments

™

Delay models and timing checks

ƒ Delay models

ƒ Specify blocks

(25)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-25

Specify Blocks

™

Keywords

ƒ specify and endspecify

™

Are used to

ƒ describe various paths across the module

ƒ assign delays to these paths

(26)

Chapter 7: Advanced Modeling Techniques

Path Delay Modeling – The specify Block

module M (input x, y, z , output f); wire a, b, c;

// specify block with path delay statements

specify (x => f) = 10; (y => f) = 8; (z => f) = 8; endspecify // gate instantiations and a1 (a, x, y);

x y z f a b c

(27)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-27

Path Declarations

™

Single-path

™

Edge-sensitive path

(28)

Chapter 7: Advanced Modeling Techniques

Single Path

™

Single path connection methods

ƒ Parallel connection (source => destination)

(29)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-29

Edge-Sensitive Path

™

posedge clock => (out +: in) = (8, 6);

ƒ module path: from clock to out

ƒ rise time = 8 and fall delay = 6

ƒ data path: from in to out

™

negedge clock => (out -: in) = (8, 6);

ƒ module path: from clock to out

ƒ rise time = 8 and fall delay = 6

(30)

Chapter 7: Advanced Modeling Techniques

Level-Sensitive Path

™

clock => (out : in) = (8, 6);

ƒ At any change in clock, a module path extends from

(31)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-31

State-Dependent Path

™

Syntax

if (cond_expr) simple_path_declaration if (cond_expr) edge_sensitive_path_declaration ifnone simple_path_declaration specify if (x) (x => f) = 10; if (~x) (y => f) = 8; endspecify specify

if (!reset && !clear) (positive clock => (out +: in) = (8, 6); endspecify

(32)

Chapter 7: Advanced Modeling Techniques

The specparam Statement

specify

// define parameters inside the specify block

specparam d_to_q = (10, 12);

specparam clk_to_q = (15, 18); ( d => q) = d_to_q;

(clk => q) = clk_to_q; endspecify

(33)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-33

An Example --- An NOR Gate

module my_nor (a, b, out); …

output out;

nor nor1 (out, a, b); specify

specparam trise = 1, tfall = 2

specparam trise_n = 2, tfall_n = 3; if (a) (b => out) = (trise, tfall);

if (b) (a => out) = (trise, tfall);

if (~a)(b => out) = (trise_n, tfall_n); if (~b)(a => out) = (trise_n, tfall_n); endspecify

(34)

Chapter 7: Advanced Modeling Techniques

Syllabus

™

Objectives

™

Blocks

™

Procedural continuous assignments

™

Delay models and timing checks

ƒ Delay models

ƒ Specify blocks

(35)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-35

Timing Checks

™

Must be inside the

specify

blocks

™

The most commonly used timing checks

ƒ $setup ƒ $hold ƒ $setuphold ƒ $width ƒ $skew ƒ $period ƒ $recovery

(36)

Chapter 7: Advanced Modeling Techniques

Timing Checks --

$setup Timing Check

$setup (data_event, reference_event, limit); Violation when treference_event – tdata_event < limit

(37)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-37

Timing Checks --

$hold Timing Check

$hold (reference_event, data_event, limit); Violation when tdata_event – treference_event < limit

specify

$hold (posedge clock, data, 8); endspecify

(38)

Chapter 7: Advanced Modeling Techniques

Timing Checks --

$setuphold Timing Check

$setuphold (reference_event, data_event, setup_limit, hold_limit); Violation when:

treference_event – tdata_event < setup_limit

(39)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-39

Timing Checks --

$width Timing Check

$width (reference_event, limit);

Violation when tdata_event – treference_event < limit

specify

$width (posedge reset, 6); endspecify

(40)

Chapter 7: Advanced Modeling Techniques

Timing Checks --

$skew Timing Check

$skew (reference_event, data_event, limit); Violation when tdata_event – treference_event > limit

(41)

Chapter 7: Advanced Modeling Techniques

Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008~2010, John Wiley 7-41

Timing Checks --

$period Timing Check

$period (reference_event, limit);

Violation when tdata_event – treference_event < limit

specify

$period (posedge clk, 15); endspecify

(42)

Chapter 7: Advanced Modeling Techniques

Timing Checks --

$recovery Timing Check

$recovery (reference_event, data_event, limit); Violation when

References

Related documents

This SLS has four major components: (a) Smart box, a sensor unit that enables measurement of data such as relative humidity, temperature, geographic positions; (b) On-board

This study addresses three questions: how Internally Displaced Persons (IDPs) following the post-election violence of 2007/2008 in Kenya are recreating their community

Hipotezės „H2b: X ir Y kartų tęstinį įsipareigojimą organizacijai lemia skirtingi psichologinės sutarties veiksniai“ ir „H2c: X ir Y kartų normatyvinį

A high-quality ranking or matching algorithm will guide consumers to high-quality decisions only in combination with adequate data of two types: (1) the relevant attributes of

During the 60-min AAA session, salivary cortisol concentration and stress-associated behavior were not statistically differ- ent compared to when dogs spent the same amount of time

It elaborates the carbon and greenhouse gas implications of DRM interventions and post-disaster reconstruction practices, drawing on case studies from flood risk reduction,

Whatever events you have lined up, be it cake sales, quiz nights or football tournaments, every penny you raise will make a huge difference to children and young people