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.

[SOLVED] Efficient way to connect 250:1 MUX in Verilog

Status
Not open for further replies.

nervecell_23

Member level 1
Joined
Apr 26, 2013
Messages
38
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,565
Hello guys,

I want to instantiate a 250:1 MUX and connect a 250bits bit vector to the input of the MUX in Verilog.
The instantiation statement would be like:

my_mux u(
.input1 (in[0]),
.input2 (in[1]),
.input3 (in[2]),
....
.input250 (in[249])
);

The question is instead of manually connect each port and repeat 250 times like the statements above, is there any efficient way to construct the connection?

It is possible to use generate for loop to instantiate multiple modules in a smart way, do we have any similar technique for my case? Any suggestion are appreciated!

Thanks a lot!
 

Instead of instantiating a multiplexer module, a single line of behavioral code can perform the intended function.

But if you need to connect a module with 250 inputs, then they have to be connected explicitely.
 

Thanks FvM,
statement like assign out=(sel)?in1:in2 would construct a mux but could you give further suggestion on how to describe a mux with large amount of inputs (each input is connected to a segment in a data bus )?

I tried the following code but doesn't work ('in' is a 500bits data bus and is connected to a 2bits 250:1 mux)
Code:
always@(sel or in)
	begin
	  assign out = in[2*sel+1:2*sel];
end
The error reports 'sel' is not constant.
How should i change the code to fix this?

Thanks!
 

See indexed part selects in 11.5.1 Vector bit-select and part-select addressing of the 1800-2012 LRM

Code:
assign out = in[2*sel+:2];
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top