0% found this document useful (0 votes)
127 views3 pages

System Verilog Class

A MemTrans class is defined with an 8-bit data_in and 4-bit address. The class includes a print function that displays the values of data_in and address. An object of the MemTrans class is instantiated in an initial block in the top module, and its print function is called to output the values.

Uploaded by

Melody Shields
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
127 views3 pages

System Verilog Class

A MemTrans class is defined with an 8-bit data_in and 4-bit address. The class includes a print function that displays the values of data_in and address. An object of the MemTrans class is instantiated in an initial block in the top module, and its print function is called to output the values.

Uploaded by

Melody Shields
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 3

System Verilog Class

Example
Requirement:
Create a class called MemTrans that
contains the following members, then
construct a MemTrans object in an initial
block.
a. An 8-bit data_in of logic type
b. A 4-bit address of logic type
c. A void function called print that prints
out the value of data_in and address

Solution:
Class MemTrans;
logic [7:0] data
logic [3:0] addr;
function void print();
$display(data = %h ,data);
$display(addr = %h ,addr);
endfunction
endclass

Top Module
module top;
initial
begin
memTrans obj; //creating an object handle
obj = new(); //Allocating Memory
obj.print();
end
endmodule

You might also like