代码之家  ›  专栏  ›  技术社区  ›  Eric

SystemVerilog stringify(`”)运算符和换行符

  •  1
  • Eric  · 技术社区  · 7 年前

    我正在使用SystemVerilog stringify运算符, `" ,如下所示。该案例是故意设计的,以显示错误:

    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
    

    这将产生输出(无尾随换行):

    ABC
    `D
    `EF
    

    为什么会有 ` 输出中的,但仅来自 println ?
    这是规范中记录的行为,还是我的模拟器(Aldec活动HDL)中的错误?

    1 回复  |  直到 7 年前
        1
  •  0
  •   dave_59    7 年前

    这是您工具中的一个错误。然而,第二个 `" 是不需要的,并给你的结果,你正在寻找。

    推荐文章