This website uses cookies. By using this site, you consent to the use of cookies. For more information, please take a look at our Privacy Policy.
Home > FPGA Technical Tutorials > Design Recipes for FPGAs Using Verilog and VHDL > A VHDL Primer: The Essentials > Basic Variable Types and Operators

TABLE OF CONTENTS

Xilinx FPGA FPGA Forum

Basic Variable Types and Operators

FONT SIZE : AAA

Constants

Whenavalueneedstobestaticthroughoutasimulation,thetypeofelementtouseisaconstant. This is often used to initialize parameters or to set fixed register values for comparison. A constant can be declared for any defined type in VHDL with examples as follows:

1 constant a : integer := 1;

2 constant b : real := 0.123;

3 constant c : std_logic := 0;

Signals

Signals are the link between processes and sequential elements within processes. They are effectively wires in the design and connect all the design elements together. When simulating signals, the simulator will in turn look at updating the signal values and also checking the sensitivity lists in processes to see whether any changes have occurred that will mean that processes become active. 

Signals can be assigned immediately or with a time delay, so that an event is scheduled for sometime in the future (after the specified delay). It is also important to recognize that signals are not the same as a set of sequential program code (such as in C), but are effectively concurrent signals that will not be able to be considered stable until the next time the process is activated. 

Examples of signal declaration and assignment are shown below: 

1 signal sig1 : integer := 0;

2 signal sig2 : integer := 1;

3 sig1 <= 14;

4 sig1 <= sig2;

5 sig1 <= sig2 after 10 ns;

Variables

While signals are the external connections between processes, variables are the internal values within a process. They are only used in a sequential manner, unlike the concurrent nature of signals within and between processes. Variables are used within processes and are declared and used as follows: 

1 variable var1 : integer := 0;

2 variable var2 : integer := 1;

3 var1 := var2;

Notice that there is no concept of a delay in the variable assignment; if you need to schedule an event, it is necessary to use a signal.

Boolean Operators

VHDL has a set of standard Boolean operators built in, which are self explanatory. The list of operators are and, or, nand, not, nor, xor. These operators can be applied to BIT, BOOLEAN, or logic types with examples as follows:

1 out1 <= in1 and in2;

2 out2 <= in3 or in4;

3 out5 <= not in5;

Arithmetic Operators

There are a set of arithmetic operators built into VHDL which again are self explanatory and these are described and examples provided as follows:

OperatorDescription Example

+
-
*
/
abs
mod
rem
**

Addition
Subtraction
Multiplication 
Division 
Absolute Value
Modulus
Remainder 
Exponent 

out1 <= in1 + in2;
out1 <= in1 - in2;
out1 <= in1 * in2;
out1 <= in1/in2;
absin1 <= abs(in1);
modin1 <= mod(in1);
remin1 <= rem(in1);
out1 <= in1 ** 3;

 Comparison Operators

VHDL has a set of standard comparison operators built in, which are self explanatory. The operators are =, / =, <, <=, >, >=. These operators can be applied to a variety of types as follows:

1 in1 < 1

2 in1 /= in2

3 in2 >= 0.4

Logical Shifting Functions

VHDL has a set of six built-in logical shift functions which are summarized in the following table:

Operator Description Example

sll 

srl 

sla 

sra

rol 

ror

Shift Left Logical
Shift Right Logical  

Shift Left Arithmetic

Shift Right Arithmetic 

Rotate Left 

Rotate Right

reg <= reg sll 2;

reg <= reg srl 2;

reg <= reg sla 2;

reg <= reg sra 2;
reg <= reg rol 2;
reg <= reg ror 2;

Concatenation

The concatenation function in VHDL is denoted by the & symbol and is used as follows:

1 A <= 1111;

2 B <= 000

3 out1 <= A & B & 1; −− out1 = 11110001;

  • XC18V04-VQ44BRT

    Manufacturer:Xilinx

  • Xilinx QFP44
  • Product Categories:

    Lifecycle:Active Active

    RoHS: -

  • XC18V04-VQ44C

    Manufacturer:Xilinx

  • PROM Parallel/Serial 4M-bit 3.3V EEPROM
  • Product Categories:

    Lifecycle:Active Active

    RoHS: -

  • XC18V04VQG44C

    Manufacturer:Xilinx

  • PROM Parallel/Serial 4M-bit 2.5V/3.3V 44-Pin VQFP
  • Product Categories: EEPROM

    Lifecycle:Active Active

    RoHS:

  • XC18V256SO20I

    Manufacturer:Xilinx

  • Ic prom ser i-temp 3.3v 20-soic
  • Product Categories: Memory - Configuration Proms for FPGA&#039;s

    Lifecycle:Active Active

    RoHS: -

  • XC18V512PC20I

    Manufacturer:Xilinx

  • PROM Parallel/Serial 512K-bit 3.3V 20-Pin PLCC
  • Product Categories: Memory - Configuration Proms for FPGA&#039;s

    Lifecycle:Obsolete -

    RoHS: No RoHS

Need Help?

Support

If you have any questions about the product and related issues, Please contact us.