A
Andrew FPGA
Guest
Hi all,
I often find myself implementing a piece of functionality whose
behaviour I want to control using either a Generic or a constant. But
sometimes I'm not sure if a generic or a constant is the best approach.
By "best" approach I mean the style which gives the best tradeoff in
flexibility of design, ease of understanding the design, and ease of
use by grouping these "build functionality modifiers". What criteria
do others use when choosing between the use of a generic or a constant
in their design?
Quick example: Say I have some debug code (say a PRBS generator) that I
only want included in the design for debug builds. For the production
release I don't want the functionality there. I would use a generate
statement around the PRBS generator. Then I could
a) have a Generic on the module in which this PRBS generator exists
called "INCLUDE_PRBS_GENERATOR : boolean" . Whenever this module is
instantiated I can choose to build with or without the PRBS generator.
b) I could have a constant INCLUDE_PRBS_GENERATOR. That constant can be
set to true/false within the module or could be put into a package
collecting together all build options in one place.
Advantages of the generic approach:
1) Each instantiation of the module can be customised differently to
the others.
2) ?
Advantages of the constant approach:
1) All build options can be packaged up in one place, not scattered
throughout the design hierarchy.
2) Less typing, don't need to remember to include the generic on every
instantiation.
3)?
Regards
Andrew
I often find myself implementing a piece of functionality whose
behaviour I want to control using either a Generic or a constant. But
sometimes I'm not sure if a generic or a constant is the best approach.
By "best" approach I mean the style which gives the best tradeoff in
flexibility of design, ease of understanding the design, and ease of
use by grouping these "build functionality modifiers". What criteria
do others use when choosing between the use of a generic or a constant
in their design?
Quick example: Say I have some debug code (say a PRBS generator) that I
only want included in the design for debug builds. For the production
release I don't want the functionality there. I would use a generate
statement around the PRBS generator. Then I could
a) have a Generic on the module in which this PRBS generator exists
called "INCLUDE_PRBS_GENERATOR : boolean" . Whenever this module is
instantiated I can choose to build with or without the PRBS generator.
b) I could have a constant INCLUDE_PRBS_GENERATOR. That constant can be
set to true/false within the module or could be put into a package
collecting together all build options in one place.
Advantages of the generic approach:
1) Each instantiation of the module can be customised differently to
the others.
2) ?
Advantages of the constant approach:
1) All build options can be packaged up in one place, not scattered
throughout the design hierarchy.
2) Less typing, don't need to remember to include the generic on every
instantiation.
3)?
Regards
Andrew