Lesson 1.3 Data Types and Description in VHDL and Verilog
Lesson 1.3 Data Types and Description in VHDL and Verilog
Begin
Composite Type
The composite data type is a • Array type: this type is defined by
collection of values. There are 3 using the pre defined word “array”.
composite data types. Arrays can be multi dimensional
(similar to arrays in C).
• Bit vector: this data type
represents a array of bits. It is Ex.
denoted as shown in example. type OneDArray is array (0 to 4) of
I1: in bit_vector(3 down to 0); it has 4 integer; -- 1D array with 5
bits. integers
type TwoDArray is array (0 to 3, 0 to 3)
of bit; -- 2D array (4x4) of bits
entity RecordExample is
Composite Type Port ( clk : in std_logic;
• Record types: this data type can be reset : in std_logic);
composed of same or different end RecordExample;
data types (similar to structures in
C).
architecture Behavioral of RecordExample is
• Basic Syntax
type StudentRecord is record
type MyRecordType is record name : string(1 to 20);
field1 : type1; age : integer;
field2 : type2; gpa : real;
... end record;
end record;
File types
Objects of this type can be read and written using built in
functions(similar to files in C).
Example:
process
file_open(input_file, "data.txt", read_mode); -- Open file for reading
for i in 0 to 9 loop
readline(input_file, line_buffer); -- Read a line from the file
read(line_buffer, my_data(i)); -- Read data into array
end loop;
file_close(input_file); -- Close the file
end process;
Summary
o Scalar Types: Basic types for single values (e.g., bit, integer, real).
o Composite Types: Complex types that group multiple values (e.g., array,
record).
o File Types: Allow interaction with external files for data input and output.
Verilog HDL data types:
SYNTAX REGISTERS
reg my_reg; // A 1-bit register Registers are declared by
reg [7:0] data_reg; // An 8-bit the predefined word “reg”.
register registers store values until they
are updated.
Usage of Register
Registers are commonly used for various purposes in digital design,
including:
Storing State: They hold the state of a system in state machines.
Data Buffers: They can act as temporary storage for data being processed.
Control Signals: Registers can store control signals for different parts of a
circuit.
Verilog HDL data types (cont):
INTEGER
The integer type is a signed, whole Example:
number data type that allows for integer count; // A single
arithmetic operations and is often used integer variable
for loop counters, array indexing, and
other calculations where non-negative integer array[0:9]; // An array of
values are insufficient. 10 integers
Verilog HDL data types (cont):
ARRAYS
Arrays are used to group • Arrays can be single-dimensional
multiple elements of the same data or multi-dimensional and are
type, enabling the efficient widely used in various digital
organization and manipulation of design scenarios, such as
related data. memory modeling and data
storage.
Example: