2013-11-24 121 views
3

我在使用ModelSim Student Edition 10.2c运行Verilog项目时遇到了问题。编译没有错误,但是我在运行时出现以下错误:Verilog运行时错误和ModelSim

# vsim -gui work.testbench 
# Loading work.testbench 
# Loading work.circuit1_assign 
# ** Error: (vsim-3033) C:/Modeltech_pe_edu_10.2c/examples/circuit1_assign.v(14): Instantiation of 'OR' failed. The design unit was not found. 
# 
#   Region: /testbench/c 
#   Searched libraries: 
#    C:/Modeltech_pe_edu_10.2c/examples/hw4 
# ** Error: (vsim-3033) C:/Modeltech_pe_edu_10.2c/examples/circuit1_assign.v(16): Instantiation of 'NOT' failed. The design unit was not found. 
# 
#   Region: /testbench/c 
#   Searched libraries: 
#    C:/Modeltech_pe_edu_10.2c/examples/hw4 
# ** Error: (vsim-3033) C:/Modeltech_pe_edu_10.2c/examples/circuit1_assign.v(18): Instantiation of 'AND' failed. The design unit was not found. 
# 
#   Region: /testbench/c 
#   Searched libraries: 
#    C:/Modeltech_pe_edu_10.2c/examples/hw4 
# Loading work.t1 
# Error loading design 

由于我是新来的Verilog,我不知道这意味着什么。我认为这是一个简单的错误,但我似乎无法解决它,也没有通过谷歌找到解决方案。有人知道我可以做什么,以便我的项目能够工作吗?

编辑:我相信这是与不能做的,包括其中ANDORNOT定义文件。谷歌搜索后,我发现文件modelsim.ini必须放置在项目目录中。但是,我已将modelsim.ini置于正确的目录中,但它仍然不起作用。

编辑:我现在已经发布的所有三个源文件为我的项目(这是简单的测试组合电路...)这里是我的circuit1_assign.v代码:

module circuit1_assign 
    (
    input x, 

    input y, 

    input z, 

    output f 
); 

    wire w1, w2; 

    OR o1 (.i0(x), .i1(y), .o(w1)); 

    NOT n1 (.i2(z), .o(w2)); 

    AND a1 (.i3(w1), .i4(w2), .o(f)); 


endmodule 

这里是代码用于测试:

`时间刻度为1ns/1ps的

模块T1 ( 输出一章, 输出REG b, output reg c );

initial 
    begin 
     a = 0;  //Do all combinations of possible input values  
     b = 0; 
     c = 0; 
     #10 a = 0; 
     #10 b = 0; 
     #10 c = 1; 
     #10 a = 0; 
     #10 b = 1; 
     #10 c = 0; 
     #10 a = 0; 
     #10 b = 1; 
     #10 c = 1; 
     #10 a = 1; 
     #10 b = 0; 
     #10 c = 0; 
     #10 a = 1; 
     #10 b = 0; 
     #10 c = 1; 
     #10 a = 1; 
     #10 b = 1; 
     #10 c = 0; 
     #10 a = 1; 
     #10 b = 1; 
     #10 c = 1; 
     #10 $finish; 
    end 
endmodule 

这里是我的测试平台代码:

`timescale 1ns/1ps 
module testbench(); 
    wire l, m, n, o; 

    circuit1_assign c 
    (
     .x (l), 
     .y (m), 
     .z (n), 
     .f (o) 
    ); 

    t1 t 
    (
     .a (l), 
     .b (m), 
     .c (n) 
    ); 

    initial 
    begin 
     $monitor ($time,,"l=%b, m=%b, n=%b, o=%b", 
         l, m, n, o); 
    end 

endmodule 

在此先感谢。

+0

发布您正在编译的代码。 – Russell

+0

感谢您的建议,我只是添加了所有的源代码。 – CodeKingPlusPlus

+0

您可以尝试将文件设置为顶级文件 –

回答

1

您的circuit1_assign正在实例化其他模块,称为OR,NOT,AND。这些工具正在寻找这些模块,但它找不到它们,所以会引发错误。如果你想使用这些模块,你需要自己创建它们。否则,您可以在Verilog中使用assign语句来实现您的目标。您可以更改circuit1_assign这样:

assign w1 = x | y; 
assign w2 = ~z; //I think this is right? 
assign f = w1 & w2; 
+0

'AND','OR'和'NOT'不包含在某些标准头文件中? – CodeKingPlusPlus

+0

@CodeKingPlusPlus不是你写他们的方式。我在上面的答案中拥有它们的方式是您要查找的按位和(而非)功能。这些符号内置于Verilog中。你编写它的方式意味着你不想使用任何内置的结构,而是告诉工具去寻找一些叫做AND,OR和NOT的第三方模块。 – Russell