Sample adress value only once which is valid for multiple clock cycle

Hello All,

I have to sample address only once while valid is asserted for multiple clocks , push it into the queue and remove when clear is asserted.


logic [7:0] valid;
logic [31:0] addr [7:0];
logic [7:0] clr_valid;

Here valid is multibit and is asserted for more then one clock cycle and with that addr[i] is also latched. When clr_valid comes(clr_valid is asserted only for one clock), valid gets de-asserted and then addr is dont care.

To sample addr and put it into queue through monitor, i used below code but I was thinking if any better way to do it, would be great.

confusion is that , here valid is multi bit and asserted for multi clocks. if it was only one bit i can easyly rely on @(posedge valid ) and sample address. since here valid is multi bit, i was not sure how to sample it in uvm_monitor. any better suggestion for below monitor_addr task ?

to clear it, its simple as clr_valid is asserted for just one clock.



in interface file, i flopped valid.

monitor_if

logic [7:0] valid_f;
always_ff @(posedge clk) valid_f <= #1ps valid;

UVM monitor :

task monitor_addr();
forever @(posedge clk) begin
  for(int i=0 ;i <8 ; i++) begin
    if(!vif.valid_f[i] && (vif.valid[i] !== valid_f[i])) begin
    mon_port.write(addr[i]);
    end
  end
end
endtask 

task clear_addr();
forever @(posedge vid.clk) begin
  for(int i=0 ;i <8 ; i++) begin
    if(vif.valid[i] !== clr_valid[i]) begin
    mon_port_clear.write(addr[i]);
    end
  end  
end
edndtask
endtask 



Thank you.

In reply to edaboy:

The way you handle a multi-bit valid signal in a UVM monitor seems to make sense. You use the flopped version valid_f and sample it on each increasing flow of the clock. When the corresponding bit in valid shifts from high to low, it queues the corresponding address on mon_port. This method effectively captures the falling edge of each bit in the correct signal.

Keep in mind, however, that this method may miss normal variations of the same clock cycle and deassert. If such changes are likely to occur in your configuration and need to be captured, you may need a detailed analysis of the changes in the clock cycle, using finer time granularity if possible, depending on your configuration on the basis of requirements

Other than that, the code takes care to capture address information based on falling valid signals. If it meets your design needs and performance expectations, it should work well.


rahulvala@gmail.com
Freelancer/verification engineer
https://www.linkedin.com/in/rahulvala/