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] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 47 qaztronic
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2018 Authors and OPENCORES.ORG                 ////
4
////                                                              ////
5
//// This source file may be used and distributed without         ////
6
//// restriction provided that this copyright statement is not    ////
7
//// removed from the file and that any derivative work contains  ////
8
//// the original copyright notice and the associated disclaimer. ////
9
////                                                              ////
10
//// This source file is free software; you can redistribute it   ////
11
//// and/or modify it under the terms of the GNU Lesser General   ////
12
//// Public License as published by the Free Software Foundation; ////
13
//// either version 2.1 of the License, or (at your option) any   ////
14
//// later version.                                               ////
15
////                                                              ////
16
//// This source is distributed in the hope that it will be       ////
17
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
18
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
19
//// PURPOSE.  See the GNU Lesser General Public License for more ////
20
//// details.                                                     ////
21
////                                                              ////
22
//// You should have received a copy of the GNU Lesser General    ////
23
//// Public License along with this source; if not, download it   ////
24
//// from http://www.opencores.org/lgpl.shtml                     ////
25
////                                                              ////
26
//////////////////////////////////////////////////////////////////////
27
 
28
class spi_sequence_item
29
  extends uvm_sequence_item;
30
  `uvm_object_utils(spi_sequence_item)
31
 
32
  // --------------------------------------------------------------------
33
  rand int data_width; // data size in bits
34
 
35
  // --------------------------------------------------------------------
36 48 qaztronic
  logic miso_data[]; // data from slave to master
37
  logic mosi_data[]; // data from master to slave
38
  bit read;
39
  bit write;
40 47 qaztronic
 
41
  // --------------------------------------------------------------------
42
  function new(string name = "");
43
    super.new(name);
44
  endfunction : new
45
 
46
  // --------------------------------------------------------------------
47 48 qaztronic
  function void init(bit read, bit write, int data_width);
48
    this.read = read;
49
    this.write = write;
50 47 qaztronic
    this.data_width = data_width;
51 48 qaztronic
    this.miso_data = new[data_width];
52
    this.mosi_data = new[data_width];
53
 
54
    if(write)
55
      foreach(this.mosi_data[i])
56
        mosi_data[i] = 0;
57 47 qaztronic
  endfunction : init
58
 
59
  // // --------------------------------------------------------------------
60
  // function bit do_compare(uvm_object rhs, uvm_comparer comparer);
61
    // spi_sequence_item tested;
62
    // bit same;
63
 
64
    // if (rhs==null)
65
      // `uvm_fatal(get_type_name(), "| %m | comparison to a null pointer");
66
 
67
    // if (!$cast(tested,rhs))
68
      // same = 0;
69
    // else
70
      // same  = super.do_compare(rhs, comparer);
71
 
72
    // return same;
73
  // endfunction : do_compare
74
 
75
  // // --------------------------------------------------------------------
76
  // function void do_copy(uvm_object rhs);
77
    // spi_sequence_item item;
78
    // assert(rhs != null) else
79
      // `uvm_fatal(get_type_name(), "| %m | copy null transaction");
80
    // super.do_copy(rhs);
81
    // assert($cast(item,rhs)) else
82
      // `uvm_fatal(get_type_name(), "| %m | failed cast");
83
    // delay     = item.delay;
84
    // command   = item.command;
85
    // wr_full   = item.wr_full;
86
    // rd_empty  = item.rd_empty;
87
    // wr_data   = item.wr_data;
88
    // rd_data   = item.rd_data;
89
    // count     = item.count;
90
  // endfunction : do_copy
91
 
92 48 qaztronic
  // --------------------------------------------------------------------
93
  function string convert2string();
94
    string s0, s1, s2, s3;
95
    byte data[];
96 47 qaztronic
 
97 48 qaztronic
    s0 = $sformatf( "\n| %m | rd | wr | data width |\n");
98
    s1 = $sformatf( "| %m | %1h  | %1h  | %d |\n"
99
                  , read
100
                  , write
101
                  , data_width
102
                  );
103
    s0 = {s0, s1};
104 47 qaztronic
 
105 48 qaztronic
    if(read)
106
    begin
107
      data = {>>{miso_data}};
108
 
109
      foreach(data[i])
110
        s2 = {s2, $sformatf("%2h|", data[i])};
111
 
112
      s2 = $sformatf("| %m | miso_data: |%s\n" , s2);
113
      s0 = {s0, s2};
114
    end
115
 
116
    if(write)
117
    begin
118
      data = {>>{mosi_data}};
119
 
120
      foreach(data[i])
121
        s3 = {s3, $sformatf("%2h|", data[i])};
122
 
123
      s3 = $sformatf("| %m | mosi_data: |%s\n" , s3);
124
      s0 = {s0, s3};
125
    end
126
 
127
    return s0;
128
  endfunction : convert2string
129
 
130 47 qaztronic
// --------------------------------------------------------------------
131
endclass : spi_sequence_item

powered by: WebSVN 2.1.0

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