In reply to mago1991:
this is actually a good point. Generally speaking interrupts are managed using some EN register which are the cleared by HW. irrespective of this they are all clocked operation anyway. One solution could be:
if(register.enable.value == '1) begin
$display("interrupt enalble waiting for being served")
fork
begin: intwait
served = 0;
wait(register.enable.value == 0); // Do not use empty function here
served = 1;
end
begin: timeout
// your timeout based on clk
served = 0;
end
join_any
// Exit
if(!served) disable intwait;
else disable timeout;
end
Frankly in this solution you should carefully set up the timeout to a reasonable value.
alternatively an interrupt signal has a positive and negative edge so you could use:
wait(your_signal == 1);
$display("interrupt enable");
wait(your_signal == 0);
$display("Interrupt served");
or again simply use the:
always @(posedge interrupt) begin
@(negedge interrupt )
// ...
a task into an interface will be useful as well. Regards