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
 

sharath666

Advanced Member level 2
Joined
Apr 4, 2011
Messages
552
Helped
126
Reputation
252
Reaction score
124
Trophy points
1,323
Location
India
Activity points
3,830
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).
 

ads-ee

Super Moderator
Staff member
Joined
Sep 10, 2013
Messages
7,820
Helped
1,811
Reputation
3,632
Reaction score
1,772
Trophy points
1,393
Location
USA
Activity points
59,029
You use the following format.

Code:
.sub_module_port_name (signal_name)
 

    V

    Points: 2
    Helpful Answer Positive Rating

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
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
 

MSBR

Member level 1
Joined
Jan 9, 2015
Messages
39
Helped
10
Reputation
20
Reaction score
10
Trophy points
8
Location
Pakistan
Activity points
242
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
 

dehati

Member level 3
Joined
Jan 9, 2008
Messages
61
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,288
Activity points
1,659
See this complete working example here - basically there were two sets of issues in the code.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top