【问题标题】:verilog ; can't use "string" type in $display验证;不能在 $display 中使用“字符串”类型
【发布时间】:2020-05-29 00:10:05
【问题描述】:

我正在使用 icarus verilog 的最新主分支构建。

我应该期望以下运行吗?

module string_display ();

//reg [10:0][7:0] x = "initial";
string x = "initial";

always @* begin
  $display ("x = %s",x);
end

initial begin

  // Assign new string 
  x = "aaaaa";
  #1

  // Assign new string     
  x = "bbbb";
  #1

  #1 $finish;
end

endmodule

上面给出了

internal error: 18vvp_fun_anyedge_sa: recv_string(initial) not implemented
vvp: vvp_net.cc:2972: virtual void vvp_net_fun_t::recv_string(vvp_net_ptr_t, const string&, vvp_context_t): Assertion `0' failed.

但是,如果我通过取消注释上面的行将“x”定义为 reg,那么它会按预期工作......

x =       aaaaa
x =        bbbb

【问题讨论】:

    标签: verilog system-verilog icarus


    【解决方案1】:

    错误消息告诉您确切的问题:“未实施”。这意味着它可以识别您想要做什么,但尚未实施。

    【讨论】:

      【解决方案2】:

      不,您不应期望 Icarus Verilog 支持 string 关键字,该关键字是在 IEEE Std 1800 for SystemVerilog 中引入的。

      根据Icarus website

      编译器本身旨在解析和详细设计 写入 IEEE 标准 IEEE Std 1364-2005 的描述。这是 一个相当大且复杂的标准,因此需要一些时间来填写 标准的所有黑暗小巷,但这就是目标。

      没有提到 IEEE Std 1800。

      您可以查看 github 站点上的 extensions.txt 文件,其中指出:

      Icarus Verilog 支持对基线 IEEE1364 的某些扩展 标准。其中一些是从扩展变体中挑选出来的 语言,例如 SystemVerilog,...

      但是,那里没有提到string

      我在edaplayground 上使用-g2012 选项尝试了您的代码,但我得到了同样的错误。你可以在你的版本上试试。

      【讨论】:

        【解决方案3】:

        我刚刚尝试了类似的方法,它对我有用:

        
        module testit;
        
        integer  code; 
        string str;
        string word_0;
        string word_1;
        string word_2;
        string word_3;
        string word_4;
        
        integer file;
        
        initial begin
            //file = $fopenr(" ../../testcase/testcase_4x4.txt");
            
            str    = "this is a test... 1, 2, 3";
            
            code = $sscanf(str, "%s %s %s %s %s", 
                            word_0, word_1, word_2, word_3, word_4);
                            
            $display("Number of words: %0d", code);
            
            $display("words[0]:(%-0s)", word_0);
            $display("words[1]:(%-0s)", word_1);
            $display("words[2]:(%-0s)", word_2);
            $display("words[3]:(%-0s)", word_3);
            $display("words[4]:(%-0s)", word_4);    
        end
        
        endmodule
        

        Icarus Verilog 运行命令:

            iverilog -g2012 .\testit.sv       
            vvp -i a.out
        

        输出:

        Number of words: 5
        words[0]:(this)
        words[1]:(is)
        words[2]:(a)
        words[3]:(test...)
        words[4]:(1,)
        

        Icarus Verilog 版本:

        PS>iverilog -v
        Icarus Verilog 版本 11.0(开发)(s20150603-612-ga9388a89)

        【讨论】:

          猜你喜欢
          • 2020-09-10
          • 1970-01-01
          • 2020-01-17
          • 2017-10-16
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多