
A 12-bit counter-based time-to-digital converter measures the high width of each input pulse. A two-stage synchronizer precedes edge detection. Each complete pulse starts a fresh count. Its falling edge stores the code and asserts DATA_VALID for one clock. A startup guard ignores an input that is already high through reset until a low interval and a new pulse occur. Long pulses saturate at 4095 and set OVERFLOW.
Select the project. Run a 1 MHz clock and hold rst_n low for at least two rising edges. Apply pulses on ui_in[0], with high and low intervals greater than 2 us. A 10 us pulse nominally produces code 10. Read bits 7:0 on uo_out and bits 11:8 on uio_out[3:0] while DATA_VALID on uio_out[4] is high. BUSY is uio_out[5]; OVERFLOW is uio_out[6]. Reset after reselecting a project.
A reference clock and a digital pulse source, such as a function generator or the output of an external voltage-to-time/PWM encoder. Use signal levels appropriate to the Tiny Tapeout board interface. Use a logic analyzer or a clocked receiver to capture the parallel output and DATA_VALID. An analog sine voltage requires an encoder before this digital input.
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | PULSE_IN: high interval to measure | WIDTH_CODE[0] | WIDTH_CODE[8] (output) |
| 1 | WIDTH_CODE[1] | WIDTH_CODE[9] (output) | |
| 2 | WIDTH_CODE[2] | WIDTH_CODE[10] (output) | |
| 3 | WIDTH_CODE[3] | WIDTH_CODE[11] (output) | |
| 4 | WIDTH_CODE[4] | DATA_VALID: new result, one clock | |
| 5 | WIDTH_CODE[5] | BUSY: internal measurement active | |
| 6 | WIDTH_CODE[6] | OVERFLOW: stored result saturated | |
| 7 | WIDTH_CODE[7] |