I want to rise a flag once I enter procedural block#1, and I want to reset it to zero in another procedural block. Of course I get an error saying the flag is driven by too many drivers. How can I overcome this problem?
Block 1, sensitive to sw (FPGA board switches):
always @ (sw)
flag =1;
begin
case (sw)
8'bxxxxxx01: x2= 13'd1249;
8'bxxxxxx10: x2= 13'd2499;
8'bxxxxxx11: x2= 13'd3749;
endcase
end
Block 2, sensitive to CLK:
always @ (posedge CLK)
begin
if (counter2 == x2)
begin
counter2 <=0;
flag=0;
end
else
counter2 <= counter2 +1;
end
Assuming all initialization are taken care of.