Introduction to Digital VLSI Design VLSI Verilog - - PowerPoint PPT Presentation

introduction to digital vlsi design vlsi
SMART_READER_LITE
LIVE PREVIEW

Introduction to Digital VLSI Design VLSI Verilog - - PowerPoint PPT Presentation

Introduction to Digital VLSI Design VLSI Verilog Logic Synthesis with Verilog HDL Lecturer: Gil Rahav Semester B , EE Dept. BGU. Freescale Semiconductors Israel 09/03/07 1 Objectives


slide-1
SLIDE 1

09/03/07

1

Introduction to Digital VLSI Design ונכתלאובמ VLSIיתרפס

Verilog – Logic Synthesis with Verilog HDL Lecturer: Gil Rahav Semester B’ , EE Dept. BGU. Freescale Semiconductors Israel

slide-2
SLIDE 2

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

2

Define logic synthesis and explain the benefits of logic synthesis Identify Verilog HDL constructs and operators accepted in logic

  • synthesis. Understand how the logic synthesis tool interprets

these constructs

Explain the typical design flow, using logic synthesis. Describe

the components in the logic synthesis-based design flow

Describe verification of the gate-level netlist produced by logic

synthesis

Understand techniques for writing efficient RTL description Describe partitioning techniques to help logic synthesis provide

the optimal gate-level netlist

Design combinational and sequential circuits, using logic

synthesis

Objectives

slide-3
SLIDE 3

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

3

Logic synthesis always existed even in the days of schematic gate-

level design, but it was always done inside the designer’s mind

For large design, manual conversion was prone to human error The designer could never be sure that the design constraints were

going to be met until the gate-level implementation was completed and tested

A significant portion of the design-cycle was dominated by the time

taken to convert a high-level design into gates

The turnaround time for redesign of blocks was very high What-if scenarios were hard to verify Each designer would implement design blocks differently If a bug was found in the final, gate-level design, this would sometimes

require redesign of thousands of gates

Timing, area, and power dissipation in library cells are fabrication-

technology specific

Design reuse was not possible (technology specific, hard to port, …)

Impact of Logic Synthesis

slide-4
SLIDE 4

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

4

The advent of computer-aided logic synthesis tools has

automated the process of converting the high-level description to logic gates

High-level design is less prone to human error High-level design is done without significant concern about design

constraints

Conversion from high-level design to gates is fast Turnaround time for redesign of blocks is shorter What-if scenarios are easy to verify Logic synthesis tools optimize the design as a whole If a bug was found in the final, gate-level design, the designer goes

back and changes the high-level description to eliminate the bug

Logic synthesis tools allow technology-independent design Design reuse is possible for technology-independent descriptions

Impact of Logic Synthesis

slide-5
SLIDE 5

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

5

For the purpose of logic synthesis, designs are currently written

in an HDL at a register transfer level (RTL)

The term RTL is used for an HDL description style that utilizes a

combination of dataflow and behavioral constructs

Verilog and VHDL are the two most popular HDLs used to

describe the functionality at the RTL level

Logic synthesis tools take the register transfer-level HDL

description and convert it to an optimized gate-level netlist

RTL-based synthesis is currently the most popular design method

Verilog HDL Synthesis

slide-6
SLIDE 6

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

6

Verilog HDL Synthesis: Verilog Constructs

In general, any construct that is used to define a cycle-by-cycle

RTL description is acceptable to the logic synthesis tool

while and forever loops must contain @(posedge clk) or @(negedge clk) for, while, forever loops Delay information is ignored Disabling of named blocks allowed initial is not supported Timing constructs ignored mymux m1(out, i0, i2, s); nand (out, a, b); Vectors are allowed Notes assign data flow begin, end, named blocks, disable procedural blocks always, if, then, else, case(x/z) function, task module & primitive instances wire, reg, tri module parameter input, inout, output Keyword of Description procedural functions & tasks instantiation signals & variables module definition parameters ports Construct Type

slide-7
SLIDE 7

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

7

Verilog HDL Synthesis: Think Hardware!!!

Remember that we are providing a cycle-by-cycle RTL description

  • f the circuit

There are restrictions on the way these constructs are used for the

logic synthesis tool. For example:

The while and forever loops must be broken by a @(posedge clock) or

@(negedge clock) statement to enforce cycle-by-cycle behavior and to prevent combinational feedback

Logic synthesis ignores all timing delays specified by #<delay>

  • construct. Therefore, pre- and post-synthesis Verilog simulation results

may not match. The designer must use a description style that eliminates these mismatches

The initial construct is not supported by logic synthesis tools. Instead,

the designer must use a reset mechanism to initialize the signals in the circuit

slide-8
SLIDE 8

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

8

Verilog HDL Synthesis: Timing Delays

module code11 (out1, out2, in);

  • utput out1, out2;

input in; reg out1, out2; always @(in) begin #25 out1 = ~in; #40 out2 = ~in; end endmodule module code11 (out1, out2, in);

  • utput out1, out2;

input in; reg out1, out2; always @(in) begin #25 out1 = ~in; #40 out2 = ~in; end endmodule

Pre- and post-synthesis Verilog

simulation results may not match

Logic synthesis ignores all timing

delays specified by #<delay> construct

In RTL simulation the outputs will

not be updated on every input (in signal) change if changes happen more frequently than the delay in the logic (65 time units in the example)

The designer must use a

description style that eliminates these mismatches

slide-9
SLIDE 9

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

9

Verilog HDL Synthesis: Verilog Operators

Almost all operators in Verilog are allowed for logic synthesis

Concatenation { } Concatenation Left shift, right shift << >> Shift Reduction and, nand, or, nor, xor, xnor & ~& | ~| ^ ~^ ^~ Reduction Bitwise negation, and, or, nor, xor, xnor ~ & | ^ ~^ ^~ Bit-wise Equality, inequality == != Equality Conditional Greater than, Less than, Greater than or equal to, Less than or equal to Logical negation, and, or Multiply, divide, add, subtract, modulus Operation Performed > < >= <= Relational ?: ! && || * / + - % Operator Symbol Logical Conditional Arithmetic Operators Type

Only operators such as “===“ and “!==“ that are related to “x” and

“z” are not allowed (equality with “x” and “z” does not have much meaning in logic synthesis)

slide-10
SLIDE 10

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

10

Verilog HDL Synthesis: Top-Down Design

Requirements Analysis Requirements Analysis System Partitioning System Partitioning Behavioral/Functional Specification Behavioral/Functional Specification Behavioral/Functional Verification Behavioral/Functional Verification Synthesis & Optimization Synthesis & Optimization Gate Level Verification Gate Level Verification

Model entire system architecturally, in

Verilog or some other high-level language

Partition your design based on functionality

  • r path length

Write a behavioral Verilog model for each

partition as an executable bus-functional specification of the design

Write or generate the same models at the

RTL level, using synthesizable constructs. Assemble and verify entire RTL system

Translate the functional models to gate-

level netlists using synthesis and

  • ptimization tool

Mixed-level logic simulation allows you to

verify the design at all levels

slide-11
SLIDE 11

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

11

Verilog HDL Synthesis: Design Partitioning

Design partitioning is another important factor for efficient

logic synthesis

The way the designer partitions the design can greatly affect the

  • utput of the logic synthesis tool

Various partitioning techniques can be used

Hierarchical partitioning Horizontal partitioning Vertical partitioning Parallelizing design structure

slide-12
SLIDE 12

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

12

Hierarchical Design Partitioning

Module statements create hierarchical design blocks (see part III

  • f this course)

Continuous assignments (assigns) and procedural blocks (always) do not create hierarchy ADR_BLK Dec

Ok

module ADR_BLK (. . .); DEC U1 (ADR, CLK, INST); OK U2 (ADR, CLK, AS, OK); endmodule; module ADR_BLK (. . .); DEC U1 (ADR, CLK, INST); OK U2 (ADR, CLK, AS, OK); endmodule;

slide-13
SLIDE 13

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

13

While writing the RTL, the designer has to decide if to keep the hierarchy of the design or to write a flat code Flattened synthesis optimization

Can take longer to execute Saves from calculating timing budgets between blocks (uses synthesis tools’ strengths in optimizing for timing)

Hierarchical synthesis optimization

Speed up optimization times Requires partitioning designs to optimize smaller blocks. Requires management of timing budgets between blocks. Simplify the synthesis process (incremental design updates, is easier to debug, multi- engineer teams) Supports a mix of options for different modules

Hierarchical Design Partitioning

slide-14
SLIDE 14

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

14

Horizontal Design Partitioning

Horizontal partitioning: use bit slices to give the logic synthesis

tool a smaller block to optimize

It reduces complexity of the problem and produces more optimal

results for each block

The downsize of horizontal partitioning is that global minima can

  • ften be different local minima

Each block is optimized individually, but there may be some global

redundancies that the synthesis tool may not be able eliminate

slide-15
SLIDE 15

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

15

Horizontal Design Partitioning Example

4-bit ALU 4-bit ALU 4-bit ALU 4-bit ALU

control flags a[15:0] b[15:0]

  • utput

Instead of directly designing a 16-bit ALU,

design a 4-bit ALU and build the 16-bit ALU with four 4-bit ALUs

Logic synthesis tool has to optimize only

the 4-bit ALU, which is a smaller problem than optimizing the 16-bit ALU

a[15:0] b[15:0]

16-bit ALU

flags control

  • utput
slide-16
SLIDE 16

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

16

Vertical Design Partitioning

Vertical partitioning implies that the functionality of the block is

divided into smaller sub-modules

This is different from horizontal partitioning

In horizontal partitioning, all blocks do the same function In vertical partitioning each block does a different function

For logic synthesis it is important to create hierarchy by

partitioning a large block into separate functional sub-blocks

A design is best synthesized if levels of hierarchy are created and

smaller blocks are synthesized individually

Creating modules that contain a lot of functionality can cause logic

synthesis to produce sub-optimal designs. Instead, divide the functionality into smaller modules and instantiate those modules.

slide-17
SLIDE 17

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

17

Vertical Design Partitioning Example

control a[3:0] b[3:0]

4-bit ALU

flags

  • utput

a[3:0] b[3:0] flags control

  • utput

Add Subtract Shift-left Shift-right

The 4-bit ALU is a four-function ALU with functions add, subtract,

shift right, and shift left

Vertical partitioning of 4-bit ALU: each block is distinct in function

slide-18
SLIDE 18

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

18

Parallelizing Design Structure

In this technique we use more

resources to produce faster design

We convert sequential operations

into parallel operations by using more logic

full adder fa_1 a[1] b[1] c_2 summ[1] full adder fa_2 a[2] b[2] c_3 summ[2] full adder fa_0 a[3] b[3] c_out summ[3] full adder fa_0 a[0] b[0] c_1 summ[0] c_in Carry Look- ahead Adder a[3:0] b[3:0] c_out summ[3:0] c_in

  • Contrast the “carry

lookahead” adder (4 gate delays, more logic gates) with a “ripple carry” adder (9 gate delays, less logic gate)

slide-19
SLIDE 19

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

19

Partitioning Rules for Synthesis

No hierarchy in combinational paths No glue logic between blocks Register all outputs Separate designs with different goals Isolate state machines Maintain a reasonable block size Separate logic, pads, clocks and non-synthesizable structures

slide-20
SLIDE 20

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

20

Partitioning Rules for Synthesis

No hierarchy in combinational paths

Reg Logic Logic Reg Logic

No glue logic between blocks

Merge glue logic into the related combinational logic description of the lower-level architectural statements

Reg Logic Reg Logic

slide-21
SLIDE 21

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

21

Partitioning Rules for Synthesis

Related combinational logic is grouped into the same block that contains the destination register for the combinational logic path Allows improved sequential mapping during optimization (no hierarchical boundaries between combinational and sequential logic) Simplifies the description of the timing interface

Register all outputs

Reg Logic Reg Logic Reg Logic

slide-22
SLIDE 22

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

22

Partitioning Rules for Synthesis

Separate designs with different goals

Reg

Critical Path

Reg

No Critical Path

Reg

Critical Path

Reg

No Critical Path

Optimization is limited because the designer cannot isolate parts of a block and optimize them solely for area or for speed Designer can now perform appropriate optimization techniques on each module

slide-23
SLIDE 23

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

23

Design Constraints Specification

Design constraints are as important as efficient HDL description

in producing optimal design

Accurate specification of timing, area, power, and environmental

parameters, such as input drive strengths, output loads, input arrival times, etc., are critical to produce a gate-level netlist that is optimal

A deviation from the correct constraints or omission of a

constraint can lead to non-optimal designs

Careful attention must be given to specifying design constrains

slide-24
SLIDE 24

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

24

Verilog HDL Synthesis: Modeling Style

There is a modeling style for each synthesis tool

It is possible to write Verilog descriptions for which there are no digital

hardware

Synthesis results are sensitive to the input description

Goals of the modeling style

Efficiency Predictability Synthesizability

Two basic guidelines for writing synthesizable Verilog descriptions:

The gate-level simulation should match the functional (RTL) simulation Sequential design should work independent of technology-specific

propagation delays

slide-25
SLIDE 25

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

25

Modeling Style Basics

Use meaningful names for signals and variables

Names of signals and variables should be meaningful so that the code

becomes self-commented and readable

Avoid mixing positive and negative edge-triggered flip-flops

Mixing negative and positive edge-triggered flip-flops may introduce

inverters and buffers into the clock tree

Be careful with multiple assignments to the same variable

Multiple assignments to the same variable can cause undesired logic to be

generated (the previous assignment might be ignored, and only the last assignment would be used

// Two assignments to the same variable always @(posedge clk) if(load1) q <= a1; always @(posedge clk) if(load2) q <= a2; // Two assignments to the same variable always @(posedge clk) if(load1) q <= a1; always @(posedge clk) if(load2) q <= a2;

  • The synthesis tool infers two flip-

flops with the outputs anded together to produce the q output

  • The designer needs to be careful

about such situation!!!

slide-26
SLIDE 26

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

26

Multiply, divide, and modulo operators are very expensive to implement in terms of logic and area

These arithmetic operators can be used to implement the desired functionality concisely and in a technology-independent manner On the other hand, designing custom blocks to do multiplication, division or modulo operation can take a longer time to design, and the module becomes more technology dependent

Use parentheses to optimize logic structure

Modeling Style Basics

// Translates to three adders in series

  • ut = a + b + c+ d;

/* Translates to two adders in parallel with one final adder to sum results*/

  • ut = (a + b) + (c+ d);

// Translates to three adders in series

  • ut = a + b + c+ d;

/* Translates to two adders in parallel with one final adder to sum results*/

  • ut = (a + b) + (c+ d);
  • The designer can control the final

structure of logic by using parentheses to group logic

  • Using parentheses also improves

readability of the Verilog description

slide-27
SLIDE 27

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

27

Modeling Style: Combinational Logic

For logic to be combinational, the output must have only one

possible value for any combination of inputs

There must be no timing or order dependencies If the description meets this definition, it can be synthesized as a

combinational logic

There are three modeling styles that meet these requirements

A netlist structure of combinational primitives with no feedback loops A continuous assignment statement with no feedback loops A procedural block with an event sensitivity list consisting of all nodes

to which assignments are made

You can group the combinational logic in a function

This guarantees that the logic will be interpreted as combinational,

eliminating the risk of generating latches in a data path

slide-28
SLIDE 28

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

28

Combinational Logic

  • Method 1: A netlist structure of

combinational primitives with no feedback loops

module orand (OUT, A, B, C, D, E); input A, B, C, D, E;

  • utput OUT;

// Use one of four methods endmodule module orand (OUT, A, B, C, D, E); input A, B, C, D, E;

  • utput OUT;

// Use one of four methods endmodule // Method 1

  • r (or1, A, B);
  • r (or2, C, D);

and (OUT, or1, or2, E); // Method 1

  • r (or1, A, B);
  • r (or2, C, D);

and (OUT, or1, or2, E);

  • Method 2: A continuous

assignment statement with no feedback loop

// Method 2 assign OUT = E & (A | B) & (C | D); // Method 2 assign OUT = E & (A | B) & (C | D);

A B E OUT D C

slide-29
SLIDE 29

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

29

Combinational Logic

  • Method 3: Since a function have no

timing control, it is interpreted as combinational logic

module orand (OUT, A, B, C, D, E); input A, B, C, D, E;

  • utput OUT;

// Use one of four methods endmodule module orand (OUT, A, B, C, D, E); input A, B, C, D, E;

  • utput OUT;

// Use one of four methods endmodule // Method 3 function out; input A, B, C, D, E;

  • ut = E & (A | B) & (C | D);

endfunction // Method 3 function out; input A, B, C, D, E;

  • ut = E & (A | B) & (C | D);

endfunction

  • Method 4: Procedural blocks with

complete event sensitivity list

// Method 4 reg OUT; always @(A or B or C or D or E) if (E) OUT = (A | B) & (C | D); else OUT = 0; // Method 4 reg OUT; always @(A or B or C or D or E) if (E) OUT = (A | B) & (C | D); else OUT = 0;

A B E OUT D C

slide-30
SLIDE 30

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

30

Combinational Logic

module mux (A, B, C, D, OUT, SEL); input [3:0] A, B, C, D; input [1:0] SEL;

  • utput [3:0] OUT;

reg [3:0] OUT; always @(SEL or A or B or C or D) case(SEL) 2’b00: OUT = A; 2’b01: OUT = B; 2’b10: OUT = C; 2’b11: OUT = D; default: OUT = 4’bx; endcase endmodule module mux (A, B, C, D, OUT, SEL); input [3:0] A, B, C, D; input [1:0] SEL;

  • utput [3:0] OUT;

reg [3:0] OUT; always @(SEL or A or B or C or D) case(SEL) 2’b00: OUT = A; 2’b01: OUT = B; 2’b10: OUT = C; 2’b11: OUT = D; default: OUT = 4’bx; endcase endmodule

A B C D

4 4 2

SEL OUT

  • If you desire combinational logic,

specify all branches of a case statement, including the default branch

  • If the assignments are not complete

in all brunches of the decision, the synthesizer adds latches to maintain the state of the circuit

slide-31
SLIDE 31

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

31

Functions in Synthesis

Functions always synthesize to combinational logic

module code3b (o, a, nrst, en);

  • utput o;

input a, nrst, en; reg o; always @(a or nrst or en)

  • = latch(a, nrst, en);

function latch; input a, nrst, en; if (!nrst) latch = 1'b0; else if (en) latch = a; endfunction endmodule module code3b (o, a, nrst, en);

  • utput o;

input a, nrst, en; reg o; always @(a or nrst or en)

  • = latch(a, nrst, en);

function latch; input a, nrst, en; if (!nrst) latch = 1'b0; else if (en) latch = a; endfunction endmodule

A problem can occurs when engineers make a mistake in the combinational function code and create simulation code that behaves like a latch.

module code3a (o, a, nrst, en);

  • utput o;

input a, nrst, en; reg o; always @(a or nrst or en) if (!nrst) o = 1'b0; else if (en) o = a; endmodule module code3a (o, a, nrst, en);

  • utput o;

input a, nrst, en; reg o; always @(a or nrst or en) if (!nrst) o = 1'b0; else if (en) o = a; endmodule

slide-32
SLIDE 32

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

32

Modeling Style: Efficient Comparison

Equality operators are implemented more efficiently

if (a <= b) @ (posedge clk) a = a + 1; if (a <= b) @ (posedge clk) a = a + 1; if (a != b) @ (posedge clk) a = a + 1; if (a != b) @ (posedge clk) a = a + 1;

Avoid threshold comparison, except where resources can be shared

In general, threshold comparisons are less efficiently implemented

if (a <= b) do_1; if (a <= b) do_1; if (a < b+1) do_1; if (a < b+1) do_1;

When there are few branches consisting of many consecutive

cases, using a “case value” is more efficient

case (a) 2, 3, 4, 5, 6, 7, 8, 9, 10: do_A; 11, 12, 13, 14, 15, 16, 17: do_B; 20: do_C; default: do_D; endcase case (a) 2, 3, 4, 5, 6, 7, 8, 9, 10: do_A; 11, 12, 13, 14, 15, 16, 17: do_B; 20: do_C; default: do_D; endcase case (a) (1 < a) && (a < 11): do_A; (11 <= a) && (a < 18): do_B; (a == 20): do_C; default: do_D; endcase case (a) (1 < a) && (a < 11): do_A; (11 <= a) && (a < 18): do_B; (a == 20): do_C; default: do_D; endcase

slide-33
SLIDE 33

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

33

Modeling Style: Latched Logic

Latched logic describes storage

devices independent from clock

  • Method 1: Using a simple feedback

module latch (OUT, IN, ENABLE); input [7:0] IN; input ENABLE;

  • utput [7:0] OUT;

// Use one of two methods endmodule module latch (OUT, IN, ENABLE); input [7:0] IN; input ENABLE;

  • utput [7:0] OUT;

// Use one of two methods endmodule // Method 1 wire [7:0] OUT; assign OUT = ENABLE ? IN : OUT; // Method 1 wire [7:0] OUT; assign OUT = ENABLE ? IN : OUT;

  • Method 2: Using an unspecified

branch in if or case statement

// Method 2 reg [7:0] OUT; always @(ENABLE or IN); if (ENABLE) OUT = IN; // no else statement !!! // Method 2 reg [7:0] OUT; always @(ENABLE or IN); if (ENABLE) OUT = IN; // no else statement !!!

in en

8 8

  • ut

D G

Be careful of unintentional latches! Try to avoid using latches => use FFs

slide-34
SLIDE 34

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

34

Modeling Style: Inferring Latches & Flip-Flops

An always block, without all its conditions specified, leads to a latch In the example below, is a false case, the value of data must be held and the synthesizer must use a storage element.

module latch (q, data, enable); input data, enable;

  • utput q;

reg q; always @(enable or data) if (enable) q <= data; endmodule module latch (q, data, enable); input data, enable;

  • utput q;

reg q; always @(enable or data) if (enable) q <= data; endmodule

A flip-flop is inferred when the procedural block is entered into

  • nly on a single edge
  • f the control signal

(clk).

module dffn (q, data, clk); input data, clk;

  • utput q;

reg q; always @( negedge clk) q <= data; endmodule module dffn (q, data, clk); input data, clk;

  • utput q;

reg q; always @( negedge clk) q <= data; endmodule

slide-35
SLIDE 35

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

35

Modeling Style: Simple Sequential Logic

A B C D

4 4 2

SEL 4

  • ut

D

CLK

module mux_dff (A, B, C, D, OUT, SEL, CLK); input [3:0] A, B, C, D;

  • utput [3:0] OUT;

input [1:0] SEL; input CLK; reg [3:0] OUT; always @(posedge CLK) case(SEL) 2’b00: OUT <= A; 2’b01: OUT <= B; 2’b10: OUT <= C; 2’b11: OUT <= D; // use default if not full case endcase endmodule module mux_dff (A, B, C, D, OUT, SEL, CLK); input [3:0] A, B, C, D;

  • utput [3:0] OUT;

input [1:0] SEL; input CLK; reg [3:0] OUT; always @(posedge CLK) case(SEL) 2’b00: OUT <= A; 2’b01: OUT <= B; 2’b10: OUT <= C; 2’b11: OUT <= D; // use default if not full case endcase endmodule

The output of a block is stored

with a flip-flop when it is triggered by an edge-sensitive event control

slide-36
SLIDE 36

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

36

Modeling Style: Simple Sequential Logic

Combinational Logic R E G

inputs

  • utputs

Modeling style rules for sequential logic:

Each always block can have only one edge of one clock (unless

you are modeling asynchronous reset with the asynchronous/synchronous brunch modeling style)

Each stored variable may be assigned from only one clock-edge-

triggered procedural block

slide-37
SLIDE 37

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

37

Modeling Style: Registers

The reg variables in a sequential block are implemented as hardware registers if they are assigned a value in one clock cycle and sampled in another If the sampling and assignment of the reg does not cross clock boundaries then the reg may be optimized away The reg variable does not necessarily imply a hardware register in the final synthesized output (reg variables do exist in RTL logic that is combinational) If the reg variable is also a primary output, it will appear in the final netlist regardless of the type of logic produced

slide-38
SLIDE 38

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

38

module ex1reg (data, clk,

  • ut);

input data, clk;

  • utput out;

reg out; reg rega; always @( posedge clk) begin rega = data;

  • ut = rega;

end endmodule module ex1reg (data, clk,

  • ut);

input data, clk;

  • utput out;

reg out; reg rega; always @( posedge clk) begin rega = data;

  • ut = rega;

end endmodule

Modeling Style: Register Examples

One clock edge imply two storage elements and rega is

  • ptimized

away One clock edge imply two storage elements and rega is

  • ptimized

away

module ex2reg (data, clk,

  • ut);

input data, clk;

  • utput out;

reg out; reg rega; always @( posedge clk) begin rega <= data;

  • ut <= rega;

end endmodule module ex2reg (data, clk,

  • ut);

input data, clk;

  • utput out;

reg out; reg rega; always @( posedge clk) begin rega <= data;

  • ut <= rega;

end endmodule

Two clock edges imply two storage elements and rega is not

  • ptimized

away Two clock edges imply two storage elements and rega is not

  • ptimized

away Blocking assignment. Don’t ever use! Blocking assignment. Don’t ever use!

slide-39
SLIDE 39

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

39

Modeling Style: Asynchronous Reset

You can model reset for any type of edge or level sensitive

storage device

Asynchronous reset can be modeled in a single block, sensitive

to the active clock edge and the active reset edge

There must be exactly one synchronous branch in the conditional

statement

The default (else) branch is typically the synchronous one

slide-40
SLIDE 40

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

40

Modeling Style: Asynchronous Reset

module latch (q, enable, set, clr, d); input enable, d, set, clr;

  • utput q;

reg q; always @(enable or set or clr or d) begin if (set) q <= 1; else if (clr) q <= 0; else if (enable) q <= d; end endmodule module latch (q, enable, set, clr, d); input enable, d, set, clr;

  • utput q;

reg q; always @(enable or set or clr or d) begin if (set) q <= 1; else if (clr) q <= 0; else if (enable) q <= d; end endmodule module dffsetclr (q, clk, reset, d); input clk, d, reset;

  • utput q;

reg q; always @(posedge clk or posedge reset) begin if (reset) q <= 0; else q <= d; end endmodule module dffsetclr (q, clk, reset, d); input clk, d, reset;

  • utput q;

reg q; always @(posedge clk or posedge reset) begin if (reset) q <= 0; else q <= d; end endmodule

Flip-flop Latch

slide-41
SLIDE 41

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

41

Modeling Style: Synchronous Reset

Check the status of the reset

signal at every clock edge

If your target library does not

contain a storage device with synchronous reset, the reset is implemented in the data path

module dffsetclr (q, clk, reset, d); input clk, d, reset;

  • utput q;

reg q; always @(posedge clk) begin if (reset) q <= 0; else q <= d; end endmodule module dffsetclr (q, clk, reset, d); input clk, d, reset;

  • utput q;

reg q; always @(posedge clk) begin if (reset) q <= 0; else q <= d; end endmodule

slide-42
SLIDE 42

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

42

Modeling Style: Complex Operators

Complex operators are operations that can be recognized as high-level operations and mapped to existing cells in a vendor’s library directly:

  • ut = a * b;

Most tools know enough to map this to a multiplier This multiplier may exist in a special macro library that has components at a higher level of complexity than the regular cell library Macro libraries can include parts for design reuse such as FIFOs, adders, substractors, shift registers, counters, decoders, etc., of a various architectures The macro library may also contain user-defined blocks that are designed and synthesized by the user and intended or re-use

slide-43
SLIDE 43

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

43

Modeling Style: Resource Sharing

Resource sharing is the sharing of a group of logic by more than

  • ne section of RTL code

Some synthesizers do resource sharing automatically You can control some resource sharing from within your RTL code You can force resource sharing by changing the coding style

b c b d a

  • ut

always @(a or b or c or d) if (a)

  • ut = b + c;

else

  • ut = b + d;

always @(a or b or c or d) if (a)

  • ut = b + c;

else

  • ut = b + d;

b c d a

  • ut

temp = a ? c : d;

  • ut = b + temp;

temp = a ? c : d;

  • ut = b + temp;
slide-44
SLIDE 44

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

44

Modeling Style: Sensitivity List

Inputs to a procedural block should be included in its sensitivity list

Some synthesis tools produce a warning when encountering an incomplete sensitivity list; others produce an error. The tools that produce a warning proceed with the assumption that you meant to have a complete list /* In this example, a, b, and c are inputs to the block;a and b are conditions, and c is contained in the RHS of the procedural assignment d = c */ always @( a or b or c) begin if (a and b) d = c; end /* In this example, a, b, and c are inputs to the block;a and b are conditions, and c is contained in the RHS of the procedural assignment d = c */ always @( a or b or c) begin if (a and b) d = c; end

slide-45
SLIDE 45

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

45

Modeling Style: Incomplete Sensitivity List

// In this example, a and b are inputs to the block and c is an

  • utput

always @( a ) // Incomplete sensitivity list begin c = a || b; end // In this example, a and b are inputs to the block and c is an

  • utput

always @( a ) // Incomplete sensitivity list begin c = a || b; end

As a result of incomplete sensitivity list (input b is not specified) the RTL and gate-level simulations will produce different results

A B C

Gate-Level

A B C

RTL

A B C

Synthesis results

slide-46
SLIDE 46

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

46

Modeling Style: (Non-) Blocking Assignments

Use non-blocking assignments when

modeling sequential logic modeling latches modeling both sequential and combinational logic within the same "always" block

Use blocking assignments when

modeling combinational logic with an "always" block

General guidelines

Do not mix blocking and non-blocking assignments in the same "always" block Do not make assignments to the same variable from more than one "always" block Use $strobe to display values that have been assigned using non- blocking assignments Do not make assignments using #0 delays

slide-47
SLIDE 47

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

47

Modeling Style: Finite State Machine (FSM) Mealy vs. Moore

Finite State Machines (FSM) types

A Mealy machine has outputs that are a function of the present state registers

and of the machine inputs.

A Moore machine has output that are function of the present state only, the

  • utputs are not directly dependent on the machine inputs

It is always possible to model an FSM specification as either Mealy or Moore machine, the difference is the output timing

A Moore machine has output that settle directly after active clock edge and

remain stable for the duration of the clock cycle.

In Mealy machine changes on the input are seen a cycle earlier than in the

Moore machine

slide-48
SLIDE 48

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

48

Finite State Machine: Implicit vs. Explicit FSMs

There are two distinct types of Finite State Machines (FSMs): explicit and implicit Implicit machines use multiple always @(posedge clk) statements to indicate state transitions

exist at a higher level of abstraction than explicit machines and in general are not synthesizable In implicit FSMs, registers are created whenever data is written in

  • ne clock cycle and read in another

Explicit machines use case statements to define each possible state explicitly

explicit machines are used in code meant for synthesis

All FSMs must have a reset, and their state changes must be synchronous to one edge of a single clock

slide-49
SLIDE 49

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

49

Finite State Machine: Implicit vs. Explicit FSMs

state 2 state 1 state 4 state 3

Implicit FSMs:

Do not need a state register Handle only linear state changes well Each state is separated by clock boundaries Are not handled by most synthesis tools

state B1 state A state D state C state B2

Explicit FSMs:

Are clearer and more well-defined Can handle default conditions Handle complex (nonlinear) state changes You specify a state variable that define the state of the state machine

slide-50
SLIDE 50

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

50

Implicit Style of FSM

module imp (out, datain, clk, rst);

  • utput out;

input clk, datain, rst; reg out; always @(posedge clk or posedge rst) if (rst) out <= 1’b0; // asynchronous // reset else begin if (!out) // state out == 0 begin if (datain) out <= 1’b0; else

  • ut <= 1’b1;

end else // state out == 1

  • ut <= 1’b0;

end endmodule module imp (out, datain, clk, rst);

  • utput out;

input clk, datain, rst; reg out; always @(posedge clk or posedge rst) if (rst) out <= 1’b0; // asynchronous // reset else begin if (!out) // state out == 0 begin if (datain) out <= 1’b0; else

  • ut <= 1’b1;

end else // state out == 1

  • ut <= 1’b0;

end endmodule

From each always block that models sequential logic, synthesis extracts a single FSM If the always block has only one clock cycle (a degenerate FSM), it is implemented with combinational logic plus a register Registers are created whenever data is written in one clock cycle and read in another clock cycle for the stored variables If the FSM has more than one cycle, the synthesis tool generates control logic, including a state variable, and adds registers for the stored variables

1

datain = 0 datain = 1

slide-51
SLIDE 51

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

51

Explicit Style of FSM

module exp (out, datain, clk, rst);

  • utput out;

input clk, datain, rst; reg out, state; // state variable always @(posedge clk or posedge rst) if (rst) {state,out} <= 2’b00; else case (state) // case statement 1’b0: begin

  • ut <= 1’b0;

if (datain) state <= 1’b1; else state <= 1’b0; end 1’b1: begin

  • ut <= datain;

state <= 1’b0; end default: {state, out} = 2’b00; endcase endmodule module exp (out, datain, clk, rst);

  • utput out;

input clk, datain, rst; reg out, state; // state variable always @(posedge clk or posedge rst) if (rst) {state,out} <= 2’b00; else case (state) // case statement 1’b0: begin

  • ut <= 1’b0;

if (datain) state <= 1’b1; else state <= 1’b0; end 1’b1: begin

  • ut <= datain;

state <= 1’b0; end default: {state, out} = 2’b00; endcase endmodule

FSM can be described explicitly in a procedural block with a single clock edge and a case statement A state variable that defines the state

  • f the FSM must be specified

To change the current state, the value

  • f the state variable must be changed

synchronous to the clock edge It is a good practice to specify a default action for conditions that normally do not occur

1

datain = 0 datain = 1

Assignments of the state variable and

  • utput signals to

constant expressions are optimized efficiently

Not required In Verilog Not required In Verilog

slide-52
SLIDE 52

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

52 module exp (out, datain, clk, rst);

  • utput out;

input clk, datain, rst; reg out, state; // state variable always @(posedge clk or posedge rst) if (rst) {state,out} <= 2’b00; else case (state) // case statement 1’b0: begin

  • ut <= 1’b0;

if (datain) state <= 1’b1; end 1’b1: begin

  • ut <= datain;

state <= 1’b0; end default: {state, out} = 2’b00; endcase endmodule module exp (out, datain, clk, rst);

  • utput out;

input clk, datain, rst; reg out, state; // state variable always @(posedge clk or posedge rst) if (rst) {state,out} <= 2’b00; else case (state) // case statement 1’b0: begin

  • ut <= 1’b0;

if (datain) state <= 1’b1; end 1’b1: begin

  • ut <= datain;

state <= 1’b0; end default: {state, out} = 2’b00; endcase endmodule

Reg Logic Reg Logic

  • ut

state datain

Explicit Style of FSM (con.)

slide-53
SLIDE 53

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

53 module exp (my_out, datain, clk, rst, my_in);

  • utput my_out;

input clk, datain, rst; input my_in; reg out, state; // state variable wire my_out; assign my_out = out & my_in; always @(posedge clk or posedge rst) if (rst) {state,out} <= 2’b00; else case (state) // case statement 1’b0: begin

  • ut <= 1’b0;

if (datain) state <= 1’b1; end 1’b1: begin

  • ut <= datain;

state <= 1’b0; end default: {state, out} = 2’b00; endcase endmodule module exp (my_out, datain, clk, rst, my_in);

  • utput my_out;

input clk, datain, rst; input my_in; reg out, state; // state variable wire my_out; assign my_out = out & my_in; always @(posedge clk or posedge rst) if (rst) {state,out} <= 2’b00; else case (state) // case statement 1’b0: begin

  • ut <= 1’b0;

if (datain) state <= 1’b1; end 1’b1: begin

  • ut <= datain;

state <= 1’b0; end default: {state, out} = 2’b00; endcase endmodule

Reg Logic Reg Logic

  • ut

state datain Logic my_in clk rst

Explicit Style of FSM (con.)

my_out

slide-54
SLIDE 54

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

54

Logic Synthesis with Verilog HDL Summary

Logic synthesis is the process of converting a high-level description of

the design into an optimized, gate-level representation, using the cells in the technology library

Computer aided logic synthesis tools have greatly reduced the design

cycle time and improved productivity. They allow designers to write technology-independent, high-level descriptions and produce technology- dependent, optimized, gate-level netlists. Both combinational and sequential RTL descriptions can be synthesized

Logic synthesis tools accept high-level descriptions at the register

transfer level (RTL). Thus, not all Verilog constructs are acceptable to a logic synthesis tool. We discussed the acceptable Verilog constructs and

  • perators and their interpretation in terms of digital circuit elements
slide-55
SLIDE 55

09/03/07 Introduction to Digital VLSI Gil Rahav Freescale Semiconductor Israel

55

Logic Synthesis with Verilog HDL Summary

A logic synthesis tool accepts an RTL description, design constraints,

and technology library, and produces an optimized gate-level netlist. Translation, logic optimization, and technology mapping are the internal processes in a logic synthesis tool and are normally invisible to the user

Proper Verilog coding techniques must be used to write efficient RTL

descriptions, and various design trade-off must be evaluated. Guidelines for writing efficient RTL descriptions were discussed

Design partitioning is an important technique used to break the design

into smaller blocks. Smaller blocks reduce the complexity of optimization for the logic synthesis tool

Accurate specification of design constraints is an important part of logic

synthesis