forked from lowRISC/opentitan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spi_device_testplan.hjson
530 lines (523 loc) · 20.1 KB
/
spi_device_testplan.hjson
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
{
name: "spi_device"
import_testplans: ["hw/dv/tools/dvsim/testplans/csr_testplan.hjson",
"hw/dv/tools/dvsim/testplans/mem_testplan.hjson",
"hw/dv/tools/dvsim/testplans/alert_test_testplan.hjson",
"hw/dv/tools/dvsim/testplans/intr_test_testplan.hjson",
"hw/dv/tools/dvsim/testplans/tl_device_access_types_testplan.hjson",
"hw/dv/tools/dvsim/testplans/stress_all_with_reset_testplan.hjson",
"spi_device_sec_cm_testplan.hjson"]
testpoints: [
{
name: smoke
desc: '''
Configures Flash/Passtrhough modes as well as TPM and drive reads/writes
through SPI alternating between TPM and SPI commands.
Sequences spi_device_flash_all_vseq and spi_device_tpm_all_vseq are
launched in parallel'''
stage: V1
tests: ["spi_device_flash_and_tpm"]
}
{
name: csb_read
desc: '''Read CSB value from CSR and check the correctness
This feature is for debug only, so it's sufficient to verify with this direct sequence:
- Assign both CSB pins with random values and read the CSB CSRs to check the values'''
stage: V2
tests: ["spi_device_csb_read"]
}
{
name: mem_parity
desc: '''Test memory parity error
pick a random mem address to inject parity errors and read it back,
then check it returns d_error with all 1s data.'''
stage: V2
tests: ["spi_device_mem_parity"]
}
{
name: mem_cfg
desc: '''Test cfg_i connectivity between spi_device and the backing RAM.
Randomly set dut.ram_cfg_i and check this value is propagated to the memory itself.
For the 1r1w implementation, where the RAM is split into ingress and egress portions,
check that the configuration makes it to both sides.'''
stage: V2
tests: ["spi_device_ram_cfg"]
}
{
name: tpm_read
desc: '''
- Set TPM_CFG.TPM_MODE to CRB mode and set TPM_CFG.EN.
- Randomise other fields in TPM_CFG.
- Assert the tpm_csb.
- Send TPM read command over the SPI bus with a randomised address.
- Check TPM_CMD_ADDR.
- Confirm FIFO behaviour dictated by TPM_CFG.tpm_mode.
- Check TPM_STATUS.cmdaddr_notempty and INTR_STATE.tpm_header_notempty, they should be asserted if hw_reg_dis == 0.
- If hw_reg_dis == 0, the data is returned to the host via return-by-HW register, else the data is returned via read TPM FIFO in SRAM.
- Confirm that the TPM submodule sends WAIT until the read FIFO is available.
- Check the read FIFO.
- When available, confirm that the TPM submodule sends START followed by the register value.
- Compare this value with the expected value.'''
stage: V2
tests: ["spi_device_tpm_rw"]
}
{
name: tpm_write
desc: '''
- Set TPM_CFG.TPM_MODE to CRB mode and set TPM_CFG.EN.
- Randomise other fields in TPM_CFG.
- Assert the tpm_csb.
- Send TPM write command with a randomised address.
- Check TPM_CMD_ADDR and write FIFO.
- Check TPM_STATUS.cmdaddr_notempty and INTR_STATE.tpm_header_notempty.
- Based on FIFO status, check SPI bus to confirm WAIT or START sent.
- Check that the TPM submodule accepts write data without the WAIT state if the write FIFO is empty.
- Otherwise, check WAIT until the write FIFO becomes available (empty).'''
stage: V2
tests: ["spi_device_tpm_rw"]
}
{
name: tpm_hw_reg
desc: '''
- Configure `TPM_CFG` as follows to have DUT directly respond for the access to the HW
registers.
- Set `tpm_mode` to fifo mode.
- Set `hw_reg_dis` to 0.
- Set `tpm_reg_chk_dis` to 0.
- Set `invalid_locality` to 1.
- Send SPI transactions of varying HW registers. In the meanwhile, SW updates the HW
registers.
- Ensure that the data returned is correct for the given address and active locality.'''
stage: V2
tests: ["spi_device_tpm_sts_read", "spi_device_tpm_read_hw_reg"]
}
{
name: tpm_fully_random_case
desc: '''
- Configure `TPM_CFG.EN` to On and fully randomize other TPM configuration.
- Run these 3 threads to randomly access TPM HW registers and other addresses.
- Host issues random TPM reads/writes to spi_device.
- SW polls the TPM interrupt `tpm_header_not_empty`, then read command/address and
the corresponding FIFO.
- SW randomly updates TPM HW registers.
- Ensure all the data is correct in the scoreboard.'''
stage: V2
tests: ["spi_device_tpm_all"]
}
{
name: pass_cmd_filtering
desc: '''
- Randomize command opcode.
- Configure unused CMD_INFO reg with new opcode and set it to valid.
- Check opcode, address and payload are passing through.
- Configure filter bit corresponding to opcode to 1.
- Check the entire command is filtered.
- Set filter bit back to 0.
- Check opcode and address are passing through again.
- Invalid opcode is also filtered'''
stage: V2
tests: ["spi_device_pass_cmd_filtering", "spi_device_flash_all"]
}
{
name: pass_addr_translation
desc: '''
- Randomize command opcode.
- Configure unused CMD_INFO reg with new opcode and set it to valid.
- Enable address translation for given command.
- Configure address translation bits.
- Check proper address translation is applied.
- Disable address translation for given command.
- Check address is now passing unchanged.'''
stage: V2
tests: ["spi_device_pass_addr_payload_swap", "spi_device_flash_all"]
}
{
name: pass_payload_translation
desc: '''
- Configure program or write_status command.
- Enable payload translation for given command.
- Configure payload translation bits.
- Check proper payload translation is applied.
- Disable payload translation for given command.
- Check payload is now passing unchanged.'''
stage: V2
tests: ["spi_device_pass_addr_payload_swap", "spi_device_flash_all"]
}
{
name: cmd_info_slots
desc: '''
- Configure first 5 slots according to required configuration.
- Configure next 6 slots for read commands
- Randomize configuration of the remaining 13 cmd info slots.
- Issue commands with various opcodes enabled in info slots.
- Check proper command propagation.
- Disable some cmd info slots.
- Check no propagation of disabled commands.'''
stage: V2
tests: ["spi_device_flash_all"]
}
{
name: cmd_read_status
desc: '''
- Configure proper read status command info slot.
- Issue read status command.
- Check propagation of read status command.
- Initiate response to the read status.
- Check proper reception of response.'''
stage: V2
tests: ["spi_device_intercept", "spi_device_flash_all"]
}
{
name: cmd_read_jedec
desc: '''
- Configure proper read jedec command info slot.
- Issue read jedec command.
- Check propagation of read jedec command.
- Initiate response to the read jedec.
- Check proper reception of response.'''
stage: V2
tests: ["spi_device_intercept", "spi_device_flash_all"]
}
{
name: cmd_read_sfdp
desc: '''
- Configure proper read sfdp command info slot.
- Issue read sfdp command.
- Check propagation of read sfdp command.
- Initiate response to the read sfdp.
- Check proper reception of response.'''
stage: V2
tests: ["spi_device_intercept", "spi_device_flash_all"]
}
{
name: cmd_fast_read
desc: '''
- Configure proper fast read command info slot.
- Issue fast read command.
- Check propagation of fast read command.
- Initiate response to the fast read.
- Check proper reception of response.'''
stage: V2
tests: ["spi_device_intercept", "spi_device_flash_all"]
}
{
name: cmd_read_pipeline
desc: '''
- Configure proper fast read command info slot with the read data pipeline feature.
- Issue fast read command.
- Check propagation of fast read command, including dummy cycles for read data pipeline.
- Initiate response to the fast read.
- Check proper reception of response.'''
stage: V2
tests: ["spi_device_intercept", "spi_device_flash_all"]
}
{
name: flash_cmd_upload
desc: '''
- Configure spi_device on flash or passthrough mode.
- Configure cmd info slots.
- Set upload to 1 for some of 13 non fixed cmd info slots.
- Host should poll busy field status to check if command is done.
- Issue next command upload and poll busy status again.'''
stage: V2
tests: ["spi_device_upload"]
}
{
name: mailbox_command
desc: '''
- Configure cmd info slots.
- Issue one of predefined read command targeting mailbox space.
- Check response to read command.
- Check if command is processed internally.'''
stage: V2
tests: ["spi_device_mailbox"]
}
{
name: mailbox_cross_outside_command
desc: '''
- Configure spi_device on passthrough mode. Mailbox boundary crossing is not expected to
be used on flash mode, so that testing this on flash mode isn't needed.
- Configure cmd info slots.
- Issue one of predefined read command targeting mailbox space.
- Command should start inside mailbox space and cross into read space.
- When the address falls in the mailbox region, data returns from the mailbox. when the
address is outside the mailbox, data returns as follows
- returns high-z if the read command is filtered.
- returns from downstream port if read command is passed through.'''
stage: V2
tests: ["spi_device_mailbox"]
}
{
name: mailbox_cross_inside_command
desc: '''
- Similar to `mailbox_cross_outside_command`, except that start address is inside the
mailbox.'''
stage: V2
tests: ["spi_device_mailbox"]
}
{
name: cmd_read_buffer
desc: '''
- Configure device in flash mode.
- Issue read commands.
- Create another parallel thread that SW updates read buffer contents after a watermark
or buffer flip event occurs.
- Check proper read data.
- Randomly issue read command that crosses read buffer boundary and switches back to
index 0.
- Check correctness of `last_read_addr`, `readbuf_watermark` and `readbuf_flip`.'''
stage: V2
tests: ["spi_device_flash_mode", "spi_device_read_buffer_direct"]
}
{
name: cmd_dummy_cycle
desc: '''
- Configure cmd info slots.
- Configure dummy cycle of read commands to non default value.
- For single mode allowed dummy cycle is 0 or more.
- For dual/quad mode allowed dummy cycle is 2 or more.
- Check return data timing for configured commands.
- Check proper read data.
- Issue new read command that crosses read maibox boundary.
- Check internal buffer index bit.'''
stage: V2
tests: ["spi_device_mailbox", "spi_device_flash_all"]
}
{
name: quad_spi
desc: '''
- Configure passthrough or flash mode.
- Configure cmd info slots.
- Configure quad mode.
- Issue supported command.
- Check data on all four lines.'''
stage: V2
tests: ["spi_device_flash_all"]
}
{
name: dual_spi
desc: '''
- Configure passthrough or flash mode.
- Configure cmd info slots.
- Configure dual mode.
- Issue supported command.
- Check data on both lines.'''
stage: V2
tests: ["spi_device_flash_all"]
}
{
name: 4b_3b_feature
desc: '''
- Configure passthrough or flash mode.
- Configure command info slots.
- Configure different values for 4B/3B.
- Randomize configuration of EN4B and EX4B register fields.
- Issue supported command with required address.
- Check proper address propagation.'''
stage: V2
tests: ["spi_device_cfg_cmd"]
}
{
name: write_enable_disable
desc: '''
- Configure passthrough or flash mode.
- Randomize WREN and WRDI command info slots.
- Issue WREN and WRDI commands along with read_status command and others.
- Read flash status via TL interface.
- Check WREN/WRDI sets/clears flash status correctly.'''
stage: V2
tests: ["spi_device_cfg_cmd"]
}
{
name: TPM_with_flash_or_passthrough_mode
desc: '''
- Enable TPM mode.
- Configure passthrough or flash mode.
- Issue TPM read/write interleaving with flash transactions.'''
stage: V2
tests: ["spi_device_flash_and_tpm"]
}
{
name: tpm_and_flash_trans_with_min_inactive_time
desc: '''
Issue these transactions with 2 sys_clk inactive time in between.
- 2 tpm transactions.
- 2 flash transactions.
- a tpm transaction and a flash transaction.'''
stage: V2
tests: ["spi_device_flash_and_tpm_min_idle"]
}
{
name: stress_all
desc: '''
- Combine above sequences in one test to run sequentially, except csr sequences.
- Test modes switch among FW, flash, passthrough and tpm.
- Randomly add reset between each sequence'''
stage: V2
tests: ["spi_device_stress_all"]
}
]
covergroups: [
{
name: all_modes_cg
desc: '''
Cover every combination of all possible modes:
- FW mode, passthrough mode and flash mode.
Cover passthrough mode and flash mode with TPM mode enabled.'''
}
// TPM mode
{
name: tpm_cfg_cg
desc: '''
Cover all combinations of these configurations in CSR `tpm_cfg`:
- tpm_mode, hw_reg_dis, tpm_reg_chk_dis, invalid_locality.
Cover these address mode:
- TPM address in both valid and invalid locality.
- TPM address in/outside TPM address region ('hd4_xxxx).
- TPM offset matching to any HW return register.
- Both word aligned and unaligned.
Cross above with TPM read and write transactions.
This CG is sampled when receiving a TPM request.'''
}
{
name: tpm_read_hw_reg_cg
desc: '''
Cover TPM read on all HW returned registered.'''
}
{
name: tpm_transfer_size_cg
desc: '''
Cover both TPM read and write.
Cover request HW returned and SW handled.
Cross above with various payload size.
- min (1B), typical (4B), max (64B).'''
}
{
name: tpm_sts_cg
desc: '''
Cover `tpm_sts` read and write on an active/inactive tpm access.
Cover `tpm_sts` read with HW returned and SW handled.
Cross above with all locality.'''
}
// flash/passthrough mode
{
name: flash_cmd_info_cg
desc: '''
Cover flash/passthrough mode.
Cover all opcode enabled in cmd info.
Cover all payload direction.
Cover all address modes.
Cover addr swap enable.
Cover payload swap enable.
Cover upload enable.
Cover busy enable.
Cover all read_pipeline_mode values
Cover all dummy sizes.
Cover number of payload lanes (single, dual and quad modes or no payload).
cross mode, payload directions, address modes, addr/payload swap enable.
cross mode, dummy sizes, number of lanes.
'''
}
{
name: passthrough_addr_swap_cg
desc: '''
Cover address swap on a transaction with both payload direction (read and program).
Cover all bits toggled on the swap address and mask.
Cross with filter enabled and disabled.'''
}
{
name: passthrough_payload_swap_cg
desc: '''
Cover payload swap on a transaction with both payload direction (read and program).
Cover all bits toggled on the swap payload and mask.
Cross with filter enabled and disabled.'''
}
{
name: passthrough_cmd_filter_cg
desc: '''
Cover all possible bits for command filter.
Every opcode should be enabled and filtering checked.'''
}
{
name: flash_status_cg
desc: '''
Cover all status bits toggled.
Cross above with host reading status and SW reading status.
Cover SW updating flash_status while CSB is active.'''
}
{
name: flash_upload_payload_size_cg
desc: '''
Cover supported payload sizes for IN transactions.
Cover supported payload sizes for OUT transactions.
Cover upload transaction payload size.
Cover payload size of upload transaction exceeds 256B limit (wrap around).'''
}
{
name: flash_command_while_busy_set_cg
desc: '''
Cover host sends flash commands while busy bit is set.
Cover above with filter enabled/disabled on that command.
'''
}
{
name: flash_read_commands_cg
desc: '''
Cover read status/read JEDEC/read SFDP and all other read commands configurable in the
first 10 slots.
Cover dummy cycle.
Cover filter enabled/disabled.
Cover various payload size
Cover INTERCEPT_EN.
Cross all above items.'''
}
{
name: passthrough_mailbox_cg
desc: '''
Cover read commands targeting inside mailbox space.
Cover command starting outside mailbox and crossing into mailbox space.
Cover command starting in mailbox comming outside mailbox space.
Cover command starting outside mailbox and crossing the entire mailbox space and coming
outside mailbox.
Cross above with filter on and off.'''
}
{
name: flash_mailbox_cg
desc: '''
Cover read commands targeting inside mailbox space in the flash mode.'''
}
{
name: spi_device_4B_enter_exit_command_cg
desc: '''
Cover both EN4B and EX4B commands.
Cross this with the previous `cfg_addr_4b_en` value.
'''
}
{
name: sw_update_addr4b_cg
desc: '''
Cover SW updating addr4b to another value.
'''
}
{
name: spi_device_write_enable_disable_cg
desc: '''
Cover write enable and write disable commands.
Cross this with the previous flash_status.wel value.'''
}
{
name: spi_device_buffer_boundary_cg
desc: '''
Cover all the read commands.
Cover buffer boundary crossing (2 buffer flips).'''
}
{
name: tpm_interleave_with_flash_item_cg
desc: '''
Cover TPM transactions interleaving with flash transactions.'''
}
]
}