
This tile is the digital lock-in core of an impedance-measurement system. The external board provides the excitation driver, response sensing, 1-bit converter, and calibration.
One 16-bit NCO generates coherent excitation and quadrature references. A single
external synchronous 1-bit converter stream (ui[3]) is correlated against I and Q
over a programmable power-of-2 number of 256-sample windows (1 to 256 windows =
256 to 65,536 clk cycles, up to 3.28 ms at 20 MHz) into 21-bit signed
accumulators, exposed as sign-extended 24-bit little-endian values with burst SPI
auto-increment readout.
Two harmonic-suppression upgrades are selectable via the configuration register while preserving full high-frequency operation:
uo[1] (CFG.dac_en):
dac_en=0 (default): direct full-rate square wave (phase[15]), operating up to
clk/4 (5 MHz at 20 MHz clk).dac_en=1: 1st-order 7-bit digital ΔΣ modulator driven by a 16-entry quarter-wave
sine ROM (64 steps/cycle, centered at half scale, with polarity aligned to
phase[15]). A PCB reconstruction filter recovers the sine from the 1-bit
output. At clk=20 MHz, 10–300 kHz gives at least 66 DAC updates per period.CFG.sine_corr):
sine_corr=0 (default): rectangular ±1 correlation (+1 if adc == ref, else -1).sine_corr=1: multiplier-free 5-bit signed quarter-wave sine weights (N=32
mid-bin steps, magnitudes [2, 4, 7, 10, 12, 14, 15, 15], average 9.875).
Suppresses odd harmonics (−53.7 dB H3, −34.7 dB H5, −41.7 dB H7, −41.8 dB H15;
first alias at 31f) with zero hardware multipliers and remains valid at high
FWORD (e.g., 0x4000, 4 samples/cycle).65,536 × 15 = 983,040
(< 2^20 = 1,048,576), so the 21-bit signed accumulators cannot overflow in any mode
or FWORD (including DC FWORD=0).Frequency = clk_hz * FWORD / 65536. Default FWORD=0x1000 gives clk/16.
At 20 MHz, resolution is about 305.18 Hz; a single 256-sample window lasts 12.8 µs
and a 256-window integration lasts 3.28 ms. At maximum SCK, a result burst takes
about 45 µs of clocking. Configuration registers (FWORD, WIN_SHIFT, CFG) are
locked while excitation is enabled. For an integer number of excitation cycles
in an integration, choose FWORD so that FWORD × sample_count is a multiple of
65,536.
phase is the NCO phase whose square references are on the pins: uo[2] is
(phase + 0x4000)[15] and, with dac_en=0, uo[1] is phase[15]. Each sample
taken at a rising clk edge is correlated against the phase that the pins show
just before that edge, in every mode, including dac_en=1, where uo[1] does not
show it.
k = phase[15:11] (32 bins per cycle) and
j = k[3] ? 7 − k[2:0] : k[2:0]. With sine_corr=1 the I weight is M[j],
M = [2, 4, 7, 10, 12, 14, 15, 15]; with sine_corr=0 it is 1. A sample adds
+weight to I when the ADC bit equals k[4], and −weight otherwise. Q uses the
same rule with k + 8 (mod 32).dac_en=1). Let j = phase[14] ? 15 − phase[13:10] : phase[13:10] and
S = [3, 9, 15, 21, 27, 33, 38, 43, 47, 51, 54, 57, 59, 61, 62, 63]. The DAC value
is 64 + S[j] when phase[15]=1 and 63 − S[j] otherwise (7 bits). Each enabled
clk, uo[1] shows the carry of err + value and err keeps the low 7 bits.
err is held at 0 while disabled, so the first enabled output is the carry of
0 + value. uo[1] is low while excitation is disabled, in both modes.| Pin | Function |
|---|---|
| clk | External master clock, 20 MHz target |
| rst_n | Active-low reset; asynchronous assertion, 2-cycle synchronous release |
| ena | Tiny Tapeout project selection; combined with rst_n into the same reset (low = full reset) |
| ui[0] | SPI SCK, mode 0 |
| ui[1] | SPI CSN, active low |
| ui[2] | SPI MOSI |
| ui[3] | External synchronous 1-bit ADC stream, selectable posedge or negedge capture |
| uo[0] | SPI MISO; driven low outside CS, not tristated |
| uo[1] | Excitation (phase[15] square or 1-bit ΔΣ sine DAC), flop-driven |
| uo[2] | Q reference (+90° square), flop-driven |
| uo[3] | Capture window: high before each sampling clk edge (256 × 2^win_shift edges) |
| uo[4] | Result ready, one clk after uo[3] falls; held until next start/reset/deselect |
| uo[5] | Forwarded master clock (ungated, runs during reset/deselect) |
| ui[7:4], uo[7:6], uio[7:0] | Unused; unused outputs zero, bidirectional output enables zero |
CFG.adc_neg)ui[3] is intentionally not passed through an asynchronous synchronizer because
sample phase is part of the measurement. Setting CFG.adc_neg=1 captures ui[3]
on negedge clk (via a dedicated falling-edge flop re-timed to posedge clk),
shifting the sampling instant by half a clock period (25 ns at 20 MHz) without
gating or inverting uo[5]. This allows board bring-up to select the capture edge
with maximum setup/hold margin against the Tiny Tapeout I/O mux + PCB round-trip
delay before calibrating deterministic latency/phase offsets against R/C standards.
Mode 0, MSB first. Command byte: [R/W bit7 | bits6:4 zero | address bits3:0].
R/W=0): two bytes ([cmd][data]). Only the data byte commits a write.R/W=1): the command returns zero on MISO. The first
dummy byte clocks out the addressed register. Keep CSN low to read one
successive register per dummy byte, wrapping from address 15 to 0. To read
results, send 0x88 followed by six dummy bytes.Each SCK half-period must be at least 8 clk cycles (SPI <= clk/16, 1.25 MHz at
20 MHz). Keep CSN high for at least 8 clk cycles between transactions. With
SCK low, allow at least 8 clk cycles between asserting CSN and the first SCK
rising edge, and between the last SCK falling edge and releasing CSN.
| Address | Read | Write |
|---|---|---|
| 0 | bit0 enabled, bit1 busy, bit2 done |
bit0 enabled; bit1 start pulse; bit2 phase_clear pulse |
| 1 | FWORD[7:0] |
Set while disabled |
| 2 | FWORD[15:8] |
Set while disabled |
| 3 | ID 0xA2 |
Ignored |
| 4 | WIN_SHIFT[3:0] (2^win_shift windows, 0..8 → 1..256; ≥8 clamps to 256) |
Set while disabled |
| 5 | CFG: bit0 dac_en, bit1 sine_corr, bit2 adc_neg |
Set while disabled |
| 6..7 | Zero | Ignored |
| 8 | I[7:0] (24-bit signed, little-endian) |
Ignored |
| 9 | I[15:8] |
Ignored |
| 10 | I[23:16] (sign-extended from 21-bit signed) |
Ignored |
| 11 | Q[7:0] (24-bit signed, little-endian) |
Ignored |
| 12 | Q[15:8] |
Ignored |
| 13 | Q[23:16] (sign-extended from 21-bit signed) |
Ignored |
| 14..15 | Zero | Ignored |
An idle write with both enabled and start set clears done and both
accumulators, then captures 256 × 2^min(WIN_SHIFT, 8) samples. While busy,
writes with enabled=1 leave the integration running and ignore start and
phase_clear. Writing CTRL=0 disables excitation and aborts any integration
whose final sample has yet to be accumulated. Disabling after completion keeps
the completed result and done set. Read addresses 8..13 while done=1 and
before starting another integration.
Reset or deselect (ena=0) clears uo[4:0] immediately, leaves uo[5] forwarding
the master clock, and restores FWORD=0x1000, WIN_SHIFT=0, and CFG=0.
Addresses 8..13 return zero until the first integration completes.
To check the digital path with a constant input, tie ui[3] low and run the steps
below with FWORD=0, WIN_SHIFT=0, and CFG=0. Expect I=256 and Q=256.
rst_n low. After reset
releases, read register 3 and expect 0xA2.CTRL=0; program FWORD (addr 1..2), WIN_SHIFT (addr 4), and CFG (addr 5).CTRL=5 to clear phase and enable excitation. Allow external analog settling.CTRL=3 to start integration with excitation running (or CTRL=7 from idle).uo[4] (or poll CTRL bit2). Perform a 6-byte burst SPI read starting at
address 8 and sign-decode two 24-bit signed integers (I, Q).9.875 × sample_count when all 32 bins
are equally represented.Provide charge amplification, a synchronous 1-bit amplitude-sensitive ADC/modulator,
excitation drive (plus a passive RC reconstruction filter if using dac_en=1),
electrode selection, bias/reference/guard, protection and absolute calibration
externally. Connect uo[1] to the external excitation driver or reconstruction
filter. The SKY130 tile core runs at 1.8 V and the standard Tiny Tapeout demo
board uses 3.3 V GPIO. Match the external digital interface to the board's I/O
supply. Tiny Tapeout GPIO specifications
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | SPI SCK | SPI MISO | |
| 1 | SPI CSN | Excitation (DS sine or square) | |
| 2 | SPI MOSI | Q ref (+90 deg) | |
| 3 | ADC data (sync 1-bit) | Capture window | |
| 4 | Result ready | ||
| 5 | ADC clock | ||
| 6 | |||
| 7 |