Guest
Hi.
I model a cpu that receives from my chip 2 interupts signals.
Upon each interrupt the cpu performs different set of registers read
and writes.
The register_read and register_write are implemented in verilog task.
Since these are time-consuming tasks, I fear from a collision between
cpu
accesses origineted by the 2 interrupts.
I have a solution in mind, but I am not sure if it is risky:
The solution is based on verilog wait statement + a global lock signal,
and on the fact that the 2
interrupt proccesses (and the tasks) are located in the same file and
module.
initial begin
@ (negedge interrupt1_n) ;
// some code that handles interrupt 1
reg_read ( ... );
...
reg_write (...) ;
..
end
initial begin
@ (negedge interrupt2_n) ;
// some code that handles interrupt 2
reg_read ( ... );
...
reg_write (...) ;
..
end
reg lock;
initial lock = 0;
task reg_read
input ...
output ...
begin
wait (lock == 0) ;
lock = 1;
// and here goes the code
lock = 0;
end
task reg_write
input ...
output ...
begin
wait (lock == 0) ;
lock = 1;
// and here goes the code
lock = 0;
end
Do you see any risk in such code ?
Can I expand it to more processes that use these tasks safely?
ThankX,
NAHUM
I model a cpu that receives from my chip 2 interupts signals.
Upon each interrupt the cpu performs different set of registers read
and writes.
The register_read and register_write are implemented in verilog task.
Since these are time-consuming tasks, I fear from a collision between
cpu
accesses origineted by the 2 interrupts.
I have a solution in mind, but I am not sure if it is risky:
The solution is based on verilog wait statement + a global lock signal,
and on the fact that the 2
interrupt proccesses (and the tasks) are located in the same file and
module.
initial begin
@ (negedge interrupt1_n) ;
// some code that handles interrupt 1
reg_read ( ... );
...
reg_write (...) ;
..
end
initial begin
@ (negedge interrupt2_n) ;
// some code that handles interrupt 2
reg_read ( ... );
...
reg_write (...) ;
..
end
reg lock;
initial lock = 0;
task reg_read
input ...
output ...
begin
wait (lock == 0) ;
lock = 1;
// and here goes the code
lock = 0;
end
task reg_write
input ...
output ...
begin
wait (lock == 0) ;
lock = 1;
// and here goes the code
lock = 0;
end
Do you see any risk in such code ?
Can I expand it to more processes that use these tasks safely?
ThankX,
NAHUM