Hi,I have a uvm test bench of a mux. I want to calculate the on/off time and time period of input signal in my test bench and print the values. How should i proceed with this problem…i am very new to uvm… please help.
In reply to Tina025:
To calculate the on/off time and time period of an input signal in a UVM testbench, you can follow these steps:
Monitor the Input Signal:
Create a monitor that observes the input signal and captures its transitions.
In the monitor, implement the run_phase or a separate thread to continuously monitor the input signal.
Record Transitions:
In the monitor, keep track of the rising and falling edges of the input signal.
Record the timestamp of each edge transition.
Calculate On/Off Time and Time Period:
Based on the recorded transitions, calculate the on-time, off-time, and time period of the input signal.
On-time is the duration between a rising edge and the subsequent falling edge.
Off-time is the duration between a falling edge and the subsequent rising edge.
Time period is the duration between consecutive rising (or falling) edges.
Print the Results:
After simulation or during simulation, print the calculated on/off time and time period.
Here’s a simplified example to illustrate the approach:
class Testbench extends uvm_test;
// ... other components ...
// Monitor class to observe the input signal
class my_monitor extends uvm_monitor;
// ... other monitor properties ...
virtual task run_phase(uvm_phase phase);
forever begin
// Monitor the input signal (assuming 'my_input' is the signal)
if (rising_edge(my_input))
$display("Rising Edge at time %0t", $time);
else if (falling_edge(my_input))
$display("Falling Edge at time %0t", $time);
// Optionally, record the timestamps for further analysis
// Record the timestamps in a data structure
// ...
// Delay to avoid simulation race conditions
#10;
end
endtask
endclass
// ... other test components ...
virtual task run_phase(uvm_phase phase);
my_monitor mon;
// ... other setup code ...
// Start the monitor in a new thread
mon = my_monitor::type_id::create("mon", this);
mon.randomize();
mon.set_auto_monitoring(1);
fork
mon.run_phase(phase);
join_none
// ... other simulation code ...
// Optionally, analyze the recorded timestamps and calculate on/off time and time period
// ...
// ... other cleanup code ...
endtask
endclass
This is a basic example, and you might need to adapt it based on your specific requirements and the structure of your testbench. Also, consider using a more sophisticated data structure to store edge timestamps for accurate calculations.
rahulvala@gmail.com
Freelancer/verification engineer
https://www.linkedin.com/in/rahulvala/