Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Instiating submodules in verilog

Status
Not open for further replies.

QMA

Member level 4
Joined
Apr 5, 2007
Messages
72
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,832
Dear all
I am new to verilog. I have written the below code for full adder using two half adders. it is giving me syntax error
"Can not find port w2 on this module"
. The code for half adder is given at the end. Please help me in this regard.
Code for full adder
Code:
module Full_adder(
    input cin,
    input a,
    input b,
    output cout,
    output sum
    );

wire w1,w2,w3;

H_adder h1(.w2(s),
			  .w1(c),
			  .a(a),
			  .b(b)
			  );
			  
H_adder h2(.sum(s),
           .w3(c),
			  .w2(w2),
			  .cin(cin));
or (cout,w1,w3);

endmodule

Code for half adder
Code:
module H_adder(
    input a,
    input b,
    output s,
    output c
    );

assign s = a^b;
assign c = a&b;

endmodule
 

The port names should be identical in the definition as well as the instantiation. Your definition has ports a,b,s &c. But your instantiation has different ports(w1,w2,a,b) and (w2,w3,sum & cin).
 

You use the following format.

Code:
.sub_module_port_name (signal_name)
 

    V

    Points: 2
    Helpful Answer Positive Rating
The port names should be identical in the definition as well as the instantiation. Your definition has ports a,b,s &c. But your instantiation has different ports(w1,w2,a,b) and (w2,w3,sum & cin).

it is not giving me error for the other ports like for w1, w3 or cin etc. i am not getting it actually.

- - - Updated - - -

You use the following format.

Code:
.sub_module_port_name (signal_name)


bundle of thanks dear. it has worked
 

Verilog instances have sub module ports names after . and in parentheses the connection name is specified. You have just reversed that order.

And yeah, in simulation when you compile a code it will only check for syntax errors. This kind of errors are found at elaboration step. May be you have just tried the compilation of your code that's why you didn't get any error.

Hope that helps.

MSBR
 

See this complete working example here - basically there were two sets of issues in the code.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top