I write SPI slave BFM module with several SPI interfaces. I use Active-HDL 9.1. I generate several blocks(spi slaves) in my SystemVerilog code. I also write functions in which I read and reset data in this blocks. This is a part of my code:
module bfm_spi(itf_spi);
parameter C_NUM = 1;
parameter C_DATA_WIDTH = 32;
spi_interface itf_spi [C_NUM];
genvar i;
generate
for(i=0; i < C_NUM; i++) begin : bfm_spi_arr
bfm_spi_1 #(.C_DATA_WIDTH(C_DATA_WIDTH)) bfm_spi_1_i (itf_spi[i]);
end
endgenerate
/**
* Reset all input buffers
* */
task Reset;
integer i;
for(i = 0; i < C_NUM; i++) bfm_spi_arr[i].bfm_spi_1_i.Reset(); //Error this
endtask // Reset
During a compile compiler write error for line, in which I note "Error this".
Error message: Generate block item selection with variable index is not supported: i
If I replace i with constant number, complile is OK.
module bfm_spi(itf_spi);
parameter C_NUM = 1;
parameter C_DATA_WIDTH = 32;
spi_interface itf_spi [C_NUM];
genvar i;
generate
for(i=0; i < C_NUM; i++) begin : bfm_spi_arr
bfm_spi_1 #(.C_DATA_WIDTH(C_DATA_WIDTH)) bfm_spi_1_i (itf_spi[i]);
end
endgenerate
/**
* Reset all input buffers
* */
task Reset;
integer i;
for(i = 0; i < C_NUM; i++) bfm_spi_arr[0].bfm_spi_1_i.Reset(); //OK
endtask // Reset
How I can select several bfm_spi_1_i block in generate in my task Reset()? This BFM module is used only for simulation, not for implemantions
What you can do create an interface or abstract class with an implementation that calls each Reset() inside the generate
interface class Reset_c; // you can use a virtual class if your simulator does not yet support interface classes.
pure virtual task Reset;
endclass
Reset_c R_h[C_NUM]; // array of handles to each implementation instance
for(genvar i=0; i < C_NUM; i++) begin : bfm_spi_arr
bfm_spi_1 #(.C_DATA_WIDTH(C_DATA_WIDTH)) bfm_spi_1_i (itf_spi[i]);
class Reset_imp implements Reset_c;
virtual task Reset;
bfm_spi_1_i.Reset()
endtask
endclass
initial R_h[i] = new;
end : bfm_spi_arr
task Reset;
for(int i = 0; i < C_NUM; i++) R_h[i].Reset();
endtask // Reset
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.