Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9297637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:07:29+00:00 2026-06-18T22:07:29+00:00

Is there a way to connect two modules port without instantiating a new wire?

  • 0

Is there a way to connect two modules port without instantiating a new wire?

little example:

module comparator(max,min,in0,in1);

    input[7:0] in0,in1;
    output[7:0] max,min;

    wire[7:0] in0;
    wire[7:0] in1;
    wire[7:0] max;
    wire[7:0] min;

    assign max = (in0>in1) ? in0 : in1;
    assign min = (in0<in1) ? in0 : in1;

endmodule

I want to connect 2 comparator modules without using a new wire, is there some kind of implicit connection? i really need a way to do such thing in order to do this net:
enter image description here

there are to many wire between the modules.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T22:07:30+00:00Added an answer on June 18, 2026 at 10:07 pm

    I’m guessing you want one module that instantiates the module comparator many times in a way that looks like your diagram. You’ll need to an array (two dimensional in my solution) were the width controlled by a parameter for the best flexibility. Inside a generate block use for-loops and if-else statements to make the connections. My solution uses slice of an array e.g. +:.

    This follows IEEE Std (1800-2009), should also be true for IEEE Std (1800-2005).

    module comparator_list #(parameter int SIZE=10) (input logic [7:0] in [SIZE-1:0], output logic [7:0] out [SIZE-1:0]);
        generate
            if (SIZE==1) begin : pass_through
                always_comb out = in;
            end : pass_through
            else if (SIZE==2) begin : simple
                comparator c0 ( .max(out[0]), .min(out[1]), .in0(in[0]), .in1(in[1]) );
            end : simple
            else if (SIZE%2==1) begin : odd_list
                logic [7:0] in_buf [SIZE:0];
                logic [7:0] out_buf [SIZE:0];
                always_comb begin : link_in
                    foreach(in[idx]) in_buf[idx] = in[idx];
                    in_buf[SIZE] = 8'h00; // force last entry to 'h0 if unasigned, 'h80 if signed
                end : link_in
                always_comb begin : link_out
                    foreach(out[idx]) out[idx] = out_buf[idx];
                    // Note: out_buf[SIZE] is don't care
                end : link_out
                comparator_list #(SIZE+1) cl (.in(in_buf), .out(out_buf));
            end : odd_list
            else begin : even_list
                logic [(SIZE/2)*8-1:0] top [SIZE+1];
                logic [(SIZE/2)*8-1:0] bot [SIZE+1];
    
                for(genvar idx=0; idx<SIZE/2; idx+=1) begin : map
                    always_comb {top[0][idx*8+:8],bot[0][idx*8+:8]} = {in[2*idx],in[2*idx+1]};
                    always_comb {out[2*idx],out[2*idx+1]} = {top[SIZE][idx*8+:8],bot[SIZE][idx*8+:8]};
                end : map
    
                for(genvar stage=0; stage<SIZE; stage++) begin : link
                    if(stage%2==0) begin : even
                        comparator c0[SIZE/2-1:0] (
                            .max(top[stage+1][0+:(SIZE/2)*8]), .in0(top[stage][0+:(SIZE/2)*8]),
                            .min(bot[stage+1][0+:(SIZE/2)*8]), .in1(bot[stage][0+:(SIZE/2)*8]) );
                    end : even
                    else begin : odd
                        assign top[stage+1][7:0] = top[stage][7:0];
                        comparator c1[SIZE/2-2:0] (
                            .max(bot[stage+1][0+:(SIZE/2-1)*8]),
                            .min(top[stage+1][8+:(SIZE/2-1)*8]),
                            .in0(bot[stage][0+:(SIZE/2-1)*8]),
                            .in1(top[stage][8+:(SIZE/2-1)*8])
                        );
                        assign bot[stage+1][(SIZE/2-1)*8+:8] = bot[stage][(SIZE/2-1)*8+:8];
                    end : odd
                end : link
            end : even_list
        endgenerate
    endmodule : comparator_list
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a new way to connect to MySQL from Python with Mac OS
Is there an easy way (without downloading any plugins) to connect to a MySQL
Is there a way in Storyboard UI to connect two UIViewControllers by a segue,
Possible Duplicate: Can C# be piped? Is there a way to connect two programs
Is there way in MySQL to have two unique keys and connect them somehow?
I'm looking for a way to connect two or more client sockets directly without
A friend of mine told me there was a way to connect two private
Is there another way to connect to a MySQL database with what came included
Is there any way to connect to RDC with help of smarphone? Can it
Is there any way to connect more then one PPC to ActiveSync in one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.