- •About This Manual
- •Additional Resources
- •Manual Contents
- •Conventions
- •Typographical
- •Online Document
- •Using Foundation Express with VHDL
- •Hardware Description Languages
- •Typical Uses for HDLs
- •Advantages of HDLs
- •About VHDL
- •Foundation Express Design Process
- •Using Foundation Express to Compile a VHDL Design
- •Design Methodology
- •Design Descriptions
- •Entities
- •Entity Generic Specifications
- •Entity Port Specifications
- •Architecture
- •Declarations
- •Components
- •Concurrent Statements
- •Constant Declarations
- •Processes
- •Signal Declarations
- •Subprograms
- •Type Declarations
- •Examples of Architectures for NAND2 Entity
- •Configurations
- •Packages
- •Using a Package
- •Package Structure
- •Package Declarations
- •Package Body
- •Resolution Functions
- •Data Types
- •Type Overview
- •Enumeration Types
- •Enumeration Overloading
- •Enumeration Encoding
- •Enumeration Encoding Values
- •Integer Types
- •Array Types
- •Constrained Array
- •Unconstrained Array
- •Array Attributes
- •Record Types
- •Record Aggregates
- •Predefined VHDL Data Types
- •Data Type BOOLEAN
- •Data Type BIT
- •Data Type CHARACTER
- •Data Type INTEGER
- •Data Type NATURAL
- •Data Type POSITIVE
- •Data Type STRING
- •Data Type BIT_VECTOR
- •Unsupported Data Types
- •Physical Types
- •Floating-Point Types
- •Access Types
- •File Types
- •Express Data Types
- •Subtypes
- •Expressions
- •Overview
- •Operators
- •Logical Operators
- •Relational Operators
- •Adding Operators
- •Unary (Signed) Operators
- •Multiplying Operators
- •Miscellaneous Arithmetic Operators
- •Operands
- •Operand Bit-Width
- •Computable Operands
- •Aggregates
- •Attributes
- •Expressions
- •Function Calls
- •Identifiers
- •Indexed Names
- •Literals
- •Numeric Literals
- •Character Literals
- •Enumeration Literals
- •String Literals
- •Qualified Expressions
- •Records and Fields
- •Slice Names
- •Limitations on Null Slices
- •Limitations on Noncomputable Slices
- •Type Conversions
- •Sequential Statements
- •Assignment Statements and Targets
- •Simple Name Targets
- •Indexed Name Targets
- •Slice Targets
- •Field Targets
- •Aggregate Targets
- •Variable Assignment Statements
- •Signal Assignment Statements
- •Variable Assignment
- •Signal Assignment
- •if Statements
- •Evaluating Conditions
- •Using the if Statement to Infer Registers and Latches
- •case Statements
- •Using Different Expression Types
- •Invalid case Statements
- •loop Statements
- •Basic loop Statement
- •while...loop Statements
- •for...loop Statements
- •Steps in the Execution of a for...loop Statement
- •for...loop Statements and Arrays
- •next Statements
- •exit Statements
- •Subprograms
- •Subprogram Always a Combinatorial Circuit
- •Subprogram Declaration and Body
- •Subprogram Calls
- •Procedure Calls
- •Function Calls
- •return Statements
- •Procedures and Functions as Design Components
- •Example with Component Implication Directives
- •Example without Component Implication Directives
- •wait Statements
- •Inferring Synchronous Logic
- •Combinatorial Versus Sequential Processes
- •null Statements
- •Concurrent Statements
- •Overview
- •process Statements
- •Combinatorial Process Example
- •Sequential Process Example
- •Driving Signals
- •block Statements
- •Nested Blocks
- •Guarded Blocks
- •Concurrent Versions of Sequential Statements
- •Concurrent Procedure Calls
- •Concurrent Signal Assignments
- •Simple Concurrent Signal Assignments
- •Conditional Signal Assignments
- •Selected Signal Assignments
- •Component Instantiation Statements
- •Direct Instantiation
- •generate Statements
- •for...generate Statements
- •Steps in the Execution of a for...generate Statement
- •Common Usage of a for...generate Statement
- •if...generate Statements
- •Register and Three-State Inference
- •Register Inference
- •The Inference Report
- •Latch Inference Warnings
- •Controlling Register Inference
- •Inferring Latches
- •Inferring Set/Reset (SR) Latches
- •Inferring D Latches
- •Inferring Master-Slave Latches
- •Inferring Flip-Flops
- •Inferring D Flip-Flops
- •Inferring JK Flip-Flops
- •Inferring Toggle Flip-Flops
- •Getting the Best Results
- •Understanding Limitations of Register Inference
- •Three-State Inference
- •Reporting Three-State Inference
- •Controlling Three-State Inference
- •Inferring Three-State Drivers
- •Inferring a Simple Three-State Driver
- •Three-State Driver with Registered Enable
- •Three-State Driver Without Registered Enable
- •Writing Circuit Descriptions
- •How Statements Are Mapped to Logic
- •Design Structure
- •Adding Structure
- •Using Variables and Signals
- •Using Parentheses
- •Using Design Knowledge
- •Optimizing Arithmetic Expressions
- •Arranging Expression Trees for Minimum Delay
- •Sharing Common Subexpressions
- •Changing an Operator Bit-Width
- •Using State Information
- •Propagating Constants
- •Sharing Complex Operators
- •Asynchronous Designs
- •Don’t Care Inference
- •Using Don’t Care Default Values
- •Differences Between Simulation and Synthesis
- •Synthesis Issues
- •Feedback Paths and Latches
- •Fully Specified Variables
- •Asynchronous Behavior
- •Understanding Superset Issues and Error Checking
- •Foundation Express Directives
- •Notation for Foundation Express Directives
- •Foundation Express Directives
- •Translation Stop and Start Pragma Directives
- •synthesis_off and synthesis_on Directives
- •Resolution Function Directives
- •Component Implication Directives
- •Foundation Express Packages
- •std_logic_1164 Package
- •std_logic_arith Package
- •Using the Package
- •Modifying the Package
- •Data Types
- •UNSIGNED
- •SIGNED
- •Conversion Functions
- •Arithmetic Functions
- •Example 10-1: Binary Arithmetic Functions
- •Example 10-2: Unary Arithmetic Functions
- •Comparison Functions
- •Example 10-3: Ordering Functions
- •Example 10-4: Equality Functions
- •Shift Functions
- •ENUM_ENCODING Attribute
- •pragma built_in
- •Type Conversion
- •numeric_std Package
- •Understanding the Limitations of numeric_std package
- •Using the Package
- •Data Types
- •Conversion Functions
- •Resize Function
- •Arithmetic Functions
- •Comparison Functions
- •Defining Logical Operators Functions
- •Shift Functions
- •Rotate Functions
- •Shift and Rotate Operators
- •std_logic_misc Package
- •ATTRIBUTES Package
- •VHDL Constructs
- •VHDL Construct Support
- •Design Units
- •Data Types
- •Declarations
- •Specifications
- •Names
- •Identifiers and Extended Identifiers
- •Specifics of Identifiers
- •Specifics of Extended Identifiers
- •Operators
- •Shift and Rotate Operators
- •xnor Operator
- •Operands and Expressions
- •Sequential Statements
- •Concurrent Statements
- •Predefined Language Environment
- •VHDL Reserved Words
- •Examples
- •Moore Machine
- •Mealy Machine
- •Read-Only Memory
- •Waveform Generator
- •Smart Waveform Generator
- •Definable-Width Adder-Subtracter
- •Count Zeros—Combinatorial Version
- •Count Zeros—Sequential Version
- •Soft Drink Machine—State Machine Version
- •Soft Drink Machine—Count Nickels Version
- •Carry-Lookahead Adder
- •Carry Value Computations
- •Implementation
- •Serial-to-Parallel Converter—Counting Bits
- •Input Format
- •Implementation Details
- •Serial-to-Parallel Converter—Shifting Bits
- •Programmable Logic Arrays
Register and Three-State Inference
attribute one_hot signal_name_list : signal is ”true”;
Inferring Latches
In simulation, a signal or variable holds its value until that output is reassigned. In hardware, a latch implements this holding-of-state capability. Foundation Express supports inference of the following types of latches.
•SR latch
•D latch
•Master-slave latch
The following sections provide details about each of these latch types.
Inferring Set/Reset (SR) Latches
Use SR latches with caution, because they are difficult to test. If you decide to use SR latches, you must verify that the inputs are hazardfree (do not glitch). During synthesis, Foundation Express does not ensure that the logic driving the inputs is hazard-free.
The following example of an SR latch provides the VHDL code that implements the SR latch described in the truth table. The inference report following the truth table for an SR latch shows the inference report that Foundation Express generates.
set |
reset |
y |
|
|
|
0 |
0 |
Not stable |
|
|
|
0 |
1 |
1 |
|
|
|
1 |
0 |
0 |
|
|
|
1 |
1 |
y |
|
|
|
The following example shows an SR latch.
library IEEE, synopsys;
use IEEE.std_logic_1164.all; use synopsys.attributes.all;
entity sr_latch is
port (SET, RESET : in std_logic; Q : out std_logic );
attribute async_set_reset of SET, RESET :
VHDL Reference Guide |
7-5 |
VHDL Reference Guide
signal is ”true”; end sr_latch;
architecture rtl of sr_latch is begin
infer: process (SET, RESET) begin if (SET = ’0’) then
Q <= ’1’;
elsif (RESET = ’0’) then Q <= ’0’;
end if;
end process infer;
end rtl;
The example below shows an inference report for an SR latch and its schematic.
Register Name |
Type |
Width |
Bus |
MB |
AR |
AS |
SR |
SS |
ST |
|
|
|
|
|
|
|
|
|
|
Q_reg |
Latch |
1 |
- |
- |
Y |
Y |
- |
- |
- |
|
|
|
|
|
|
|
|
|
|
y_reg
Async-reset: RESET’ Async-set: SET’
Async-set and Async-reset ==> Q: 1
Q
RESET 

SET
X8590a
Figure 7-1 SR Latch
7-6 |
Xilinx Development System |
Register and Three-State Inference
Inferring D Latches
When you do not specify the resulting value for an output under all conditions, as in an incompletely specified if statement, Foundation Express infers a D latch.
For example, the if statement in the following example infers a D latch because there is no else clause. The resulting value for output Q is specified only when input enable has a logic 1 value. As a result, output Q becomes a latched value.
process(DATA, GATE) begin if (GATE = ’1’) then
Q <= DATA; end if;
end process;
To avoid latch inference, assign a value to the signal under all conditions, as shown in the following example.
process(DATA, GATE) begin if (GATE = ’1’) then
Q <= DATA; else
Q <= ’0’; end if;
end process;
Variables declared locally within a subprogram do not hold their value over time, because each time a subprogram is called, its variables are reinitialized. Therefore, Foundation Express does not infer latches for variables declared in subprograms. In the following example, Foundation Express does not infer a latch for output Q.
function MY_FUNC(DATA, GATE : std_logic) return std_logic is
variable STATE: std_logic; begin
if (GATE = ’1’) then STATE <= DATA;
end if; return STATE;
end;
. . .
Q <= MY_FUNC(DATA, GATE);
VHDL Reference Guide |
7-7 |
VHDL Reference Guide
The following sections provide code examples, inference reports, and figures for these types of D latches.
•Simple D latch
•D latch with asynchronous set
•D latch with asynchronous reset
•D latch with asynchronous set and reset
Simple D Latch When you infer a D latch, control the gate and data signals from the top-level design ports or through combinatorial logic. Gate and data signals that can be controlled ensure that simulation can initialize the design.
The following example provides the VHDL template for a D latch. Foundation Express generates the inference report shown after the example for a D latch. The figure “D Latch” shows the inferred latch.
library IEEE;
use IEEE.std_logic_1164.all;
entity d_latch is
port (GATE, DATA: in std_logic; Q : out std_logic );
end d_latch;
architecture rtl of d_latch is begin
infer: process (GATE, DATA) begin if (GATE = ’1’) then
Q <= DATA; end if;
end process infer;
end rtl;
The example below shows an inference report for a D latch.
Register Name Type Width Bus MB AR AS SR SS ST
Q_reg |
Latch 1 |
- - N N - - - |
Q_reg
reset/set:none
7-8 |
Xilinx Development System |
Register and Three-State Inference
DATA |
|
|
|
Q |
|
|
|
||
GATE |
|
|
|
X8591 |
|
|
|
||
|
|
|
|
|
|
|
|
|
|
Figure 7-2 D Latch |
|
|
||
D Latch with Asynchronous Set |
The template in this section uses |
|||
the async_set_reset attribute to direct Foundation Express to the asynchronous set (AS) pins of the inferred latch.
The following example provides the VHDL template for a D latch with an asynchronous set. Foundation Express generates the inference report shown following the example for a D latch with asynchronous set. The figure “D Latch with Asynchronous Set” shows the inferred latch.
library IEEE, synopsys;
use IEEE.std_logic_1164.all; use synopsys.attributes.all;
entity d_latch_async_set is
port (GATE, DATA, SET : in std_logic; Q : out std_logic );
attribute async_set_reset of SET : signal is ”true”;
end d_latch_async_set;
architecture rtl of d_latch_async_set is begin
infer: process (GATE, DATA, SET) begin if (SET = ’0’) then
Q <= ’1’;
elsif (GATE = ’1’) then Q <= DATA;
VHDL Reference Guide |
7-9 |
VHDL Reference Guide
end if;
end process infer;
end rtl;
The following example shows an inference report for a D latch with asynchronous set.
Register Name Type Width Bus MB AR AS SR SS ST
Q_reg |
Latch 1 |
- - N Y - - - |
Q_reg
Async-set: SET’
DATA 
Q
GATE 
SET 
X8592
Figure 7-3 D Latch with Asynchronous Set
Note: Because the target technology library does not contain a latch with an asynchronous set, Foundation Express synthesizes the set logic by using combinatorial logic.
D Latch with Asynchronous Reset The template in this section uses the async_set_reset attribute to direct Foundation Express to the asynchronous reset (AR) pins of the inferred latch.
The following example provides the VHDL template for a D latch with an asynchronous reset. Foundation Express generates the inference report shown following the example for a D latch with asynchronous reset. The figure “D Latch with Asynchronous Reset” shows the inferred latch.
7-10 |
Xilinx Development System |
Register and Three-State Inference
library IEEE, synopsys;
use IEEE.std_logic_1164.all; use synopsys.attributes.all;
entity d_latch_async_reset is
port (GATE, DATA, RESET : in std_logic; Q : out std_logic );
attribute async_set_reset of RESET : signal is ”true”;
end d_latch_async_reset;
architecture rtl of d_latch_async_reset is begin
infer : process (GATE, DATA, RESET) begin if (RESET = ’0’) then
Q <= ’0’;
elsif (GATE = ’1’) then Q <= DATA;
end if;
end process infer;
end rtl;
The following example shows an inference report for a D latch with asynchronous reset.
Register Name |
Type |
Width |
Bus |
MB |
AR |
AS |
SR |
SS |
ST |
|
|
|
|
|
|
|
|
|
|
Q_reg |
Latch |
1 |
- |
- |
Y |
N |
- |
- |
- |
|
|
|
|
|
|
|
|
|
|
Q_reg
Async-reset: RESET’
VHDL Reference Guide |
7-11 |
VHDL Reference Guide
DATA |
Q |
GATE 
RESET 
X8593a
Figure 7-4 D Latch with Asynchronous Reset
D Latch with Asynchronous Set and Reset The following example provides the VHDL template for a D latch with an activelow asynchronous set and reset. This template uses the async_set_reset_local attribute to direct Foundation Express to the asynchronous signals in the infer process.
The template in the following example uses the one_cold attribute to prevent priority encoding of the set and reset signals. If you do not specify the one_cold attribute, the set signal has priority, because it is used as the condition for the if clause. Foundation Express generates the inference report shown following the example for a D latch with asynchronous set and reset. The figure “D Latch with Asynchronous Set and Reset” shows the inferred latch.
library IEEE, synopsys;
use IEEE.std_logic_1164.all; use synopsys.attributes.all;
entity d_latch_async is
port (GATE, DATA, SET, RESET :in std_logic; Q : out std_logic );
attribute one_cold of SET, RESET : signal is ”true”;
end d_latch_async;
architecture rtl of d_latch_async is attribute async_set_reset_local of infer :
7-12 |
Xilinx Development System |
Register and Three-State Inference
GATE
SET
DATA
RESET
label is ”SET, RESET”; begin
infer : process (GATE, DATA, SET, RESET) begin if (SET = ’0’) then
Q <= ’1’;
elsif (RESET = ’0’) then Q <= ’0’;
elsif (GATE = ’1’) then Q <= DATA;
end if;
end process infer; end rtl;
The following example shows an inference report for a D latch with asynchronous set and reset.
Register Name Type Width Bus MB AR AS SR SS ST
Q_reg |
Latch 1 |
- |
- |
Y Y - - - |
Q_reg
Async-reset: RESET’
Async-set: SET’
Async-set and Async-reset ==> Q: X
Q
X8594
Figure 7-5 D Latch with Asynchronous Set and Reset
Understanding the Limitations of D Latch Inference A variable must always have a value before it is read. As a result, a conditionally assigned variable cannot be read after the if statement in which it is assigned. A conditionally assigned variable is assigned a new value
VHDL Reference Guide |
7-13 |
