Logic Synthesis - University of California, Los...

28
EE M216A .:. Fall 2010 Lecture 13 Logic Synthesis Prof. Dejan Marković [email protected] Design Challenges: An Industrial View TIMING AREA POWER DESIGNER RUNTIME MEMORY D. Markovic / Slide 2 Correct functionality requirements EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 2 TIME TO MARKET

Transcript of Logic Synthesis - University of California, Los...

Page 1: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

1

EE M216A .:. Fall 2010Lecture 13

Logic Synthesis

Prof. Dejan Marković[email protected]

Design Challenges: An Industrial View

TIMING AREA POWER

DESIGNERRUNTIME MEMORY

D. Markovic / Slide 2

Correct functionality requirements

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 2

TIME TO MARKET

Page 2: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

2

Logic Synthesis

Constraining your design for logic synthesis

Design constraintsE i t l t i t– Environmental constraints● Driver● Load (max fanout)

– Define clocks● Cycle time● Uncertainty

– Optimization constraints

D. Markovic / Slide 3

Optimization constraints● In and out delay / max transition● Max area etc.

– (Timing exceptions)

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 3

Logic Synthesis is Timing‐Driven

This is a generic design used during synthesis– Internal data‐path delay (cycle (and hold) time analysis)– Relationship to in and out paths

Ti i ti– Timing exceptions

D Q

QB

D Q

QBFF2 FF3

TOP

A

Clk

Z

D. Markovic / Slide 4EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 4

Page 3: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

3

Timing Constraints

Clock period: set by define_clockInput delay: arrival of an external path with respect to a Clk edgeOutput delay: timing path from an output port to a register input of an external blockof an external block

D. Markovic / Slide 5EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 5

Input and output delays budget timing for surrounding logic in general case when the in/out ports are not registered

Understanding Timing Constraints

Three important constraints (clock, input, output)– Blue box = current_design (to be retimed)

logic logic logiclogiclogic

Clk

(input) (internal) (output)

D. Markovic / Slide 6

“set_input_delay”(affects input logic)

“set_output_delay”(affects output logic)

“create_clock”(affects internal logic)

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 6

Page 4: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

4

Environment: Drivers, Load…

To simulate realistic inputs, we can set the driving cell using the external_driver command, to be any cell in the library– This ensures that the input has a finite slew rate

The load capacitance can be set on the output ports using the external_pin_cap command

By default the Encounter RTL Compiler only tries to meet the timing constraints without optimizing power

If h d i ib i l h

D. Markovic / Slide 7

If the max_dynamic_power attribute is set to some value, the tool tries to meet the timing specs while also optimizing for power in the process

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 7

Example: Automated Adder Synthesis

Copy the following files to your work directory/usr/public.2/ee216a/cadence/SOC62/SynLib.v/usr/public.2/ee216a/cadence/SOC62/adder.v/ / bli 2/ 216 / d /SOC62/ dd t l/usr/public.2/ee216a/cadence/SOC62/adder.tcl

The top level synthesis script adder.tcl reads in the HDL file, sets timing, load and power constraints, and runs synthesis

To run RTL synthesis type the following command> rc –files adder.tcl –gui

D. Markovic / Slide 8

The GUI window will show detailed architecture (gate level). Use report power, report area, report timing commands in the rccommand window to get Power, Area and Delay numbers

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 8

Page 5: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

5

set_attribute library /w/apps/apps.16/cadence/gsclib090_v2.9/timing/typical.lib set_attribute hdl_language v2001read_hdl adder.vread_hdl SynLib.v

Setup Example: Adder.tcl (1/2)

Define lib

Read HDL

elaborate adder dc::current_design adderdc::set_time_unit ‐picoseconds dc::set_load_unit ‐femtofarads define_clock ‐name clk ‐period 1000 ‐design /designs/adder

{/designs/adder/ports_in/clk} dc::set_input_delay 20 ‐clock clk [all_inputs]dc::set output delay 100 ‐clock clk [all outputs]

Elaborate

Set timing

D. Markovic / Slide 9

dc::set_output_delay 100 clock clk [all_outputs]set_attribute external_driver [find [find / ‐libcell DFFX1] ‐libpin D]

{/designs/adder/ports_in/*}set_attribute external_pin_cap 26.5488 {/designs/adder/ports_out/*}set_attribute lp_power_unit mW /set_attribute max_dynamic_power 0.5 /designs/adder

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 9

Setenv.

Opt.

Setup Example: Adder.tcl (2/2)

synthesize ‐to_mapped ‐effort highreport area > adder_area.rptreport power > adder_power.rptreport timing > adder_timing.rptreport clocks > adder clocks rpt

Synthesis

Reports

report clocks > adder_clocks.rptwrite_encounter design adder ‐basename adder ‐lef [format "%s %s %s"

/usr/public.2/ee216a/cadence/SOC62/gpdk090_9lm.lef /w/apps/apps.16/cadence/gsclib090_v2.9/lef/gsclib090_tech.lef /w/apps/apps.16/cadence/gsclib090_v2.9/lef/gsclib090_macro.lef]

D. Markovic / Slide 10

How does synthesis work?

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 10

Page 6: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

6

Example Clock, In and Out Delay [Synopsys]

create_clock –name “Clk” –period $Tclkset_input_delay 0.5

Define clock, input and output delay

set_output_delay [expr $Tclk – 0.5 + $wire_margin] ;# wire_margin = 0.2

Work with expressions and variables

D. Markovic / Slide 11EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 11

Adder.tcl

The adder.tcl file sets constraints & optimization parameters

D. Markovic / Slide 12EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 12

Page 7: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

7

Pre‐ and Post‐Layout Clock

ideal clock

pre‐layout post‐layout

latency uncertainty transition

[ jitter 0.1 + skew 0.4 ]

Courtesy: Synopsys

D. Markovic / Slide 13EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 13

create_clock ‐p 30 ‐n MCLK Clk

set_clock_uncertainty 0.5 MCLK

set_clock_transition 0.25 MCLK

set_clock_latency ‐source 4 MCLK

set_clock_latency 2 MCLK

create_clock ‐p 30 ‐n MCLK Clk

set_clock_uncertainty 0.1 MCLK

set_clock_latency ‐source 4 MCLK

set_propagated_clock MCLK

pre layout post layout

Synthesis Results: Fast Adder

Adder synthesized to meet timing constraint of 550 psInput is registered from a FF

Clk Q delay 157 ps– Clk‐Q delay = 157 ps– Setup time = 82 ps

Effective adder delay = 311 psTiming constraints are stringent, tool synthesizes a carry look ahead type of adderS h i

D. Markovic / Slide 14

Synthesis reports– Area = 1035 µm2

– Energy (active) = 0.2145 fJ– Power (leak) = 0.005 mW

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 14

Page 8: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

8

Synthesis Results: Slow Adder

Adder delay = 757 psStructure is somewhat like carry ripple topologyArea 548 µm2 (half ofArea = 548 µm2 (half of previous)Energy (active) = 0.13 fJ– Nearly ½ of previous design– Expected since VDD was the

same, Eactive depends only on C hi h h l d ith

D. Markovic / Slide 15

Csw, which was halved with the area being halved…

Power (leak) = 0.002 mW– Also reduced due to

reduced area

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 15

Synthesis Results

Energy‐delay tradeoff plot obtained from synthesis– Keep timing constraint, move down the energy axis (left plot)– Resulting energy‐area should be below reference curve (right

plot)plot)

18

20

22

24

26

per O

perta

ion

(fJ)

(311,24)

18

20

22

24

26

per O

perta

ion

(fJ)

(1035,24)

D. Markovic / Slide 16

200 400 600 80014

16

18

Delay (ps)

Ener

gy p

(361,16)(757,15)

400 600 800 1000 120014

16

18

Area (µm2)

Ener

gy p (813,16)

(548,15)

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 16

Page 9: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

9

High‐Level Design Issues

You may think design is a straightforward logical process– Start with the idea of what you need to build– And then build it

Real design is not like that– Think you have an idea of what to build– Through the design process you figure out

what you really want to build– Need to validate idea early in the process

What you build depends on the i l i bili i d i

Specification

Implementation

D. Markovic / Slide 17

implementation capabilities and constraints– Implementation issues will change the

specificationNeed a language that helps with the real

(interactive) design process

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 17

Verification

Hardware Description Languages

Need a description level up from logic gates

Work at the level of functional blocks, not logic gatesComplexity of the functional blocks is up to the designer– Complexity of the functional blocks is up to the designer

– A functional unit could be an ALU, or could be a microprocessor

The description consists of functional blocks and their interconnections– Describe functional block (not predefined)

Support hierarchical description (function block nesting)

D. Markovic / Slide 18

– Support hierarchical description (function block nesting)

To make sure the specification is correct, make it “executable”– Run the functional specification and check what it does

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 18

Page 10: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

10

Hardware Description Languages

A hardware description language (HDL) translates the specification of a hardware device into a software medium; This software medium can be

Verified via simulation– Verified via simulation– Translated into an optimized, technology‐specific, gate‐level

implementation

Register Transfer Level (RTL) synthesis explicitly defines register boundaries and the combinational logic between them:

D t fl t l fl d hi t t li itl

D. Markovic / Slide 19

– Data flow, control flow, and machine states are explicitly defined by the coding style that is used

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 19

Hardware Description Languages (Examples)

There are many different systems for modeling and simulating hardware– Verilog– VHDL

IEEE Standard

– L‐language, M‐language (Mentor)– DECSIM (DEC)– Aida (IBM / HaL)– and many others

The two most standard languages: Verilog & VHDL

D. Markovic / Slide 20

– For this class we will be using Verilog

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 20

Page 11: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

11

Verilog from 20,000 Feet

Verilog descriptions look like programs:

C / Pascal VerilogProcedures/Functions Modules

Block structure is a key principle– Use hierarchy/modularity to manage complexity

Procedures/FunctionsProcedure parametersVariables

ModulesPortsWires / Regs

Courtesy: Synopsys

D. Markovic / Slide 21EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 21

But they aren’t ‘normal’ programs– Module evaluation is concurrent – Model is really that of communicating blocks

Verilog (or any HDL) View of the World

A design consists of a set of communicating modulesThere are graphic‐input tools for Verilogg– Come to EE216B– Matlab/Simulink RTL

We will use the text method– EEM216A

Basic philosophy– Label the wires, and pass

h b d l

Ctrl

Datapath

Memory

bus da

b

c

D. Markovic / Slide 22

them between modules as you would parameters in function calls

– Wires are I/O nets for modules

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 22

Datapath

Page 12: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

12

Example Verilog

ModuleName InstanceName (wires);

module system;wire [7:0] bus_v1, const_s1;wire [2:0] regSpec_s1, regSpecA_s1,

S B 1patternsource

clkgen

Phi1Phi2regSpecB_s1;wire [1:0] opcode_s1;wire Phi1, Phi2, writeReg_s1,

ReadReg_s1,nextVector_s1clkgen clkgen(Phi1, Phi2);datapath datapath(Phi1, Phi2, regSpec_s1, bus_v1, writeReg_s1, readReg_s1);controller controller1(Phi1, Phi2, regSpec_s1, bus_v1, const_s1, writeReg_s1, readReg_s1,

opcode_s1, regSpecA_s1, regSpecB_s1,

controller

bu

regSwrit

read

D. Markovic / Slide 23EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 23

nextVector_s1);patternsource patternsource(Phi1,

Phi2,nextVector_s1, opcode_s1, regSpecA_s1, regSpecB_s1, const_s1);

In this example the instance name and the module name are the same, except for controller1. datapath

us SpecteReg

dReg

Ways to Describe A Function

Structural– Consists only of module calls

DeclarativeDeclarative– Concurrently executed combinational logic

Procedural– Sequentially executed program

● A state machine (with storage)● Or combinational logic

D. Markovic / Slide 24

● Or combinational logic

Functional– Function/task calls

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 24

Page 13: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

13

Structural Description

Maps a physical structure into Verilog– Example is one shown

li ( t d h )

ModuleName InstanceName (wires);

module system;wire [7:0] bus_v1, const_s1;wire [2:0] regSpec_s1, regSpecA_s1,

S B 1 earlier (repeated here)Possible hierarchically– List of functions– List of sub‐functions– List of gates– List of transistors

regSpecB_s1;wire [1:0] opcode_s1;wire Phi1, Phi2, writeReg_s1,

ReadReg_s1,nextVector_s1clkgen clkgen(Phi1, Phi2);datapath datapath(Phi1, Phi2, regSpec_s1, bus_v1, writeReg_s1, readReg_s1);controller controller1(Phi1, Phi2, regSpec_s1, bus_v1, const_s1, writeReg_s1, readReg_s1,

opcode_s1, regSpecA_s1, regSpecB_s1,

D. Markovic / Slide 25

Typically don’t need to go below a gate level list– Standard cells

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 25

nextVector_s1);patternsource patternsource(Phi1,

Phi2,nextVector_s1, opcode_s1, regSpecA_s1, regSpecB_s1, const_s1);

Compose a module out of module cells. Specify wiring.

Declarative Statements

Provide the logical relations between inputs and outputsAssign outputs to be some function of the inputs (continuously)– Key word is assign

Models a piece of combinational logicModels a piece of combinational logicUses a C‐like expression syntaxDenoted by keyword assign

Examples (all execute in parallel):assign nor = ~(b | c);assign a = x & y, o = x | y;assign sum[4:0] = a[3:0] + b[3:0];

C

L

D. Markovic / Slide 26

assign sum[4:0] = a[3:0] + b[3:0];assign out = (Sel) ? in1: in2; //conditional

Outputs are wires, and can be a single bit or multiple bits.It is good practice to declare all variables even though Verilogallows undeclared single bit wires

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 26

Page 14: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

14

Declarative Order of Execution

Don’t assume any particular order.– Each statement occurs concurrently.

assign x = aaa;assign aaa = bbb;assign aaa bbb;

– Unlike C, the order of the above statements does not matter

Internally, however, declarative statements are still executed in a particular order– Verilog has an internal event linked list– But, there is no guarantee of that order

D. Markovic / Slide 27

assign out = aaa;assign out = bbb;

– This yields a warning and is not allowed

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 27

Procedural Statements

Procedural statements = sequential orderKeyword always– Provides functionality of a tiny program that executes

sequentiallyq yInside an always block, standard control flow statements:

if (<conditional>) then <statements> else <statements>;case (<var>) <value>: <statements>; … default: <statements>

Note: Case statements are actually prioritized– The 2nd case entry can’t happen unless the 1st doesn’t match– May not be what the actual hardware implies – especially when

cases are mutually exclusive

D. Markovic / Slide 28

cases are mutually exclusive.– Need additional directives (parallel‐case) to indicate this

Statements can be compound – Use begin and end to form blocks

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 28

Page 15: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

15

Procedural Statements (Cont.)

Example

always @ (Activation List…stuff we still need to talk about)begin

// more than 1 statement allowed inside here// more than 1 statement allowed inside hereif (x==y) then

out= in1 else

out = in2;end

D. Markovic / Slide 29EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 29

always Block Issues

Two issues with always blocks…

Issue #1: Unset outputsA ll t t i l ith li it i t– Are all outputs given a value with an explicit assignment statement at the end of the block?

– If not, then it is “unset”– If the output is always set, then the always block is no different

from a combinational logic

D. Markovic / Slide 30

Issue #2: Activation list– Determines when to execute the always block

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 30

Page 16: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

16

Unset Outputs

Occur when an output is not set on all the paths in the codeExample: always @ (Activation List…stuff we need to talk about)

begin// more than 1 statement allowed inside hereif (x==y) thenif (x==y) then

out= in1 // no else statement. So, if x!= y then out is unset.

end– In Verilog, this creates storage

● The value of the output remains the previous value● In synthesized result, it appears as an explicit FF or latch

Is this storage what we want?Careful to not build storage elements when you don’t intend to

D. Markovic / Slide 31

– Careful to not build storage elements when you don t intend toThe outputs of always blocks might act as storage elements– Left‐hand sides of expressions in always blocks must be

declared as registers (regs)● That does not mean the synthesized result contains registers● If output is set on all paths, there is no storage

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 31

Unset Outputs

alwaysbegin

Did he want latch or combinational logic?

gData_Out = In_B;if (Enable)beginData_Out = In_A;

endend

1

0

Data_Out

In A

In_B

D. Markovic / Slide 32EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 32

Enable

In_A

MUX

Courtesy: Synopsys

Page 17: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

17

Unset Outputs

always @(Enable or In_A or In_B)begin

if (E bl )

Courtesy: Synopsys

if (Enable)beginOut_1 = In_A;

endelsebeginOut_2 = In_B;

end

Out_1In_A

Enable

LATCH

Out_2In_B

D. Markovic / Slide 33

endLATCH

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 33

Intentionally Creating Storage in Verilog

To make a simple latch in Verilog is easy– Just make the output of an always block not get set when you

want to hold its valueExample:Example:

reg myout; //a latchalways @ (stuff we still need to talk about)

if (Enable) thenmyout = in;

– When Enable is high, the output myout is updated– When Enable is low myout will hold its last value

D. Markovic / Slide 34

When Enable is low, myout will hold its last value. – This is like the simple pass transistor latch

In this example, myout would need to be declared a register, because it is the LHS of an expression in an always block

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 34

Page 18: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

18

Is This an Infinite Loop?

Example 1

assign nor = ~(b | c);

Example 2

alwaysnor = ~(b | c);

D. Markovic / Slide 35EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 35

Activation List

The last tricky part about the always block…

Activation ListT ll th i l t h t thi bl k– Tells the simulator when to run this block

– Allows the user to specify when to run the block and makes the simulator more efficient● If not sensitized to every input, you get a storage element

– But also enables subtle errors to enter into the design

D. Markovic / Slide 36EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 36

Page 19: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

19

Two Forms of Activation List in Verilog

@(signalName1 or signalName2 or …)– Evaluate this block when any of the named signals change

(either positive or negative change)

@(posedge signalName);or @(negedge signalName);– Makes an edge triggered flop– Evaluates only on one edge of a signal– Can have @(posedge signal1, posedge signal2)

● Implied OR (not AND) because edges are singular eventsN d i hi l b diffi l l

D. Markovic / Slide 37

● Not used in this class because difficult to map to an actual gate

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 37

Activation Lists

Example:always @ (Enable or In) // latch

if (Enable) thenout=In;

always @ (x or y or in1 or in2) //combinational logicalways @ (x or y or in1 or in2) //combinational logicbeginif (x==y) then

out= in1 else

out = in2;end //same as out = (x==y) ? in1 : in2;

To represent Combinational Logic

D. Markovic / Slide 38

p g– The activation lists must contain everything on the RHS of the

expressions (and both side of conditionals). Why?Beware, if an always block has no activation list (or # delay statements), then the simulator goes into an infinite loopalways@* syntax

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 38

Page 20: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

20

Activation Errors: Examples

always @(phi) always @(phi) always @(phi or in)outA =in; if(phi) outB = in; if(phi) outC = in;

phiphi

in

outA

D. Markovic / Slide 39EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 39

outB

outC

What would synthesis results look like?

Procedural Order of Execution

Be careful of the sequential nature! (C‐like behavior)Case 1

always @(posedge clock) beginq2=q1;

1 0q1=q0;end

Case 2always @(posedge clock) begin

q1=q0;q2=q1;

end

Case 3 – Which one is this case more similar to?

D. Markovic / Slide 40

always @(posedge clock) beginq1=q0;

endalways @(posedge clock) begin

q2=q1;end

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 40

Page 21: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

21

Non‐Blocked Assignment

A feature of Verilog helps by eliminating the order of evaluation– Instead of “=“ ; known as a blocking assignment

● Blocks future action until RHS is updated● Blocks future action until RHS is updated

– Use “<=“; known as non‐blocking assignment● All LHS are changed first before the RHS is updated

always @ (posedge clock)begin

a[0] <= inp;a[1] <= a[0];

[2] [1]

D. Markovic / Slide 41

a[2] <= a[1];a[3] <= a[2];

end

The above is equivalent to a[3:0]={a[2:0],inp};If we had used “=“ instead of “<=“, then a = 4{inp};

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 41

Parallel Case Definition

A case statement is called parallel case if its case items do not overlap:– If synthesis determines that the case statement is parallel case

then a multiplexer or equivalent logic will be synthesizedthen a multiplexer or equivalent logic will be synthesized● Otherwise priority‐checking logic will be synthesized

D. Markovic / Slide 42EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 42

Page 22: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

22

Parallel Case Example

No priority logic needed

case (Sel)2'b00 : D_Out = A;2'b01 : D_Out = B;2'b10 : D_Out = C;2'b11 : D_Out = D;

endcase

D. Markovic / Slide 43EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 43

Initial Block

This is another type of procedural block– Does not need an activation list– It is run just once, when the simulation starts

Used to do extra stuff at the very start of simulation– Initialize simulation environment– Initialize design

● This is usually only used in the first pass of writing a design● Beware, real hardware does not have initial blocks

All t ti f d i ( t id f th d i d l )

D. Markovic / Slide 44

– Allows testing of a design (outside of the design module)

Best to use initial blocks only for non‐hardware statements (like $display)

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 44

Page 23: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

23

Summary of Verilog Variables

There are two types of “physical” variables in Verilog:– Wires (all outputs of assign statements must be wires)– Regs (all outputs of always blocks must be regs)

B th i bl b d i t hBoth variables can be used as inputs anywhere– Can use regs or wires as inputs (RHS) to assign statements

assign bus = LatchOutput + ImmediateValue● Bus must be a wire, but LatchOutput can be a reg

– Can use regs or wires as inputs (RHS) in always blocksalways @ (in or clk)if (clk) out = in

D. Markovic / Slide 45

if (clk) out = in● in can be a wire, out must be a reg

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 45

Summary of Verilog Variables (Cont.)

Module outputs can be either regs or wiresmodule div_ctrl(ctl1, ctl2, dp1, clock, reset, start);

output ctl1, ctl2;input dp1 clock reset start;input dp1, clock, reset, start;

Integer and real do not map into hardware– Useful for initial functional description but not for

implementation

D. Markovic / Slide 46EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 46

Page 24: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

24

Delays in Verilog

Verilog simulated time is in “units” or “ticks”– Simulated time unrelated to the wall‐clock to run the simulator– Simulated time models the time in the modeled machine

Wh th t l t ith ll th “ t ” th t t th● When the computer completes with all the “events” that occur at the current simulated time

● The computer increases time until another signal is scheduled to change values

User must specify delay values explicitly to Verilog– # delayAmount

● When the simulator sees this symbol, it stops “evaluating”, and pause

D. Markovic / Slide 47

delayAmount of simulated time (# of ticks).● Delays are often used to model the delay in functional units● Can be tricky to use properly

– We will design our logic to have zero (or unit) delay● The standard cell library we use can annotate delay information

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 47

RTL Subset

HDLs were designed for simulationSubset of the language is supported for SynthesisUnsupported Verilog language constructs:

D l– Delays– “initial” blocks– $display– Tool Specific

Organize synthesis and simulation specific code into separate files

D. Markovic / Slide 48

– RTL– Test bench

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 48

Page 25: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

25

Verilog Summary

An HDL provides a means for the user to specify a design at a higher level than just gates– This lecture addresses mostly form and not content

● How to represent combinational logic and state machines– We can now use this tool to specify any machine with state

A good question to ask is– “What should my code look like?”– “Are there certain styles of hardware that are easier to

understand / build / test?”– Gets back to the question of abstractions, and is really asking

whether there are some hardware abstractions that work well

D. Markovic / Slide 49

whether there are some hardware abstractions that work wellThe answer is briefly introduced in the examples above– Partitioning of the problem into

● Finite State Machines● Data flows

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 49

Now What?

Synthesis = Translation + Logic Optimization + Mapping

residue = 16’h0000;

if (high_bits == 2’b10)

residue = state_table[index];

else

state_table[index] = 16’h0000;

HDL Source

Translate (read)

Optimize + Map (compile)

D. Markovic / Slide 50EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 50

Generic Boolean (GTECH)

Target Technology

Courtesy: Synopsys

Page 26: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

26

Synthesis Design Flow

Floorplan

T tb h

Code RTLSpec

SelectArchitecture

RTL Code Check

SynthesisLogic Synthesis

Test (Scan/JTAG)Power Reduction

Datapath Synthesis

CWLM

Lib

DW

Constraints

Formal Verification

Testbench

RTL Verification

ATPG

RTL

Gate‐level

D. Markovic / Slide 51EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 51

Gate‐level Verification

Physical Design

Static TimingAnalysis

netlist/db

PlacementInfo

GDSII

Courtesy: Synopsys

Simplified View: EEM216A Flow

Today

D. Markovic / Slide 52

Next fewlectures

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 52

Page 27: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

27

B

BetterStartPoint

PoorStartPoint

The Importance of HDL Coding Styles

Courtesy: Synopsys

BestStartPoint

Goal

Different coding styles that are functionally equivalent may synthesize into hardware that have different timing and area

D. Markovic / Slide 53

synthesize into hardware that have different timing and areaSynthesis engineers cannot rely solely on the synthesis tool to "fix" a poorly coded designAlternative coding styles should be explored, so that the synthesis algorithms will have the best possible starting point

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 53

Area

Synthesis Is Constraint‐Driven

Large

Small

Short DelayLong

••

• • •

D. Markovic / Slide 54

Delay

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 54

Courtesy: SynopsysYou set the goals (through constraints)Synthesis tool optimizes the design to meet your goals

Page 28: Logic Synthesis - University of California, Los Angelesicslwebs.ee.ucla.edu/.../images/8/8b/Lec-13_Logic-Synthesis.pdf · Constraining your design for logic synthesis ... Need a description

28

Synthesis Summary

Synthesis tools are like compilers– Allow the user to work at a higher level– Show you what the details look like

Use tools to understand the parts that need extra work– Optimize the parts that don’t meet the constraints– Don’t improve what is not broken

Tools leverage your creativity– Not a substitute for thinking

N d t t ith th i th t l !

D. Markovic / Slide 55

– Need to compete with others using the same tools!

EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 55

Cadence Manuals / Tips Etc.

Online resources:http://sourcelink.cadence.com

Sign up for an accountSign up for an account– Disclaimer (from Cadence)

● Reference key for UCLA is: 606‐ucla1108● Only university staff, faculty and students may use this reference key● You must sign up using a university domain email address

D. Markovic / Slide 56EEM216A .:. Fall 2010 Lecture 13: Logic Synthesis | 56