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.

Compile directtive and conditional instantiation

Status
Not open for further replies.

lostinxlation

Advanced Member level 2
Joined
Aug 19, 2010
Messages
699
Helped
197
Reputation
394
Reaction score
183
Trophy points
1,323
Location
San Jose area
Activity points
5,051
Compile directtive and conditional instantiation - Verilog

I have a module that instantiates a cell based on the input value and I so far have no success. I wonder if someone can shed light on it.

let's say the module instanitates a PAD0 if SEL is 0, and PAD1 if SEL is 1.
Code:
module pad_drvr (IN, OUT, SEL);
input IN, SEL;
output OUT;

`define A (SEL==1'b0)

`ifdef A
    PAD0 (IN, OUT);
`else
    PAD1 (IN, OUT);
`end

endmodule

This module is instantiated on the upper level with either 0 or 1 on SEL.
Code:
pad_drvr (in0, out0, 1'b0);
pad_drvr (in1, out1, 1'b1);
.....
...

The issue is the tool doesn't properly pick PAD0 or PAD1 when I run a simulation. I guess passing the information between a compile directive and module ports is the issue, and I don't know if it's even possible, but if anyone knows a good solution for this, appreciate your input.
 
Last edited:

What you are trying to do is possible, but not the way your approaching it.
The problem with your code is the `define A (SEL==1'b0) & `ifdef statements are evaluated during compile time and not run time.
I'd recommend using parameters & generate statements.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top