Académique Documents
Professionnel Documents
Culture Documents
Comments?
E-mail your comments about Synopsys
documentation to doc@synopsys.com
Copyright Notice and Proprietary Information
Copyright 2004 Synopsys, Inc. All rights reserved. This software and documentation contain confidential and proprietary
information that is the property of Synopsys, Inc. The software and documentation are furnished under a license agreement and
may be used or copied only in accordance with the terms of the license agreement. No part of the software and documentation may
be reproduced, transmitted, or translated, in any form or by any means, electronic, mechanical, manual, optical, or otherwise,
without prior written permission of Synopsys, Inc., or as expressly provided by the license agreement.
Right to Copy Documentation
The license agreement with Synopsys permits licensee to make copies of the documentation for its internal use only.
Each copy shall include all copyrights, trademarks, service marks, and proprietary rights notices, if any. Licensee must
assign sequential numbers to all copies. These copies shall contain the following legend on the cover page:
This document is duplicated with the permission of Synopsys, Inc., for the exclusive use of
__________________________________________ and its employees. This is copy number
__________.
All other product or company names may be trademarks of their respective owners.
ii
Contents
Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii
Related Publications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii
SolvNet Online Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Customer Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Conventions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x
1. General Guidelines
VHDL Coding Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
VHDL Value and Character Limits. . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
2. Testbench Guidelines
General Testbench Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
Clock Generation from the Testbench . . . . . . . . . . . . . . . . . . . . . . . 2-5
Clock Generation from the Main Clock . . . . . . . . . . . . . . . . . . . . . . 2-8
Reset Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
Data Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
iii
Stimulus and Response Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16
Message Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20
3. Design Guidelines
Pullups and Pulldowns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
Vectorization and Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
Combinatorial Logic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
Sequential Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
Clock Generation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
Gate-level Modeling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
iv
D Flip-Flop with Asynchronous Set and Reset . . . . . . . . . . . . . A-9
D Flip-Flop with Synchronous Reset or Set . . . . . . . . . . . . . . . . A-10
D Flip-Flop with Synchronous and Asynchronous Load . . . . . . A-11
D Flip-Flop with Asynchronous Reset, Set, Load, and Synchronous
Load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-12
JK Flip-Flops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-13
JK Flip-Flop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-13
JK Flip-Flop with Asynchronous Reset and Set. . . . . . . . . . . . . A-14
Toggle Flip-Flops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-15
Toggle Flip-Flop with Asynchronous Reset or Set . . . . . . . . . . . A-15
Toggle Flip-Flops with Enable and Asynchronous Reset. . . . . . A-17
v
Cycle Testbench Process Policy . . . . . . . . . . . . . . . . . . . . . . . . . . . B-18
The textio Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-18
Wait Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-19
Multiple Clocks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-20
VHDL Reserved Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-21
Index
vi
About This Manual
Audience
Related Publications
SolvNet Online Help
Customer Support
Conventions
vii
Audience
Related Publications
installation_directory/doc/online/sim/sc_home.pdf
http://www.synopsys.com
viii
SolvNet Online Help
solvitfb@synopsys.com
http://www.synopsys.com
Customer Support
Send e-mail to
support_center@synopsys.com
ix
Conventions
Convention Description
courier Indicates command syntax.
In command syntax and examples, shows
system prompts, text from files, error
messages, and reports printed by the
system.
courier italic Indicates a user specification, such as
object_name
courier bold In command syntax and examples, indicates
user input (text the user types verbatim).
[ ] Denotes optional parameters, such as pin1
[pin2, . . pinN]
| Indicates a choice among alternatives, such
as
low | medium | high
x
1
General Guidelines 1
VHDL coding style is the most important factor affecting simulation
speed. VHDL is a behavioral language, so you can write a model
many different ways. How you write your VHDL design models can
affect the performance of both the VHDL Analyzer and simulator.
This chapter describes the general coding guidelines for the following
topics:
General Guidelines
1-1
VHDL Coding Style
Guideline
Use the highest level of abstraction as possible to code your design.
The higher the level of abstraction of the modeling style, the faster
the simulation run. Thus, RTL style simulates faster than gate-level
and behavioral style simulates faster than RTL.
Guideline
Use variables rather than signals, especially when modelling memory
contents. Variables require much less memory and overhead which
yields to faster simulation.
Guideline
Group functionality into processes according to the signals that
activate that functionality. VCS MX cycle frequently groups related
processes as part of the overall cycle optimization techniques.
However, in event simulation, this task remains for the designer to
accomplish.
Guideline
Use commonly accepted synthesis coding templates. For sequential
processes, only include the clock and any required asynchronous
control signals in the sensitivity list. Use the synthesis accepted style
for synchronous and asynchronous controlled sequential processes
(see the Templates for Register Inference appendix).
General Guidelines
1-2
Guideline
Use complete sensitivity lists for combinatorial processes. Although
it is possible to not include all signals read in a combinatorial style
process in the sensitivity list (which can speed event simulation), but
using incomplete sensitivity lists can result in simulation/synthesis
and event simulation/cycle simulation mismatches.
Guideline
Minimize the use of text I/O. This includes minimizing the use of Read
and Write routines to parse or construct a formatted LINE-type
variable (whether that line is read or written from a file or not).
Guideline
Use subprograms for large processing blocks. Using subprograms
for small and simple blocks of code slows down the simulation.
General Guidelines
1-3
Guideline
Use the following IEEE standard VHDL types:
std_logic
std_logic_vector
std_ulogic
std_ulogic_vector
numeric_std signed and unsigned
std_logic_arith signed and unsigned
Guideline
Avoid bit-blasting. Bit-blasting refers to separation of vector signals
into scalar elements that are then operated on individually and then
re-grouped into the vector signal. Perform vector-level operations and
manipulations when possible.
Guideline
Perform operations only when necessary. For example, do not
convert a value into a string that is used only to report a message for
some exceptional condition. Ensure the value to string conversion
only occurs if the exception occurs.
Guideline
For loops in VCS MX cycle are unrolled. This can result in large
generated code which impacts performance if the number of iterations
is large and the loop contains significant operations. To decrease the
size of unrolled for loop code,
General Guidelines
1-4
Reduce the number of iterations (if possible). For example, use
vector operations or slice assignments instead of bit-level
operations and assignment.
Keep code that is loop-invariant outside the loop.
Reduce operations and calculations inside the loop. For example,
eliminate common expressions by using temporary variables.
Guideline
Structure branch logic optimally to avoid unnecessary expression
evaluation. For example, the following code is inefficient as both
condA and condB are always evaluated:
if condA then
target <= valueA;
end if;
if condB then
target <= valueB;
end if;
if condB then
target <= valueB;
elsif condA then
target <= valueA;
end if;
General Guidelines
1-5
Guideline
Minimize the number of signal assignments in a process. Signal
assignments are easy to write, but they require significant processing
under-the-hood. This overhead does not exist for combinatorial
signals in cycle simulation. The following is an example of an
inefficient description:
S <= default;
case sel is
when "00" => S <= valA;
when "01" => S <= valB;
when "10" => S <= valC;
when others => null;
end case;
var := default;
case sel is
when "00" => var := valA;
when "01" => var := valB;
when "10" => var := valC;
when others => null;
end case;
S <= var;
General Guidelines
1-6
VHDL Value and Character Limits
This section provides the rules for VHDL value and character limits.
Rule
The value range for VHDL objects is as follows:
Rule
The maximum number of characters you can use in items in your
VHDL design code is as follows:
General Guidelines
1-7
General Guidelines
1-8
2
Testbench Guidelines 1
This chapter presents a number of coding rules and guidelines for
testbenches. These guidelines help you construct VHDL testbenches
that are efficient for VCS MX in event and cycle mode.
Testbench Guidelines
2-1
In general, a testbench to be simulated in VCS MX cycle is limited to
the same VHDL constructs as synthesis and the design being
simulated in cycle mode. In addition to the synthesis policy, the cycle
testbench supports the use of behavioral style wait statements, assert
statements, and TEXTIO constructs.
Testbench Guidelines
2-2
General Testbench Guidelines
Rule
For a cycle testbench, use processes with behavioral wait statements
to create timing in the testbench and to model asynchronous activity.
Behavioral wait statements do not conform to the synthesis policy.
For example, wait for time is a behavioral wait statement. Thus,
these processes are identified as testbench processes (see above).
Testbench Guidelines
2-3
Do not use the after clause to produce delays or timing in your
models, cycle simulation ignores the after clause.
Testbench Guidelines
2-4
Guideline
Limit the use of behavioral waits that indicate cycle testbench
processes to the smallest number of processes possible. Testbench
processes cannot be optimized as effectively. Therefore, simulation
performance can be negatively impacted by a large number of cycle
testbench processes.
Guideline
Separate testbench code into non-synthesizable (behavioral) and
synthesizable style processes. Use behavioral code to read and write
data and to generate clocks and resets. Use non-testbench
processes (that is, synthesizable style) to model the synchronous
portions of the testbench, for example, to manipulate data in a finite
state machine.
This section provides rules and guidelines for generating clocks from
the testbench.
Rule
When using cycle simulation for the testbench as well as the design,
use a process suspension statement (wait) to create time and
generate clocks and waveforms. Do not use a scheduling statement
(after) to create timing. Cycle simulation ignores after clauses in signal
assignment statements.
Testbench Guidelines
2-5
Example 2-3 shows a simple clock process that fails to analyze for
cycle mode because of the multiple waveforms and after clause
(shown in bold). Example 2-4 shows a simple clock process that
generates the desired 50 ns clock period waveform.
Example 2-3 Using the after Clause Waveform Fragment Fails Analysis
junk : process
begin
CLK <= 0, 1 after 25 ns; --ERROR HERE
wait for 50 ns;
end process;
Example 2-4 Using the wait for time Statement Generates a Clock
clock : process
begin
CLK <= 0;
wait for 25 ns;
CLK <= 1;
wait for 25 ns;
end process;
Guideline
Generate clocks and asynchronous resets from a testbench process.
Testbench-driven clocks are globally implemented and simulate
faster than clocks generated in local design modules.
Guideline
When simulating the testbench in cycle mode, use separate
processes to generate multiple asynchronous clocks. VCS MX cycle
can simulate multiple clocks and each clock can contain different
(unrelated) clock periods. It is simplest and most efficient to use
multiple processes containing only wait for time statements to define
each clock, as shown in Figure 2-1 and Example 2-5.
Testbench Guidelines
2-6
Figure 2-1 Separate Processes to Generate Multiple Clocks
TESTBENCH DESIGN
Combo Combo
SEQ Logic Logic SEQ
Separate Testbench
Processes Clock A
Combo Combo
SEQ Logic Logic SEQ
Testbench
Clock B
Testbench Guidelines
2-7
Clock Generation from the Main Clock
Ideally, you must only use wait for time statements to create clocks
when simulating in cycle mode. In some cases, you might want to
create a clock that is synchronized to another clock or the main clock.
Examples of these derived clocks include clock dividers, clock
multipliers, and phase lock loops.
Guideline
When deriving clocks from a main clock, use only the derived clocks
in the design. The main clock must be restricted to the processes that
create the other clocks.
Testbench Guidelines
2-8
clk100 <= not clk100;
end loop;
clk50 <= not clk50;
end loop;
end process divider;
Note that the clock (clk200) has the same frequency as the main clock
(clk), but it is delayed by a delta cycle. The derived clocks occur
simultaneously and are the ones used by the design.
Reset Generation
This section provides rules and guidelines for creating resets from
the testbench. These rules and guidelines apply to asynchronous
resets because cycle simulation treats resets and clocks the same
way. You can also generate synchronous resets using the same
guidelines. These guidelines also apply to modeling other
asynchronous signals such as interrupt signals.
In general, apply the same rules to reset signals that you apply for
clocks. For instance, use minimum number of buffers or temporary
signals for connecting the reset signal to the registers.
Rule
Always pulse the reset signal to the active state from the inactive
state. Asynchronous resets in cycle simulation are edge triggered
even if in the registers they appear to be level sensitive. To ensure
the registers are reset properly, always create a reset process that
toggles the reset condition value. Example 2-7 creates a pulse for an
active-low reset.
Testbench Guidelines
2-9
Example 2-7 Generating Reset from a Testbench
reset: process
begin
RST<= 1;
wait for 25 ns;
RST<= 0;
wait for 100 ns;
RST<= 1;
wait;
end process;
Guideline
When simulating the design in cycle simulation (with the testbench
in either cycle or event), model asynchronous resets as you do clocks,
that is, generate resets globally from a testbench process. Use a wait
statement with no condition or time to indefinitely suspend the
processes that contain the reset.
Data Generation
This section provides guidelines for creating data other than simple
clocks in a testbench when simulating the design in cycle mode. You
can simulate the testbench in either cycle or event mode.
Rule
Avoid race conditions between data and clock. Applying the data and
active edge of the clock simultaneously might cause a race condition
during simulation and most likely unexpected results. This usually
causes mismatches between event simulation and cycle simulation.
Testbench Guidelines
2-10
To keep data synchronized with the clock while avoiding a race
condition, apply the data at a different point in the clock period than
at the active edge(s) of clock. If the clock has only one active edge,
apply the data during the inactive clock edge as shown in
Example 2-8.
You can also use wait until clkevent and clk=0" instead of wait for
time to synchronize a data generation process with the clock, as
shown in Example 2-9.
Testbench Guidelines
2-11
while not (data_done) loop
DATA1 <= X1;
DATA2 <= X2;
...
wait until clkevent and clk=0;
...
Guideline
Separate data generation from resets and clocks. Use separate
processes for these different functions as shown in Figure 2-2.
TESTBENCH DESIGN
Testbench
Reset
Guideline
For efficiency, model your testbench such that it executes
synchronously with the design you are testing. Remember that cycle
simulates the designs functionality and not timing delays. Apply data
at once on cycle boundaries using wait statements based on the clock
period. Example 2-10 shows an asynchronous testbench where data
is applied through out the clock period. Example 2-11 shows a
synchronous testbench where data is applied at once based on the
clock period.
Testbench Guidelines
2-12
Example 2-10 Using an Asynchronous Testbench (Not Recommended)
data: process
begin
...
elsif (memory_phase = true) then
wait for 5 ns; -- setup time
DATA1 <= X1;
wait for 2 ns; -- setup time
DATA2 <= X2;
wait for 3 ns; -- setup time
DATA3 <= X3;
wait for 3 ns; -- setup time
DATA4 <= X4;
wait for 7 ns; -- finish clock period
else
....
Guideline
Avoid using multiple subprograms or repeatedly calling the same
subprogram from a process when simulating in cycle mode. This
applies to user-defined subprograms (procedures or functions) and
not to the subprograms already analyzed into the Synopsys supplied
design libraries.
Testbench Guidelines
2-13
Subprograms are inlined in cycle simulation (including testbench
processes simulated in cycle mode), causing the virtual size of the
process to increase. Heavy use of subprograms can create virtual
processes so large that they significantly impact performance.This
can lead to very long elaboration times and can cause an out-of-
memory error during elaboration.
Testbench Guidelines
2-14
Example 2-12 Using Multiple Procedure Calls (Not Recommended)
decode: process
procedure do_instr(instr:t, data:d) is
begin
....
end do_instr;
begin
case I1 is
when "0000" => do_instr(STOP, data);
when "0001" => do_instr(JMP, data);
when "0010" => do_instr(CALL, data);
...
end case;
decode: process
procedure do_instr(instr:t, data:d) is
begin
....
end do_instr;
begin
case I1 is
when "0000" => instr := STOP;
when "0001" => instr := JMP;
when "0010" => instr := CALL;
...
end case;
do_instr(instr, data);
...
Testbench Guidelines
2-15
Stimulus and Response Files
This section provides guidelines for reading and writing stimulus files
from the VHDL testbench by using TEXTIO.
The most common method of reading data from files is using VHDL
TEXTIO files. Other methods of reading data include using (binary)
file I/O, using memories with the load_memory command, or using C
models via the VHDL PLI.
Rule
When simulating the testbench in cycle mode, access line types
using the read procedures defined in the TEXTIO and std_logic_textio
packages. The analyzer restricts most uses of the line access types
such as indexing when simulating in cycle mode. You can determine
the length of a line using the length attribute.
Testbench Guidelines
2-16
Example 2-14 Indexing a Line Fails Analysis (Not Recommended)
variable L : LINE;
...
--Skip Blank/Comment Lines
while not endfile ( infile ) loop
readline(infile, L );
if Llength = 0
or L(1) = # then next; -- ERRORS
end if;
end loop;
Testbench Guidelines
2-17
read(L, line_from_file(1 to Llength));
lin := line_from_file;
return;
end;
Guideline
When simulating the testbench in cycle mode, use procedures from
STD.textio or IEEE.std_logic_textio packages to read and parse the
files. User-defined procedures for reading and parsing files simulate
less efficiently, and heavy use of user-defined procedures can create
large virtual processes, which can cause elaboration problems.
Testbench Guidelines
2-18
Example 2-18 Using IEEE TEXTIO to Read Stimulus
(Recommended Coding)
use IEEE.std_logic_textio.all;
begin -- architecture
read_it: process
variable vline : line;
begin
readline (infile, vline);
hread (vline, v1);
Guideline
Avoid advancing simulation time based on time value read from the
TEXTIO file (Example 2-19). This style leads to an inefficient
testbench as the vector file controls the amount of time to advance.
Usually your vector file contains more than one line per clock. This
might be efficient only when your vector file contains waits for several
clocks before advancing time. Example 2-20 shows the wait for time
statement as the recommended coding style for reading and applying
vectors.
Testbench Guidelines
2-19
Example 2-20 Reading and Applying Vectors (Recommended Coding)
while not endfile(infile) loop
readline(infile, L);
wait for 50 ns; -- One clock
read(L, vDATA1);
DATA1 <= vDATA1;
read(L, vDATA2);
DATA2 <= vDATA2;
...
end loop;
Message Files
Guideline
Use TEXTIO instead of assert statements to print messages. TEXTIO
supports most data types and allows writing to multiple files. Asserts
are limited to strings only, and data types must be converted to strings
by inefficient functions. Example 2-21 shows the use of TEXTIO for
printing messages.
Testbench Guidelines
2-20
Guideline
Control the severity levels of assertions to reduce the amount of
assertion output when using assertions. VCS MX provides assertion
filtering capabilities with the following two simulation environment
variables:
ASSERT_IGNORE
Controls which user-defined assertions are ignored based on
severity level.
ASSERT_IGNORE_OPTIMIZED_LIBS
Controls the filtering of assertion messages generated from within
the optimized libraries (for example, IEEE.Numeric_Std,
IEEE.Std_Logic_1164).
By carefully planning the severity level of your assertions and by
setting these simulation environment variables, you can filter out
informational and non-error warning messages. This improves your
simulation performance and reduces the volume of data in the
simulation results which must be checked for true design errors.
Guideline
Use assert statements for printing text messages to avoid
performance degradation.
Testbench Guidelines
2-21
Testbench Guidelines
2-22
3
Design Guidelines 1
VCS MX cycle mode is designed to provide the best possible capacity
and performance for simulating synthesizable, register-transfer level
descriptions of synchronous circuits. However, as your VHDL code
departs from the coding style recommended for cycle simulation, a
gradual degradation in simulation performance occurs.
This chapter describes coding guidelines that allow you to get the
maximum advantage of the inherent speed and capacity from cycle
simulation. These guidelines will also improve the quality of your
synthesis results.
This chapter describes the design coding guidelines for the following
topics:
Design Guidelines
3-1
Combinatorial logic
Sequential logic
Clock generation
Gate-level modeling
For more information about design coding styles, see the VHDL
Compiler Reference Manual.
Guideline
Use only the strong corresponding states (0, 1, X, Z) of the standard
types to model pullups and pulldowns. Cycle simulation maps weak
states to strong ones, it maps H states to 1, L to 0. For example,
in cycle mode H and 0 states are resolved to X, because the H
is really a 1.
Guideline
Remove weak state pullups and pulldowns from the design, because
they do not simulate correctly. Use the types defined in the standard
IEEE.std_logic_1164 package to model pullups and pulldowns. For
pullups, use the tri1 and tri1_vector types. For pulldowns, use the tri0
and tri0_vector types.
Design Guidelines
3-2
In Example 3-1, pu_bit is resolved to 1 and pu_bus is resolved to
1101.
p2 : process
begin
...
pu_bit <= Z;
pu_bus <= ZZ01;
...
end process p1;
Guideline
If the pullup or pulldown functionality is implemented in an I/O PAD,
it is best to simulate the PAD cells in event simulation and only partition
the DUT into cycle simulation mode.
Note:
There might be other reasons for PAD cells to remain in event.
For example, signal assignments with after clauses which cannot
be modeled easily as cycle testbench processes and for which
the delays are necessary to ensure correct results.
Design Guidelines
3-3
Vectorization and Loops
Guideline
Use vector assignments and operations wherever possible.
Vectorization improves runtime performance because cycle
simulation maps vector operations to word operations on the target
computer.
Guideline
Use vectorization to make your code more compact and readable.
For example, you can set an entire array of arrays to zero (such as
arrays representing a RAM) as shown in Example 3-2.
Guideline
Do not use for loops to iterate over an array index, you lose the
compactness and performance advantages of vectorization.
Example 3-3 shows a slow method for computing a bitwise XOR. The
vectorized version in Example 3-4 produces a faster runtime
performance.
Example 3-3 Using Bitwise XOR with FOR loop (Not Recommended)
function SLOW_XOR(bbit : std_logic;
avec : std_logic_vector)
return std_logic_vector is
variable cvec : std_logic_vector(avecrange);
begin
for I in avecrange loop
Design Guidelines
3-4
cvec(I) := avec (I) XOR bbit;
end loop;
return(cvec);
end;
Combinatorial Logic
Guideline
Use complete sensitivity lists for combinatorial processes. Incomplete
sensitivity lists can cause a mismatch between cycle simulation (and
synthesis) and event simulation, as shown in Example 3-5 and Figure
3-1.
Design Guidelines
3-5
Example 3-5 shows a VHDL process that yields an OR gate when
synthesized and behaves like an OR gate in cycle simulation. Figure
3-1 shows an event simulator that complies with strict VHDL
semantics and does not propagate changes on signal B through the
gate until signal A changes.
B B
C C
Guideline
In case and if statements, be sure to cover all possible conditions,
and for each condition, specify what happens to all output signals.
Incomplete specifications, such as in Example 3-6, can lead to the
inference of unwanted latches in cycle simulation (and VHDL
Compiler).
Design Guidelines
3-6
Example 3-6 Using Incomplete if and case Statements
(Not Recommended)
process (A, B) begin
if (A = 1) then
Q <= B;
end if;--missing else clause!
end process;
Guideline
Do not insert VHDL assertion statements in combinatorial logic,
although they are supported in cycle simulation. Using assertion
statements in combinatorial logic can result in assertion message
mismatches between cycle and event simulation. The order in which
combinatorial processes are executed is not guaranteed in cycle
simulation. Nor does cycle simulation guarantee that combinatorial
processes are even executed during a given evaluation cycle.
Guideline
Do not use feedback loops that do not include a single register
element. They can degrade both simulation performance and
synthesis results. The cycle elaborator detects and reports warning
for such loops.
Design Guidelines
3-7
Sequential Logic
Guideline
Do not explicitly instantiate registers (flip-flops and latches) in the
source code, instead, let VCS MX infer them. This method can help
you to meet the design requirements without adhering to a particular
technology.
Certain VHDL templates imply (by VCS MX and the synthesis tools)
a particular register type. Example 3-7 shows a template for a
sequential process. A full catalog of templates is provided in the
Templates for Register Inference appendix.
Design Guidelines
3-8
Clock Generation
Guideline
Keep the gated clock process in a separate architecture, and make
the clock as global as possible. Example 3-8 shows the gated clock
architecture in bold.
Design Guidelines
3-9
Guideline
In zero-delay simulation (such as in cycle simulation), use an inverse
polarity sequential device to model the gated logic, or replace the
gated clock with a synchronous load if the clock and gate signals are
both generated from the same logic and they occur at the same time.
Otherwise, the gated clock does not function correctly.
If the clock and gate signals occur at a different time, the gated clock
will function properly.
DESIGN
SEQ
Gate Gated_CLK
Gating
Logic
CLK
Design Guidelines
3-10
Guideline
If you are using multiple clocks and gate signals, generate the clocks
at different times and make the gate signal occur before the clock
signals. For example, as shown in Figure 3-3, the CLKA and CLKB
signals must occur at different times and the Enable signal must
happen before the clock signals.
DESIGN
Combo Combo
SEQ Logic SEQ Logic SEQ
CLKA CLKB
Gating
Logic
Enable
Clocks must be at
different times
Design Guidelines
3-11
Guideline
Use negative edge registers in gating logic to ensure that the enable
and clock edge occur at different times. Later, you can replace the
negative edge registers with real logic for gate-level timing simulation.
Figure 3-4 shows a negative edge sequential device that is used in
the gating logic.
DESIGN
Combo
SEQ Logic
CLK SEQ
Gated_CLK
Enable
Combo
SEQ Logic Gate
SEQ
Gating Logic
Guideline
Do not use clock buffering because clock buffering can break up
processes into separate functions. Use one trigger function for each
clock region.
Design Guidelines
3-12
Gate-level Modeling
Guideline
Do not use gate-level simulation in cycle mode as it degrades
simulation performance. However, if it is necessary to use some gate-
level models, cycle simulation can handle VITAL Level 1 compliant
models in a functional mode. Ensure that both the design and the
VITAL component do not depend on accurate timing through the
VITAL component for correct results.
Design Guidelines
3-13
Guideline
When using VITAL Level 0 compliant models, ensure that the coding
style of the architecture closely follows that required for Level 1
compliant models in any of the timing areas (Wire Delay, Path Delay,
and Timing Checks) that the model includes.
Note:
Because all VITAL Level 1 compliant models are also Level 0
compliant, it is important to note that this guideline applies only to
those models which are only Level 0 compliant and not Level 1
compliant.
Guideline
Use VITAL models that conform to the VITAL 95 standard. VCS MX
does not support VITAL 2000.
Guideline
The GTECH library can be used for gate-level modeling with cycle
simulation. The GTECH library is compiled for cycle simulation.
Design Guidelines
3-14
Guideline
Use the novitaltiming option to scsim to enable fast functional event
simulation with VCS MX. Use this switch only if the design is not
dependent on accurate timing through the VITAL components.
Design Guidelines
3-15
Design Guidelines
3-16
4
Memory Model Guidelines 1
This chapter presents several rules and guidelines for coding ROM
and RAM memory models. These guidelines show examples of
coding both synchronous and asynchronous memory models. The
examples also show how to use the mem_api package to create
efficient sparse memory models. VCS MX provides the best
simulation performance when you use these guidelines.
This chapter describes coding rules and guidelines for the following
topics:
This section provides one rule and several guidelines for coding
memory models.
Rule
Do not use multi-dimensional arrays to model the memory, as shown
in Example 4-1. VCS MX cycle does not support multi-dimensional
arrays. Instead, use an array of arrays as shown in Example 4-2.
Guideline
Guideline
Clear dense memories by using a vector assignment and others
clauses instead of for loops. Example 4-4 shows, in bold, how to
properly clear a memory at reset.
Guideline
For asynchronous memories, use variables in the memory process.
With asynchronous memory models, you can use multiple enables
or clocks. Example 4-5 shows an asynchronous memory model that
contains a reset, write enable, read enable, and chip select.
Guideline
Use functions and procedures in the mem_api package to model
sparse memory models.
Example 4-6 and Example 4-7 show a sparse ROM and a RAM
modeled using the mem_api package. Basically, you use the previous
dense memory examples, but you only replace the variable
assignments with the signal assignment that calls the mem_init
function. The reading and writing to the memory is done using the
mem_read and mem_write procedures defined in the mem_api
package.
begin
READER: process (rclk)
variable v : std_logic_vector(n_data - 1 downto 0);
begin
if (rclkevent and rclk = 1) then
mem_read(handle, addr, v);
data <= v;
entity RAM is
generic (n_addr : natural; n_data : natural);
port (addr : in std_logic_vector(n_addr - 1 downto 0);
datain : in std_logic_vector(n_data - 1 downto 0);
dataout : out std_logic_vector(n_data - 1 downto 0);
rw : in std_logic
clk : in std_logic );
end;
architecture CYCLONE of RAM is
signal handle : memHandle := mem_init(MK_RAM, n_addr,
n_data);
begin
READER_WRITER: process (clk)
variable v : std_logic_vector(n_data - 1 downto 0);
begin
if (clkevent and clk = 1) then
if (rw = 0) then
mem_write(handle, addr, datain);
else
mem_read(handle, addr, v);
dataout <= v;
end if;
end if;
end process;
end;
Guideline
Guideline
Example 4-8 Dual Port RAM Modeling with Read/Write Conflict Checks
architecture behave of dual_port_ram is
type ram_type is array(0 to 2**addr_bits) of word;
begin
if rsta = 1 then
data_outa <= (others => 0);
if rstb = 1 then
data_outb <= (others => 0);
elsif clkbevent and clkb = 1 then
if web = 1 then
if porta_read and addra = addrb then
data_outa <= (others => X);
end if;
address := to_integer(addrb);
ram(address) := data_inb;
end if;
if (web = 1) or (enb = 1) then
if porta_write and addra = addrb then
data_outb <= (others => X);
else
address := to_integer(addrb);
data_outb <= ram(address);
end if;
end if;
D Latches
D Flip-Flops
JK Flip-Flops
Toggle Flip-Flops
For more detailed information about inferring latches and flip-flops,
see the Register, Multibit, Multiplexer, and Three-State Inference
chapter in the VHDL Compiler Reference Manual. Note, that VCS
MX ignores the directives and attributes that control the VHDL
Compilers inference mechanism. VCS MX relies entirely on the
structure of the template when it infers a register element.
AD
Asynchronous Data loaded when AL is active
AL
Asynchronous Load, also known as the gate or enable pin
AR
Asynchronous Reset
AS
Asynchronous Set
D Latch
Example A-1 infers a D latch with an enable and data input only. There
are no asynchronous or synchronous controls as inputs.
If you infer a D latch using the template in Example A-1, you must
ensure that the enable and data objects can be controlled from ports
of the top-level design or through combinatorial logic to ensure
initialization during simulation.
In Example A-2, data and gate are inputs to the AD pin on a latch
enabled by enable. In this example, the AL pin on the latch is not
driven by combinatorial logic, but the AD pin is. The AL pin is driven
by the enable port, which is the only expression listed in the condition
for the if statement. Figure A-1 illustrates a D latch with gated
asynchronous data.
Example A-6 infers a D latch with active low asynchronous reset and
set. Set has priority over reset in the logic synthesized for these
examples.
D Flip-Flops
Example A-15 D Flip-Flop with Asynchronous Reset, Set, and Load, and
Synchronous Load
entity dff_arsl_sl is
port( reset, set, aload, sload, clk :in std_logic;
adata,sdata : in std_logic_vector (3 downto 0);
q : out std_logic_vector (3 downto 0) );
end dff_arsl_sl;
JK Flip-Flop
Example A-16 shows a JK flip-flop with the truth table shown in Table
A-1.
architecture rtl of JK is
signal Q : std_logic;
Toggle Flip-Flops
This section lists VHDL language constructs and describes the level
of support provided for each constructs in cycle simulation. A
construct can be supported, ignored, or unsupported. Ignored
constructs can appear in your VHDL code without causing an error,
they simply have no effect. Unsupported means that the construct
cannot appear in your VHDL code. Either the VHDL Analyzer or the
cycle elaborator generate an error message when they find an
unsupported construct.
Note:
VCS MX ignores the synthesis translate_off, translate_on,
synthesis_off, and synthesis_on directives. The simulators
attempt to parse and generate executable code from the VHDL
source code between such directives. Therefore, all such VHDL
code must either conform to the cycle simulation policy or the
cycle testbench policy. (See the Cycle Testbench Policy later in
this appendix.)
Note:
VCS MX supports the pragma_resolution_method (which accepts
wired_and, wired_or, or three_state as the value) and
pragma_resolution_nodrivers (which accepts pullup or pulldown
as the value) pragmas.
Design units
Data types
Declarations
Design Units
entity
The entity statement part is ignored.
In VCS MX, the root of a cycle partition cannot have generics. Nor
can it have ports of an unconstrained type.
architecture
Multiple architectures are supported for an entity.
- MATH_COMPLEX
- STD_LOGIC_COMPONENTS
The following packages from SYNOPSYS library are not
supported:
- DISTRIBUTIONS
- INTEGER_QUEUES
- INTEGER_ZQUEUES
- BV_ARITHMETIC
library
Libraries and separate compilation are supported.
For bits and bit-vectors, use the std_logic and std_logic_vector types
defined in the IEEE std_logic_1164 package or the SIGNED and
UNSIGNED types from either the IEEE Numeric_Std or
std_logic_arith packages.
enumeration
Enumeration is supported.
integer
Integer is supported.
physical
The only supported physical type is time.
floating
Floating-point type declarations are supported.
record
Record data types are supported except in subprogram
declarative part. But, variables of a record type can be declared
in a subprogram declarative part.
access
Access type declarations are unsupported.
Only the line type is supported. Slicing and indexing a line variable
are unsupported. The TextIO Read and Write routines must be
used to manipulate line variables.
file
File names in a declaration must be globally static.
constant
Constant declarations are supported except for deferred constant
declarations.
signal
The register and bus declarations are treated as normal signals
only.
Only signal declarations that are from a globally static type are
supported.
variable
Only declarations that are from a globally static type are
supported. Except declarations within a subprogram can depend
on input parameters (such as the range of an input vector
parameter can be used to define a temporary variable of the same
size).
file
File declarations are supported in packages.
interface
buffer and linkage are translated to out and inout, respectively.
The driving or sourcing value of buffer ports can be read within
the design entity.
alias
Aliases of objects (signals, variables, constants) are supported.
All other aliases are not supported in cycle mode.
component
Component declarations are supported.
Specifications
disconnection
Disconnection specifications are unsupported.
Names
simple
Simple names are supported.
operator symbols
Operator symbols are supported.
indexed
Indexed names are supported but indexing objects of type line is
unsupported.
slice
Slice names are supported but slicing objects of type line is
unsupported.
Attributes
predefined
The only supported predefined attributes are base, left, right, high,
low, range, reverse_range, and length.
Or
Synopsys-defined
The only attribute supported by Cyclone is the TABLE attribute.
There are two table attributes. The cyclone_table_eval_fn
attribute enables table optimization and the
cyclone_table_input_width attribute tells the cycle elaborator how
many inputs there are. For example,
user-defined
User-defined attributes are unsupported.
Operators
logical
Logical operators are supported. The operators sll, srl, sla, sra,
ror, rol and xnor are supported only for the IEEE Numeric_Std
SIGNED and UNSIGNED types.
relational
Relational operators are supported.
signing
Sign operators are supported.
multiplying
The * (multiply) operator is supported.
miscellaneous
The ** operator is supported.
operator overloading
Operator overloading is supported.
short-circuit operations
The short-circuit behavior of operators is only supported in a cycle
testbench process.
based literals
Based literals are supported.
1 downto 12
BUSA(5 to 0)
physical literals
Only physical literals of types time are supported.
strings
Strings are supported.
aggregates
The use of types as aggregate choices is unsupported.
qualified expressions
Qualified expressions are supported.
type conversion
Type conversion is supported. Type conversions on formal ports
in a port map are unsupported.
allocators
Allocators are unsupported.
static expressions
Static expressions are supported.
Sequential Statements
wait
Outside a testbench process, the wait statement is unsupported
unless it is in one of the following synthesizable sequential
template forms as the first statement in the process:
assertion
report
report statement is unsupported.
signal
Guarded signal assignment is unsupported.
variable
Variable statements are supported.
procedure call
Type conversion on formal parameters is unsupported.
if
if statements are supported.
case
case statements are supported.
next
next statements are supported.
exit
exit statements are supported.
return
return statements are supported.
null
null statements are supported.
Concurrent Statements
process
concurrent procedure call
concurrent assertion
generate
severity_level type
time type
now function
TEXTIO package
predefined attributes
The only supported predefined attributes are: base, left, right,
high, low, range, reverse_range, and length.
The event and stable attributes are supported only in the if and
wait statements following the synthesis coding style.
The textio package provides procedures for reading and writing ASCII
files during simulation. All textio procedures defined in the IEEE VHDL
Standard Language Reference Manual are supported. In addition,
the procedures defined in the Synopsys package
IEEE.std_logic_textio are supported.
Note:
You cannot read from stdin using textio routines within a cycle
partition in VCS MX.
wait;
The process suspends forever.
wait on signal_list;
The process activates whenever there is an event on any of the
signals in the signal list.
You can also use on, until, and for clauses in combination, as in
Multiple Clocks
Do not use the following words as identifiers, they are reserved for
the VHDL language:
a for port
abs function procedure
access g process
after generate postponed
alias generic pure
all group r
and guarded range
architecture i record
array impure register
assert in reject
attribute inertial rem
b inout report
begin is rol
block l ror
body label s
buffer library select
bus literal severity
c linkage shared
case loop signal
component m sla
configuration mod sll
constant n sra
d nand srl
disconnect next subtype
downto not t
e null the
else o to
elsif of transport
end open type
entity or u
exit out unaffected
f p unit
file package until
Architecture A of E is
Signal foo : std_ulogic_vector (1 to 7);
begin
p1: process (sws)
begin
for i in 1 to 3 loop
foo(i) <=sws;
end loop;
end process;
p2: process (swr)
begin
for i in 4 to 7 loop
foo(i) <=swr;
end loop;
end process;
end;
According to the LRM, p1 and p2 drive the entire vector foo (because
the index i is not static). The signal foo must be a resolved type.
Sensitivity Lists
In most cases, cycle ignores the user-supplied process sensitivity list
(the same as synthesis).
Signal Initialization
Cycle simulators do not follow the LRM semantics for process
evaluation at simulation startup. Cycle simulators only execute the
combinatorial and testbench processes at time 0, whereas event
simulators execute all the processes (combinatorial and sequential)
at time 0. As with synthesis, do not depend on the LRM semantics
for the correct initialization of the design, especially in sequential logic
design.
Symbols E
length attribute 2-16 expressions B-11
A F
after clause 2-4, 2-5 for loops 3-4
array index 3-4
assert statements 2-21
attributes B-9
G
gated clocks C-1
C
case statements 3-6
H
clock divider 2-8 help -ix
clock generation 2-5, 2-8
combinatorial logic 3-5 I
comment lines 2-16
IEEE.std_logic_textio package 2-18
if statements 3-6
D initialization, signal C-3
data generation 2-10
data types B-5 K
declarations B-7
keywords B-21
design units B-3
documentation, SolvNet -ix
IN-1
L SolvNet -ix
specifications B-8
latches
inference 3-6 statements
case 3-6
limits
VHDL values 1-7 concurrent B-16
if 3-6
incomplete 3-6
M sequential B-14
wait B-19
multiple clocks 2-6
STD.textio package 2-18
stimulus files 2-16
N subprograms 2-13, B-14
names B-8 synthesizable code 2-5
nonsynthesizable code 2-5
T
O templates
online documentation -ix definition 3-8
operands B-11 testbenches
policy B-18
operators B-10
TEXTIO file 2-16, 2-17
P U
predefined language environment B-17
user-defined procedures 2-18
printing messages 2-20
process drivers C-2
pullups and pulldowns 3-2 V
values, maximum and minimum in VHDL 1-7
R vectors
assignments 3-4
race conditions 2-10 for loops 3-4
reserved words B-21 VHDL
reset generation 2-6, 2-9 coding style
resolution functions C-3 effect on simulation speed 1-1
keywords B-21
language
S implementation limits 1-7
sensitivity lists 3-5, C-3 predefined language environment B-17
sequential logic 3-8 reserved words B-21
signal initialization C-3 virtual processes 2-14
IN-2
W
wait statements 2-3, 2-5, 2-8, 2-11
IN-3
IN-4