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

Subversion Repositories openhmc

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

Go to most recent revision | 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
`ifndef AXI4_STREAM_MASTER_DRIVER_SV
41
`define AXI4_STREAM_MASTER_DRIVER_SV
42
 
43
class axi4_stream_master_driver #(parameter DATA_BYTES = 16, parameter TUSER_WIDTH = 16) extends uvm_driver #(axi4_stream_valid_cycle #(.DATA_BYTES(DATA_BYTES), .TUSER_WIDTH(TUSER_WIDTH)));
44
 
45
        axi4_stream_config axi4_stream_cfg;
46
 
47
        virtual interface axi4_stream_if #(.DATA_BYTES(DATA_BYTES), .TUSER_WIDTH(TUSER_WIDTH)) vif;
48
 
49
        `uvm_component_param_utils_begin(axi4_stream_master_driver #(.DATA_BYTES(DATA_BYTES), .TUSER_WIDTH(TUSER_WIDTH)))
50
                `uvm_field_object(axi4_stream_cfg, UVM_DEFAULT)
51
        `uvm_component_utils_end
52
 
53
        function new(string name="axi4_stream_master_driver", uvm_component parent);
54
                super.new(name,parent);
55
        endfunction : new
56
 
57
        function void build_phase(uvm_phase phase);
58
                super.build_phase(phase);
59
 
60
                if(!uvm_config_db#(virtual interface axi4_stream_if #(.DATA_BYTES(DATA_BYTES), .TUSER_WIDTH(TUSER_WIDTH)))::get(this, "", "vif",vif) ) begin
61
                        `uvm_fatal(get_type_name(),"vif is not set")
62
                end
63
        endfunction : build_phase
64
 
65
        task run_phase(uvm_phase phase);
66
                super.run_phase(phase);
67
 
68
                forever begin
69
                        if(vif.ARESET_N !== 1) begin
70
                                vif.TVALID <= 0;
71
                                `uvm_info(get_type_name(),$psprintf("reset"), UVM_HIGH)
72
                                @(posedge vif.ARESET_N);
73
                                `uvm_info(get_type_name(),$psprintf("coming out of reset"), UVM_HIGH)
74
                        end
75
 
76
                        fork
77
                                begin //-- Asynchronous reset
78
                                        @(negedge vif.ARESET_N);
79
                                end
80
                                begin
81
                                        drive_valid_cycles();
82
                                end
83
                        join_any
84
                        disable fork;
85
                end
86
 
87
        endtask : run_phase
88
 
89
        task drive_valid_cycles();
90
                @(posedge vif.ACLK);
91
 
92
                forever begin
93
                        axi4_stream_valid_cycle #(.DATA_BYTES(DATA_BYTES), .TUSER_WIDTH(TUSER_WIDTH)) vc;
94
 
95
                        //-- Try next AXI4 item
96
                        seq_item_port.try_next_item(vc);
97
                        if( vc != null) begin
98
                                `uvm_info(get_type_name(),$psprintf("There is an item to sent"), UVM_MEDIUM)
99
                                `uvm_info(get_type_name(),$psprintf("send %0x %0x", vc.tuser, vc.tdata), UVM_MEDIUM)
100
 
101
                                //-- Wait until delay
102
                                repeat(vc.delay)
103
                                        @(posedge vif.ACLK);
104
 
105
                                //-- Send AXI4 cycle
106
                                vif.TDATA  <= vc.tdata;
107
                                vif.TUSER  <= vc.tuser;
108
                                vif.TVALID <= 1;
109
                                @(posedge vif.ACLK)
110
                                while(vif.TREADY == 0)
111
                                        @(posedge vif.ACLK);
112
 
113
                                vif.TUSER  <= 0;
114
                                vif.TDATA  <= 0;
115
                                vif.TVALID <= 0;
116
                                `uvm_info(get_type_name(),$psprintf("send done: %0x %0x", vc.tuser, vc.tdata), UVM_MEDIUM)
117
 
118
                                seq_item_port.item_done();
119
                        end else //-- Else wait 1 cycle
120
                                @(posedge vif.ACLK);
121
 
122
                end
123
        endtask : drive_valid_cycles
124
 
125
endclass : axi4_stream_master_driver
126
 
127
`endif  //AXI4_STREAM_MASTER_DRIVER_SV

powered by: WebSVN 2.1.0

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