Roronoa137
Junior Member level 1
I would like to check if the name of two variables is the same.
In particular one of those variable is the input of a task and the other one is a variable declared in the main.
I already know that there is an error in my code due to the fact that I'm comparing the value of s with the name of dut.f, but I don't know how to compare the names. Can anyone help me please? Thanks!
In particular one of those variable is the input of a task and the other one is a variable declared in the main.
Code:
module ex();
logic clk;
logic [ 3:0] btn;
logic vaux2_p;
logic vaux2_n;
logic gpio1;
logic gpio2;
main dut(
.clk(clk),
.btn (btn),
.vaux2_p (vaux2_p),
.vaux2_n (vaux2_n),
.pio3 (pio3),
.pio4 (pio4)
);
task test;
input [ 7:0] a;
input [23:0] v;
input [23:0] s;
integer f1;
integer f2;
begin
f1 = $fopen("file.txt","w");
if (!f1) begin
$display("File \"file.txt\" cannot be opened!");
end else begin
if(s=="dut.f") begin
$fwrite(f1, "1:\n");
end else if(s=="dut.f") begin
$fwrite(f1, "2:\n");
end
end
endtask
initial begin
test(8'h1a,16'hF0, dut.f);
$finish;
end
endmodule
I already know that there is an error in my code due to the fact that I'm comparing the value of s with the name of dut.f, but I don't know how to compare the names. Can anyone help me please? Thanks!