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

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [agent/] [monitor/] [uart_monitor.svh] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 HanySalah
//-----------------------------------------------------------------------------
2
//
3
//                             UART2BUS VERIFICATION
4
//
5
//-----------------------------------------------------------------------------
6
// CREATOR    : HANY SALAH
7
// PROJECT    : UART2BUS UVM TEST BENCH
8
// UNIT       : MONITOR
9
//-----------------------------------------------------------------------------
10
// TITLE      : UART Monitor
11
// DESCRIPTION: This
12
//-----------------------------------------------------------------------------
13
// LOG DETAILS
14
//-------------
15
// VERSION      NAME        DATE        DESCRIPTION
16
//    1       HANY SALAH    12012016    FILE CREATION
17 3 HanySalah
//    2       HANY SALAH    31012016    ADD INVALID WRITE CASE TO TRANSACTION
18
//                                      PACKETAIZATION METHOD
19 2 HanySalah
//-----------------------------------------------------------------------------
20
// ALL COPYRIGHTS ARE RESERVED FOR THE PRODUCER ONLY .THIS FILE IS PRODUCED FOR
21
// OPENCORES MEMBERS ONLY AND IT IS PROHIBTED TO USE THIS MATERIAL WITHOUT THE
22
// CREATOR'S PERMISSION
23
//-----------------------------------------------------------------------------
24
class uart_monitor extends uvm_monitor;
25
 
26
  uart_transaction  trans;
27
 
28
  uart_config       _config;
29
 
30
  virtual uart_interface    uart_inf;
31
 
32
  virtual rf_interface      rf_inf;
33
 
34
  uvm_analysis_port #(uart_transaction) mon_scbd;
35
 
36
  `uvm_component_utils(uart_monitor)
37
 
38
  function new (string name, uvm_component parent);
39
    super.new(name,parent);
40
  endfunction:new
41
 
42
  function void display_content ();
43
    $display("here %s\n command_type = %p \n command = %p \n char_type = %p \n  space_type1 = %p \n  space_wrong1 = %8b \n  space_type2 = %p \n  space_wrong2 = %8b \n  eol_type = %p \n  eol_wrong = %8b \n  address = %h \n  data = %8b", get_full_name(),trans._mode,
44
              trans._command,
45
              trans._chartype,
46
              trans._spacetype1,
47
              trans.space_wrong1,
48
              trans._spacetype2,
49
              trans.space_wrong2,
50
              trans._eoltype,
51
              trans.eol_wrong,
52
              trans.address,
53
              trans._data[0]);
54
  endfunction:display_content
55
 
56
  extern function void build_phase (uvm_phase phase);
57
 
58
  extern function void connect_phase (uvm_phase phase);
59
 
60
  extern function void end_of_elaboration_phase (uvm_phase phase);
61
 
62
  extern task run_phase (uvm_phase phase);
63
 
64
endclass:uart_monitor
65
 
66
function void uart_monitor::build_phase (uvm_phase phase);
67
  super.build_phase(phase);
68
 
69
  _config = uart_config::type_id::create("_config",this);
70
 
71
  trans = uart_transaction::type_id::create("trans");
72
 
73
  mon_scbd = new ("mon_scbd",this);
74
endfunction:build_phase
75
 
76
function void uart_monitor::connect_phase (uvm_phase phase);
77
 
78
endfunction:connect_phase
79
 
80
function void uart_monitor::end_of_elaboration_phase(uvm_phase phase);
81
  if (!uvm_config_db#(uart_config)::get(this,"","UART_CONFIGURATION",_config))
82
    `uvm_fatal("NOCONFIGURATION",{"configuration instance must be set for",get_full_name(),"._config"})
83
 
84
  if (!uvm_config_db#(virtual uart_interface)::get(this,"","uart_inf",_config.uart_inf))
85
    `uvm_fatal("NOINF",{"UART Interface instance must be set for",get_full_name,".uart_inf"})
86
  uart_inf = _config.uart_inf;
87
 
88
  if(!uvm_config_db#(virtual rf_interface)::get(this,"","rf_inf",_config.rf_inf))
89
    `uvm_fatal("NOINF",{"RF Interface instance must be set for",get_full_name(),".rf_inf"})
90
  rf_inf = _config.rf_inf;
91
 
92
endfunction:end_of_elaboration_phase
93
 
94
task uart_monitor::run_phase (uvm_phase phase);
95
  int iteration;
96
  int command_type;
97
  int _command;
98
  int _chartype;
99
  int _spacetype1;
100
  int _spacetype2;
101
  int _eoltype;
102
  int _reqack;
103
  int _reqinc;
104 3 HanySalah
  byte data_temp[$];
105
 
106 2 HanySalah
  iteration = 0;
107
  forever
108
    begin
109
    iteration++;
110 3 HanySalah
    //trans.reset_fields();
111 2 HanySalah
    uart_inf.wait_event();
112 3 HanySalah
    trans.acknowledge=8'b00;
113
 
114 2 HanySalah
    uart_inf.capture_command(command_type,
115
                             _command,
116
                             _chartype,
117
                             _spacetype1,
118
                             trans.space_wrong1,
119
                             _spacetype2,
120
                             trans.space_wrong2,
121
                             _eoltype,
122
                             trans.eol_wrong,
123
                             trans.address,
124
                             trans._data,
125
                             trans.acknowledge,
126
                             trans.length_data,
127
                             _reqack,
128
                             _reqinc);
129 3 HanySalah
    trans._mode        = mode'(command_type);
130
    trans._command     = command'(_command);
131
    trans._chartype    = char_type'(_chartype);
132
    trans._spacetype1  = space_type'(_spacetype1);
133
    trans._spacetype2  = space_type'(_spacetype2);
134
    trans._eoltype     = eol_type '(_eoltype);
135
    trans._reqinc      = req '(_reqinc);
136
    trans._reqack      = req '(_reqack);
137
    if (trans._command == write || trans._command == invalid_write)
138 2 HanySalah
      begin
139 3 HanySalah
      if (trans._mode == text || trans._mode == wrong_mode_text)
140
        begin
141
        trans._data[0] = rf_inf.read_mem_data(trans.address);
142
        end
143
      else if (trans._mode == binary || trans._mode == wrong_mode_bin)
144
        begin
145
        rf_inf.read_block(trans.length_data,
146
                          trans.address,
147
                          trans._data);
148
        end
149 2 HanySalah
      end
150 3 HanySalah
    //display_content();
151
    trans._id = iteration;
152
    mon_scbd.write(trans);
153 2 HanySalah
   end
154 3 HanySalah
 
155 2 HanySalah
endtask:run_phase

powered by: WebSVN 2.1.0

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