How to implement fly on reset in below APB driver code?
class apb_driver extends uvm_driver#(apb_transaction);
`uvm_component_utils(apb_driver)
..............
.............
virtual task run_phase(uvm_phase phase);
super.run_phase(phase);
// getting option for PREADY from commandline
proc.get_arg_value ("+option=",option_s);
option_value=option_s.atoi();
// getting max wait value for PREADY
proc.get_arg_value ("+range_max=",range_max_s);
range_max=range_max_s.atoi();
// getting min wait value for PREADY
proc.get_arg_value ("+range_min=",range_min_s);
range_min=range_min_s.atoi();
// getting hardcoded value for PREADY
proc.get_arg_value ("+hardcoded=",hardcoded_s);
hardcoded=hardcoded_s.atoi();
// getting option for PRDATA
proc.get_arg_value ("+option_prdata=",option_prdata_s);
option_prdata=option_prdata_s.atoi();
// getting max value for PRDATA
proc.get_arg_value ("+range_max_prdata=",range_max_prdata_s);
range_max_prdata=range_max_prdata_s.atoi();
// getting min value for PRDATA
proc.get_arg_value ("+range_min_prdata=",range_min_prdata_s);
range_min_prdata=range_min_prdata_s.atoi();
// getting hardcoded value for PRDATA
proc.get_arg_value ("+hardcoded_prdata=",hardcoded_prdata_s);
hardcoded_prdata=hardcoded_prdata_s.atoi();
forever begin
@(intf_inst.MASTER.master_cb);
if (intf_inst.MASTER.PRESET)
begin
if(MS)
begin
// driver as a master functionality task
driver_master();
end
else
begin
// driver as a slave functionality task
driver_slave();
end
end
else
begin
// reset task
reset_condition_task(); end
end
endtask
........
driver_slave() and driver_master() task
....
endclass
AND also is there any other way of taking commandline arguments for PRDATA (new value for every transaction)as mentioned in above code or how can we read PRDATA value from a file?
AND also is there any other way of taking commandline arguments for PRDATA (new value for every transaction)as mentioned in above code or how can we read PRDATA value from a file?
As far as I get this, you want to get PRDATA value for every transaction from command line. One can use array of PRDATA to read a pre-formatted file. Following is a sample code about how one can read the file and store it in an array. Note that I have not tried exact syntax over here.
logic [31:0] val; // Temporary variable to read each value from file
logic [31:0] PRDATA [$]; // Data Queue/Array
file=$fopen("myfile.txt", "r"); // myfile.txt can come from plusarg
while(! $feof(file)) begin // While EOF has not arrived
r = $fscanf(file, "%0h",val); // Read each line
PRDATA.push_back(val); // Push value read in PRDATA
end
$fclose(file);
Refer to this link for more information on file handling.
For me is not really clear what your objective is. Why do you want to read your Stimuli from a pattern file. It is more easy and powerful to use Random pattern. And of cause you can randomly generate your reset signal with a reset sequence.
In reply to Ravina:
For me is not really clear what your objective is. Why do you want to read your Stimuli from a pattern file. It is more easy and powerful to use Random pattern. And of cause you can randomly generate your reset signal with a reset sequence.
yes, i can give RESET randomly. but i am getting issue when RESET comes in between the transaction, SO that transaction get missed. So how can i send that transaction after the RESET get finish??? Because in my case the sequence generates the next transaction and that get transmitted after RESET gets completed.
So any idea to to transmit the missed transaction again afer completion of RESET???
In reply to Ravina:
As far as I get this, you want to get PRDATA value for every transaction from command line. One can use array of PRDATA to read a pre-formatted file. Following is a sample code about how one can read the file and store it in an array. Note that I have not tried exact syntax over here.
logic [31:0] val; // Temporary variable to read each value from file
logic [31:0] PRDATA [$]; // Data Queue/Array
file=$fopen("myfile.txt", "r"); // myfile.txt can come from plusarg
while(! $feof(file)) begin // While EOF has not arrived
r = $fscanf(file, "%0h",val); // Read each line
PRDATA.push_back(val); // Push value read in PRDATA
end
$fclose(file);
Refer to this link for more information on file handling.
Thanks for your rply.
is there any other way of providing no of cycles for PREADY (i.e. PREADY should be enable after that no of cycles) in case of wait state and that is different for every trancation???
In reply to Ravina:
If you are using a transmit sequence and a reset sequence the reset sequence can lock the execution of the transmit sequence, doing the reset and after completing the reset continuing the transmit sequence. This works without loosing data or seq_items.
In reply to Ravina:
If you are using a transmit sequence and a reset sequence the reset sequence can lock the execution of the transmit sequence, doing the reset and after completing the reset continuing the transmit sequence. This works without loosing data or seq_items.
In reply to sharvil111:
is there any other way of providing no of cycles for PREADY (i.e. PREADY should be enable after that no of cycles) in case of wait state and that is different for every trancation???
You can add PREADY to your seq_item definition. Randomizing the seq_item gives you randomly generated numbers for PREADY.
Either randomize PREADY signal for every transaction.
rand bit PREADY; // PREADY randomized in every transaction
Or give some distribution constrained value from plusarg. This plusarg value will go to constraint and the randomization will occur as per user’s inputs.
rand bit PREADY;
int user_pready_cycles; // user/plusarg defined cycles for PREADY
bit user_pready_val; // user/plusarg defined value for PREADY
int num_pready_cycles; // number of randomizations for PREADY
int unsigned user_freq;
constraint PREADY_cn{
if(num_pready_cycles = user_pready_cycles) {
PREADY == user_pready_val; // user_pready_val will come from plusarg
} else {
PREADY inside {[0:1]};
}
};
function post_randomize();
num_pready_cycles ++;
endfunction
If one wants to give PREADY for each transaction, then you can add it in the same input file and read the PREADY also from that file. Refer to this link for similar code:
logic [31:0] val; // Temporary variable to read each value from file
logic [31:0] PRDATA [$]; // Data Queue/Array
logic [31:0] PREADY [$]; // Ready Queue/Array
file=$fopen("myfile.txt", "r"); // myfile.txt can come from plusarg
while(! $feof(file)) begin // While EOF has not arrived
r = $fscanf(file, "%0b %0h",ready,val); // Read each line
PRDATA.push_back(val); // Push value read in PRDATA
PRREADY.push_back(ready); // Push value read in PREADY
end
$fclose(file);
// Sample File format:
1 0123
0 4567
1 89AB
Note that this will constrain each and every transaction and it is not a good practice to do so.