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

Subversion Repositories ahb2wishbone

[/] [ahb2wishbone/] [branches/] [toomuch/] [svtb/] [avm_svtb/] [ahb_wb_monitor.svh] - Blame information for rev 5

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 toomuch
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2
//*****************************************************************************************************************
3
// Copyright (c) 2007 TooMuch Semiconductor Solutions Pvt Ltd.
4
//
5
//File name             :       ahb_wb_monitor.svh
6
//Designer              :       Sanjay kumar
7
//Date                  :       3rd Aug'2007
8
//Description           :       ahb_wb_monitor:Class to monitor transaction on interface and send a copy of monitor
9
//                              packets to each subscribers(scoreboard and coverage).
10
//Revision              :       1.0
11
//*****************************************************************************************************************
12
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
13
 
14
import avm_pkg::*;
15
import global::*;
16
 
17
class ahb_wb_monitor extends avm_threaded_component;
18
 
19
avm_analysis_port#(monitor_pkt) ap_sb; // analysis port
20
monitor_pkt m_pkt;  // instance of packet
21
 
22
local bit flag1;
23
local bit flag2;
24
 
25
virtual ahb_wb_if pin_if;
26
 
27
        function new(string name ,avm_named_component parent);
28
                super.new(name,parent);
29
                ap_sb = new("ap_sb",this);
30
                pin_if =null;
31
        endfunction
32
// task to monitor event on read/write signal
33
task rdwr;
34
        forever
35
                begin
36
                @(pin_if.monitor.hwrite);
37
                flag1='b1;
38
                end
39
endtask
40
// task to monitor event on hready or htrans (wait state)
41
task wait_ms;
42
        forever
43
                begin
44
                @(pin_if.monitor.hready or pin_if.monitor.htrans);
45
                flag2='b1;
46
                end
47
endtask
48
 
49
task main_run;
50
        forever
51
        begin
52
                @(posedge pin_if.monitor.hclk);
53
                if((pin_if.monitor.hready) && (pin_if.monitor.htrans == 'b10)) //No wait state
54
                begin
55
                        if(pin_if.monitor.hwrite) //write mode
56
                        begin
57
                                if(flag1) // first clock
58
                                begin
59
                                        m_pkt.adr1=pin_if.monitor.haddr;
60
                                        m_pkt.wr='b1;
61
                                        m_pkt.sel=pin_if.monitor.hready;
62
                                        m_pkt.mode=pin_if.monitor.htrans;
63
                                        m_pkt.flag1='b1;
64
                                        // write packet to scoreboard
65
                                        ap_sb.write(m_pkt);
66
                                        flag1='b0;
67
                                end
68
                                else
69
                                begin
70
                                        m_pkt.adr1=pin_if.monitor.haddr;
71
                                        m_pkt.dat1=pin_if.monitor.hwdata;
72
                                        m_pkt.adr2=pin_if.monitor.adr_o;
73
                                        m_pkt.dat2=pin_if.monitor.dat_o;
74
                                        m_pkt.wr='b1;
75
                                        m_pkt.sel=pin_if.monitor.hready;
76
                                        m_pkt.mode=pin_if.monitor.htrans;
77
                                        m_pkt.flag1='b0;
78
                                        m_pkt.flag2=flag2;
79
                                        ap_sb.write(m_pkt);
80
                                end
81
                        end
82
                        else// read mode
83
                        begin
84
                                if(flag1) // first clock
85
                                begin
86
                                        m_pkt.adr1=pin_if.monitor.haddr;
87
                                        m_pkt.wr='b0;
88
                                        m_pkt.sel=pin_if.monitor.hready;
89
                                        m_pkt.mode=pin_if.monitor.htrans;
90
                                        m_pkt.flag1='b1;
91
                                        //write packet to scoreboard
92
                                        ap_sb.write(m_pkt);
93
                                        flag1='b0;
94
                                end
95
                                else
96
                                begin
97
                                        m_pkt.adr1=pin_if.monitor.haddr;
98
                                        m_pkt.dat1=pin_if.monitor.hrdata;
99
                                        m_pkt.adr2=pin_if.monitor.adr_o;
100
                                        m_pkt.dat2=pin_if.monitor.dat_i;
101
                                        m_pkt.wr='b0;
102
                                        m_pkt.sel=pin_if.monitor.hready;
103
                                        m_pkt.mode=pin_if.monitor.htrans;
104
                                        m_pkt.flag1='b0;
105
                                        m_pkt.flag2=flag2;
106
                                        // write packet to scoreboard
107
                                        ap_sb.write(m_pkt);
108
                                end
109
                        end
110
                end
111
                else // wait state by slave or master
112
                begin
113
                        if(pin_if.monitor.hwrite) // write mode
114
                        begin
115
                                if(flag2) // latch the value
116
                                begin
117
                                        m_pkt.adr1=pin_if.monitor.haddr;
118
                                        m_pkt.dat1=pin_if.monitor.hwdata;
119
                                        m_pkt.adr2=pin_if.monitor.adr_o;
120
                                        m_pkt.dat2=pin_if.monitor.dat_o;
121
                                        m_pkt.wr='b1;
122
                                        m_pkt.sel=pin_if.monitor.hready;
123
                                        m_pkt.mode=pin_if.monitor.htrans;
124
                                        m_pkt.flag2='b1;
125
                                        ap_sb.write(m_pkt);
126
                                        flag2='b0;
127
                                end
128
                                else
129
                                begin
130
                                        m_pkt.adr1=pin_if.monitor.haddr;
131
                                        m_pkt.dat1=pin_if.monitor.hwdata;
132
                                        m_pkt.adr2=pin_if.monitor.adr_o;
133
                                        m_pkt.dat2=pin_if.monitor.dat_o;
134
                                        m_pkt.wr='b1;
135
                                        m_pkt.sel=pin_if.monitor.hready;
136
                                        m_pkt.mode=pin_if.monitor.htrans;
137
                                        m_pkt.flag2='b0;
138
                                        ap_sb.write(m_pkt);
139
                                end
140
                        end
141
                        else
142
                        begin
143
                                if(flag2) // latch the value
144
                                begin
145
                                        m_pkt.adr1=pin_if.monitor.haddr;
146
                                        m_pkt.dat1=pin_if.monitor.hrdata;
147
                                        m_pkt.adr2=pin_if.monitor.adr_o;
148
                                        m_pkt.dat2=pin_if.monitor.dat_i;
149
                                        m_pkt.wr='b0;
150
                                        m_pkt.sel=pin_if.monitor.hready;
151
                                        m_pkt.mode=pin_if.monitor.htrans;
152
                                        m_pkt.flag2='b1;
153
                                        ap_sb.write(m_pkt);
154
                                        flag2='b0;
155
                                end
156
                                else
157
                                begin
158
                                        m_pkt.adr1=pin_if.monitor.haddr;
159
                                        m_pkt.dat1=pin_if.monitor.hrdata;
160
                                        m_pkt.adr2=pin_if.monitor.adr_o;
161
                                        m_pkt.dat2=pin_if.monitor.dat_i;
162
                                        m_pkt.wr='b0;
163
                                        m_pkt.sel=pin_if.monitor.hready;
164
                                        m_pkt.mode=pin_if.monitor.htrans;
165
                                        m_pkt.flag2='b0;
166
                                        ap_sb.write(m_pkt);
167
                                end
168
                        end
169
                end
170
        end
171
endtask
172
 
173
// run all task simultanoe task
174
task run;
175
        fork
176
                rdwr();
177
                wait_ms();
178
                main_run();
179
        join
180
endtask
181
 
182
endclass
183
 
184
 
185
 

powered by: WebSVN 2.1.0

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