Return to previous page Advance to next page
Synthesis and Simulation Design Guide
Chapter 5: Simulating Your Design

Setting VHDL Global Set/Reset Emulation in Functional Simulation

When using the VHDL UniSim library, it is important to control the global signals for reset and output tristate enable. If do not control these signals, your timing simulation results will not match your functional simulation results because the initialization differs.

VHDL simulation does not support test bench driven internal global signals. If the test bench drives the global signal, a port is required. Otherwise, the global net must be driven by a component within the architecture.

Also, the register components do not have pins for the global signals because you do not want to wire to these special pre-laid nets. Instead, you want implementation to use the dedicated network on the chip.

For the HDL synthesis flow, the global reset and output tristate enable signals are emulated with the local reset and tristate enable signals. Special implementation directives are put on the nets to move them to the special pre-routed nets for global signals.

The VHDL UniSim library uses special components to drive the local reset and tristate enable signals. These components use the local signal connections to emulate the global signal, and also provide the implementation directives to ensure that the pre-routed wires are used.

You can instantiate these special components in the RTL description to ensure that all functional simulations match the timing simulation with respect to global signal initializations.

Global Signal Considerations (VHDL)

The following are important to VHDL simulation, synthesis, and implementation of global signals in FPGAs.

GSR Network Design Cases

When defining a methodology to control a device's global set/reset (GSR) network, you should consider the following three general cases.

Table 5_7 GSR Design Cases

Name
Description
Case 1

Case 1A
Case 1B
Reset-On-Configuration pulse only; no user control of GSR
Simulation model ROC initializes sequential elements
User initializes sequential elements with ROCBUF model and simulation vectors
Case 2
Case 2A
Case 2B
User control of GSR after Power-on-Reset
External Port driving GSR
Internal signal driving GSR
Case 3
Don't Care

Note: Reset-on-Configuration for PLDs is similar to Power-on-Reset for ASICs except it occurs at power-up and during configuration of the PLD.

Case 1 is defined as follows.

Using VHDL Reset-On-Configuration (ROC) Cell (Case 1A)

For Case 1A, the ROC (Reset-On-Configuration) instantiated component model is used. This model creates a one-shot pulse for the global set/reset signal. The pulse width is a generic and can be configured to match the device and conditions specified. The ROC cell is in the post-routed netlist and, with the same pulse width, it mimics the pre-route global set/reset net. The following is an example of an ROC cell.

Note: The TPOR parameter from The Programmable Logic Data Book is used as the WIDTH parameter.

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
library UNISIM;
use UNISIM.all;
entity EX_ROC is
port (CLOCK, ENABLE : in std_logic;
CUP, CDOWN : out std_logic_vector (3 downto 0));
end EX_ROC;
architecture A of EX_ROC is
signal GSR : std_logic;
signal COUNT_UP, COUNT_DOWN : std_logic_vector (3 downto 0);
component ROC
port (O : out std_logic);
end component;
begin
U1 : ROC port map (O => GSR);

UP_COUNTER : process (CLOCK, ENABLE, GSR)
begin
if (GSR = '1') then
COUNT_UP <= "0000";
elsif (CLOCK'event AND CLOCK = '1') then
if (ENABLE = '1') then
COUNT_UP <= COUNT_UP + "0001";
end if;
end if;
end process UP_COUNTER;
DOWN_COUNTER : process (CLOCK, ENABLE, GSR, COUNT_DOWN)
begin
if (GSR = '1' OR COUNT_DOWN = "0101") then
COUNT_DOWN <= "1111";
elsif (CLOCK'event AND CLOCK = '1') then
if (ENABLE = '1') then
COUNT_DOWN <= COUNT_DOWN - "0001";
end if;
end if;
end process DOWN_COUNTER;
CUP <= COUNT_UP;
CDOWN <= COUNT_DOWN;
end A;

Using ROC Cell Implementation Model (Case 1A)

Complementary to the previous VHDL model is an implementation model that guides the place and route tool to connect the net driven by the ROC cell to the special purpose net.

This cell is created during back-annotation if you do not use the -gp or STARTUP block options. It can be instantiated in the front end to match functionality with GSR, GR, or PRLD (in both functional and timing simulation.) During back-annotation, the entity and architecture for the ROC cell is placed in your design's output VHDL file. In the front end, the entity and architecture are in the UniSim Library, requiring only a component instantiation. The ROC cell generates a one-time initial pulse to drive the GR, GSR, or PRLD net starting at time zero for a specified pulse width. You can set the pulse width with a generic in a configuration statement. The default value of the pulse width is 0 ns. This value disables the ROC cell and causes the global set/reset to be held low. (Active low resets are handled within the netlist itself and need to be inverted before using.)

ROC Test Bench (Case 1A)

With the ROC cell you can simulate with the same test bench used in RTL simulation, and you can control the width of the global set/reset signal in your implemented design. ROC cells require a generic WIDTH value, usually specified with a configuration statement. Otherwise, a generic map is required as part of the component instantiation. You can set the generic with any generic mapping method. Set the width generic after consulting The Programmable Logic Data Book for the particular part and mode implemented. For example, an XC4000E part can vary from 10 ms to 130 ms. Use the TPOR parameter in the Configuration Switching Characteristics tables for Master, Slave, and Peripheral modes. The following is the test bench for the ROC example.

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;

library UNISIM;
use UNISIM.all;

entity test_ofex_roc is end test_ofexroc;

architecture inside of test_ofex_roc is

Component ex_roc
Port ( CLOCK, ENABLE: in STD_LOGIC;
CUP, CDOWN: out STD_LOGIC_VECTOR (3 downto 0));
End component;

.
.
.

Begin

UUT: ex_roc port map(. . . .);
.
.
.
End inside;

The best method for mapping the generic is a configuration in your test bench, as shown in the following example.

Configuration overall of test_ofexroc is
For inside
For UUT:ex_roc
For A
For U1:ROC use entity UNISIM.ROC (ROC_V)
Generic map (WIDTH=>52 ns);
End for;
End for;
End for;
End overall;

This configuration is for pre-NGDBuild simulation. A similar configuration is used for post-NGDBuild simulation. The ROC, TOC, and OSC4 are mapped to the WORK library, and corresponding architecture names may be different. Review the .vhd file created by NGD2VHDL for the current entity and architecture names for post-NGDBuild simulation.

ROC Model in Four Design Phases (Case 1A)

The following figure shows the progression of the ROC model and its interpretation in the four main design phases.

Figure 5.3 ROC Simulation and Implementation

Using VHDL ROCBUF Cell (Case 1B)

For Case 1B, the ROCBUF (Reset-On-Configuration Buffer) instantiated component is used. This component creates a buffer for the global set/reset signal, and provides an input port on the buffer to drive the global set reset line. During the place and route process, this port is removed so it is not implemented on the chip. ROCBUF does not reappear in the post-routed netlist. Instead, you can select an implementation option to add a global set/reset port to the back-annotated netlist. A buffer is not necessary since the implementation directive is no longer required.

The following example illustrates how to use the ROCBUF in your designs.

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;

library UNISIM;
use UNISIM.all;
entity EX_ROCBUF is
port (CLOCK, ENABLE, SRP : in std_logic;
CUP, CDOWN : out std_logic_vector (3 downto 0));
end EX_ROCBUF;
architecture A of EX_ROCBUF is
signal GSR : std_logic;
signal COUNT_UP, COUNT_DOWN : std_logic_vector (3 downto 0);
component ROCBUF
port (I : in std_logic;
O : out std_logic);
end component;
begin
U1 : ROCBUF port map (I => SRP, O => GSR);
UP_COUNTER : process (CLOCK, ENABLE, GSR)
begin
if (GSR = '1') then
COUNT_UP <= "0000";
elsif (CLOCK'event AND CLOCK = '1') then
if (ENABLE = '1') then
COUNT_UP <= COUNT_UP + "0001";
end if;
end if;
end process UP_COUNTER;
DOWN_COUNTER : process (CLOCK, ENABLE, GSR, COUNT_DOWN)
begin
if (GSR = '1' OR COUNT_DOWN = "0101") then
COUNT_DOWN <= "1111";
elsif (CLOCK'event AND CLOCK = '1') then
if (ENABLE = '1') then
COUNT_DOWN <= COUNT_DOWN - "0001";
end if;
end if;
end process DOWN_COUNTER;
CUP <= COUNT_UP;
CDOWN <= COUNT_DOWN;
end A;

ROCBUF Model in Four Design Phases (Case 1B)

The following figure shows the progression of the ROCBUF model and its interpretation in the four main design phases.

Figure 5.4 ROCBUF Simulation and Implementation

Using VHDL STARTBUF Block (Case 2A and 2B)

The STARTUP block is traditionally instantiated to identify the GR, PRLD, or GSR signals for implementation if the global reset on tristate is connected to a chip pin. However, this implementation directive component cannot be simulated, and causes warning messages from the simulator. However, you can use the STARTBUF cell instead, which can be simulated. STARTUP blocks are allowed if the warnings can be addressed or safely ignored.

For Cases 2A and 2B, use the STARTBUF cell. This cell provides access to the input and output ports of the STARTUP cell that direct the implementation tool to use the global networks. The input and output port names differ from the names of the corresponding ports of the STARTUP cell. This was done for the following reasons.

The mapping to the architecture-specific STARTUP cell from the instantiation of the STARTBUF is done during implementation. The STARTBUF pins have the suffix “IN” (input port) or “OUT” (output port). Two additional output ports, GSROUT and GTSOUT, are available to drive a signal for clearing or setting a design's registers (GSROUT), or for tri-stating your design's I/Os (GTSOUT).

The input ports, GSRIN and GTSIN, can be connected either directly or indirectly via combinational logic to input ports of your design. Your design's input ports appear as input pins in the implemented design. The design input port connected to the input port, GSRIN, is then referred to as the device reset port, and the design input port connected to the input port, GTSIN, is referred to as the device tristate port. The following table shows the correspondence of pins between STARTBUF and STARTUP.

Table 5_8 STARTBUF/STARTUP Pin Descriptions

STARTBUF Pin Name
Connection Point
XC4000 STARTUP Pin Name
XC5200 STARTUP Pin Name
Spartan
GSRIN
Global Set/Reset Port of Design
GSR
GR
GSR
GTSIN
Global Tristate Port of Design
GTS
GTS
GTS
GSROUT
All Registers Asynchronous Set/Reset
Not Available For Simulation Only
Not Available For Simulation Only
Not Available For Simulation Only
GTSOUT
All Output Buffers Tristate Control
Not Available For Simulation Only
Not Available For Simulation Only
N/A
CLKIN
Port or INternal Logic
CLK
CLK
CLK
Q2OUT
Port Or Internal Logic
Q2
Q2
Q2
Q3OUT
Port Or Internal Logic
Q3
Q3
Q3
OUT
Port Or Internal Logic
Q1Q4
Q1Q4
Q1Q4
DONEINOUT
Port Or Internal Logic
DONEIN
DONEIN
DONEIN

Note: Using STARTBUF indicates that you want to access the global set/reset and/or tristate pre-routed networks available in your design's target device. As a result, you must provide the stimulus for emulating the automatic pulse as well as the user-defined set/reset. This allows you complete control of the reset network from the test bench.

The following example shows how to use the STARTBUF cell.

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
library UNISIM;
use UNISIM.all;
entity EX_STARTBUF is
port (CLOCK, ENABLE, DRP, DTP : in std_logic;
CUP, CDOWN : out std_logic_vector (3 downto 0));
end EX_STARTBUF;
architecture A of EX_STARTBUF is
signal GSR, GSRIN_NET, GROUND, GTS : std_logic;
signal COUNT_UP, COUNT_DOWN : std_logic_vector (3 downto 0);
component STARTBUF
port (GSRIN, GTSIN, CLKIN : in std_logic; GSROUT, GTSOUT,
DONEINOUT, Q1Q4OUT, Q2OUT, Q3OUT : out std_logic);
end component;
begin
GROUND <= '0';
GSRIN_NET <= NOT DRP;
U1 : STARTBUF port map (GSRIN => GSRIN_NET, GTSIN => DTP,
CLKIN => GROUND, GSROUT => GSR, GTSOUT => GTS);
UP_COUNTER : process (CLOCK, ENABLE, GSR)
begin
if (GSR = '1') then
COUNT_UP <= "0000";
elsif (CLOCK'event AND CLOCK = '1') then
if (ENABLE = '1') then
COUNT_UP <= COUNT_UP + "0001";
end if;
end if;
end process UP_COUNTER;
DOWN_COUNTER : process (CLOCK, ENABLE, GSR, COUNT_DOWN)
begin
if (GSR = '1' OR COUNT_DOWN = "0101") then
COUNT_DOWN <= "1111";
elsif (CLOCK'event AND CLOCK = '1') then
if (ENABLE = '1') then
COUNT_DOWN <= COUNT_DOWN - "0001";
end if;
end if;
end process DOWN_COUNTER;
CUP <= COUNT_UP when (GTS = '0' AND COUNT_UP /= "0000") else "ZZZZ";
CDOWN <= COUNT_DOWN when (GTS = '0') else "ZZZZ";
end A;

GTS Network Design Cases

Just as for the global set/reset net there are three cases for using your device's output tristate enable (GTS) network, as shown in the following table.

Table 5_9 GTS Design Cases

Name
Description
Case A
Case A1

Case A2
Tristate-On-Configuration only; no user control of GTS
Simulation Model TOC Tristates output buffers during configuration or power-up
User initializes sequential elements with TOCBUF model and simulation vectors
Case B
Case B1
Case B2
User control of GTS after Tristate-On-Configuration
External PORT driving GTS
Internal signal driving GTS
Case C
Don't Care

Case A is defined as follows.

Using VHDL Tristate-On-Configuration (TOC)

The TOC cell is created if you do not use the -tp or STARTUP block options. The entity and architecture for the TOC cell is placed in the design's output VHDL file. The TOC cell generates a one-time initial pulse to drive the GR, GSR, or PRLD net starting at time `0' for a user-defined pulse width. The pulse width can be set with a generic. The default WIDTH value is 0 ns, which disables the TOC cell and holds the tristate enable low. (Active low tristate enables are handled within the netlist itself; you must invert this signal before using it.)

The TOC cell enables you to simulate with the same test bench as in the RTL simulation, and also allows you to control the width of the tristate enable signal in your implemented design.

The TOC components require a value for the generic WIDTH, usually specified with a configuration statement. Otherwise, a generic map is required as part of the component instantiation.

You may set the generic with any generic mapping method you choose. Set the WIDTH generic after consulting The Programmable Logic Data Book for the particular part and mode you have implemented. For example, an XC4000E part can vary from 10 ms to 130 ms. Use the TPOR (Power-On Reset) parameter found in the Configuration Switching Characteristics tables for Master, Slave, and Peripheral modes.

VHDL TOC Cell (Case A1)

For Case A1, use the TOC (Tristate-On-Configuration) instantiated component. This component creates a one-shot pulse for the global Tristate-On-Configuration signal. The pulse width is a generic and can be selected to match the device and conditions you want. The TOC cell is in the post-routed netlist and, with the same pulse width set, it mimics the pre-route Tristate-On-Configuration net.

TOC Cell Instantiation (Case A1)

The following is an example of how to use the TOC cell.

Note: The TPOR parameter from The Programmable Logic Data Book is used as the WIDTH parameter in this example.

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
library UNISIM;
use UNISIM.all;
entity EX_TOC is
   port (CLOCK, ENABLE : in std_logic;  
         CUP, CDOWN : out std_logic_vector (3 downto 0));
end EX_TOC;
architecture A of EX_TOC is
   signal GSR, GTS : std_logic;
   signal COUNT_UP, COUNT_DOWN : std_logic_vector (3 downto 0);
   component ROC
       port (O : out std_logic);
   end component;
   component TOC
       port (O : out std_logic);
   end component;
begin
   U1 : ROC port map (O => GSR);
   U2 : TOC port map (O => GTS);
   UP_COUNTER : process (CLOCK, ENABLE, GSR)
   begin
       if (GSR = '1') then
           COUNT_UP <= "0000";
       elsif (CLOCK'event AND CLOCK = '1') then
           if (ENABLE = '1') then
               COUNT_UP <= COUNT_UP + "0001";
           end if;
       end if;
   end process UP_COUNTER;
   DOWN_COUNTER : process (CLOCK, ENABLE, GSR, COUNT_DOWN) 
   begin 
       if (GSR = '1' OR COUNT_DOWN = "0101") then 
           COUNT_DOWN <= "1111"; 
       elsif (CLOCK'event AND CLOCK = '1') then 
           if (ENABLE = '1') then
               COUNT_DOWN <= COUNT_DOWN - "0001"; 
           end if; 
       end if; 
   end process DOWN_COUNTER;
   CUP <= COUNT_UP when (GTS = '0' AND COUNT_UP /= "0000") else "ZZZZ";
   CDOWN <= COUNT_DOWN when (GTS = '0') else "ZZZZ";
end A;

TOC Test Bench (Case A1)

The following is the test bench for the TOC example.

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;

library UNISIM;
use UNISIM.all;

entity test_ofex_toc is end test_ofextoc;

architecture inside of test_ofex_toc is

Component ex_toc
Port ( CLOCK, ENABLE: in STD_LOGIC;
CUP, CDOWN: out STD_LOGIC_VECTOR (3 downto 0));
End component;

.
.
.

Begin

UUT: ex_toc port map(. . . .);
.
.
.
End inside;

The best method for mapping the generic is a configuration in the test bench, as shown in the following example.

Configuration overall of test_ofextoc is
For inside
For UUT:ex_toc
For A
For U1:TOC use entity UNISIM.TOC (TOC_V)
Generic map (WIDTH=>52 ns);
End for;
End for;
End for;
End overall;

This configuration is for pre-NGDBuild simulation. A similar configuration is used for post-NGDBuild simulation. The ROC, TOC, and OSC4 are mapped to the WORK library, and corresponding architecture names may be different. Review the .vhd file created by NGD2VHDL for the current entity and architecture names for post-NGDBuild simulation.

TOC Model in Four Design Phases (Case A1)

The following figure shows the progression of the TOC model and its interpretation in the four main design phases.

Figure 5.5 TOC Simulation and Implementation

Using VHDL TOCBUF (Case B1)

For Case B1, use the TOCBUF (Tristate-On-Configuration Buffer) instantiated component model. This model creates a buffer for the global output tristate enable signal. You now have an input port on the buffer to drive the global set reset line. The implementation model directs the place and route tool to remove the port so it is not implemented on the actual chip. The TOCBUF cell does not reappear in the post-routed netlist. Instead, you can select an option on the implementation tool to add a global output tristate enable port to the back-annotated netlist. A buffer is not necessary because the implementation directive is no longer required.

TOCBUF Model Example (Case B1)

The following is an example of the TOCBUF model.

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
library UNISIM;
use UNISIM.all;
entity EX_TOCBUF is
port (CLOCK, ENABLE, SRP, STP : in std_logic;
CUP, CDOWN : out std_logic_vector (3 downto 0));
end EX_TOCBUF;
architecture A of EX_TOCBUF is
signal GSR, GTS : std_logic;
signal COUNT_UP, COUNT_DOWN : std_logic_vector (3 downto 0);
component ROCBUF
port (I : in std_logic;
O : out std_logic);
end component;
component TOCBUF
port (I : in std_logic;
O : out std_logic);
end component;
begin
U1 : ROCBUF port map (I => SRP, O => GSR);
U2 : TOCBUF port map (I => STP, O => GTS);
UP_COUNTER : process (CLOCK, ENABLE, GSR)
begin
if (GSR = '1') then
COUNT_UP <= "0000";
elsif (CLOCK'event AND CLOCK = '1') then
if (ENABLE = '1') then
COUNT_UP <= COUNT_UP + "0001";
end if;
end if;
end process UP_COUNTER;
DOWN_COUNTER : process (CLOCK, ENABLE, GSR, COUNT_DOWN)
begin
if (GSR = '1' OR COUNT_DOWN = "0101") then
COUNT_DOWN <= "1111";
elsif (CLOCK'event AND CLOCK = '1') then
if (ENABLE = '1') then
COUNT_DOWN <= COUNT_DOWN - "0001";
end if;
end if;
end process DOWN_COUNTER;
CUP <= COUNT_UP when (GTS = '0' AND COUNT_UP /= "0000") else "ZZZZ";
CDOWN <= COUNT_DOWN when (GTS = '0') else "ZZZZ";
end A;

TOCBUF Model in Four Design Phases (Case B1)

The following figure shows the progression of the TOCBUF model and its interpretation in the four main design phases.

Figure 5.6 TOCBUF Simulation and Implementation