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.

Variable number of inputs in a Verilog module

Status
Not open for further replies.

vikasvij1982

Newbie level 5
Joined
Oct 31, 2004
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
86
Hi,

I wanted to code a generalized module for a project in which based on the parameters the number of inputs can vary. I know how to have different bit widths based on parameters, but not number of inputs.

As an example, if i want to have a module M1 which can have only in1 as input or it can also have in2, or in3 as inputs and this input selection is done by parameter.


Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
module #(parameter in2_select = 0, parameter in3_select = 0) M1
(
if(in2_select)
input in2,
 
if(in3_select)
input in3,
 
input in1,
 
output out
);



Can i do something like that?? Or is there any way i can do overloading of the module name in Verilog??

Thanks for any help you can provide

Vikas
 
Last edited by a moderator:

I'm not sure if verilog supports things like: "input [N-1:0] x [1:W]" if not, you might just do this by having an input [N*W-1:0].
 

Thanks permute for the quick reply, but what i meant with the question was that if i have a new pin name instead of a bus kind of representation for the inputs. That is why i was stating in1, in2 and in3.

If i am not clear then please let me know

Vikas
 

actually i have never seen that before.
but i have seen something using define instead.

Code:
    output wire                       cclk_0,      // controller clock output
    input  wire                       ctl_rst_n,
    input  wire [2              -1:0] msd_tie,     // tie-hi:tie-low i.e. 2'b10
`ifdef DWC_DDR3PHY_ITMC_D2
    input  wire                       mode_sel,    // mode select
`endif
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top