Verilog测试台编译,但模拟在700点停止

Verilog测试台编译,但模拟在700点停止,verilog,boolean-logic,Verilog,Boolean Logic,首先请原谅任何拼写错误,英语不是我的第一语言 对于一个项目,我试图使用iverilog模拟一些“基本”逻辑。目前我有一个模拟,由于某种原因,它挂在时钟信号的第三个向下侧面。测试台编译良好,但在模拟过程中,它在6ns处停止。据我所知,对信号的调查显示并没有未定义的信号或锁存情况。此时唯一变化的信号是CLK信号 模拟是一个简单的带异步清除和复位(CBU22)的2位递增计数器,目标是使计数器增加,直到达到其最大值,然后保持该信号直到复位。因此,当CBU22.Q0和CBU22.Q1都处于高位时,这将导致

首先请原谅任何拼写错误,英语不是我的第一语言

对于一个项目,我试图使用iverilog模拟一些“基本”逻辑。目前我有一个模拟,由于某种原因,它挂在时钟信号的第三个向下侧面。测试台编译良好,但在模拟过程中,它在6ns处停止。据我所知,对信号的调查显示并没有未定义的信号或锁存情况。此时唯一变化的信号是CLK信号

模拟是一个简单的带异步清除和复位(CBU22)的2位递增计数器,目标是使计数器增加,直到达到其最大值,然后保持该信号直到复位。因此,当CBU22.Q0和CBU22.Q1都处于高位时,这将导致CBU22.CAO变为高位,进而将CBU22.EN_拉至低位,从而阻止其进一步计数

如果有人知道为什么模拟挂起,我将非常感谢您的输入

我用来编译和运行代码的命令有:

> iverilog -o test -ylibrary test_tb.v
> ./test
我确信这是正确的,因为我在其他模型上使用相同的命令,这些模型模拟得很好

这是测试台的代码

测试tb.v:

`include "library/lsc_minimal.v"
`timescale 1 ns / 1 ns

// Define Module for Test Fixture
module test_tb();

// Inputs
    reg CLK;
    reg CD;
    reg EN;

// Outputs
    wire Q0;
    wire Q1;

// Bidirs


// Instantiate the UUT
    test UUT (
            .EN(EN),
            .CLK(CLK),
            .CD(CD),
            .Q0(Q0),
            .Q1(Q1)
            );

    always #1 CLK <= !CLK;

// Initialize Inputs
// You can add your stimulus here
    initial begin
    $dumpfile ("signals.vcd"); 
    $dumpvars;
        // initialize variables
        CLK = 0;
        CD = 0;
        EN = 0;

        //Simulation parameters
        #1 EN <= 1;
        #8 $finish;
    end

endmodule //test_tb
/* Verilog model */

module test(EN, CLK, CD, Q0, Q1);
    input EN, CLK, CD;
    output Q0, Q1;
    wire CAI, CAO, EN_IN, NOT_CAO;

buf (CAI,1);
and (EN_IN,EN,NOT_CAO);
not (NOT_CAO,CAO);

CBU22 I1 (
            .Q0(Q0),
            .Q1(Q1),
            .CAO(CAO),
            .CAI(CAI),
            .CLK(CLK),
            .EN(EN_IN),
            .CD(CD)
            );

endmodule //
/*
Minimal modules for counter test
Variables changed to remove duplicate names
*/

/*
* "Cell CBU22"                                                                 *
*/

`timescale 10 ps / 10 ps 
module CBU22(
    Q0, Q1, CAO, CAI, 
    CLK, EN, CD);

    output Q0;
    output Q1;
    output CAO;
    input CAI;
    input CLK;
    input EN;
    input CD;

    FD21 I1  (.Q0(QI0), .D0(CBU22_I8_Z0 ), .CLK(CLK), .CD(CD));
    FD21 I2  (.Q0(QI1), .D0(CBU22_I9_Z0 ), .CLK(CLK), .CD(CD));
    AND2 I3  (.Z0(CBU22_I3_Z0 ), .A0(CAI), .A1(EN));
    AND3 I4  (.Z0(CBU22_I4_Z0 ), .A0(QI0), .A1(CAI), .A2(EN));
    AND4 I5  (.Z0(CAO), .A0(QI0), .A1(QI1), .A2(CAI), .A3(EN));
    BUF I6  (.Z0(Q1), .A0(QI1));
    BUF I7  (.Z0(Q0), .A0(QI0));
    LXOR2 I8  (.Z0(CBU22_I8_Z0 ), .A0(QI0), .A1(CBU22_I3_Z0 ));
    LXOR2 I9  (.Z0(CBU22_I9_Z0 ), .A0(QI1), .A1(CBU22_I4_Z0 ));
endmodule

/*
* "Cell AND2"                                                                 *
*/

`timescale 10 ps / 10 ps 

module AND2 (Z0, A0, A1);

    input  A0;
    input  A1;

    output  Z0;

    and I10 (Z0, A0, A1);

endmodule

/*
* "Cell AND3"                                                                 *
*/
`timescale 10 ps / 10 ps
module AND3 (Z0, A0, A1, A2);

    input  A0;
    input  A1;
    input  A2;

    output  Z0;

    and I11 (Z0, A0, A1, A2);

endmodule

/*
* "Cell AND4"                                                                 *
*/

`timescale 10 ps / 10 ps
module AND4 (Z0, A0, A1, A2, A3);

    input  A0;
    input  A1;
    input  A2;
    input  A3;

    output  Z0;

    and I12 (Z0, A0, A1, A2, A3);

endmodule

/*
* "Cell BUF"                                                                  *
*/
`timescale 10 ps / 10 ps
module BUF (Z0, A0);

    input  A0;

    output  Z0;

    buf I13  (Z0, A0);

endmodule

/*
* "Cell LXOR2"                                                                *
*/
`timescale 10 ps / 10 ps
module LXOR2 (Z0, A0, A1);

    input  A0;
    input  A1;

    output  Z0;

    xor I14 (Z0, A0, A1);

endmodule

/**************
*     FD21    *
***************/

`timescale 10 ps / 10 ps
module FD21 (Q0, D0, CLK, CD);

  input   CLK, D0, CD;
  output  Q0;
  supply1 reset;
  //reg Q0;

  not  blk0 (t1, reset);
  or   blk1 (t2, t1, CD);

  DFF_FD blk2 (Q0, D0, CLK, t2);

endmodule

/**************************
*     PRIMITIVE DFF_FD    *
**************************/

`timescale 10 ps / 10 ps
primitive DFF_FD (Q, D, CP, R);

    output Q;  
    input  D, CP, R;
    reg    Q; 

    initial Q = 0; //Added to prevent from remaining undefined

    table
    //  D   CP      R   :   Qt  :   Qt+1

        1   (01)    0   :   ?   :   1;  // clocked data
        0   (01)    0   :   ?   :   0;

        0   (01)    x   :   ?   :   0;  // pessimism
        0    ?      x   :   0   :   0;  // pessimism

        1    0      x   :   0   :   0;  // pessimism
        1    x    (?x)  :   0   :   0;  // pessimism
        1    1    (?x)  :   0   :   0;  // pessimism

        x    0      x   :   0   :   0;  // pessimism
        x    x    (?x)  :   0   :   0;  // pessimism
        x    1    (?x)  :   0   :   0;  // pessimism

        1   (x1)    0   :   1   :   1;  // reducing pessimism
        0   (x1)    0   :   0   :   0;                          
        1   (0x)    0   :   1   :   1;  
        0   (0x)    0   :   0   :   0;  


        ?   ?       1   :   ?   :   0;  // asynchronous clear

        ?   (?0)    ?   :   ?   :   -;  // ignore falling clock
        ?   (1x)    ?   :   ?   :   -;  // ignore falling clock
        *    ?      ?   :   ?   :   -;  // ignore the edges on data

        ?    ?    (?0)  :   ?   :   -;  // ignore the edges on clear 

    endtable
endprimitive
更改测试模块中的与门允许完成模拟,但这不是我想要模拟的行为

最后,这就是我要介绍的图书馆。它基于Lattice提供的库。最终的代码将在他们的一个设备上实现。我发现这个库不太可能有问题,但是我已经包含了它,所以你可以用它来重现我的问题

库/lsc\u最小值。v:

`include "library/lsc_minimal.v"
`timescale 1 ns / 1 ns

// Define Module for Test Fixture
module test_tb();

// Inputs
    reg CLK;
    reg CD;
    reg EN;

// Outputs
    wire Q0;
    wire Q1;

// Bidirs


// Instantiate the UUT
    test UUT (
            .EN(EN),
            .CLK(CLK),
            .CD(CD),
            .Q0(Q0),
            .Q1(Q1)
            );

    always #1 CLK <= !CLK;

// Initialize Inputs
// You can add your stimulus here
    initial begin
    $dumpfile ("signals.vcd"); 
    $dumpvars;
        // initialize variables
        CLK = 0;
        CD = 0;
        EN = 0;

        //Simulation parameters
        #1 EN <= 1;
        #8 $finish;
    end

endmodule //test_tb
/* Verilog model */

module test(EN, CLK, CD, Q0, Q1);
    input EN, CLK, CD;
    output Q0, Q1;
    wire CAI, CAO, EN_IN, NOT_CAO;

buf (CAI,1);
and (EN_IN,EN,NOT_CAO);
not (NOT_CAO,CAO);

CBU22 I1 (
            .Q0(Q0),
            .Q1(Q1),
            .CAO(CAO),
            .CAI(CAI),
            .CLK(CLK),
            .EN(EN_IN),
            .CD(CD)
            );

endmodule //
/*
Minimal modules for counter test
Variables changed to remove duplicate names
*/

/*
* "Cell CBU22"                                                                 *
*/

`timescale 10 ps / 10 ps 
module CBU22(
    Q0, Q1, CAO, CAI, 
    CLK, EN, CD);

    output Q0;
    output Q1;
    output CAO;
    input CAI;
    input CLK;
    input EN;
    input CD;

    FD21 I1  (.Q0(QI0), .D0(CBU22_I8_Z0 ), .CLK(CLK), .CD(CD));
    FD21 I2  (.Q0(QI1), .D0(CBU22_I9_Z0 ), .CLK(CLK), .CD(CD));
    AND2 I3  (.Z0(CBU22_I3_Z0 ), .A0(CAI), .A1(EN));
    AND3 I4  (.Z0(CBU22_I4_Z0 ), .A0(QI0), .A1(CAI), .A2(EN));
    AND4 I5  (.Z0(CAO), .A0(QI0), .A1(QI1), .A2(CAI), .A3(EN));
    BUF I6  (.Z0(Q1), .A0(QI1));
    BUF I7  (.Z0(Q0), .A0(QI0));
    LXOR2 I8  (.Z0(CBU22_I8_Z0 ), .A0(QI0), .A1(CBU22_I3_Z0 ));
    LXOR2 I9  (.Z0(CBU22_I9_Z0 ), .A0(QI1), .A1(CBU22_I4_Z0 ));
endmodule

/*
* "Cell AND2"                                                                 *
*/

`timescale 10 ps / 10 ps 

module AND2 (Z0, A0, A1);

    input  A0;
    input  A1;

    output  Z0;

    and I10 (Z0, A0, A1);

endmodule

/*
* "Cell AND3"                                                                 *
*/
`timescale 10 ps / 10 ps
module AND3 (Z0, A0, A1, A2);

    input  A0;
    input  A1;
    input  A2;

    output  Z0;

    and I11 (Z0, A0, A1, A2);

endmodule

/*
* "Cell AND4"                                                                 *
*/

`timescale 10 ps / 10 ps
module AND4 (Z0, A0, A1, A2, A3);

    input  A0;
    input  A1;
    input  A2;
    input  A3;

    output  Z0;

    and I12 (Z0, A0, A1, A2, A3);

endmodule

/*
* "Cell BUF"                                                                  *
*/
`timescale 10 ps / 10 ps
module BUF (Z0, A0);

    input  A0;

    output  Z0;

    buf I13  (Z0, A0);

endmodule

/*
* "Cell LXOR2"                                                                *
*/
`timescale 10 ps / 10 ps
module LXOR2 (Z0, A0, A1);

    input  A0;
    input  A1;

    output  Z0;

    xor I14 (Z0, A0, A1);

endmodule

/**************
*     FD21    *
***************/

`timescale 10 ps / 10 ps
module FD21 (Q0, D0, CLK, CD);

  input   CLK, D0, CD;
  output  Q0;
  supply1 reset;
  //reg Q0;

  not  blk0 (t1, reset);
  or   blk1 (t2, t1, CD);

  DFF_FD blk2 (Q0, D0, CLK, t2);

endmodule

/**************************
*     PRIMITIVE DFF_FD    *
**************************/

`timescale 10 ps / 10 ps
primitive DFF_FD (Q, D, CP, R);

    output Q;  
    input  D, CP, R;
    reg    Q; 

    initial Q = 0; //Added to prevent from remaining undefined

    table
    //  D   CP      R   :   Qt  :   Qt+1

        1   (01)    0   :   ?   :   1;  // clocked data
        0   (01)    0   :   ?   :   0;

        0   (01)    x   :   ?   :   0;  // pessimism
        0    ?      x   :   0   :   0;  // pessimism

        1    0      x   :   0   :   0;  // pessimism
        1    x    (?x)  :   0   :   0;  // pessimism
        1    1    (?x)  :   0   :   0;  // pessimism

        x    0      x   :   0   :   0;  // pessimism
        x    x    (?x)  :   0   :   0;  // pessimism
        x    1    (?x)  :   0   :   0;  // pessimism

        1   (x1)    0   :   1   :   1;  // reducing pessimism
        0   (x1)    0   :   0   :   0;                          
        1   (0x)    0   :   1   :   1;  
        0   (0x)    0   :   0   :   0;  


        ?   ?       1   :   ?   :   0;  // asynchronous clear

        ?   (?0)    ?   :   ?   :   -;  // ignore falling clock
        ?   (1x)    ?   :   ?   :   -;  // ignore falling clock
        *    ?      ?   :   ?   :   -;  // ignore the edges on data

        ?    ?    (?0)  :   ?   :   -;  // ignore the edges on clear 

    endtable
endprimitive

我试图尽可能清楚,但如果有不清楚的地方,请告诉我。

从未完全弄清楚原始电路的错误(没有时间),但用下面的描述替换了test.v,从而使模拟得以完成并产生正确的结果

/* Verilog model */

module test(EN, CLK, CD, Q0, Q1);
    input EN, CLK, CD;
    output Q0, Q1;
    wire CAI, CAO, EN_IN, NOT_CAO;

buf (CAI,1);
and (W_1,Q0,Q1);
not (EN_IN,W_1);

CBU22 I1 (
            .Q0(Q0),
            .Q1(Q1),
            .CAO(CAO),
            .CAI(CAI_IN),
            .CLK(CLK),
            .EN(EN_IN),
            .CD(CD)
            );

endmodule //

您在测试台上粗暴地混合了阻塞和非阻塞延迟分配,因此它可能没有达到您期望的效果。谢谢您的回复Eugine,不过混合是有意的。阻塞分配用于初始化试验台。将所有内容更改为非阻塞(或阻塞语句)没有任何区别。我开始怀疑问题出在FD21模块中,它是使用lsc_minimal.v中的原语DFF_FD中的一个表定义的。然而,我不能完全弄清楚表中是什么导致了这个问题。