typedef struct packed signed{
bit valid;
bit tag;
bit signed[31:0] data;
}my_data;
module structure_example5(input clk,input my_data a);
always@(posedge clk) begin
if(a.tag>a.valid)begin
$display("G");
end
else begin
$display("L");
end
end
endmodule:structure_example5
//TEST BENCH
module structure_example5_tb;
reg clk;
reg a.tag,a.valid;
structure_example5 uut (clk,a);
initial begin
#5
clk=0;
forever
#5clk=!clk;
end
initial begin
a.tag=1'b1;
a.valid=1'b0;
#50
$finish();
end
endmodule:structure_example5_tb
How to access the structures from testbench
589 Views Asked by ranadheer chinthalapalli At
1
Until and unless struct is of single direction there won't be any difficulty in connecting test-bench and DUT ports together
Here at your test-bench code comment out reg declaration of structure members and use structure declaration
and try to run your code, the corrected/working code can be found in the link
UPDATE:
As per Dave's suggestion, it is recommended that when sharing typedefs with multiple modules using a package is the better solution, to use, define all your typedefs inside the package and import the package in the required module, it can be any module including testbench and DUT.
eg:
and whenever you require content of package inside your module use
Also updated the link mentioned above with package