【问题标题】:Interface SystemVerilog with a verilog module将 SystemVerilog 与 verilog 模块接口
【发布时间】:2014-02-19 07:56:24
【问题描述】:

我相信SystemVerilog 是编码中更高层次的抽象。是否可以将SystemVerilog 模块与verilog 模块连接起来?在尝试整合它们时是否应该牢记它们的任何方面?

【问题讨论】:

  • SystemVerilog 和 Verilog 标准于 2009 年合并。因此 SystemVerilog 和 Verilog module 在现代编译器/模拟器中是相同的。你是说 SystemVerilog 类吗?

标签: verilog system-verilog


【解决方案1】:

Verilog 和 SystemVerilog 是同一种语言 - 也就是说,您对 Verilog 的了解都存在于 SystemVerilog 中。从综合的角度来看,您仍会将信号位与其他信号位连接起来。只是使用 SystemVerilog,您将拥有更高级的方式来声明这些信号,以及更多的操作符来操作这些信号。

在不了解任何 SystemVerilog 的情况下,我建议您在尝试将较旧的 Verilog 模块与 SystemVerilog 模块集成之前自学。很难解释要注意什么。

从 Verilog 继承到 SystemVerilog 的一件事是网络(wires)和变量(regs)的概念。确保您对此有清晰的理解,以及 SystemVerilog 添加的新语义。我有一个small article。 Verilog 只允许电线通过端口并且不强制执行指令。 SV 允许变量通过端口(意味着端口连接两侧的变量),但强烈强制执行方向性。

【讨论】:

    【解决方案2】:

    是的,可以将系统verilog模块连接到verilog模块。 在此之前,您必须了解verilog模块中使用的信号(变量)。

    您必须创建接口,通过该接口将您的 verilog 信号连接到系统 verilog 模块。 因此,verilog和系统verilog模块之间的数据传输是可能的。

    这里我提供verilog模块和系统verilog模块。代码的主要部分是verilog和系统verilog模块连接的接口。

    verilog 模块代码:

    module dff(qn,d,clk,reset);
    
    output qn;
    input d,clk,reset;
    reg qn;
    
    always@(posedge clk,negedge reset)
    
    begin
    
    if (!reset)
    
    begin
    qn=1'bx;
    end
    
    else if (d==0)
    begin
    qn=0;
    end
    else if (d==1)
    begin 
    qn=1;
    end
    
    end
    
    endmodule
    

    系统verilog模块代码:

    interface melay_intf(input bit clk);
    
      logic o,clk,rst,i;
    
      clocking c1@(posedge clk);
        input o;
        output i,rst;
      endclocking
    
    endinterface
    
    module top;
      bit clk;
    
      always
        #1 clk = ~clk;
    
      melay_intf i1(clk);
    
      dff d1(.o(i1.o),.clk(i1.clk),.rst(i1.rst),.i(i1.i));
    
      melay_tes(i1.tes);
    
    endmodule
    
    program melay_tes(melay_intf i1);
    
      initial
        #100 $finish;
    
      initial
        begin
          i1.rst <= 0;
          #4 i1.rst <= 1;
          #4 i1.rst <= 0;
    
          i1.i = 1;
              #2 i1.i = 0;
              #2 i1.i = 1;
              #2 i1.i = 0;
              #2 i1.i = 1;
              #2 i1.i = 0;
    
    
          repeat(10)
            begin
              i1.i = 1;
              #2 i1.i = $urandom_range(0,1); 
            end
        end
    
      initial
        $monitor("output = %d   clk = %d    rst = %d    i = %d",i1.o,i1.clk,i1.rst,i1.i);
      initial
        begin
          $dumpfile("mem.vcd");
          $dumpvars();
    
        end
    endprogram
    

    这里重要的部分是接口,在其中我使用时钟块进行同步。 这里计时 c1@(posedge clk);所以时钟块内提到的所有信号都是 i,o,rst。所有这些信号在 clk 信号的每一个位置都会改变它的值。

    这里dff d1(.o(i1.o),.clk(i1.clk),.rst(i1.rst),.i(i1.i)); 您在顶部模块中发现的重要内容是我在 verilog 信号和系统 verilog 信号之间建立了联系。

    你可以发现verilog模块名称是“dff”。 我采用了 dff verilog 模块的实例并建立了连接。 这里 i1.o,i1.clk,i1.rst,i1.i 是系统verilog信号,连接到带有点约定的verilog模块的o,clk,rst,i信号。

    【讨论】:

      【解决方案3】:

      系统verilog(SV)主要用于设计验证,所以问题是DUT(被测设备)是用verilog编写的,主要是因为verilog大部分都可以合成。然后使用 SV 为该 DUT 编写验证环境。 两者之间需要接口来将 SV 与 Verilog 的 DUT 连接起来。单独的文件写的是 SV 来指定两个文件之间有什么不同的连接。该文件说接口文件包含在需要这些连接的所有单独块中。 您可以参考 IEEE 标准https://standards.ieee.org/getieee/1800/download/1800-2012.pdf 了解更多关于 SV 的信息。

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多