代码之家  ›  专栏  ›  技术社区  ›  sara8d

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

  •  0
  • sara8d  · 技术社区  · 8 年前

    我编写了一个序列,它可以通用于各种测试。我想为每个测试添加配置文件。 sequnce的代码:

    //----------------------------------------------------------------------
    //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())?

    1 回复  |  直到 8 年前
        1
  •  1
  •   noobuntu    8 年前

    每个测试不需要单独的配置文件。理想情况下,您只需通过config_db(或通过代理的单独配置对象)将配置从测试级别向下传递到环境中

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