I'm designing a Qsys component which I want to be user-configurable. It has config parameters which are defined in the TCL file. For example, for a GPIO bank component I would write:
add_parameter GPIO_OUTPUTS_COUNT POSITIVE 8 "Number of GPIO pins"
set_parameter_property GPIO_OUTPUTS_COUNT DEFAULT_VALUE 8
set_parameter_property GPIO_OUTPUTS_COUNT ALLOWED_RANGES 1:32
set_parameter_property GPIO_OUTPUTS_COUNT HDL_PARAMETER true
The value of this parameter can be accesses in HDL code easily:
module gpio
(
...
);
parameter GPIO_OUTPUTS_COUNT; // gets the value assigned by user
Now, I would also like to have this value in my driver's C code, e.g. to check for errors where the user is trying to access non-existing pins:
int gpio_write(pin, level) {
if(pin >= GPIO_OUTPUTS_COUNT) return -1; // No such pin
...
return 0; // Success
}
How can I get GPIO_OUTPUTS_COUNT
name defined in my C code?