Eric
Eric

Reputation: 97601

SystemVerilog stringify (`") operator and line breaks

I'm using the SystemVerilog stringify operator, `", in a macro, as below. The case is deliberately contrived to show the bug:

module my_test();
    `define print(x) $fwrite(log_file, `"x`")
    `define println(x) $fwrite(log_file, `"x\n`")
    integer log_file;

    initial begin
        log_file = $fopen("result.txt", "w");
        `print(A);
        `print(B);
        `println(C);
        `println(D);
        `print(E);
        `print(F);
    end
endmodule

This gives the output (no trailing newline):

ABC
`D
`EF

Why are there `s in the output, but only from the println?
Is this documented behaviour in the spec, or a bug in my simulator (Aldec Active-HDL)?

Upvotes: 1

Views: 2922

Answers (1)

dave_59
dave_59

Reputation: 42698

This is a bug in your tool. However, the second `" is not needed and gives you the results you are looking for.

Upvotes: 0

Related Questions