-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
longint is the sole type that is used in the Verilog API. This makes sense given the limitations of the DPI, but I often end up with compiler warnings due to automatic casts from longint <-> whatever the type of my knob is.
For example, bit types are common for boolean knobs, and the implied casting gives several warnings on this line:
bit my_bit = 0;
// WARNING 1. get_value casts longint -> bit
// WARNING 2. default_value param casts bit -> longint
my_bit = sknobs::get_value("my_value", my_bit); In order to avoid these warnings, I have to manually cast everything in a very ugly manner:
bit my_bit = bit'(sknobs::get_value("my_value", longint'(my_bit)));What I'm proposing is to wrap the API in a templated class, and have the API do the casting internally.
// sknobs.sv
class sknobs #(type T=longint);
static function T get_value(string name, T default_value=0);
get_value = T'(sknobs_get_value(name, longint'(default_value)));
endfuncion
endclass : sknobsThat way, my ugly casting example can become the following in user code:
bit my_bit = 0;
my_bit = sknobs#(bit)::get_value("my_value", my_bit);Metadata
Metadata
Assignees
Labels
No labels