Is there any way can we pass the “type” variable in struct or pkg instead of passing as parameter ? So that rather than listing multiple type in the parameter list, instead can be passed in the struct or so ?
typedef struct {
int width = 1;
// type T = logic;
} try_s;
// parameter try_s try_i = '{ width:8, T=reg};
parameter try_s try_i = '{ width:8};
module struct_try #(parameter try_s try=try_i);
logic blue;
logic [try.width-1:0] red;
// try.T black;
initial begin
$display(" width= %0d\n", try.width);
// $display(" width= %0d, type %s\n", try.width, try.T);
end
endmodule: struct_try
Thanks for the technique. But is it possible with the classes as well ? Somehting like given below ?
module try;
class cfg_A;
typedef int t1;
int DEP = 4;
endclass: cfg_A
class cfg_B;
typedef bit t1;
int DEP = 8;
endclass: cfg_B
class aloha #(type t);
type (t::t1)[t::DEP-1:0] data;
function display();
$display("Value of data = %h\n", data);
endfunction: display
endclass: aloha
aloha #(cfg_A) al;
aloha #(cfg_B) bl;
initial begin
al = new(); bl = new();
al.display(); bl.display();
end
endmodule: try