What Is Real Data Type in Verilog?


Heather Bennett

What Is Real Data Type in Verilog?

Verilog is a hardware description language (HDL) used for designing digital systems. It provides several data types to represent different types of values and variables. One such data type is the ‘real’ data type.

Introduction to the Real Data Type

The ‘real’ data type in Verilog is used to represent floating-point numbers. It is commonly used when dealing with decimal values or when high precision is required.

The real data type can store both positive and negative numbers and supports a wide range of values, including fractional numbers. It is particularly useful when performing mathematical calculations or simulations that involve real-world quantities.

Declaring a Real Variable

To declare a variable of the real data type in Verilog, you need to use the ‘real’ keyword followed by the variable name. For example:

    real voltage;
    real temperature = 25.5;

In the above example, we declared two variables: ‘voltage’ and ‘temperature’. The second variable, ‘temperature’, is initialized with a value of 25.5.

Operations on Real Variables

You can perform various operations on variables of the real data type in Verilog. These operations include arithmetic operations such as addition, subtraction, multiplication, and division.

    real value1 = 10.5;
    real value2 = 5.3;
    real result;

    result = value1 + value2; // Addition
    result = value1 - value2; // Subtraction
    result = value1 * value2; // Multiplication
    result = value1 / value2; // Division

In the above example, we perform different arithmetic operations on the variables ‘value1’ and ‘value2’. The results are stored in the ‘result’ variable.

Conversion of Real to Other Data Types

Verilog provides mechanisms to convert a real value to other data types. This can be useful when interacting with other parts of your design that require different data types.

To convert a real value to an integer, you can use the ‘int’ or ‘integer’ data type:

    real realValue = 10.7;
    int intValue;
    intValue = int(realValue); // Conversion to int

In the above example, we convert the real value ‘realValue’ to an integer and store it in the variable ‘intValue’ using the ‘int()’ function.


The real data type in Verilog is a valuable tool for representing floating-point numbers and performing accurate mathematical calculations. It allows for precise simulations and handling of decimal values. By understanding its usage and operations, you can enhance your Verilog designs and ensure accurate representation of real-world quantities.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy