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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [PCIe/] [sim/] [src/] [pcie_bfm_pkg.sv] - Diff between revs 32 and 33

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 32 Rev 33
Line 38... Line 38...
  // --------------------------------------------------------------------
  // --------------------------------------------------------------------
  //
  //
  class altera_pcie_transaction;
  class altera_pcie_transaction;
 
 
    tlp_header_class hd_h;
    tlp_header_class hd_h;
    byte packet[];
    byte data[];
 
    bit tlp_always_packed;
 
 
 
 
    //--------------------------------------------------------------------
    //--------------------------------------------------------------------
    //
    //
    function new(tlp_header_class hd_h, bit qword_aligned);
    function bit is_qword_aligned;
      this.hd_h = hd_h;
      is_qword_aligned = ~hd_h.address[2];
      if(qword_aligned & hd_h.fmt_type[5] == 0)
    endfunction: is_qword_aligned
        if(hd_h.length == 0)
 
          this.packet = new[1024 + 1];
 
 
    //--------------------------------------------------------------------
 
    //
 
    function bit is_tlp_packed;
 
      if(tlp_always_packed)
 
        return(1);
 
      if(hd_h.is_3_dw)
 
        if(is_qword_aligned)
 
          return(0);
        else
        else
          this.packet = new[hd_h.length + 1];
          return(1);
 
      else  // is_4_dw
 
        if(is_qword_aligned)
 
          return(1);
      else
      else
        if(hd_h.length == 0)
          return(0);
          this.packet = new[1024];
    endfunction: is_tlp_packed
 
 
 
 
 
    //--------------------------------------------------------------------
 
    //
 
    function void init(tlp_header_class hd_h);
 
      this.hd_h = hd_h;
 
    endfunction: init
 
 
 
 
 
    // --------------------------------------------------------------------
 
    // Memory Read Request
 
    function void make_MRd
 
    (
 
      logic [63:0] address,
 
      logic [9:0] length,
 
      bit use_64_addr = 0
 
    );
 
      hd_h = new(use_64_addr ? DW_4_NO_DATA : DW_3_NO_DATA, MRd, length);
 
      hd_h.set_address(address);
 
      init(hd_h);
 
      data.delete();
 
    endfunction: make_MRd
 
 
 
 
 
    // --------------------------------------------------------------------
 
    // Memory Write Request
 
    function void make_MWr
 
    (
 
      logic [63:0] address,
 
      byte data[],
 
      bit use_64_addr = 0
 
    );
 
      logic [9:0] length = (data.size() > 1023) ? 0 : data.size();
 
      hd_h = new(use_64_addr ? DW_4_DATA : DW_3_DATA, MWr, length);
 
      init(hd_h);
 
      this.data = data;
 
      hd_h.set_address(address);
 
    endfunction: make_MWr
 
 
 
 
 
    // --------------------------------------------------------------------
 
    //
 
    function tpl_packet_t make_packet;
 
      byte h0[4] = {<
 
      byte h1[4] = {<
 
      byte h2[4] = {<
 
      byte h3[4] = {<
 
      byte pad[4] = '{8'hxx, 8'hxx, 8'hxx, 8'hxx};
 
      byte header[];
 
      if(hd_h.is_4_dw)
 
      begin
 
        h3 = {<
 
        header = {h0, h1, h2, h3};
 
      end
 
      else
 
        header = {h0, h1, h2};
 
      if(data.size() == 0)
 
        make_packet = header;
 
      else if(is_tlp_packed)
 
        make_packet = {header, data};
        else
        else
          this.packet = new[hd_h.length];
        make_packet = {header, pad, data};
 
 
 
      // else if(hd_h.is_3_dw)
 
        // if(is_qword_aligned)
 
          // make_packet = {header, pad, data};
 
        // else
 
          // make_packet = {header, data};
 
      // else  // is_4_dw
 
        // if(is_qword_aligned)
 
          // make_packet = {header, data};
 
        // else
 
          // make_packet = {header, pad, data};
 
 
 
    endfunction: make_packet
 
 
 
 
 
    // --------------------------------------------------------------------
 
    //
 
    function tpl_packet_t get_MRd
 
    (
 
      logic [63:0] address,
 
      logic [9:0] length,
 
      bit use_64_addr = 0
 
    );
 
      make_MRd(address, length, use_64_addr);
 
      return(make_packet());
 
    endfunction: get_MRd
 
 
 
 
 
    // --------------------------------------------------------------------
 
    //
 
    function tpl_packet_t get_counting_MWr
 
    (
 
      logic [63:0] address,
 
      int size,
 
      bit use_64_addr = 0
 
    );
 
      byte data[];
 
      data = new[size];
 
      foreach(data[i])
 
        data[i] = i;
 
      make_MWr(address, data, use_64_addr);
 
      return(make_packet());
 
    endfunction: get_counting_MWr
 
 
 
 
 
    //--------------------------------------------------------------------
 
    //
 
    function new(bit tlp_always_packed = 0);
 
      this.tlp_always_packed = tlp_always_packed;
    endfunction: new
    endfunction: new
 
 
 
 
  // --------------------------------------------------------------------
  // --------------------------------------------------------------------
  //
  //

powered by: WebSVN 2.1.0

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