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

Subversion Repositories nysa_sata

[/] [nysa_sata/] [trunk/] [test/] [test_sata.py] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 cospan
# Simple tests for an adder module
2
import cocotb
3
from cocotb.result import TestFailure
4
#from cocotb.triggers import Timer, RisingEdge
5
from sata_model import SataController
6
#import random
7
 
8
CLK_PERIOD = 4
9
 
10
@cocotb.test(skip = True)
11
def bootup_test(dut):
12
    """
13
    Description:
14
        Bootup the SATA stack
15
 
16
    Test ID: 0
17
 
18
    Expected Results:
19
        The SATA stack should be ready and in the IDLE state
20
    """
21
    dut.test_id = 0
22
    sata = SataController(dut, CLK_PERIOD)
23
    yield(sata.reset())
24
 
25
    #yield(sata.wait_for_idle()0))
26
    yield(sata.wait_for_idle())
27
    if not sata.ready():
28
        dut.log.error("Sata Is not ready")
29
        TestFailure()
30
    else:
31
        dut.log.info("Sata is Ready")
32
 
33
 
34 3 cospan
 
35 5 cospan
@cocotb.test(skip = False)
36 2 cospan
def short_write_test(dut):
37
    """
38
    Description:
39
        Perform a single write to the SATA stack
40
 
41
    Test ID: 1
42
 
43
    Expected Results:
44
        Data and Addressed should be read from the
45
        fake hard drive
46
    """
47
    dut.test_id = 1
48
    sata = SataController(dut, CLK_PERIOD)
49
    yield(sata.reset())
50
 
51
    yield(sata.wait_for_idle())
52
    yield(sata.write_to_hard_drive(10, 0x00))
53
    yield(sata.wait_clocks(100))
54
 
55
    dut.log.info("Wrote 1 piece of data to SATA")
56
 
57
 
58
@cocotb.test(skip = True)
59
def short_read_test(dut):
60
    """
61
    Description:
62
        Perform a single read from the SATA stack
63
    Test ID: 2
64
    Expected Result:
65
        -Address should be seen on the fake hard drive side
66
        -Data should be read out of the hard drive
67
    """
68
    dut.test_id = 2
69
    sata = SataController(dut, CLK_PERIOD)
70
    yield(sata.reset())
71
 
72
    yield(sata.wait_for_idle())
73
    yield(sata.read_from_hard_drive(10, 0x00))
74
    yield(sata.wait_clocks(10))
75
 
76
    yield(sata.wait_for_idle())
77
    yield(sata.wait_clocks(200))
78
 
79
 
80
@cocotb.test(skip = True)
81
def long_write_test(dut):
82
    """
83
    Description:
84
        Perform a long write to the hard drive
85
    Test ID: 3
86
    Expected Result:
87
        -Address should be seen on the fake hard drive side
88
        -Data should be read out of the hard drive side
89
        -Number of data should be the same as the write amount
90
    """
91
    dut.test_id = 3
92 3 cospan
    data_count = 2048
93 2 cospan
    sata = SataController(dut, CLK_PERIOD)
94
    yield(sata.reset())
95
 
96
    yield(sata.wait_for_idle())
97
    yield(sata.wait_clocks(100))
98
 
99 3 cospan
    yield(sata.write_to_hard_drive(data_count, 0x00))
100
    dut.u2h_write_enable = 1
101
    yield(sata.wait_clocks(10000))
102
 
103 2 cospan
    dut.log.info("Wrote %d piece of data to SATA" % data_count)
104
 
105
 
106
@cocotb.test(skip = True)
107
def long_read_test(dut):
108
    """
109
    Description:
110
        Perform a long read from the hard drive
111
    Test ID: 4
112
    Expected Result:
113
        -Address should be seen on the fake hard drive side
114
        -Data should be written in to the hard drive side
115
        -Data should be read out of the stack side
116
        -The length of data that is read should be the same as the
117
            data entered into the hard drive
118
    """
119
    dut.test_id = 4
120
    sata = SataController(dut, CLK_PERIOD)
121
    yield(sata.reset())
122
 
123
    yield(sata.wait_for_idle())
124
    yield(sata.read_from_hard_drive(0x900, 0x00))
125
    yield(sata.wait_clocks(10))
126
 
127
    yield(sata.wait_for_idle())
128
    yield(sata.wait_clocks(100))
129
 
130
@cocotb.test(skip = True)
131
def long_write_with_easy_back_preassure_test(dut):
132
    """
133
    Description:
134
        Perform a long write to the hard drive and simulate a stall condition
135
    Test ID: 5
136
    Expected Result:
137
        -Address should be seen on the fake hard drive side
138
        -Data should be read out of the hard drive side
139
        -Length of data read should be the same as the length of data written
140
    """
141
    dut.test_id = 5
142
    sata = SataController(dut, CLK_PERIOD)
143
    yield(sata.reset())
144
    yield(sata.wait_for_idle())
145
 
146
    length = 400
147
    address = 0x00
148 3 cospan
    dut.u2h_write_enable = 1
149
    yield(sata.wait_clocks(800))
150 2 cospan
 
151 3 cospan
    #dut.write_count = length
152
    #dut.write_enable = 1
153
    #dut.u2h_write_enable = 1
154
    #dut.u2h_write_count = length
155
    ##dut.h2u_read_enable = 1
156
    #dut.sector_address = address
157
    ##What does this do?
158
    yield(sata.write_to_hard_drive(length, address))
159
 
160 2 cospan
    dut.sector_count = 0
161
    dut.write_data_en = 1
162
    yield(sata.wait_clocks(1))
163
    dut.write_data_en = 0
164
    yield(sata.wait_clocks(200))
165
    dut.hold = 1
166
    yield(sata.wait_clocks(200))
167
    dut.hold = 0
168 3 cospan
    yield(sata.wait_clocks(200))
169 2 cospan
    dut.hold = 1
170
    yield(sata.wait_clocks(300))
171
    dut.hold = 0
172
    yield(sata.wait_for_idle())
173
 
174
    dut.write_enable = 0
175
    dut.write_count = 0
176 3 cospan
    yield(sata.wait_clocks(2000))
177 2 cospan
    #dut.h2u_read_enable = 0
178
    dut.log.info("Wrote %d piece of data to SATA" % length)
179
 
180 3 cospan
@cocotb.test(skip = False)
181 2 cospan
def long_write_with_hard_back_preassure_test(dut):
182
    """
183
    Description:
184
        Perform a long write to the hard drive and simulate difficult
185
        stall condition
186
    Test ID: 7
187
    Expected Result:
188
        -Address should be seen on the fake hard drive side
189
        -Data should be read out of the hard drive
190
        -Length of data in should be equal to the length of data read
191
    """
192
    dut.test_id = 7
193
    sata = SataController(dut, CLK_PERIOD)
194
    yield(sata.reset())
195
    yield(sata.wait_for_idle())
196
 
197
    length = 9000
198
    address = 0x00
199
 
200
    dut.write_count = length
201
    dut.write_enable = 1
202
    dut.u2h_write_enable = 1
203 3 cospan
    yield(sata.wait_clocks(1000))
204
    #dut.u2h_write_count = length
205 2 cospan
    #dut.h2u_read_enable = 1
206
    dut.sector_address = address
207
    #What does this do?
208
    dut.sector_count = 0
209 3 cospan
    #dut.write_data_en = 1
210
    yield(sata.write_to_hard_drive(length, address))
211 2 cospan
    yield(sata.wait_clocks(2500))
212
    dut.hold = 1
213
    yield(sata.wait_clocks(1))
214
    dut.hold = 0
215 3 cospan
    yield(sata.wait_clocks(394))
216 2 cospan
    dut.hold = 1
217 3 cospan
    yield(sata.wait_clocks(9))
218 2 cospan
    dut.hold = 0
219
    yield(sata.wait_clocks(400))
220
    dut.hold = 1
221
    yield(sata.wait_clocks(20))
222
    dut.hold = 0
223
    yield(sata.wait_clocks(400))
224
    dut.hold = 1
225
    yield(sata.wait_clocks(1))
226
    dut.hold = 0
227
 
228
    yield(sata.wait_for_idle())
229
 
230
    dut.write_enable = 0
231
    dut.write_count = 0
232
    yield(sata.wait_clocks(100))
233
    #dut.h2u_read_enable = 0
234
    dut.log.info("Wrote %d piece of data to SATA" % length)
235
 
236 3 cospan
@cocotb.test(skip = True)
237 2 cospan
def long_write_long_read_back_preassure_test(dut):
238
    """
239
    Description:
240
        Perform a long write to the hard drive and simulate difficult
241
        stall condition, then start a new long read transaction
242
    Test ID: 8
243
    Expected Result:
244
        -Address should be seen on the fake hard drive side
245
        -Data should be read out of the hard drive
246
        -Length of data in should be equal to the length of data read
247
    """
248
    dut.test_id = 8
249
    sata = SataController(dut, CLK_PERIOD)
250
    yield(sata.reset())
251
    yield(sata.wait_for_idle())
252
 
253
    length = 9000
254
    address = 0x00
255
 
256
    dut.write_count = length
257
    dut.write_enable = 1
258
    dut.u2h_write_enable = 1
259
    dut.u2h_write_count = length
260
    #dut.h2u_read_enable = 1
261
    dut.sector_address = address
262
    #What does this do?
263
    dut.sector_count = 0
264
    dut.write_data_en = 1
265
    yield(sata.wait_clocks(1))
266
    dut.write_data_en = 0
267
    yield(sata.wait_clocks(2500))
268
    dut.hold = 1
269
    yield(sata.wait_clocks(1))
270
    dut.hold = 0
271
    yield(sata.wait_clocks(400))
272
    dut.hold = 1
273
    yield(sata.wait_clocks(10))
274
    dut.hold = 0
275
    yield(sata.wait_clocks(400))
276
    dut.hold = 1
277
    yield(sata.wait_clocks(20))
278
    dut.hold = 0
279
    yield(sata.wait_clocks(400))
280
    dut.hold = 1
281
    yield(sata.wait_clocks(1))
282
    dut.hold = 0
283
 
284
    yield(sata.wait_for_idle())
285
 
286
    dut.write_enable = 0
287
    dut.write_count = 0
288
    yield(sata.wait_clocks(100))
289
    #dut.h2u_read_enable = 0
290
    dut.log.info("Wrote %d piece of data to SATA" % length)
291
 
292
    data_count = 0x900
293
    yield(sata.read_from_hard_drive(data_count, 0x00))
294
    yield(sata.wait_clocks(10))
295
 
296
    yield(sata.wait_for_idle())
297
    yield(sata.wait_clocks(100))
298
    dut.log.info("Read %d words of data" % data_count)
299
 
300
 
301
    data_count = 400
302
    yield(sata.write_to_hard_drive(data_count, 0x00))
303
    yield(sata.wait_clocks(200))
304
 
305
    dut.log.info("Wrote %d piece of data to SATA" % data_count)
306
 
307
 
308
 

powered by: WebSVN 2.1.0

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