S_tb
and V_tb
are the expected outputs which are asserted by the design module which in this case is "statemachine".
The test bench encompasses the design, it acts as a stimulus for your design. In this case you will apply inputs like
initial
begin
rstn_tb = 0; //assuming an active low reset
clk_tb = 0;
#10 X_tb = 0;
end
always
#5 clk_tb = ~clk_tb; //generates a clock having a frequency of 100MHz
The above inputs are passed on-to the statemachine module and in response to that the statemachine module generates some result which is received at the ports S_tb
& V_tb
.
Also while instantiating the module its better to use the dot-name convention like
module half_add(a,b,sum,carry); //half adder, partially written
input a,b;
output sum,carry;
//logic
endmodule
module full_add(a,b,cin,sum,carry)
input a,b,cin;
output sum,carry;
//wires are not declared
//instantiating half_add
half_add h1(.a(w1),
.b(w2),
.sum(sum1),
.carry(carry1)
);
half_add h2(
//similar call as h1 instance
);
endmodule
The above type of instance avoids errors now if I instantiate the module like the one below
half_add h1(w1,
w2,
sum1,
carry1
);
Here the ports are connected based on the position and one may make mistakes while writing this like accidentally one may write
half_add h1(w1,
w2,
carry1,
sum1
);
This will cause carry1
to be connected to the sum port of the half adder module resulting in erroneous output. Hence I suggest you to avoid such type of instance calling. I guess that could be the reason for the error.