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

Subversion Repositories openhmc

[/] [openhmc/] [trunk/] [openHMC/] [sim/] [UVC/] [axi4_stream/] [sv/] [axi4_stream_monitor.sv] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 juko
/*
2
 *                              .--------------. .----------------. .------------.
3
 *                             | .------------. | .--------------. | .----------. |
4
 *                             | | ____  ____ | | | ____    ____ | | |   ______ | |
5
 *                             | ||_   ||   _|| | ||_   \  /   _|| | | .' ___  || |
6
 *       ___  _ __   ___ _ __  | |  | |__| |  | | |  |   \/   |  | | |/ .'   \_|| |
7
 *      / _ \| '_ \ / _ \ '_ \ | |  |  __  |  | | |  | |\  /| |  | | || |       | |
8
 *       (_) | |_) |  __/ | | || | _| |  | |_ | | | _| |_\/_| |_ | | |\ `.___.'\| |
9
 *      \___/| .__/ \___|_| |_|| ||____||____|| | ||_____||_____|| | | `._____.'| |
10
 *           | |               | |            | | |              | | |          | |
11
 *           |_|               | '------------' | '--------------' | '----------' |
12
 *                              '--------------' '----------------' '------------'
13
 *
14
 *  openHMC - An Open Source Hybrid Memory Cube Controller
15
 *  (C) Copyright 2014 Computer Architecture Group - University of Heidelberg
16
 *  www.ziti.uni-heidelberg.de
17
 *  B6, 26
18
 *  68159 Mannheim
19
 *  Germany
20
 *
21
 *  Contact: openhmc@ziti.uni-heidelberg.de
22
 *  http://ra.ziti.uni-heidelberg.de/openhmc
23
 *
24
 *   This source file is free software: you can redistribute it and/or modify
25
 *   it under the terms of the GNU Lesser General Public License as published by
26
 *   the Free Software Foundation, either version 3 of the License, or
27
 *   (at your option) any later version.
28
 *
29
 *   This source file is distributed in the hope that it will be useful,
30
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
 *   GNU Lesser General Public License for more details.
33
 *
34
 *   You should have received a copy of the GNU Lesser General Public License
35
 *   along with this source file.  If not, see .
36
 *
37
 *
38
 */
39
 
40
//
41
//
42
// axi4_stream_packet monitor
43
//
44
//
45
 
46
`ifndef AXI4_STREAM_MONITOR_SV
47
`define AXI4_STREAM_MONITOR_SV
48
 
49
class axi4_stream_monitor #(parameter DATA_BYTES = 16, parameter TUSER_WIDTH = 16) extends uvm_monitor;
50
 
51
        virtual interface axi4_stream_if #(.DATA_BYTES(DATA_BYTES), .TUSER_WIDTH(TUSER_WIDTH))                          vif;
52
 
53
        uvm_analysis_port #(axi4_stream_valid_cycle #(.DATA_BYTES(DATA_BYTES), .TUSER_WIDTH(TUSER_WIDTH)))      item_collected_port;
54
 
55
 
56
        `uvm_component_param_utils(axi4_stream_monitor #(.DATA_BYTES(DATA_BYTES), .TUSER_WIDTH(TUSER_WIDTH)))
57
 
58
 
59
        function new ( string name="axi4_stream_monitor", uvm_component parent );
60
                super.new(name, parent);
61
 
62
                item_collected_port = new("item_collected_port", this);
63
 
64
        endfunction : new
65
 
66
        function void build_phase(uvm_phase phase);
67
                super.build_phase(phase);
68
 
69
                if(uvm_config_db#(virtual interface axi4_stream_if #(.DATA_BYTES(DATA_BYTES), .TUSER_WIDTH(TUSER_WIDTH)))::get(this, "", "vif",vif) ) begin
70
                        this.vif = vif;
71
                end else begin
72
                        `uvm_fatal(get_type_name(),"vif is not set")
73
                end
74
 
75
        endfunction : build_phase
76
 
77
 
78
        task run();
79
                axi4_stream_valid_cycle #(.DATA_BYTES(DATA_BYTES), .TUSER_WIDTH(TUSER_WIDTH)) vc;
80
 
81
                forever begin
82
                        if (vif.ARESET_N !== 1)
83
                        begin
84
                                @(posedge vif.ARESET_N);
85
                        end
86
 
87
                        fork
88
                                begin //-- Asynchronous reset
89
                                        @(negedge vif.ARESET_N);
90
                                end
91
 
92
 
93
                                forever begin
94
                                        //-- At the positive edge of ACLK
95
                                        @(posedge vif.ACLK);
96
 
97
                                        //-- Capture valid bus cycles
98
                                        vc = new();
99
 
100
                                        if (vif.TVALID == 1 && vif.TREADY == 1) begin
101
 
102
                                                vc.tuser        = vif.TUSER;
103
                                                vc.tdata        = vif.TDATA;
104
                                                item_collected_port.write(vc);
105
                                                `uvm_info(get_type_name(),$psprintf("valid cycle tuser %0x tdata %0x", vc.tuser, vc.tdata), UVM_HIGH)
106
 
107
                                        end
108
 
109
                                        //-- used to detect the hmc_pkt_delay between packets
110
                                        if (vif.TVALID == 0) begin
111
                                                vc.tuser        = {TUSER_WIDTH{1'b0}};
112
                                                vc.tdata        = {DATA_BYTES{8'b0}};;
113
                                                item_collected_port.write(vc);
114
                                        end
115
 
116
                                end
117
                        join_any
118
                        disable fork;
119
 
120
 
121
                end
122
        endtask : run
123
 
124
endclass : axi4_stream_monitor
125
 
126
`endif // AXI4_STREAM_MONITOR_SV

powered by: WebSVN 2.1.0

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