I wrote few lines of code and it is giving error. The code is below:
module tb();
wire [7:0] m1,m2,m3;
reg [7:0] a,b,c;
reg en;
reg clka=0;
s_three call(m1,m2,m3,a,b,c,en,clka);
always begin
#10 clka<=~clka;
end
initial begin
en<=1'b1;
a<=8'h00;
b<=8'haf;
c<=8'ha2;
end
endmodule
module s_three(m1,m2,m3,a,b,c,en,clka);
input [7:0] a,b,c;
input en,clka;
output [7:0] m1,m2,m3;
wire [7:0] m11,m12;
s1 s0(m11,m12,a,b,en,clka);
endmodule
The error given below:
ERROR:HDLCompiler:329 – "tb.v" Line 29. Concurrent assignment to a
non-net a is not permittedERROR:Simulator:778 – Static elaboration of top level Verilog design
unit(s) in library work failed
How can I resolve it ?
Thank you
Best Answer
Right, so what is happening is you have declared your module as this:
Now you might expect the ports to be connected in the order they appear in the brackets, but this is actually not so, they need to be connected in the order they are declared by the
input ...
,output ...
lines, i.e. the implicit connection order for your module will actually be:As a result you are connecting up your ports in a way you aren't expecting which can lead to funny errors. In this case outputs are connected to inputs, the register
c
is connected to an output (bad!), etc.Implicit connection of ports is a debugging headache and while it saves a little bit of typing you really should avoid it for your own sanity when it comes to testing things. Also if you happened to want to add a new port, or change them around later on, anything that is implicitly connected would break.
To solve the problem, you should use explicit connections. For example the following explicitly connects the pins:
The connections are described as:
.portInModule(signalToConnect)
. By doing it this way it doesn't matter what order they appear. This would work just as well: