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 2

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
//-----------------------------------------------------------------------------
18
// ALL COPYRIGHTS ARE RESERVED FOR THE PRODUCER ONLY .THIS FILE IS PRODUCED FOR
19
// OPENCORES MEMBERS ONLY AND IT IS PROHIBTED TO USE THIS MATERIAL WITHOUT THE
20
// CREATOR'S PERMISSION
21
//-----------------------------------------------------------------------------
22
class uart_monitor extends uvm_monitor;
23
 
24
  uart_transaction  trans;
25
 
26
  uart_config       _config;
27
 
28
  virtual uart_interface    uart_inf;
29
 
30
  virtual rf_interface      rf_inf;
31
 
32
  uvm_analysis_port #(uart_transaction) mon_scbd;
33
 
34
  `uvm_component_utils(uart_monitor)
35
 
36
  function new (string name, uvm_component parent);
37
    super.new(name,parent);
38
  endfunction:new
39
 
40
  function void display_content ();
41
    $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,
42
              trans._command,
43
              trans._chartype,
44
              trans._spacetype1,
45
              trans.space_wrong1,
46
              trans._spacetype2,
47
              trans.space_wrong2,
48
              trans._eoltype,
49
              trans.eol_wrong,
50
              trans.address,
51
              trans._data[0]);
52
  endfunction:display_content
53
 
54
  extern function void build_phase (uvm_phase phase);
55
 
56
  extern function void connect_phase (uvm_phase phase);
57
 
58
  extern function void end_of_elaboration_phase (uvm_phase phase);
59
 
60
  extern task run_phase (uvm_phase phase);
61
 
62
endclass:uart_monitor
63
 
64
function void uart_monitor::build_phase (uvm_phase phase);
65
  super.build_phase(phase);
66
 
67
  _config = uart_config::type_id::create("_config",this);
68
 
69
  trans = uart_transaction::type_id::create("trans");
70
 
71
  mon_scbd = new ("mon_scbd",this);
72
endfunction:build_phase
73
 
74
function void uart_monitor::connect_phase (uvm_phase phase);
75
 
76
endfunction:connect_phase
77
 
78
function void uart_monitor::end_of_elaboration_phase(uvm_phase phase);
79
  if (!uvm_config_db#(uart_config)::get(this,"","UART_CONFIGURATION",_config))
80
    `uvm_fatal("NOCONFIGURATION",{"configuration instance must be set for",get_full_name(),"._config"})
81
 
82
  if (!uvm_config_db#(virtual uart_interface)::get(this,"","uart_inf",_config.uart_inf))
83
    `uvm_fatal("NOINF",{"UART Interface instance must be set for",get_full_name,".uart_inf"})
84
  uart_inf = _config.uart_inf;
85
 
86
  if(!uvm_config_db#(virtual rf_interface)::get(this,"","rf_inf",_config.rf_inf))
87
    `uvm_fatal("NOINF",{"RF Interface instance must be set for",get_full_name(),".rf_inf"})
88
  rf_inf = _config.rf_inf;
89
 
90
endfunction:end_of_elaboration_phase
91
 
92
task uart_monitor::run_phase (uvm_phase phase);
93
  int iteration;
94
  int command_type;
95
  int _command;
96
  int _chartype;
97
  int _spacetype1;
98
  int _spacetype2;
99
  int _eoltype;
100
  int _reqack;
101
  int _reqinc;
102
  iteration = 0;
103
  forever
104
    begin
105
    iteration++;
106
    uart_inf.wait_event();
107
    uart_inf.capture_command(command_type,
108
                             _command,
109
                             _chartype,
110
                             _spacetype1,
111
                             trans.space_wrong1,
112
                             _spacetype2,
113
                             trans.space_wrong2,
114
                             _eoltype,
115
                             trans.eol_wrong,
116
                             trans.address,
117
                             trans._data,
118
                             trans.acknowledge,
119
                             trans.length_data,
120
                             _reqack,
121
                             _reqinc);
122
   trans._mode        = mode'(command_type);
123
   trans._command     = command'(_command);
124
   trans._chartype    = char_type'(_chartype);
125
   trans._spacetype1  = space_type'(_spacetype1);
126
   trans._spacetype2  = space_type'(_spacetype2);
127
   trans._eoltype     = eol_type '(_eoltype);
128
   trans._reqinc      = req '(_reqinc);
129
   trans._reqack      = req '(_reqack);
130
   if (trans._command == write)
131
    begin
132
    if (trans._mode == text)
133
      begin
134
      trans._data[0] = rf_inf.read_mem_data(trans.address[7:0]);
135
      end
136
    else if (trans._mode == binary)
137
      begin
138
      rf_inf.read_block(trans.data_length,
139
                        trans.address,
140
                        trans._data);
141
      end
142
    end
143
   //display_content();
144
   mon_scbd.write(trans);
145
   end
146
 
147
endtask:run_phase

powered by: WebSVN 2.1.0

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