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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [PCIe/] [sim/] [src/] [riffa_bfm_class_pkg.sv] - Diff between revs 37 and 39

Show entire file | Details | Blame | View Log

Rev 37 Rev 39
Line 44... Line 44...
 
 
 
 
    //--------------------------------------------------------------------
    //--------------------------------------------------------------------
    //
    //
    function int get_data_size(int len);
    function int get_data_size(int len);
      // int words = $ceil(len/(N/4));  // need to fix
      int words = ((len * 4) % N == 0) ? ((len * 4) / N) : ((len * 4) / N) + 1;
      int words = len/(N/4);
      // $display("^^^ %16.t | N     = %d", $time, N);
 
      // $display("^^^ %16.t | len   = %d", $time, len);
 
      // $display("^^^ %16.t | mod   = %d", $time, (len * 4) % N);
      // $display("^^^ %16.t | words = %d", $time, words);
      // $display("^^^ %16.t | words = %d", $time, words);
      return(words);
      return(words);
    endfunction: get_data_size
    endfunction: get_data_size
 
 
 
 
Line 77... Line 79...
    endfunction: counting
    endfunction: counting
 
 
 
 
    //--------------------------------------------------------------------
    //--------------------------------------------------------------------
    //
    //
 
    function void hex(string str, int off, bit last);
 
      string rev_str;
 
      string char;
 
      int w, c;
 
      this.len  = (str.len() % (2 * 4)) == 0
 
                ? (str.len() / (2 * 4))
 
                : (str.len() / (2 * 4)) + 1;
 
      this.data = new[get_data_size(this.len)];
 
      this.off = off;
 
      this.last = last;
 
      rev_str = {<<8{str}}; // reverse string
 
      for(w = 0; w < rev_str.len(); w += (N * 2))
 
        for(c = 0; c < (N * 2); c++)
 
        begin
 
          char = string'(rev_str.getc(w + c));
 
          if(char == "")
 
            this.data[w / (N * 2)][(c * 4) +: 4] = 0;
 
          else
 
            this.data[w / (N * 2)][(c * 4) +: 4] = char.atohex();
 
        end
 
    endfunction: hex
 
 
 
 
 
    //--------------------------------------------------------------------
 
    //
    function void random(int len, int off, bit last);
    function void random(int len, int off, bit last);
      this.data = new[get_data_size(len)];
      this.data = new[get_data_size(len)];
      assert(this.randomize() with
      assert(this.randomize() with
      {
      {
        this.len == len;  // why not working?
        this.len == len;  // why not working?
Line 250... Line 277...
 
 
      chnl_bus.cb_rp_rx.tx_ack <= 1;
      chnl_bus.cb_rp_rx.tx_ack <= 1;
      chnl_bus.cb_rp_rx.tx_data_ren <= 1;
      chnl_bus.cb_rp_rx.tx_data_ren <= 1;
 
 
      fork
      fork
        @(chnl_bus.cb_rp_tx)
        @(chnl_bus.cb_rp_rx)
          chnl_bus.cb_rp_rx.tx_ack <= 0;
          chnl_bus.cb_rp_rx.tx_ack <= 0;
      join_none
      join_none
 
 
      // foreach(tr_h.data[i])
 
        // @(chnl_bus.cb_rp_tx)
 
          // if(~chnl_bus.cb_rp_rx.tx)
 
            // break;
 
          // else if(chnl_bus.cb_rp_rx.tx_data_valid)
 
            // tr_h.data[i] <= chnl_bus.cb_rp_rx.tx_data;
 
 
 
      foreach(tr_h.data[i])
      foreach(tr_h.data[i])
        @(chnl_bus.cb_rp_tx iff chnl_bus.cb_rp_rx.tx_data_valid)
      begin
 
        @(chnl_bus.cb_rp_rx iff chnl_bus.cb_rp_rx.tx_data_valid)
          tr_h.data[i] <= chnl_bus.cb_rp_rx.tx_data;
          tr_h.data[i] <= chnl_bus.cb_rp_rx.tx_data;
 
        // $display("^^^ %16.t | %d | %h", $time, i, chnl_bus.cb_rp_rx.tx_data);
 
      end
 
 
      rx_q.put(tr_h);
      rx_q.put(tr_h);
      set_default();
      set_default();
      ->rx_done;
      ->rx_done;
    endtask: transmit
    endtask: transmit

powered by: WebSVN 2.1.0

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