OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [BFM/] [src/] [SPI/] [spi_sequence_item.svh] - Diff between revs 48 and 50

Show entire file | Details | Blame | View Log

Rev 48 Rev 50
Line 33... Line 33...
  rand int data_width; // data size in bits
  rand int data_width; // data size in bits
 
 
  // --------------------------------------------------------------------
  // --------------------------------------------------------------------
  logic miso_data[]; // data from slave to master
  logic miso_data[]; // data from slave to master
  logic mosi_data[]; // data from master to slave
  logic mosi_data[]; // data from master to slave
 
  int ss_index = 0;
  bit read;
  bit read;
  bit write;
  bit write;
 
 
  // --------------------------------------------------------------------
  // --------------------------------------------------------------------
  function new(string name = "");
  function new(string name = "");
Line 54... Line 55...
    if(write)
    if(write)
      foreach(this.mosi_data[i])
      foreach(this.mosi_data[i])
        mosi_data[i] = 0;
        mosi_data[i] = 0;
  endfunction : init
  endfunction : init
 
 
  // // --------------------------------------------------------------------
  // --------------------------------------------------------------------
  // function bit do_compare(uvm_object rhs, uvm_comparer comparer);
  function void load_mosi_from_file(string file_name);
    // spi_sequence_item tested;
    byte buffer;
    // bit same;
    integer fd;
 
    integer code;
    // if (rhs==null)
    integer size;
      // `uvm_fatal(get_type_name(), "| %m | comparison to a null pointer");
 
 
    fd = $fopen(file_name, "rb");
    // if (!$cast(tested,rhs))
    code = $fseek(fd, 0, 2); // SEEK_END
      // same = 0;
    size = $ftell(fd);
    // else
    code = $rewind(fd);
      // same  = super.do_compare(rhs, comparer);
    data_width = size*8;
 
    mosi_data = new[data_width];
    // return same;
    write = 1;
  // endfunction : do_compare
 
 
    for(int i = 0; i < size; i++) begin
  // // --------------------------------------------------------------------
      code = $fread(buffer, fd);
  // function void do_copy(uvm_object rhs);
      mosi_data[i*8 +: 8] = {>>{buffer}};
    // spi_sequence_item item;
    end
    // assert(rhs != null) else
 
      // `uvm_fatal(get_type_name(), "| %m | copy null transaction");
    $fclose(fd);
    // super.do_copy(rhs);
  endfunction
    // assert($cast(item,rhs)) else
 
      // `uvm_fatal(get_type_name(), "| %m | failed cast");
  // --------------------------------------------------------------------
    // delay     = item.delay;
  function void load_mosi_from_byte_array(byte byte_array[]);
    // command   = item.command;
    foreach(byte_array[i])
    // wr_full   = item.wr_full;
      mosi_data[i*8 +: 8] = {>>{byte_array[i]}};
    // rd_empty  = item.rd_empty;
  endfunction
    // wr_data   = item.wr_data;
 
    // rd_data   = item.rd_data;
 
    // count     = item.count;
 
  // endfunction : do_copy
 
 
 
  // --------------------------------------------------------------------
  // --------------------------------------------------------------------
  function string convert2string();
  function string convert2string();
    string s0, s1, s2, s3;
    string s0, s1, s2, s3;
    byte data[];
    byte data[];
Line 100... Line 97...
                  , write
                  , write
                  , data_width
                  , data_width
                  );
                  );
    s0 = {s0, s1};
    s0 = {s0, s1};
 
 
    if(read)
    if(read) begin
    begin
 
      data = {>>{miso_data}};
      data = {>>{miso_data}};
 
 
      foreach(data[i])
      foreach(data[i])
        s2 = {s2, $sformatf("%2h|", data[i])};
        s2 = {s2, $sformatf("%2h|", data[i])};
 
 
      s2 = $sformatf("| %m | miso_data: |%s\n" , s2);
      s2 = $sformatf("| %m | miso_data: |%s\n" , s2);
      s0 = {s0, s2};
      s0 = {s0, s2};
    end
    end
 
 
    if(write)
    if(write) begin
    begin
 
      data = {>>{mosi_data}};
      data = {>>{mosi_data}};
 
 
      foreach(data[i])
      foreach(data[i])
        s3 = {s3, $sformatf("%2h|", data[i])};
        s3 = {s3, $sformatf("%2h|", data[i])};
 
 
Line 126... Line 121...
 
 
    return s0;
    return s0;
  endfunction : convert2string
  endfunction : convert2string
 
 
// --------------------------------------------------------------------
// --------------------------------------------------------------------
endclass : spi_sequence_item
endclass
endclass
endclass

powered by: WebSVN 2.1.0

© copyright 1999-2020 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.