1
\$\begingroup\$

I'm having trouble running my Verilog code.

Here is my code:

module hello(A,B);
input A;
output B;
assign B = A; 
endmodule

And here is my testbench:

`timescale 1ns / 1ns
`include "hello.v"
 
module hello_tb;
reg A;
wire B;
hello uut(A, B);
initial begin 
 $dumfile("hello_tb.vcd");
 $dumpvar(0, hello_tb);
 A = 20;
 #20;
 A = -1;
 #20;
 A = 0;
 #20;
 $display("Test complete");
end
endmodule

These are the commands I'm running on my terminal:

iverilog -o hello_tb.vvp hello_tb.v

vvp hello_tb.vvp

And that's the error I'm getting:

hello_tb.vvp: Unable to open input file.

I don't know what I am doing wrong.

toolic
10.8k11 gold badges31 silver badges35 bronze badges
asked Aug 18, 2023 at 16:23
\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

You have syntax errors in your testbench file.

I get different error messages from you, but it is likely that I am running a different version of iverilog. It's too bad you don't get a more specific error message. Here are the errors I get:

iverilog -o hello_tb.vvp hello_tb.v
vvp hello_tb.vvp
hello_tb.v:13: Error: System task/function $dumfile() is not defined by any module.
hello_tb.v:14: Error: System task/function $dumpvar() is not defined by any module.
hello_tb.vvp: Program not runnable, 2 errors.

To fix those errors, change the testbench lines to:

$dumpfile("hello_tb.vcd");
$dumpvars(0, hello_tb);

That works for me.

It is important to note that both of the Verilog source code files (hello_tb.v and hello.v) are in the current directory when I run the iverilog command.


It is also unusual to assign values like 20 and -1 to a 1-bit signal (A) in the testbench.

answered Aug 18, 2023 at 18:48
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.