HDL Compiler Directives 7

Similar documents
CSE140L: Components and Design Techniques for Digital Systems Lab

CSE140L: Components and Design

EEL 4783: HDL in Digital System Design

Synthesis vs. Compilation Descriptions mapped to hardware Verilog design patterns for best synthesis. Spring 2007 Lec #8 -- HW Synthesis 1

Writing Circuit Descriptions 8

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

10 Writing Circuit Descriptions

Design Compiler Interface 8

EECS150 - Digital Design Lecture 10 Logic Synthesis

EECS150 - Digital Design Lecture 10 Logic Synthesis

Speaker: Kayting Adviser: Prof. An-Yeu Wu Date: 2009/11/23

Verilog for Synthesis Ing. Pullini Antonio

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

8 Register, Multiplexer and

Course Topics - Outline

Nikhil Gupta. FPGA Challenge Takneek 2012

FSM and Efficient Synthesizable FSM Design using Verilog

EECS 270 Verilog Reference: Sequential Logic

Differences Between HDL Compiler (Presto Verilog) and the Original HDL Compiler C

ECE 551 Design Vision Tutorial

CME341 Assignment 4. module if\_else\_combinational\_logic( input [3:0] a, b, output reg [3:0] y ); * begin

Verilog for High Performance

Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA

VHDL: RTL Synthesis Basics. 1 of 59

ECEN 468 Advanced Logic Design

Verilog Sequential Logic. Verilog for Synthesis Rev C (module 3 and 4)

Synthesizable Watchdog Logic: A Key Coding Strategy for Managing Complex Designs

Simple Behavioral Model: the always block

Synthesis of Language Constructs. 5/10/04 & 5/13/04 Hardware Description Languages and Synthesis

Working With Design Files 3

EECS 470: Computer Architecture. Discussion #2 Friday, September 14, 2007

ECE 4514 Digital Design II. Spring Lecture 15: FSM-based Control

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

The Verilog Language COMS W Prof. Stephen A. Edwards Fall 2002 Columbia University Department of Computer Science

ECE 574: Modeling and Synthesis of Digital Systems using Verilog and VHDL. Fall 2017 Final Exam (6.00 to 8.30pm) Verilog SOLUTIONS

Synthesizable Verilog

Lecture #2: Verilog HDL

Verilog For Synthesis

Graduate Institute of Electronics Engineering, NTU. Lecturer: Chihhao Chao Date:

Designing Safe Verilog State Machines with Synplify

ECE 4514 Digital Design II. Spring Lecture 13: Logic Synthesis

Sunburst Design - Comprehensive SystemVerilog Design & Synthesis by Recognized Verilog & SystemVerilog Guru, Cliff Cummings of Sunburst Design, Inc.

Introduction to Digital Design with Verilog HDL

Graduate Institute of Electronics Engineering, NTU. Lecturer: Chihhao Chao Date:

EE178 Lecture Verilog FSM Examples. Eric Crabill SJSU / Xilinx Fall 2007

FSM Components. FSM Description. HDL Coding Methods. Chapter 7: HDL Coding Techniques

What, If Anything, In SystemVerilog Will Help Me With FPGA-based Design. Stuart Sutherland, Consultant and Trainer, Sutherland HDL, Inc.

Stuart Sutherland, Sutherland HDL, Inc.

Quick Introduction to SystemVerilog: Sequental Logic

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

Modeling Combinational Logic 3

Chap 6 Introduction to HDL (d)

ASIC Development. ASIC Classes. What s an ASIC, Anyhow? ASIC Methodology. Abstract Representations 2/16/2018

1 Design Process HOME CONTENTS INDEX. For further assistance, or call your local support center

HDLs and SystemVerilog. Digital Computer Design

Recommended Design Techniques for ECE241 Project Franjo Plavec Department of Electrical and Computer Engineering University of Toronto

ECE 551: Digital System *

EEL 4783: HDL in Digital System Design

Lecture 11 Logic Synthesis, Part 2

VHDL for Synthesis. Course Description. Course Duration. Goals

Behavioral Modeling and Timing Constraints

EECS 427 Lecture 14: Verilog HDL Reading: Many handouts/references. EECS 427 W07 Lecture 14 1

Verilog. What is Verilog? VHDL vs. Verilog. Hardware description language: Two major languages. Many EDA tools support HDL-based design

Using Quartus II Verilog HDL & VHDL Integrated Synthesis

fpp: Fortran preprocessor March 9, 2009

SystemVerilog 3.1: It s What The DAVEs In Your Company Asked For

Verilog Module 1 Introduction and Combinational Logic

IP Core Design. Lecture 6 Introduction to Verilog-2001

Graduate Institute of Electronics Engineering, NTU Design of Datapath Controllers

Digital Design with FPGAs. By Neeraj Kulkarni

Lecture 15: System Modeling and Verilog

ES611 FPGA Based System Design. Behavioral Model

Synthesis - Concepts and Applications

Course Topics - Outline

FPGA: FIELD PROGRAMMABLE GATE ARRAY Verilog: a hardware description language. Reference: [1]

A Verilog Primer. An Overview of Verilog for Digital Design and Simulation

Synthesis of Combinational and Sequential Circuits with Verilog

Online Verilog Resources

Verilog 1 - Fundamentals

Behavioral Modeling and Timing Constraints

CMPE 415 Full and Parallel Case

Have examined process Creating program Have developed program Written in C Source code

VHDL Modeling Behavior from Synthesis Perspective -Part B - EL 310 Erkay Savaş Sabancı University

N-input EX-NOR gate. N-output inverter. N-input NOR gate

OBJECT ORIENTED PROGRAMMING USING C++

Verilog 1 - Fundamentals

Yet Another Latch and Gotchas Paper

v HDL Compiler for Verilog Reference Manual Resource Sharing 7

Computer Aided Design Basic Syntax Gate Level Modeling Behavioral Modeling. Verilog

Hardware Description Language (HDL)

OPEN VERIFICATION LIBRARY

SystemVerilog Essentials Simulation & Synthesis

Synplify Pro for Microsemi Edition Release Notes Version L M-G5, November 2016

VERILOG: FLIP-FLOPS AND REGISTERS

CAD for VLSI Design - I. Lecture 21 V. Kamakoti and Shankar Balachandran

Logic Circuits II ECE 2411 Thursday 4:45pm-7:20pm. Lecture 3

Verilog: The Next Generation Accellera s SystemVerilog Standard

General Coding Style Guidelines 5

Introduction to HDL Synthesis. Prof. Chien-Nan Liu TEL: ext: Synthesis overview RTL synthesis

Bulletproofing FSM Verification Automated Approach to Detect Corner Case Issues in an FSM Design

Transcription:

7 HDL Compiler Directives 7 Directives are a special case of regular comments and are ignored by the Verilog HDL simulator HDL Compiler directives begin, like all other Verilog comments, with the characters // or /* The // characters begin a comment that fits on one line (most HDL Compiler directives do) If you use the /* characters to begin a multiline comment, you must end the comment with */ You do not need to use the /* characters at the beginning of each line but only at the beginning of the first line If the word following these characters is synopsys (all lowercase), HDL Compiler treats the remaining comment text as a compiler directive Note: You cannot use // synopsys in a regular comment Also, the compiler displays a syntax error if Verilog code is in a // synopsys directive / 7-1

This chapter contains the following sections that describe HDL Compiler directives and their effect on translation: Embedding Constraints and Attributes `ifdef, `else, `endif, `ifndef, and `elsif Directives Standard Macros (SYNTHESIS, PRESTO, VERILOG_2001, and VERILOG_1995) analyze Command -define Option `undef `undefineall `define Directive Macro Substitution `include parallel_case Directive full_case Directive enum Directive template Directive map_to_module and return_port_name one_hot one_cold don t_munch preserve_sequential / 7-2

Embedding Constraints and Attributes Example 7-1 You can describe the area and performance constraints for a design module directly in your Verilog description HDL Compiler inputs constraints specified for a design when they are embedded in a Synopsys-defined HDL Compiler directive By specifying constraints with your HDL description, You can control the optimization of a design module from within the Verilog description Design Compiler attempts to optimize each module so that all design constraints are met You can use the Verilog description to document important specification information Constraints and attributes, usually entered at the dc_shell prompt, can be embedded in your Verilog source code Prefix the usual constraint or attribute statement with the Verilog comment characters //, and delimit the embedded statements with the compiler directives // synopsys dc_script_begin and //synopsys dc_script_end The method is shown in Example 7-1 Embedding Constraints and Attributes With // Delimiters // synopsys dc_script_begin // max_area 00 // set_drive -rise 1 port_b // max_delay 00 port_z // synopsys dc_script_end / 7-3

Example 7-2 Constraints and attributes as shown in Example 7-2 can also be delimited with the characters /* and */ When you use these delimiters, the // synopsys dc_script_end comment is not required or valid, because the attributes or constraints are terminated by */ Embedding Constraints and Attributes With /* and */ Delimiters /* synopsys dc_script_begin max_area 100 max_delay 00 port_z */ The dc_shell script interprets the statements embedded between the // synopsys dc_script_begin and the // synopsys dc_script_end directives If you want to comment out part of your dc_shell script, use the dc_shell convention The following limitations apply to the use of constraints and attributes in your design: Constraints and attributes declared outside a module apply to all subsequent modules declared in the file Constraints and attributes declared inside a module apply only to the enclosing module Any dc_shell scripts embedded in functions apply to the whole module Include in your dc_shell script only commands that set constraints and attributes Do not use action commands such as compile, gen, and report / 7-4

The constraints or attributes set in the embedded script go into effect after the read command is executed Therefore, variables that affect the read process itself are not in effect before the read Thus, if you set the variable hdlin_no_latches = true in the embedded script, this variable does not influence latch inference in the current read dc_shell performs error checking after the read command finishes Syntactic and semantic errors in dc_shell strings are reported at this time `ifdef, `else, `endif, `ifndef, and `elsif Directives These directives allow the conditional inclusion of code The `ifdef directive executes the statements following it if the indicated macro is defined; if the macro is not defined, the statements after `else are executed The`ifndef directive executes the statements following it if the indicated macro is not defined; if the macro is defined, the statements after `else are executed The `elsif directive allows one level of nesting and is equivalent to the `else `ifdef `endif directive sequence The macros that are arguments to the `ifdef directive can either be defined by the `define directive or the analyze command See `define Directive on page 7-8 See analyze Command -define Option on page 7-7 Example 7-3 shows a design that uses the `ifdef`else`endif directives Example 7-3 Design Using `ifdef`else`endif Directives `ifdef SELECT_XOR_DESIGN / 7-5

module selective_design(a,b,c); input a, b; output c; assign c = a ^ b; endmodule `else module selective_design(a,b,c); input a, b; output c; assign c = a b; endmodule `endif Standard Macros (SYNTHESIS, PRESTO, VERILOG_2001, and VERILOG_1995) Example 7-4 The following macros are predefined: SYNTHESIS used to specify simulation only code as shown in the example below In this example, the SYNTHESIS macro and the `ifndef `endif constructs enclose the simulation only code that checks if reset and set are asserted at the same time The main always block is both simulated and synthesized; the block that checks at simulation time what the designer assumed to be true, is actually true, is wrapped in the `ifndef `endif constructs This code infers a D flip-flop with active-high asynchronous set and reset pins For more information on this flip-flop inference, see D Flip-Flop With Asynchronous Set and Reset on page 4-25 Using SYNTHESIS and `ifndef `endif Constructs module dff_async (RESET, SET, DATA, Q, CLK); input CLK; input RESET, SET, DATA; / 7-6

output Q; reg Q; // synopsys one_hot "RESET, SET" always @(posedge CLK or posedge RESET or posedge SET) if (RESET) Q <= 1'b0; else if (SET) Q <= 1'b1; else Q <= DATA; 'ifndef SYNTHESIS always @ (RESET or SET) if (RESET + SET > 1) $write ("ONE-HOT violation for RESET and SET"); 'endif endmodule PRESTO running the new HDL Compiler (Presto Verilog) VERILOG_2001 and VERILOG_1995 running the conditional inclusion of Verilog 2001 features and running without the Verilog 2001 features respectively Verilog 2001 features are listed in Table C-1 on page C-2 To disable Verilog 2001 features, set hdlin_vrlg_std to 1995; default is hdlin_vrlg_std = 2001, which enables Verilog 2001 features analyze Command -define Option An option of the analyze command, -define (or -d, abbreviated), allows macro definition on the command line Only one -define per analyze command is allowed, but the argument can be a list of macros, as shown in Example 7-5 Curly brackets are not required to enclose one macro, as shown in Example 7-6 However, if the argument is a list of macros, curly brackets are required / 7-7

Example 7-5 Example 7-6 analyze Command With List of Defines analyze -f verilog -d { RIPPLE, SIMPLE } mydesignv analyze Command With One Define analyze -f verilog -define ONLY_ONE mydesignv Note: In the dc_shell Tcl mode, the command read_verilog (dc_shell -t) does not accept the -d option The analyze command outputs an mr and a pv1 file `undef The `undef directive resets the macro immediately following it `undefineall The `undefineall directive is a global reset for all macros that causes all the macros defined earlier in the source file to be reset to undefined `define Directive The `define directive can specify macros that take arguments For example, `define BYTE_TO_BITS(arg)((arg) << 3) / 7-8

The `define directive can do more than simple text substitution It can also take arguments and substitute their values in its replacement text Macro Substitution Macro substitution assigns a string of text to a macro variable The string of text is inserted into the code where the macro is encountered The definition begins with the back quotation mark (`), followed by the keyword define, followed by the name of the macro variable All text from the macro variable until the end of the line is assigned to the macro variable You can declare and use macro variables anywhere in the description The definitions can carry across several files that are read into Design Compiler at the same time To make a macro substitution, type a back quotation mark (`) followed by the macro variable name Some sample macro variable declarations are shown in Example 7-7 Example 7-7 Macro Variable Declarations `define highbits 31:29 `define bitlist {first, second, third} wire [31:0] bus; `bitlist = bus[ highbits]; / 7-9

`include The `include construct in Verilog is similar to the #include directive in the C language You can use this construct to include Verilog code, such as type declarations and functions, from one module in another module Example 7-8 shows an application of the `include construct Example 7-8 Including a File Within a File Contents of file1v `define WORDSIZE 8 function [WORDSIZE-1:0] fastadder; endfunction Contents of secondfile module secondfile (in1,in2,out) `include file1v wire [WORDSIZE-1:0] temp; assign temp = fastadder (in1,in2); endmodule Included files can include other files, with up to 24 levels of nesting You cannot use the `include construct recursively Set the include directory with the search_path variable in dc_shell parallel_case Directive Set the // synopsys parallel_case directive on a case statement when you know that only one branch of the case statement will be true at a time This directive prevents HDL / 7-10

Compiler from building additional logic to ensure the first occurrence of a true branch is executed if more than one branch were true at one time Additional parallel case usage is described in Chapter 3 See Full Case and Parallel Case on page 3-47 Caution! Marking a case statement as parallel when it actually is not parallel can cause the simulation to behave differently from the logic HDL Compiler synthesizes because HDL Compiler does not generate priority encoding logic to make sure that the branch listed first in the case statement takes effect The syntax for the parallel_case directive is // synopsys parallel_case or Example 7-9 /* synopsys parallel_case */ Use the parallel_case directive immediately after the case expression In Example 7-9, the states of a state machine are encoded as a one-hot signal; the designer knows that only one branch is true at a time and therefore sets the // synopsys parallel_case directive on the case statement // synopsys parallel_case Directives reg [3:0] current_state, next_state; parameter state1 = 4 b0001, state2 = 4 b0010, state3 = 4 b0100, state4 = 4 b1000; case (1)//synopsys parallel_case current_state[0] : next_state = state2; current_state[1] : next_state = state3; current_state[2] : next_state = state4; current_state[3] : next_state = state1; endcase / 7-11

full_case Directive Set the // synopsys full_case directive on a case statement when you know that all possible branches of the case statement are listed within the case statement This directive prevents HDL Compiler from generating logic to test for any value that is not covered by the case branches and creating an implicit default branch When a variable is assigned in a case statement that is not full, the variable is conditionally assigned and requires a latch Additional full case usage is described in Chapter 3 See Full Case and Parallel Case on page 3-47 Caution! Marking a case statement as full when it actually is not full can cause the simulation to behave differently from the logic HDL Compiler synthesizes because HDL Compiler does not generate a latch to handle the implicit default condition The syntax for the full_case directive is // synopsys full_case or Example 7-10 /* synopsys full_case */ In Example 7-10, full_case is set on the first case statement and parallel_case and full_case directives are set on the second case statement // synopsys full_case Directives reg [1:0] in, out; reg [3:0] current_state, next_state; parameter state1 = 4 b0001, state2 = 4 b0010, state3 = 4 b0100, state4 = 4 b1000; / 7-12

case (in) // synopsys full_case 0: out = 2; 1: out = 3; 2: out = 0; endcase case (1) // synopsys parallel_case full_case current_state[0] : next_state = state2; current_state[1] : next_state = state3; current_state[2] : next_state = state4; current_state[3] : next_state = state1; endcase In the first case statement, the condition in == 3 is not covered but The designer knows that in == 3 will never occur and therefore sets the full_case directive on the case statement In the second case statement, not all 16 possible branch conditions are covered; for example, current_state == 4 b0101 is not covered, but The designer knows that these states will never occur and therefore sets the full_case directive on the case statement The designer also knows that only one branch is true at a time and therefore sets the parallel_case directive on the case statement enum Directive The // synopsys enum directive is designed for use with the Verilog parameter definition statement to specify state machine encodings HDL Compiler uses the enum values and names to optimize the design if hdlin_optimize_enum_types is set to true The syntax of the enum directive is / 7-13

// synopsys enum enum_name or /* synopsys enum enum_name */ Example 7-11 shows the declaration of an enumeration of type colors that is 3 bits wide and has the enumeration literals red, green, blue, and cyan with the values shown Example 7-11 Enumeration of Type Colors parameter [2:0] // synopsys enum colors red = 3 b000, green = 3 b001, blue = 3 b010, cyan = 3 b011; The enumeration must include a size (bit-width) specification Example 7-12 shows an invalid enum declaration Example 7-12 Invalid enum Declaration parameter /* synopsys enum colors */ red = 3 b000, green = 1; // [2:0] required Example 7-13 shows a register, a wire, and an input port with the declared type of colors In each of the following declarations, the array bounds must match those of the enumeration declaration If you use different bounds, synthesis might not agree with simulation behavior Example 7-13 More enum Type Declarations reg [2:0] /* synopsys enum colors */ counter; wire [2:0] /* synopsys enum colors */ peri_bus; input [2:0] /* synopsys enum colors */ input_port; / 7-14

Even though you declare a variable to be of type enum, it can still be assigned a bit value that is not one of the enumeration values in the definition Example 7-14 relates to Example 7-13 and shows an invalid encoding for colors Example 7-14 Invalid Bit Value Encoding for Colors counter = 3 b111; Because 111 is not in the definition for colors, it is not a valid encoding HDL Compiler accepts this encoding, but issues a warning for this assignment You can use enumeration literals just like constants, as shown in Example 7-15 Example 7-15 Enumeration Literals Used as Constants if (input_port == blue) counter = red; If you declare a port as a reg and as an enumerated type, you must declare the enumeration when you declare the port Example 7-16 shows the declaration of the enumeration Example 7-16 Enumerated Type Declaration for a Port module good_example (a,b); parameter [1:0] /* synopsys enum colors */ green = 2 b00, white = 2 b11; input a; output [1:0] /* synopsys enum colors */ b; reg [1:0] b; endmodule / 7-15

Example 7-17 declares a port as an enumerated type incorrectly because the enumerated type declaration appears with the reg declaration instead of with the output declaration Example 7-17 Incorrect Enumerated Type Declaration for a Port module bad_example (a,b); parameter [1:0] /* synopsys enum colors */ green = 2 b00, white = 2 b11; input a; output [1:0] b; reg [1:0] /* synopsys enum colors */ b; endmodule template Directive Example 7-18 The // synopsys template directive saves the analyzed file and does not elaborate it Without this directive, the analyzed file is saved and elaborated If you use this directive and your design contains parameters, the design is archived as a template Example 7-18 shows how to use the directive // synopsys template Directive in a Design With a Parameter module template (a, b, c); input a, b, c; // synopsys template parameter width = 8; endmodule See Building Parameterized Designs on page 8-6 / 7-16

map_to_module and return_port_name From the DC 200205-SP2 release onward, HDL Compiler supports the instantiation of modules in the behavioral code In other words, the map_to_module directive can be used with functions as well as tasks To include an embedded netlist in your behavioral code, use the directives // synopsys map_to_module and // synopsys return_port_name which enable HDL Compiler to recognize the netlist as a function being implemented by another module When this subprogram is invoked in the behavioral code, HDL Compiler will instantiate the appropriate module (see Example 7-19) The first directive, // synopsys map_to_module, flags a function for implementation as a distinct component The syntax is // synopsys map_to_module modulename The second directive, // synopsys return_port_name, identifies a return port (functions in Verilog do not have output ports) To instantiate the function as a component, the return port must have a name The syntax is // synopsys return_port_name portname If you add a map_to_module directive to a function or a task, the contents of the function/task are parsed and ignored whereas the indicated module is instantiated Ensure that the functionality of the module instantiated in this way and the function it replaces are the same; otherwise, pre-synthesis and post-synthesis simulation will not match Example 7-19 illustrates the map_to_module and return_port_name directives / 7-17

Example 7-19 Component Implication module mux_inst (a, b, c, d, e); input a, b, c, d; output e; function mux_func; // synopsys map_to_module mux_module // synopsys return_port_name mux_ret input in1, in2, cntrl; /* ** the contents of this function are ignored for ** synthesis, but the behavior of this function ** must match the behavior of mux_module for ** simulation purposes */ begin if (cntrl) mux_func = in1; else mux_func = in2; end endfunction assign e = a & mux_func (b, c, d); // this function call actually instantiates component (module) mux_module endmodule module mux_module (in1, in2, cntrl, mux_ret); input in1, in2, cntrl; output mux_ret; and and2_0 (wire1, in1, cntrl); not not1 (not_cntrl, cntrl); and and2_1 (wire2, in2, not_cntrl); or or2 (mux_ret, wire1, wire2); endmodule one_hot A one-hot implementation indicates that all signals in a group are active-high and that only one signal can be active at a given time Synthesis implements the one_hot directive by omitting a priority circuit in front of a flip-flop Simulation ignores the one_hot / 7-18

synthesis directive The one_hot directive prevents Design Compiler from implementing priority-encoding logic for the set and reset signals Attach this directive to set or reset signals on sequential devices, using the following syntax: // synopsys one_hot signal_name_list For examples, see Inferring Flip-Flops on page 4-21 one_cold A one-cold implementation indicates that all signals in a group are active-low and that only one signal can be active at a given time Synthesis implements the one_cold directive by omitting a priority circuit in front of the flip-flop Simulation ignores the one_cold synthesis directive The one_cold directive prevents Design Compiler from implementing priority-encoding logic for the set and reset signals Attach this directive to set or reset signals on sequential devices, using the following syntax: // synopsys one_cold signal_name_list For examples, see Inferring Flip-Flops on page 4-21 don t_munch If you want to preserve all nets in a module, use the dont_munch directive in the module as shown in Example 7-20 See Internal Net Preservation on page 2-16 / 7-19

Example 7-20 synopsys dont_munch directive module m(p,d,out); input p,d; output out; wire w1, w2; /*synopsys dont_munch "w1, w2" */ assign w1= p&d; assign w2= p d; endmodule preserve_sequential The preserve_sequential directive allows you to preserve specific cells that would otherwise be optimized away by HDL Compiler See Sequential Cell Preservation on page 2-14 / 7-20