How Can I Connect Multiple Modules in Verilog?

  • Thread starter Thread starter david90
  • Start date Start date
  • Tags Tags
    Language
Click For Summary

Discussion Overview

The discussion revolves around connecting multiple modules in Verilog, specifically how to instantiate and wire them together in a top-level module. Participants explore the mechanics of module interconnection, including the use of wires and the integration of outputs into logical operations like AND gates.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Homework-related

Main Points Raised

  • One participant asks how to connect three modules in Verilog so that the output of one feeds into another.
  • Another participant suggests creating a top-level module that instantiates the three modules and connects them with wires.
  • A participant seeks clarification on the term "instantiates" and requests more detail on how to use wires for connections.
  • A participant provides an example of a top-level module that connects two sub-modules using the "wire" keyword.
  • There is a confirmation that the input of one sub-module is wired to the output of another, though the naming in the example is noted as potentially confusing.
  • A participant presents a new problem involving connecting three module outputs to an AND gate and asks for guidance on this setup.
  • Another participant provides a snippet showing how to connect outputs to an AND gate using wires.
  • A participant inquires about linking four one-bit ALUs to create a four-bit ALU, questioning if the same method applies.
  • A participant confirms that the same method can be used but advises caution regarding carry signals.

Areas of Agreement / Disagreement

Participants generally agree on the method of using a top-level module and wires to connect sub-modules, but there are varying levels of understanding and requests for clarification on specific terms and implementations.

Contextual Notes

Some participants express uncertainty about terminology and specific implementation details, indicating a need for further clarification on wiring and module instantiation.

david90
Messages
311
Reaction score
2
Say I have 3 modules and I want them to connect them together (make them work together. Ie, output of one module would go into another etc.), how would I do this in verilog?
 
Engineering news on Phys.org
Create a top-level module that instantiates each of the three modules, and connects them with wires.

- Warren
 
instantiates ?[?] [b(] U mean create a 4th module that connects the 3 modules together with wire? Can u elaborate on the "wire" part?
 
Last edited:
Yes, make a top level module which creates instances of the three lower modules.

The "wire" keyword, surprisingly, makes wires.

Here's a simple example with two modules, sub_a and sub_b, and a toplevel module which connects their inputs and outputs.

module sub_a ( in, out );

input in;
output out;

...

endmodule

module sub_b ( in, out );

input in;
output out;

...

endmodule

module toplevel;

wire one;
wire two;

sub_a sub_a_instance ( .in(one), .out(two) );

sub_b sub_b_instance ( .in(two), .out(one) );

endmodule
 
My interpretation of ur code sub_a input is wired to sub_b output. Am I right?
 
Yup, it just wires the inputs of each to outputs of the other. Of course the names are not exactly well-chosen. I just wanted to demonstrate the concept.

- Warren
 
Thanks you've cleared it up a lot. I have another problem. I'm trying to write a code for a chip that has 3 modules and the output of those three modules are connected to an AND gate. How do I go about doing that??
 
...

wire sub_1_output;
wire sub_2_output;
wire sub_3_output;

wire and_output;

and and_gate (and_output, sub_1_output, sub_2_output, sub_3_output);

...

- Warren
 
now that i have a one bit ALU, how would I link 4 of them together for a 4bit ALU? same method?
 
  • #10
yep, just be careful not to mix up the carry signals...
 

Similar threads

Replies
2
Views
779
  • · Replies 5 ·
Replies
5
Views
3K
Replies
8
Views
2K
  • · Replies 15 ·
Replies
15
Views
5K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 9 ·
Replies
9
Views
6K
Replies
37
Views
8K
Replies
2
Views
7K
Replies
5
Views
2K
  • · Replies 28 ·
Replies
28
Views
6K