Skip to content

Commit 1968855

Browse files
committed
Update tests/README.md
1 parent a90a3fd commit 1968855

File tree

2 files changed

+97
-28
lines changed

2 files changed

+97
-28
lines changed

tests/CodeCoverageIndex.md

+21-20
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
**Uart8Receiver**
22

3-
| Code location | Test # |
4-
| :------------------------------------------------------------| :-------------|
5-
| 79   if (out_hold_count == 5'b10000) begin | 12, 25, 27 |
6-
| 110 if (en && err && !in_sample) begin | 30 |
7-
| 133 if (sample_count == 4'b0) begin | 1, 16 |
8-
| 134 if (&in_prior_hold_reg \|\| done && !err) begin | 1, 16, 24, 28 |
9-
| 141 end else begin | 17, 18, 24 |
10-
| 148 if (sample_count == 4'b1100) begin | 1, 16 |
11-
| 158 end else if (\|sample_count) begin | 18, 19 |
12-
| 215 if (sample_count[3]) begin | 20, 21, 22 |
13-
| 216 if (!in_sample) begin | 21*, 22* |
14-
| 220 if (sample_count == 4'b1000 && &in_prior_hold_reg) begin | 25 |
15-
| 228 end else if (&sample_count) begin | 23 |
16-
| 238 if (&in_current_hold_reg) begin | 1, 20, 21 |
17-
| 244 end else if (&sample_count) begin | 5**, 22 |
18-
| 261 if (!err && !in_sample \|\| &sample_count) begin | 27 |
19-
| 269 if (in_sample) begin | 1, 9, 28 |
20-
| 274 end else begin [case: !in_sample] | |
21-
| 282 end else begin [case: !&sample_count] | 12 |
22-
| 290 end else if (&sample_count[3:1]) begin | 30 |
3+
| Code location | Test # |
4+
| :------------------------------------------------------------| :-----------------|
5+
| 79   if (out_hold_count == 5'b10000) begin | 12, 25, 26, 27 |
6+
| 110 if (en && err && !in_sample) begin | 30 |
7+
| 133 if (sample_count == 4'b0) begin | 1, 16 |
8+
| 134 if (&in_prior_hold_reg \|\| done && !err) begin | 1, 16, 24 |
9+
| 141 end else begin | 17, 18, 24 |
10+
| 148 if (sample_count == 4'b1100) begin | 1, 16 |
11+
| 158 end else if (\|sample_count) begin | 18, 19, 26 |
12+
| 215 if (sample_count[3]) begin | 20, 21, 22 |
13+
| 216 if (!in_sample) begin | 21*, 22* |
14+
| 220 if (sample_count == 4'b1000 && &in_prior_hold_reg) begin | 25, 26 |
15+
| 228 end else if (&sample_count) begin | 23 |
16+
| 238 if (&in_current_hold_reg) begin | 1, 20, 21, 27, 29 |
17+
| 244 end else if (&sample_count) begin | 5**, 22 |
18+
| 261 if (!err && !in_sample \|\| &sample_count) begin | 27, 29 |
19+
| 269 if (in_sample) begin | 1, 9 |
20+
| 274 end else begin [case: !in_sample] | 28 |
21+
| 282 end else begin [case: !&sample_count] | 12, 27, 29 |
22+
| 290 end else if (&sample_count[3:1]) begin | 30*** |
2323

2424
<br />
2525

@@ -39,3 +39,4 @@
3939

4040
\* With no meeting the inner conditions lines 220 and 228
4141
\*\* See second transaction
42+
\*\*\* And meeting inner condition line 293

tests/README.md

+76-8
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ Group 1 traces show the communication as an integrated whole:
123123

124124
- Second transmission frame is shortened, but it's not enough to affect the result since it's during the output. Note when `rxEn` drops to `0`: It makes the `rxDone` pulse shorter than `rxDone` in the first frame, it makes the state `101` shorter, and makes the availability of the "`7F`" data shorter
125125

126+
<br />
127+
126128
### #5 Correct data is read out for first frame, incorrect for second due to mismatch
127129

128130
[5.v](5.v "Test bench 5.v")
@@ -131,6 +133,8 @@ Group 1 traces show the communication as an integrated whole:
131133

132134
`Uart8Receiver:` [`244 (*second frame)`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Receiver.v#L244)
133135

136+
<br />
137+
134138
### #6 Interrupted transmit followed by complete transmit
135139

136140
[6.v](6.v "Test bench 6.v")
@@ -139,6 +143,8 @@ Group 1 traces show the communication as an integrated whole:
139143

140144
`Uart8Transmitter:` [`84`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Transmitter.v#L84)
141145

146+
<br />
147+
142148
### #7 Interrupted transmit followed by complete transmit ("txStart" overlaps)
143149

144150
[7.v](7.v "Test bench 7.v")
@@ -147,6 +153,8 @@ Group 1 traces show the communication as an integrated whole:
147153

148154
`Uart8Transmitter:` [`84`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Transmitter.v#L84)
149155

156+
<br />
157+
150158
### #8 Interrupted transmit followed by failed transmit ("txStart" too short)
151159

152160
[![Test case 8][img-8-cr]][img-8]
@@ -204,13 +212,13 @@ Group 1 traces show the communication as an integrated whole:
204212

205213
**Observations**
206214

207-
- Unlike in #9 and #10, the second `in` data signal lags the transmitter's high-going done signal; thus at the moment of the high-going `txDone`, you can see the previous `in` value is re-captured in `in_data`
215+
- Unlike in #9 and #10, the second `in` data byte "`B1`" lags; at the moment of the high-going `txDone`, the previous `in` value is re-captured in `in_data`
208216

209217
- Shows a third transmit starting, because `txStart` goes low too late at the end of second transmit
210218

211219
- This test bench uses a feedback method of control to shut off `txStart`; so it's suggestive of ideas for external control of the UART; but these tests do not go into how you can use outputs for external control, and how to decide the timing of inputs
212220

213-
- The test benches in general though rely on tuned timings to present the inputs according to the intent of the test - in other words, empirical or ad hoc timings. Examples to illustrate:
221+
- However the test benches in general rely on tuned timings to present the inputs according to the intent of the test - in other words, empirical or ad hoc timings. Examples to illustrate:
214222

215223
- Interval `#11500` used in test [#13](#13-turbo_frames--0): Because each cycle is about 11.5ms, this gives prep or set-up times mid-way through each transmit for pushing each next byte (this is the `in` transitions relative to the `txDone` pulses)
216224
- Compare `#10750` used in test [#14](#13-turbo_frames--0), because its cycles are shorter
@@ -366,11 +374,11 @@ So, these tests are fine-grained in order to nail down the behaviour of the RX d
366374
<summary>Some Verilog hints to understand the code</summary>
367375
<br />
368376

369-
- The "`&`" operator of `&in_prior_hold_reg` collects the bits, and the expression is true if all the bits are `1`; secondly, `in_prior_hold_reg` is a vector of size `4`, and is a shift register; this provides a connection to time passing: `4` ticks of the clock for it to fill up (say with `1`s)
377+
The "`&`" operator of `&in_prior_hold_reg` collects the bits, and the expression is true if all the bits are `1`. Secondly, `in_prior_hold_reg` is a vector of size `4`, and is a shift register. This provides a connection to time passing: `4` ticks of the clock for it to fill up (say with `1`s).
370378

371-
- Ticks of the clock are implicitly being examined, and waited for, by this section of code: `4` ticks, `8` ticks, `12` ticks; `16` ticks is the nominal duration of an incoming bit being sampled; if you understand line [`152`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Receiver.v#L152): `sample_count <= 4'b0100;` and how `sample_count` is being used cycling from `0` to `F`, then you've understood a lot of the code and the protocol, and how a Finite State Machine is useful
379+
Ticks of the clock are implicitly being examined, and waited for, by this section of code: `4` ticks, `8` ticks, `12` ticks; `16` ticks is the nominal duration of an incoming bit being sampled. If you understand line [`152`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Receiver.v#L152): `sample_count <= 4'b0100;` and how `sample_count` is being used cycling from `0` to `F`, then you've understood a lot of the code and the protocol, and how a Finite State Machine is useful.
372380

373-
- When `in_sample` drops to `0`, that's the trigger for recovering from the error: `in_prior_hold_reg` is losing its `1` bits and goes away from the `F` or `&in_prior_hold_reg` condition; `sample_count`, if it continues to increase, will allow moving from the `IDLE` state to `START_BIT` state
381+
When `in_sample` drops to `0`, that's the trigger for recovering from the error: `in_prior_hold_reg` is losing its `1` bits and goes away from the `F` or `&in_prior_hold_reg` condition; `sample_count`, if it continues to increase, will allow moving from the `IDLE` state to `START_BIT` state.
374382

375383
</details>
376384
<br />
@@ -399,7 +407,7 @@ So, these tests are fine-grained in order to nail down the behaviour of the RX d
399407

400408
**Variant #18a**
401409

402-
- Focuses on the high in `IDLE` state after a false start bit (start signal has gone high too early)
410+
- Focuses on the high in `IDLE` state after a false "start" bit (the signal has gone high too early)
403411

404412
- `18a.v` line [`63`](https://github.com/TimRudy/uart-verilog/blob/a805332/tests/18a.v#L63 "Test bench changes at line 63"): Try `#230` for short, `#250` meets the minimum, `#300` long
405413

@@ -433,7 +441,7 @@ So, these tests are fine-grained in order to nail down the behaviour of the RX d
433441

434442
**Observations**
435443

436-
- The reader can explore the implication of splitting `in_current_hold_reg` from `in_prior_hold_reg`; these are views into the register that stores the most recent `in` signal values/changes; the look-back allows for **signal hold time checks**
444+
- The reader can explore the implication of splitting `in_current_hold_reg` from `in_prior_hold_reg`; these are views into the register that stores the most recent `in` signal values/changes (and this look-back allows for **signal hold time checks**)
437445

438446
**Variant #20a**
439447

@@ -520,31 +528,91 @@ So, these tests are fine-grained in order to nail down the behaviour of the RX d
520528

521529
[26.v](26.v "Test bench 26.v")
522530

531+
**Code Coverage Refs**
532+
533+
`Uart8Receiver:` [`79`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Receiver.v#L79), [`158`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Receiver.v#L158), [`220`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Receiver.v#L215-L221)
534+
535+
**Observations**
536+
537+
- The `done` signal counts out to `16` as required
538+
539+
- `err`, caused during the next transmit start, overlaps and actually ends before `done` ends
540+
523541
<br />
524542

525543
### #27 Next transmit frame start overlaps with previous frame done signal
526544

527545
[27.v](27.v "Test bench 27.v")
528546

547+
**Code Coverage Refs**
548+
549+
`Uart8Receiver:` [`238`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Receiver.v#L237-L238), [`261`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Receiver.v#L261), [`282`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Receiver.v#L282)
550+
551+
**Observations**
552+
553+
- Shows going to the `READY` state, but only remaining in that state for a few clock ticks; whereupon the next frame starts
554+
555+
- Despite the transition from `READY` to `IDLE` state, `done` is sustained for a `16`-tick cycle; this is implemented by moving the value in `sample_count` over to `out_hold_count` (line `287`)
556+
557+
- At line [`287`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Receiver.v#L287), the value assigned to `out_hold_count` tracks whatever `sample_count` has gone up to by that time - It does not use `sample_count <= 4'b1;` from the previous line, for the reason explained above about a value not changing till the end of a time slice in procedural block code
558+
529559
**Variant #27a**
530560

561+
<br />
562+
531563
### #28 Next transmit frame start overlaps with previous frame done signal 2
532564

533565
[28.v](28.v "Test bench 28.v")
534566

567+
**Code Coverage Refs**
568+
569+
`Uart8Receiver:` [`274`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Receiver.v#L274)
570+
571+
**Observations**
572+
573+
- Shows a complete `READY` state of exactly `16` ticks; whereupon the next frame starts
574+
575+
- At the red marker when `sample_count` is `E`, nothing happens
576+
577+
- In this particular case `in_sample` drops to `0` between `E` and `F`
578+
579+
- When `sample_count` is `F`, the assignments after line [`274`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Receiver.v#L274-L281) are what start the next frame, the `IDLE` state, the "start" bit hold count of `12` ticks
580+
581+
- If you follow further, in the `IDLE` state, the condition at line `132` holds, the condition at line `133` does not hold, and so the counting continues in the branch at line `146`
582+
583+
<br />
584+
535585
### #29 Successful transmit done signal overlaps with next transmit start error 2
536586

537587
[29.v](29.v "Test bench 29.v")
538588

589+
**Code Coverage Refs**
590+
591+
`Uart8Receiver:` [`238`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Receiver.v#L237-L238), [`261`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Receiver.v#L261), [`282`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Receiver.v#L282)
592+
593+
**Observations**
594+
595+
- Shows a `READY` state of exactly `1` tick, because `in_sample` drops to `0` at the same tick that `READY` state is entered
596+
597+
- The `done` signal counts out to `16` as required
598+
599+
- `err`, caused during the next transmit start, overlaps; the duration of `err` is unconstrained and it continues past the `done` signal
600+
539601
**Variant #29a**
540602

603+
<br />
604+
541605
### #30 Transmit fails, error state is continuous with next transmit start error
542606

543607
[30.v](30.v "Test bench 30.v")
544608

609+
**Code Coverage Refs**
610+
611+
`Uart8Receiver:` [`290, 293`](https://github.com/TimRudy/uart-verilog/blob/a805332/Uart8Receiver.v#L290-L293)
612+
545613
**Observations**
546614

547-
- Shows err sustained high, no glitch low-high
615+
- Shows `err` sustained high; there is no glitch low-high (`RESET` state), given that the `busy` state signal continues high
548616

549617
</details>
550618

0 commit comments

Comments
 (0)