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

Subversion Repositories wisbone_2_ahb

[/] [wisbone_2_ahb/] [tags/] [t2/] [svtb/] [avm_svtb/] [wb_ahb_responder.svh] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 toomuch
//******************************************************************************************************
2
// Copyright (c) 2007 TooMuch Semiconductor Solutions Pvt Ltd.
3
 
4
 
5
//File name             :       wb_ahb_responder.svh
6
//Date                  :        Aug, 2007
7
//Description           :       Response from AHB to the Inputs from Wishbone
8
//Revision              :       1.0
9
 
10
//******************************************************************************************************
11
 
12
 
13
// responder class
14
import avm_pkg::*;
15
import global::*;
16
class wb_ahb_responder extends avm_threaded_component;
17
 
18
int cnt;
19
virtual wb_ahb_if pin_if;
20
 
21
        function new(string name ,avm_named_component parent);
22
                super.new(name,parent);
23
                pin_if   =null;
24
        endfunction
25
 
26
task run;
27
        // local memory in AHB slave model
28
        logic [DWIDTH-1 : 0] ahb_mem [AWIDTH-1 : 0];
29
        logic [AWIDTH-1:0] haddr_temp;
30
        logic [DWIDTH-1 :0] hrdata_temp;
31
        logic hwrite_temp;
32
 
33
        forever
34
                begin
35
                        @(pin_if.slave_ba.haddr or pin_if.slave_ba.hwrite);
36
 
37
                                if(pin_if.master_wb.rst_i)
38
                                        begin
39
                                        pin_if.slave_ba.hready='b0;
40
                                        pin_if.slave_ba.hwdata='bx;
41
                                        pin_if.slave_ba.hresp='b00;
42
                                        end
43
                                else
44
                                        @(posedge pin_if.master_wb.clk_i)
45
                                        if(pin_if.slave_ba.hready)
46
                                        begin
47
                                        haddr_temp = #2 pin_if.slave_ba.haddr;
48
                                        hwrite_temp=#2 pin_if.slave_ba.hwrite;
49
                                        $display("@ %0d,temp addr=%0d",$time,haddr_temp);
50
                                        if(hwrite_temp)
51
                                                begin
52
                                                ahb_mem[haddr_temp] = #2 pin_if.slave_ba.hwdata;// data stored in ahb slave
53
                                                $display("@ %0d,temp data=%0d",$time,pin_if.slave_ba.hwdata);
54
                                                end
55
                                        else if (!pin_if.slave_ba.hwrite) //Read Operation
56
                                                begin
57
                                                pin_if.slave_ba.hrdata = #2 ahb_mem[pin_if.slave_ba.haddr];
58
                                                end
59
                                        end
60
                end
61
endtask
62
 
63
 
64
//*****************************************
65
//Write operations with no wait states
66
//*****************************************
67
task wait_state_by_slave;
68
        pin_if.slave_ba.hready='b1;
69
        $display("\n@%0d Block Write operations \n",$time);
70
                do
71
                        begin
72
                        @(posedge pin_if.master_wb.clk_i);
73
                        cnt++;
74
                        end
75
                while (cnt <= 6);//Write operations with no wait states for 7 clk cycles
76
//************************************************
77
//Write operations with wait states from AHB Slave
78
//************************************************
79
        #2 pin_if.slave_ba.hready='b0;
80
        $display("\n@%0d Write operations with wait states from AHB Slave \n",$time);
81
        cnt=0;
82
                do
83
                        begin
84
                        @(posedge pin_if.master_wb.clk_i);
85
                        ++cnt;
86
                        end
87
                while (cnt <= 1);// 2 clock cycle asserted AHB Master is in Wait State
88
//*****************************************
89
//Write operations with no wait states
90
//*****************************************
91
        #2 pin_if.slave_ba.hready='b1;
92
        $display("\n@%0d Block Write operations \n",$time);
93
        cnt=0;
94
                do
95
                        begin
96
                        @(posedge pin_if.master_wb.clk_i);
97
                        cnt++;
98
                        end
99
                while (cnt <= 3);//Write operations with no wait states for 4 clk cycles
100
//***********************************************
101
//Write operations with wait states from WB Master
102
//***********************************************
103
         #2 pin_if.slave_ba.hready='b1;
104
        $display("\n@%0d Write operations with wait states from WB Master \n",$time);
105
        cnt=0;
106
                do
107
                        begin
108
                        @(posedge pin_if.master_wb.clk_i);
109
                        ++cnt;
110
                        end
111
                while (cnt <= 1);// 2 clock cycle deasserted WB Master is in Wait State
112
//*****************************************
113
//Write operations with no wait states
114
//*****************************************
115
        #2 pin_if.slave_ba.hready='b1;
116
        $display("\n@%0d Block Write operations \n",$time);
117
        cnt=0;
118
                do
119
                        begin
120
                        @(posedge pin_if.master_wb.clk_i);
121
                        cnt++;
122
                        end
123
                while (cnt <= 3);//Write operations with no wait states for 4 clk cycles
124
 
125
//*************************************
126
//Read operations without wait states
127
//*************************************
128
        #2 pin_if.slave_ba.hready='b1;
129
        $display("\n@%0d Block Read operations \n",$time);
130
        cnt=0;
131
                do
132
                        begin
133
                                @(posedge pin_if.master_wb.clk_i);
134
                        cnt++;
135
                        end
136
        while (cnt <= 5);// Read operations with no wait states for 6 clk cycles
137
 
138
//**********************************************
139
//Read operations with wait states from AHB Slave
140
//**********************************************
141
        #2 pin_if.slave_ba.hready='b0; // 25 clock cycle asserted AHB Master is in Wait State
142
        $display("\n@%0d Read operations with wait states from AHB Slave\n",$time);
143
        cnt=0;
144
                do
145
                        begin
146
                                @(posedge pin_if.master_wb.clk_i);
147
                        ++cnt;
148
                        end
149
        while (cnt <= 1);// 2 clock cycle asserted AHB Master is in Wait State
150
 
151
//*************************************
152
//Read operations without wait states
153
//*************************************
154
        #2 pin_if.slave_ba.hready='b1;
155
        $display("\n@%0d Block Read operations \n",$time);
156
        cnt=0;
157
                do
158
                        begin
159
                                @(posedge pin_if.master_wb.clk_i);
160
                        cnt++;
161
                        end
162
        while (cnt <= 3);// Read operations with no wait states for 4 clk cycles
163
//**********************************************
164
//Read operations with wait states from WB Master
165
//**********************************************
166
        #2 pin_if.slave_ba.hready='b1; // 5 clock cycle  deasserted WB Master in in Wait state
167
        $display("\n@%0d Read operations with wait states from WB Master\n",$time);
168
        cnt=0;
169
                do
170
                        begin
171
                                @(posedge pin_if.master_wb.clk_i);
172
                        ++cnt;
173
                        end
174
                while (cnt <= 4);// 5 clock cycle  asserted WB Master in in Wait state
175
 
176
endtask
177
 
178
 
179
endclass

powered by: WebSVN 2.1.0

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