Altera_Forum
Honored Contributor
13 years agoforeach in systemverilog
What is wrong with this piece of code? Questa has no problem with it but Quartus does. Quartus has no issues with it if I remove the foreach and replace it with generate statement.
always_ff@(posedge register_if.clk or negedge register_if.rstn) if(!register_if.rstn) begin foreach (int_stat_update_cnt_reg[intStatIter]) begin int_stat_update_cnt_reg[intStatIter] <= 'd0; end foreach (int_stat_cnt_reg[intStatIter]) begin int_stat_cnt_reg[intStatIter] <= 'd0; end end <... snip ...> Generate statement as below works - genvar intStatIter; generate for (intStatIter=0;intStatIter<NUM_OF_INT_STAT_REG; intStatIter+=1) begin : intStat_gen always_ff@(posedge register_if.clk or negedge register_if.rstn) if(!register_if.rstn) begin //foreach (int_stat_update_cnt_reg[intStatIter]) begin int_stat_update_cnt_reg[intStatIter] <= 'd0; //end //foreach (int_stat_cnt_reg[intStatIter]) begin int_stat_cnt_reg[intStatIter] <= 'd0; //end end