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 14

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 14 HanySalah
    `uvm_info("TRACE","Printing the transaction content:",UVM_HIGH);
44
     trans.print();
45 2 HanySalah
  endfunction:display_content
46
 
47
  extern function void build_phase (uvm_phase phase);
48
 
49
  extern function void connect_phase (uvm_phase phase);
50
 
51
  extern function void end_of_elaboration_phase (uvm_phase phase);
52
 
53
  extern task run_phase (uvm_phase phase);
54
 
55
endclass:uart_monitor
56
 
57
function void uart_monitor::build_phase (uvm_phase phase);
58
  super.build_phase(phase);
59
 
60
  _config = uart_config::type_id::create("_config",this);
61
 
62
  trans = uart_transaction::type_id::create("trans");
63
 
64
  mon_scbd = new ("mon_scbd",this);
65
endfunction:build_phase
66
 
67
function void uart_monitor::connect_phase (uvm_phase phase);
68
 
69
endfunction:connect_phase
70
 
71
function void uart_monitor::end_of_elaboration_phase(uvm_phase phase);
72
  if (!uvm_config_db#(uart_config)::get(this,"","UART_CONFIGURATION",_config))
73
    `uvm_fatal("NOCONFIGURATION",{"configuration instance must be set for",get_full_name(),"._config"})
74
 
75
  if (!uvm_config_db#(virtual uart_interface)::get(this,"","uart_inf",_config.uart_inf))
76
    `uvm_fatal("NOINF",{"UART Interface instance must be set for",get_full_name,".uart_inf"})
77
  uart_inf = _config.uart_inf;
78
 
79
  if(!uvm_config_db#(virtual rf_interface)::get(this,"","rf_inf",_config.rf_inf))
80
    `uvm_fatal("NOINF",{"RF Interface instance must be set for",get_full_name(),".rf_inf"})
81
  rf_inf = _config.rf_inf;
82
 
83
endfunction:end_of_elaboration_phase
84
 
85
task uart_monitor::run_phase (uvm_phase phase);
86
  int iteration;
87
  int command_type;
88
  int _command;
89
  int _chartype;
90
  int _spacetype1;
91
  int _spacetype2;
92
  int _eoltype;
93
  int _reqack;
94
  int _reqinc;
95 3 HanySalah
  byte data_temp[$];
96
 
97 2 HanySalah
  iteration = 0;
98
  forever
99
    begin
100
    iteration++;
101
    uart_inf.wait_event();
102 3 HanySalah
    trans.acknowledge=8'b00;
103
 
104 2 HanySalah
    uart_inf.capture_command(command_type,
105
                             _command,
106
                             _chartype,
107
                             _spacetype1,
108
                             trans.space_wrong1,
109
                             _spacetype2,
110
                             trans.space_wrong2,
111
                             _eoltype,
112
                             trans.eol_wrong,
113
                             trans.address,
114
                             trans._data,
115
                             trans.acknowledge,
116
                             trans.length_data,
117
                             _reqack,
118
                             _reqinc);
119 3 HanySalah
    trans._mode        = mode'(command_type);
120
    trans._command     = command'(_command);
121
    trans._chartype    = char_type'(_chartype);
122
    trans._spacetype1  = space_type'(_spacetype1);
123
    trans._spacetype2  = space_type'(_spacetype2);
124
    trans._eoltype     = eol_type '(_eoltype);
125
    trans._reqinc      = req '(_reqinc);
126
    trans._reqack      = req '(_reqack);
127
    if (trans._command == write || trans._command == invalid_write)
128 2 HanySalah
      begin
129 3 HanySalah
      if (trans._mode == text || trans._mode == wrong_mode_text)
130
        begin
131
        trans._data[0] = rf_inf.read_mem_data(trans.address);
132
        end
133
      else if (trans._mode == binary || trans._mode == wrong_mode_bin)
134
        begin
135
        rf_inf.read_block(trans.length_data,
136
                          trans.address,
137
                          trans._data);
138
        end
139 2 HanySalah
      end
140 3 HanySalah
    //display_content();
141
    trans._id = iteration;
142
    mon_scbd.write(trans);
143 2 HanySalah
   end
144 3 HanySalah
 
145 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.