- •Preface
- •About This Manual
- •Other Information Sources
- •Syntax Conventions
- •Text Command Syntax
- •About the Graphical User Interface
- •Using Menus
- •Using Forms
- •HDL Synthesis Overview
- •HDL Synthesis Flow
- •Read Technology Libraries
- •Read Design Data
- •Build Generic Design
- •Save Generic Netlist
- •Synthesizing Mixed VHDL/Verilog Designs
- •Querying the HDL Design Pool
- •Using get_hdl_top_level Command
- •Using get_hdl_hierarchy Command
- •Using get_hdl_type Command
- •Building Generic Netlists from HDL
- •Multiple Top-Level Designs
- •Building Parameterized Designs
- •Verilog Modeling Styles
- •Modeling Combinational Logic
- •Register Inferencing
- •Latch Inference
- •Flip-Flop Inference
- •case Statements
- •Incomplete case Statement
- •Complete case Statement
- •Use of casex and casez Statements
- •for Statement
- •Synthesis Directives
- •Code Selection Directives
- •Architecture Selection Directive
- •case Statement Directives
- •Module Template Directive
- •Function and Task Mapping Directives
- •Set and Reset Synthesis Directives
- •Verilog Preprocessor Directives
- •Compiler Directives
- •The ‘for Compiler Directive
- •The ‘if Compiler Directive
- •The ‘eval Compiler Directive
- •The ‘{} Compiler Directive
- •Command Line Options
- •VPP Flag Attribute
- •Verilog-Related Commands and Globals
- •VHDL Modeling Style
- •Modeling Combinational Logic
- •Register Inferencing
- •Latch Inference
- •Flip-Flop Inferencing
- •Specifying Clock Edges
- •case Statement
- •Incomplete case Statement
- •Complete case Statement
- •for loop
- •Synthesis Directives
- •Code Selection Directives
- •Architecture Selection Directive
- •case Statement Directive
- •Enumeration Encoding Directive
- •Entity Template Directive
- •Function and Procedure Mapping Directives
- •Signed Type Directive
- •Resolution Function Directives
- •Type Conversion Directives
- •Set and Reset Synthesis Directives
- •Reading VHDL Designs
- •Using Arithmetic Packages From Other Vendors
- •Switching between VHDL’87 / VHDL’93
- •Reusing Previously Analyzed Entities
- •Modifying Case of VHDL Names
- •Writing VHDL Netlists
- •Selecting Bit-Level Representation
- •Selecting Between VHDL’87 and VHDL’93
- •Referring to VHDL Packages in Netlists
- •Writing Component Declarations
- •Hierarchical VHDL Designs
- •Component Instantiations and Bindings
- •Restrictions on Entities with Multiple Architectures
- •Precedence Rules for Architecture Selection
- •VHDL-Related Commands and Globals
- •Finite State Machine Overview
- •BuildGates Synthesis and Finite State Machines
- •Extracting the State Transition Table for the FSM
- •Viewing the State Transition Table for the FSM
- •FSM Optimization Features
- •Unreachable State Removal
- •State Assignment or Re-Encoding
- •State Minimization
- •Terminal State Check
- •Verilog and VHDL FSM Directives
- •Verilog FSM Directives
- •VHDL FSM Directives
- •FSM Coding Styles
- •Using the -reachable Option
- •Avoiding a Simulation Mismatch
- •EDIF Interface
- •Reading EDIF Designs
- •Writing EDIF Designs
- •Representing Power and Ground in EDIF
- •Net Representation for Power and Ground
- •Port Representation for Power and Ground
- •Instance Representation for Power and Ground
- •Verilog Constructs
- •Fully Supported Constructs
- •Declarations
- •Operators and Expressions
- •Partially Supported Constructs
- •Ignored Constructs
- •Unsupported Constructs
- •Summary of Verilog Constructs
- •VHDL Constructs
- •Notes on Supported Constructs
Envisia HDL Modeling Reference
Verilog Modeling Styles
Only single-bit controls are accepted for set and reset. See Synthesis Directives on page 31 for more information on controlling the set and reset connections for a flip-flop.
case Statements
Using a case statement allows for multi-way branching in a functional description. When a case statement is used as a decoder to assign one of several different values to a variable, the logic can be implemented as combinational or sequential logic based on whether the variable is assigned a value in branches of the case statement. Ambit BuildGates synthesis automatically determines whether a case statement is full and/or parallel. A case statement is full if all possible case items are specified. A case statement is parallel if none of the case items overlap. If automatic determination of full and/or parallel case is not possible, the full and parallel case directives can be used (see Full Case Directive on page 34, Parallel Case Directive on page 35).
The following sections describe the impact on synthesis for different use models and types of case statements.
■Incomplete case Statement on page 27
■Complete case Statement on page 28
■Use of casex and casez Statements on page 28
Incomplete case Statement
When a case statement specifies only some of the values that the case expression can possibly have, a latch is inferred. For example, a state transition table may be modeled as follows:
reg [2:0] curr_state, next_state, modifier; always @ (modifier)
case (curr_state)
3’b000 : next_state = 3’b100 & modifier ; 3’b001 : next_state = 3’b110 | modifier ; 3’b010 : next_state = 3’b001 & modifier ; 3’b100 : next_state = 3’b101 | modifier ; 3’b101 : next_state = 3’b010 & modifier ; 3’b110 : next_state = 3’b000 | modifier ;
endcase
September 2000 |
27 |
Product Version 4.0 |
Envisia HDL Modeling Reference
Verilog Modeling Styles
The next_state variable is assigned a new value if curr_state is any one of the six values specified. For the other two possible states, the next_state variable retains its previous value. This behavior causes the software to infer a 3-bit latch for next_state.
Complete case Statement
If you do not want to infer a latch, the next_state variable must be assigned a value under all situations. In other words, the next_state variable should have a default value.
Assigning a Default Value for Incomplete case Statements
There are several ways to assign a default value to next_state.
■The first approach model follows:
next_state = 3’b000 ; // unconditional assignment
case (curr_state)
…
endcase
The next_state variable is assigned a value unconditionally, then it is modified appropriately by the case statement. This approach prevents the software from inferring
a latch.
■The second approach model follows:
case (curr_state)
…
default : next_state = 3’b000 ; // all other cases endcase
Use the default case in the case statement to capture all the remaining cases where the next_state variable is assigned a value. This approach also prevents the software from inferring a latch.
■The third approach model uses the full case synthesis directive as discussed in Full Case Directive on page 34. This states that the simulation results between functional and gate level models may mismatch if this synthesis directive is used.
Use of casex and casez Statements
The casex and casez statements allow the x, z and ? values to be treated like don’t care conditions when comparing for the matching case. These statements are treated like case statements with the following differences:
September 2000 |
28 |
Product Version 4.0 |
Envisia HDL Modeling Reference
Verilog Modeling Styles
■casez statement allows z and ? to be treated as a don’t care condition
■casex statement allows x, z and ? to be treated as a don’t care condition
The following model shows a casez statement using don’t care conditions to mask three of the four bits in the decoding select line (input sel).
module casez_example(sel, out); input [3:0] sel;
output [1:0] out; reg [1:0] out; always @ (sel) begin
casez (sel)
4’b???1 : out = 2’b00; 4’b??1? : out = 2’b01; 4’b?1?? : out = 2’b10; 4’b1??? : out = 2’b11;
endcase
end
endmodule
In the example out will be set to 2’b00 if sel[0] = 1, regardless of the values of sel[3], sel[2] and sel[1]; out will be set to 2’b01 only if sel[0] = 0 and sel[1] = 1, regardless of the values of sel[3] and se[2].
If you perform technology independent mapping, running read_verilog and do_build_generic provides you with a report of the casez statement as shown below.
ac_shell[1]> read_verilog casez.v
ac_shell[2]> do_build_generic
Info: |
Processing design ’casez_example’ <CDFG-303>. |
|||||||
|
Statistics for case statements in module ’casez_example’ (File casez.v)<CDFG-800>. |
|||||||
|
+---------------------------------------- |
|
|
|
|
|
|
+ |
|
| |
Case Statistics Table |
|
| |
||||
|
|---------------------------------------- |
|
|
|
|
|
|
| |
|
| Line |
| |
Type |
| |
Full |
| Parallel | |
||
|
|--------- |
+ |
--------- |
+ |
--------- |
+ |
---------- |
| |
|
| |
6 | |
casez |
| |
NO |
| |
NO |
| |
|
+---------------------------------------- |
|
|
|
|
|
|
+ |
+ |
Finished processing module: ’casez _ example’ |
<ALLOC-110>. |
+ |
||||||||
-------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
||
| |
|
|
Table for sequential elements |
|
|
|
|
|
| |
||
|-------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
|
| |
| |
File Name |
| Line | Register | Type |
| Width | |
AS |
| AR |
| SS | SR | |
|||||
| |
|
| |
| |
Name | |
| |
| |
|
| |
| |
| |
| |
|-------------------- ------ ---------- ------- ------- ---- ---- ---- ---- |
|
+ |
+ |
+ |
+ |
+ |
|
+ |
+ |
+ |
| |
| casez.v |
| |
5 | |
out_reg | Latch |
| 2 |
| |
N |
| N |
| |
- | |
- | |
|
+-------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
|
+ |
September 2000 |
29 |
Product Version 4.0 |