@@ -19,38 +19,72 @@ a guess about signal function based only on its name, which in some cases gives
19
19
wrong results. Such cases are mentioned in the signal descriptions under the
20
20
diagrams.
21
21
22
- Current FPGA utilization:
22
+ Current FPGA utilization for LPC :
23
23
24
24
``` text
25
25
Info: Device utilisation:
26
- Info: TRELLIS_IO: 65/ 197 32%
27
- Info: DCCA: 5/ 56 8%
28
- Info: DP16KD: 5/ 56 8%
29
- Info: MULT18X18D: 1/ 28 3%
30
- Info: ALU54B: 0/ 14 0%
31
- Info: EHXPLLL: 1/ 2 50%
32
- Info: EXTREFB: 0/ 1 0%
33
- Info: DCUA: 0/ 1 0%
34
- Info: PCSCLKDIV: 0/ 2 0%
35
- Info: IOLOGIC: 44/ 128 34%
36
- Info: SIOLOGIC: 0/ 69 0%
37
- Info: GSR: 0/ 1 0%
38
- Info: JTAGG: 0/ 1 0%
39
- Info: OSCG: 0/ 1 0%
40
- Info: SEDGA: 0/ 1 0%
41
- Info: DTR: 0/ 1 0%
42
- Info: USRMCLK: 1/ 1 100%
43
- Info: CLKDIVF: 1/ 4 25%
44
- Info: ECLKSYNCB: 1/ 10 10%
45
- Info: DLLDELD: 0/ 8 0%
46
- Info: DDRDLL: 1/ 4 25%
47
- Info: DQSBUFM: 2/ 8 25%
48
- Info: TRELLIS_ECLKBUF: 3/ 8 37%
49
- Info: ECLKBRIDGECS: 1/ 2 50%
50
- Info: DCSC: 0/ 2 0%
51
- Info: TRELLIS_FF: 5081/24288 20%
52
- Info: TRELLIS_COMB: 12350/24288 50%
53
- Info: TRELLIS_RAMW: 121/ 3036 3%
26
+ Info: TRELLIS_IO: 65/ 197 32%
27
+ Info: DCCA: 5/ 56 8%
28
+ Info: DP16KD: 5/ 56 8%
29
+ Info: MULT18X18D: 1/ 28 3%
30
+ Info: ALU54B: 0/ 14 0%
31
+ Info: EHXPLLL: 1/ 2 50%
32
+ Info: EXTREFB: 0/ 1 0%
33
+ Info: DCUA: 0/ 1 0%
34
+ Info: PCSCLKDIV: 0/ 2 0%
35
+ Info: IOLOGIC: 44/ 128 34%
36
+ Info: SIOLOGIC: 0/ 69 0%
37
+ Info: GSR: 0/ 1 0%
38
+ Info: JTAGG: 0/ 1 0%
39
+ Info: OSCG: 0/ 1 0%
40
+ Info: SEDGA: 0/ 1 0%
41
+ Info: DTR: 0/ 1 0%
42
+ Info: USRMCLK: 1/ 1 100%
43
+ Info: CLKDIVF: 1/ 4 25%
44
+ Info: ECLKSYNCB: 1/ 10 10%
45
+ Info: DLLDELD: 0/ 8 0%
46
+ Info: DDRDLL: 1/ 4 25%
47
+ Info: DQSBUFM: 2/ 8 25%
48
+ Info: TRELLIS_ECLKBUF: 3/ 8 37%
49
+ Info: ECLKBRIDGECS: 1/ 2 50%
50
+ Info: DCSC: 0/ 2 0%
51
+ Info: TRELLIS_FF: 5049/24288 20%
52
+ Info: TRELLIS_COMB: 12639/24288 52%
53
+ Info: TRELLIS_RAMW: 121/ 3036 3%
54
+ ```
55
+
56
+ Current FPGA utilization for SPI:
57
+
58
+ ``` text
59
+ Info: Device utilisation:
60
+ Info: TRELLIS_IO: 62/ 197 31%
61
+ Info: DCCA: 6/ 56 10%
62
+ Info: DP16KD: 5/ 56 8%
63
+ Info: MULT18X18D: 0/ 28 0%
64
+ Info: ALU54B: 0/ 14 0%
65
+ Info: EHXPLLL: 1/ 2 50%
66
+ Info: EXTREFB: 0/ 1 0%
67
+ Info: DCUA: 0/ 1 0%
68
+ Info: PCSCLKDIV: 0/ 2 0%
69
+ Info: IOLOGIC: 44/ 128 34%
70
+ Info: SIOLOGIC: 0/ 69 0%
71
+ Info: GSR: 0/ 1 0%
72
+ Info: JTAGG: 0/ 1 0%
73
+ Info: OSCG: 0/ 1 0%
74
+ Info: SEDGA: 0/ 1 0%
75
+ Info: DTR: 0/ 1 0%
76
+ Info: USRMCLK: 1/ 1 100%
77
+ Info: CLKDIVF: 1/ 4 25%
78
+ Info: ECLKSYNCB: 1/ 10 10%
79
+ Info: DLLDELD: 0/ 8 0%
80
+ Info: DDRDLL: 1/ 4 25%
81
+ Info: DQSBUFM: 2/ 8 25%
82
+ Info: TRELLIS_ECLKBUF: 3/ 8 37%
83
+ Info: ECLKBRIDGECS: 1/ 2 50%
84
+ Info: DCSC: 0/ 2 0%
85
+ Info: TRELLIS_FF: 5025/24288 20%
86
+ Info: TRELLIS_COMB: 12175/24288 50%
87
+ Info: TRELLIS_RAMW: 121/ 3036 3%
54
88
```
55
89
56
90
## Top level
@@ -82,9 +116,15 @@ External ports:
82
116
marked as negated on the diagram due to how Symbolator detects such signals,
83
117
i.e. its name doesn't end with either ` _n ` or ` _b ` ).
84
118
- ` uart_rxd_i ` , ` uart_txd_o ` : UART running at 115200n8.
85
- - LPC signals: those are to be connected to the mainboard, see
86
- [ Connecting TwPM to mainboard] ( /tutorials/mainboard-connection/ ) .
87
- - SPI signals: connected to onboard SPI flash. Note that there is no clock
119
+ - LPC interface: those are to be connected to the mainboard, see
120
+ [ Connecting TwPM to mainboard] ( /tutorials/mainboard-connection/ ) . Note that
121
+ only one of LPC or SPI interface is present at any given time, depending on
122
+ build configuration.
123
+ - SPI interface: those are to be connected to the mainboard, see
124
+ [ Connecting TwPM to mainboard] ( /tutorials/mainboard-connection/ ) . Note that
125
+ only one of LPC or SPI interface is present at any given time, depending on
126
+ build configuration.
127
+ - SPI flash signals: connected to onboard SPI flash. Note that there is no clock
88
128
signal on the diagram, a hardware macro must be used instead of defining it as
89
129
a port.
90
130
- DDR3 interface: signals to and from onboard DRAM, connected directly to
@@ -158,6 +198,50 @@ List of ports:
158
198
159
199
Source code: [ Dasharo/verilog-lpc-module] ( https://github.com/Dasharo/verilog-lpc-module )
160
200
201
+ Testbench results:
202
+
203
+ ``` text
204
+ VCD info: dumpfile lpc_periph_tb.vcd opened for output.
205
+ Performing TPM write w/o delay
206
+ Performing TPM write with delay
207
+ Performing TPM read with delay
208
+ Performing TPM read w/o delay
209
+ Testing reset behaviour - TPM write w/o delay
210
+ Testing reset behaviour - TPM read w/o delay
211
+ Testing reset behaviour - TPM write with delay
212
+ Testing reset behaviour - TPM read with delay
213
+ Testing non-TPM transactions
214
+ Testing extended LFRAME# timings - write
215
+ Testing extended LFRAME# timings - read
216
+ Testing abort mechanism - write
217
+ Testing abort mechanism - read
218
+ Testing interrupts - Continuous mode:
219
+ no interrupt reported when not requested?
220
+ proper IRQ reported?
221
+ IRQ number latched at start frame?
222
+ IRQ keeps being sent while active?
223
+ IRQ stops being sent when no longer active?
224
+ recovery and turn-around phases executed when int is deactivated?
225
+ IRQs reported with idle clock cycles before stop frame?
226
+ IRQs reported with idle clock cycles after stop frame?
227
+ IRQs reported with longer start pulse width?
228
+ Testing interrupts - switching between modes:
229
+ peripheral doesn't initialize SERIRQ cycle in Quiet mode when not needed?
230
+ peripheral initializes SERIRQ cycle when IRQ needed in Quiet mode?
231
+ reset switches peripheral to Continuous mode?
232
+ Testing interrupts - Quiet mode:
233
+ proper IRQ reported?
234
+ IRQ number latched at start frame?
235
+ IRQ keeps being sent while active?
236
+ IRQ stops being sent when no longer active?
237
+ recovery and turn-around phases executed when int is deactivated?
238
+ IRQs reported with idle clock cycles before stop frame?
239
+ peripheral keeps working after spurious interrupt?
240
+ IRQs reported with longer start pulse width?
241
+ Testing interrupts - IRQ stops being reported on reset
242
+ lpc_periph_tb.v:1344: $stop called at 518601000 (1ps)
243
+ ```
244
+
161
245
This module is responsible for managing LPC communication. It responds only to
162
246
TPM cycles, other cycle types are ignored. SERIRQ (both continuous and quiet
163
247
mode), cycle aborts and LPC resets are implemented.
@@ -211,36 +295,113 @@ Ports for signals to/from data provider:
211
295
that, in quiet mode this signal initializes SERIRQ cycle. Data provider should
212
296
drive this signal as long as reason for interrupt is valid.
213
297
298
+ ## SPI module
299
+
300
+ Source code: [ Dasharo/verilog-spi-module] ( https://github.com/Dasharo/verilog-spi-module )
301
+
302
+ Testbench results:
303
+
304
+ ``` text
305
+ VCD info: dumpfile spi_periph_tb.vcd opened for output.
306
+ Performing TPM write w/o delay
307
+ Performing TPM write with delay
308
+ Performing TPM read with delay
309
+ Performing TPM read w/o delay
310
+ Testing transfers with scattered clock between bytes
311
+ Testing over-sized transfers
312
+ Testing non-TPM addresses
313
+ Testing crossing registers boundary
314
+ spi_periph_tb.v:349: $stop called at 86540000 (1ps)
315
+ ```
316
+
317
+ This module is responsible for managing SPI communication with PC. It only
318
+ supports SPI protocol as described in TPM specification.
319
+
320
+ ![ SPI peripheral module] ( /images/spi_periph.svg )
321
+
322
+ Ports for SPI interface:
323
+
324
+ - ` clk_i ` : SPI clock.
325
+ - ` cs_n ` : Chip select (active low).
326
+ - ` mosi ` : SPI Main Out Sub In.
327
+ - ` miso ` : SPI Main In Sub Out, slow pull-up on host side.
328
+
329
+ Ports for signals to/from data provider:
330
+
331
+ - ` addr_o ` : 16-bit address of TPM register.
332
+ - ` data_i ` , ` data_o ` : data received from or sent to TPM registers module.
333
+ - ` data_wr ` : signal to data provider that ` addr_o ` and ` data_o ` have valid data
334
+ and write is requested.
335
+ - ` wr_done ` : signal from data provider that ` data_o ` has been read. This signal
336
+ isn't used by SPI module because it would most likely arrive when the clock is
337
+ no longer running. Contrary to the LPC, SPI clock runs only during the
338
+ transmission.
339
+ - ` data_req ` : signal to data provider that data is requested.
340
+ - ` data_rd ` : signal from data provider that ` data_i ` has valid data for reading.
341
+ This signal should be driven in response to ` data_req ` .
342
+
343
+ Note that there are no signals responsible for interrupts. SPI uses PIRQ, which
344
+ doesn't require any additional logic, so ` interrupt ` signal from TPM registers
345
+ module is used to drive it directly in the top level module.
346
+
214
347
## TPM registers module
215
348
216
349
Source code: [ Dasharo/verilog-tpm-fifo-registers] ( https://github.com/Dasharo/verilog-tpm-fifo-registers )
217
350
351
+ Testbench results:
352
+
353
+ ``` text
354
+ VCD info: dumpfile regs_tb.vcd opened for output.
355
+ Testing simple register reads without delay
356
+ Testing simple register reads with delay
357
+ Checking register values against expected.txt
358
+ Checking if RO registers are writable
359
+ Testing mechanisms for changing locality
360
+ Testing mechanisms for seizing locality
361
+ Testing TPM_INT_VECTOR write without delay - proper locality
362
+ Testing TPM_INT_VECTOR write with delay - proper locality
363
+ Testing TPM_INT_VECTOR write without delay - wrong locality
364
+ Testing TPM_INT_VECTOR write with delay - wrong locality
365
+ Testing TPM_INT_VECTOR write without delay - no locality
366
+ Testing TPM_INT_VECTOR write with delay - no locality
367
+ Testing command/response exchange and TPM state machine - basic
368
+ Testing command/response exchange and TPM state machine - advanced
369
+ regs_tb.v:1075: $stop called at 2023220000 (1ps)
370
+ ```
371
+
218
372
This module implements TPM register space. It also handles locality transitions,
219
373
TPM interrupt generation and command finite state machine. Register values are
220
374
reported accordingly to the current state. Registers not defined by PC Client
221
375
specification return 0xFF on reads, and writes are dropped.
222
376
223
- The module is located between host interface module (LPC or, in the future, SPI)
224
- and memory buffer for TPM commands and responses. It also exposes hardware
225
- interface that is translated by top module into software interface for TPM stack
226
- running on NEORV32 processor.
377
+ The module is located between host interface module (LPC or SPI) and memory
378
+ buffer for TPM commands and responses. It also exposes hardware interface that
379
+ is translated by top module into software interface for TPM stack running on
380
+ NEORV32 processor.
227
381
228
382
![ TPM registers module] ( /images/regs_module.svg )
229
383
230
- Ports for signals to/from LPC module:
384
+ Ports for signals to/from LPC or SPI module:
231
385
232
- - ` clk_i ` : LPC clock is used for this module to allow for synchronous
233
- communication with LPC module. Because of that, all registers' values are
234
- available in one clock cycle and no wait states have to be inserted.
386
+ - ` clk_i ` : LPC/SPI clock is used for this module to allow for synchronous
387
+ communication with LPC/SPI module. Because of that, all registers' values are
388
+ available in one clock cycle and no wait states (LPC) or exactly one wait
389
+ state (SPI) has to be inserted. For LPC,the clock is free-running, but for SPI
390
+ it is enabled only during the communication.
391
+ - ` reset ` : reset signal, required to reset registers to their initial values,
392
+ active low.
235
393
- ` addr_i ` : 16-bit address of register to access.
236
- - ` data_i ` : 8-bit data from LPC module.
237
- - ` data_o ` : 8-bit data to LPC module.
394
+ - ` data_i ` : 8-bit data from LPC/SPI module.
395
+ - ` data_o ` : 8-bit data to LPC/SPI module.
238
396
- ` data_wr ` , ` wr_done ` , ` data_req ` , ` data_rd ` : 4 signals coordinating
239
397
communication over ` data_i ` and ` data_o ` . Their functions can be found in the
240
- [ LPC module description] ( #lpc-module ) above.
398
+ [ LPC module description] ( #lpc-module ) or [ SPI module description] ( #spi-module )
399
+ above.
241
400
- ` irq_num ` , ` interrupt ` : configuration and request of interrupts sent to host,
242
- see [ LPC module description] ( #lpc-module ) for details. Note that these are not
243
- interrupts sent towards NEORV32.
401
+ see [ LPC module description] ( #lpc-module ) for details. In case of SPI,
402
+ ` interrupt ` is negated and routed directly to I/O pin in top level and
403
+ ` irq_num ` is not used. Note that these are not interrupts sent towards
404
+ NEORV32.
244
405
245
406
Ports for signals for MCU interface:
246
407
@@ -284,5 +445,5 @@ Ports:
284
445
285
446
- ` A ` : address, counted in 32-bit words.
286
447
- ` WD ` , ` RD ` : input and output data, respectively.
287
- - ` Clk ` : input clock, arbitrated by top level between LPC and system clocks.
448
+ - ` Clk ` : input clock, arbitrated by top level between LPC/SPI and system clocks.
288
449
- ` WEN ` : write enable for each byte of ` WD ` .
0 commit comments