OpenCores
URL https://opencores.org/ocsvn/avalon-wishbone-bridge/avalon-wishbone-bridge/trunk

Subversion Repositories avalon-wishbone-bridge

[/] [avalon-wishbone-bridge/] [trunk/] [UVM/] [wb_slave_agent/] [wb_slave_driver.svh] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sumanta.ch
//------------------------------------------------------------
2
//   Copyright 2010 Mentor Graphics Corporation
3
//   All Rights Reserved Worldwide
4
//
5
//   Licensed under the Apache License, Version 2.0 (the
6
//   "License"); you may not use this file except in
7
//   compliance with the License.  You may obtain a copy of
8
//   the License at
9
//
10
//       http://www.apache.org/licenses/LICENSE-2.0
11
//
12
//   Unless required by applicable law or agreed to in
13
//   writing, software distributed under the License is
14
//   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
15
//   CONDITIONS OF ANY KIND, either express or implied.  See
16
//   the License for the specific language governing
17
//   permissions and limitations under the License.
18
//------------------------------------------------------------
19
`ifndef wb_slave_driver
20
`define wb_slave_driver
21
 
22
//
23
// Class Description:
24
//
25
//
26
class wb_slave_driver #(AW =32, DW=64, TW= 2) extends uvm_driver #(wb_slave_seq_item #(AW, DW, TW),wb_slave_seq_item#(AW,DW,TW));
27
 
28
// UVM Factory Registration Macro
29
//
30
`uvm_component_utils(wb_slave_driver)
31
 
32
// Virtual Interface
33
virtual wb_if #(AW, DW, TW) WB;
34
 
35
//------------------------------------------
36
// Data Members
37
//------------------------------------------
38
wb_slave_agent_config m_cfg;
39
mailbox slave_mbox;
40
//------------------------------------------
41
// Methods
42
//------------------------------------------
43
// Standard UVM Methods:
44
extern function new(string name = "wb_slave_driver", uvm_component parent = null);
45
extern function void build_phase(uvm_phase phase);
46
extern task run_phase(uvm_phase phase);
47
extern task req_loop();
48
extern task resp_loop(uvm_phase phase);
49
//task handle_req(wb_slave_seq_item #(AW, DW, TW) req);
50
//endtask
51
//
52
//task handle_rsp(wb_slave_seq_item #(AW, DW, TW) rsp,wb_slave_seq_item #(AW, DW, TW) req);
53
//endtask
54
 
55
endclass: wb_slave_driver
56
 
57
function wb_slave_driver::new(string name = "wb_slave_driver", uvm_component parent = null);
58
  super.new(name, parent);
59
  slave_mbox=new(1);
60
endfunction
61
 
62
function void wb_slave_driver::build_phase(uvm_phase phase);
63
  m_cfg = wb_slave_agent_config::get_config(this);
64
  WB = m_cfg.WB;
65
endfunction: build_phase
66
 
67
task wb_slave_driver::run_phase(uvm_phase phase);
68
  //wb_slave_seq_item #(AW, DW, TW) req;
69
  //wb_slave_seq_item #(AW, DW, TW) rsp;
70
 
71
//phase.raise_objection(this);
72
        fork
73
                this.req_loop();
74
                this.resp_loop(phase);
75
        join
76
 
77
 
78
      `uvm_info("** WB SLAVE RUN PHASE EXITED **", "", UVM_LOW)
79
//phase.drop_objection(this);
80
endtask: run_phase
81
 
82
task wb_slave_driver::req_loop();
83
        wb_slave_seq_item #(this.AW, this.DW, this.TW) req=new();
84
 
85
        forever begin
86
 
87
        if (!this.WB.rst_n) begin
88
                this.WB.stall<=1'b0;
89
                @(posedge this.WB.clk);
90
        end else begin
91
                //@(posedge this.WB.clk);
92
                $strobe("waiting\n");
93
                //this.seq_item_port.get_next_item(req);
94
                while (!(this.WB.cyc === 1'b1 && this.WB.stb ===1'b1)) @(posedge this.WB.clk);
95
                //@((this.WB.clk ===1'b1 && this.WB.cyc === 1'b1));
96
                $strobe("got request %d\n",this.WB.adr);
97
                if(slave_mbox.try_put(req)) begin
98
                        this.WB.stall<=1'b0;
99
                        req.addr<= this.WB.adr;
100
                        req.rw<= this.WB.we;
101
                        if (req.rw) req.wdata<= this.WB.dat_o;
102
                        //this.seq_item_port.item_done();
103
                        slave_mbox.put(req);
104
                end else
105
                        this.WB.stall<=1'b1;
106
                @(posedge this.WB.clk);
107
        end
108
 
109
        end
110
endtask
111
 
112
 
113
task wb_slave_driver::resp_loop(uvm_phase phase);
114
        wb_slave_seq_item #(this.AW, this.DW, this.TW) req1;
115
        wb_slave_seq_item #(this.AW, this.DW, this.TW) req;
116
        wb_slave_seq_item #(this.AW, this.DW, this.TW) rsp;
117
        forever begin
118
 
119
        if (!this.WB.rst_n) begin
120
                this.WB.ack<= 1'b0;
121
                this.WB.err<= 1'b0;
122
                this.WB.rty<= 1'b0;
123
                this.WB.dat_i<='0;
124
                @(posedge this.WB.clk);
125
        end
126
        else begin
127
                this.WB.ack<=1'b0;
128
                this.WB.err<= 1'b0;
129
                this.WB.rty<= 1'b0;
130
                this.WB.dat_i<='0;
131
                if(slave_mbox.try_get(req)) //begin
132
                //@(slave_mbox.try_get(req));
133
                begin
134
                        $strobe("Processing req\n");
135
                        slave_mbox.get(req);
136
                        this.seq_item_port.get_next_item(req1);
137
                        req1.copy(req);
138
                        this.seq_item_port.item_done();
139
                        this.seq_item_port.get_next_item(rsp);
140
                                $strobe("wait cycle %d\n",rsp.delay);
141
                        //phase.raise_objection(this);
142
                        repeat (rsp.delay) begin
143
                                @(posedge this.WB.clk);
144
                                this.WB.ack<=1'b0;
145
                                this.WB.err<= 1'b0;
146
                                this.WB.rty<= 1'b0;
147
                                this.WB.dat_i<='0;
148
                        end
149
                        //phase.raise_objection(this);
150
 
151
                        if ( ! req.rw) this.WB.dat_i<= rsp.rdata;
152
                                $strobe("rsp %d\n",rsp.rdata);
153
                        this.WB.ack<=1'b1;
154
                        this.WB.err<= rsp.slv_err;
155
                        this.seq_item_port.item_done();
156
                end
157
                @(posedge this.WB.clk);
158
        end
159
 
160
        end
161
 
162
endtask
163
 
164
 
165
`endif // wb_slave_driver

powered by: WebSVN 2.1.0

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