UVM-使用我自己的配置文件与使用配置数据库

UVM- Using my own configuration files vs using config db

我写了一个可以通用于各种测试的序列。我想通过为每个测试添加配置文件来做到这一点。 序列代码:

//----------------------------------------------------------------------
//Sequence
//----------------------------------------------------------------------
class axi_sequence extends uvm_sequence#(axi_transaction);
   `uvm_object_utils(axi_sequence)

   //new
   function new (string name = "axi_sequence");
      super.new(name);
   endfunction: new

   //main task
   task body();
      int file_p, temp, len;
      byte mode;
      bit [31:0] addr;
      string str;      
      axi_transaction axi_trx;
      bit [31:0] transfers [$];
      bit [31:0] data;      


      //open file
      file_p = $fopen("./sv/write_only.txt", "r"); //the name of the file should be same as the name of the test
      //in case file doesn't exist
      `my_fatal(file_p != 0, "FILE OPENED FAILED")
      //read file
      while ($feof(file_p) == 0)
    begin
       temp = $fgets(str, file_p);
       axi_trx =  axi_transaction::type_id::create(.name("axi_trx"), .contxt(get_full_name()));
       // ~start_item~ and <finish_item> together will initiate operation of
       // a sequence item.
       start_item(axi_trx);
       transfers = {};
       $sscanf(str, "%c %d %h", mode, len, addr);
       //assign the data to str
       str = str.substr(12,str.len()-1);
       //create and assign to transfers queue
       if(mode == "w") 
         begin
            for (int i = 0; i <= len; i++) begin
           temp = $sscanf(str, "%h", data);
           `my_fatal(temp > 0, "THE LENGHT PARAM IS WRONG- too big")
           transfers. push_back(data);
           str = str.substr(13+(i+1)*8,str.len()-1);
        end//end for
            `my_fatal($sscanf(str, "%h", temp) <= 0, "THE LENGHT PARAM IS WRONG- too small")
       end//if     
       axi_trx.init(mode,len,addr,transfers);
       if (to_random == 1) to_random should be a part of the configuration file.
           trx.my_random(); //trx is transaction instance
           else
           trx.delay = const_config; //const_delay should be a part of the configuration file.
       //contains the send_request which send the request item to the sequencer, which will forward
           // it to the driver.
       finish_item(axi_trx);
    end//begin
   endtask: body

endclass: axi_sequence

我应该使用不同的配置文件来完成,还是可以通过配置数据库从测试传递给代理的值来完成? 我如何为每个测试传递不同的路径(对于 file_p = $fopen())?

您不应该为每个测试都需要一个单独的配置文件。理想情况下,您只需通过 config_db(或通过代理的单独配置对象)

将配置从测试级别向下传递到环境中

当您在测试(或虚拟音序器)中创建序列时,您应该能够根据需要设置变量。