hi.
how shall i populate the array in check phase? here iam trying to capture the time into an array in run phase and do the necessary calculations in check phase. a pseudo code is shown below
task void run_phase(uvm_phase phase);
int fd; // file handle
// array declaration for capturing start and run time
time s[1:0];// start time
time e[1:0];// end time
//to open file in write mode
fd = $fopen ("file.txt","w");
$fdisplay(fd," Printing time into the file");
fork begin
forever begin
@posedge(clk);
startt[1:0] = $time;
$fdisplay( fd," s[%0d]: %0t", s);
end
end
begin
forever begin
@posedge(clk);
endt[1:0] = $time;
$fdisplay( fd," e[%0d]: %0t", e);
end
end
join
endtask :run_phase
i need to use both s and e to calculate my latency . the formula is end time- start time. can you tell me how can I use these array in check phase and do the calculation?
sorry there has been a mistake in the code it should be
s[1:0] = $time; and similarly e[1:0] =$time;
i want to know how can i use the arrays s and e and do the latency calculation in check phase. how can i read back these arrays in check phase ? here iam completely using array operations and not file handling operation.
$time returns 1 value. But you are assigning this value to a 2-dim array.
You can write only a string to the file.
Reading back the data from the file you have to re-format this string.
Look here to see the details:
If you want to use an array (without file I/O) you need for each entry an array element. It might result in a huge array.
If you want to set a variable in one phase and read it in another phase of of the same uvm_component, they need to be declared as class members, not local to the phase methods. If the phases are in different components, then they should be shared is a uvm_config_db object.
The pseudocode you show does not make much sense. How are you expecting to index into the array? You also might want to use realtime instead of time.
here the time comes from simulation that is its coming from the design.also how can i use $time to capture the start n end time from the simulation. according to me s[1:0] = $time captures the current simulation time into the respective arrays.
did you mean to say i should declare those arrays outside the run phase? like below:
class my_monitor extends uvm_monitor;
time s[1:0];
time e[1:0];
.
.
.
.
task void run_phase(uvm_phase phase);
.
.
.
also should i use $realtime instead of $time?
can you help me with a pseudo code to capture the start and end time of 10 packets into an array in run phase and populate or use that array to calculate the latency in check phase?
latency = end time- start time
can you help me with a pseudo code to capture the start and end time of 10 packets into an array in run phase and populate or use that array to calculate the latency in check phase?
latency = end time- start time
Instead of calculating latency in check phase, why don’t you calculate it in run phase and pass the information to check phase?
You can declare latency as an array and just you have to store previous timestamp. Something like,
real latency[$];
realtime start_time;
latency.push_back($realtime-start_time);
As Dave suggested, you can pass it to check phase without using another file.
here start and end time are two interface signals and its impossible to avoid end time signal Thats the reason why i mentioned end time and start time. And both the timings need to be captured in array in run phase and then in check phase using that array doing the calculations