Conditional inclusion of a component within a project

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I have noticed there is a disable setting in the Built-in section of components and that it has an fx option.    Can this feature be used to include/exclude the component using something like #defines in source?

   

That would be nice !

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

It is working for me just the other way: I am using an #ifdef and checking for the symbol created in the component's .h file as

   

found in generated .h

   

#if !defined(CY_SCB_UART_H)
#define CY_SCB_UART_H

   


I check for

   

#ifdef CY_SCB_UART_H

   

... code for my UART

   

#endif

   

 

   

I am quite sure that it cannot work the other way by having conditionals in the C source to activate / de-activate components.

   

The reason is that the fitter (which instanciates the components) is run first, then the code generation step comes and at last the compiler (where your wanted #defines must reside) reads all the stuff.

   

 

   

Bob

View solution in original post

0 Likes
6 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

It is working for me just the other way: I am using an #ifdef and checking for the symbol created in the component's .h file as

   

found in generated .h

   

#if !defined(CY_SCB_UART_H)
#define CY_SCB_UART_H

   


I check for

   

#ifdef CY_SCB_UART_H

   

... code for my UART

   

#endif

   

 

   

I am quite sure that it cannot work the other way by having conditionals in the C source to activate / de-activate components.

   

The reason is that the fitter (which instanciates the components) is run first, then the code generation step comes and at last the compiler (where your wanted #defines must reside) reads all the stuff.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Thank you Bob.   I am a bit confused, which should not be much of a surprise.    This is from the Component Author Guide:

   

CY_REMOVE:   This parameter is a flag to the elaborator, which tells it to remove the instance
from the netlist. It works in conjunction with the live mux to allow Component
authors to dynamically switch between two different implementations of a
Component in a single schematic. The default value is false (that is, keep the
instance around).

   

I am trying to grasp its use.   What is a "live mux"?   

   

Edit:  May be best would be if there is an example project to see it.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The term "live mux" probably refers to the "Virtual Mux" components. these can be used to make connections selected at design time using parameters. These virtual muxes do not use any hardware. So you can imagine you are using a SD ADC or  an SAR depending on a parameter set. This is something for the component designers.

   

 

   

Bob

Anonymous
Not applicable

I think I got it.    I may give it a try one day.

   

Thank you

   

Tony

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You are always welcome.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

I tried the virtual mux  !    I have been working on this one project, having to set a "1" or a "0"  on a wire for tests.   I just dropped in a virtual mux and fed it with a "1" on pin 1 and a "0" on pin 0.    Then I  can just click on the component and select the one I want.    Trivial but cool !

0 Likes