The problem is that I want call do_something() with different interfaces item size but always lower then 16 bit.
If for example vif.item size is [7:0] I get the error
packed array [15:0] of logic’ but found ‘packed array [7:0] of logic’ instead
I understand why it happens but how can I fix this?
I tried casting, concatenation but with out success
I need that do_something will support input from many interfaces items with different item sizes.
Just to give you a context, do_somthing reads a value of a register form RAL and compare it to the interface that this specific register controls.
I use ref logic because I don’t know exactly when the register will be read, so I need that the value of the input will reflect the exact value of the interface when the register if finally been read.
You can use parametrized class to implement the logic with variable width.
class var_width #(parameter WIDTH=0);
static task do_something(ref logic [WIDTH-1 : 0] data);
wait_some_time();
$display(data);
endtask
endclass
// In your module or class
var_width#(8)::do_something(vif.data_a);
var_width#(12)::do_something(vif.data_b);