937-3 MCPU8 DAC: 8-bit CPU with a sigma-delta DAC

937-3 : MCPU8 DAC: 8-bit CPU with a sigma-delta DAC

Design render

How it works

MCPU8 DAC is a complete 8-bit CPU with a digital-to-analog converter (DAC) in a micro tile. The CPU is MCPU, the minimal CPU Tim Böscke designed to fit a 32-macrocell CPLD: four instructions, an 8-bit accumulator with a carry flag, a 6-bit program counter, and a 64-byte memory that holds both the program and its data. The CPU is on the chip. The memory is outside it, in whatever drives the pins: on the Tiny Tapeout demo board that is the board's microcontroller (an RP2350B on the current ETR demo board, v3, for TT09 and later shuttles; the boards of TT04 to TT08 had an RP2040), which keeps the 64 bytes in an array.

The DAC is a first-order sigma-delta modulator with its own output pin, uo[7]. A program sets its 8-bit value by storing to address 63. With a resistor and a capacitor on uo[7], the CPU drives an analog voltage.

Block diagram

Block diagram. Left: the demo board, which only serves the memory and drives the clock and reset. Middle: the CPU (decode, phase state machine, program counter, address register, ALU, accumulator and carry) and the output mux that puts the address, the accumulator or acc[7] on uo[6:0]. Right: the sigma-delta DAC, loaded by a store to address 63, on uo[7].

Instructions. Each instruction is one byte: the top two bits are the opcode, the low six bits a memory address a.

Byte Instruction Effect
00aaaaaa NOR a acc = NOT (acc OR mem[a])
01aaaaaa ADD a acc = acc + mem[a]; carry = the carry out of bit 7
10aaaaaa STA a mem[a] = acc; for a = 63 the DAC's value is also set to acc
11aaaaaa JCC a if carry is 0, jump to a; otherwise clear carry and go on

The other operations come from short sequences. With the constants 0x00, 0xFF and 0x01 kept in memory: NOR allones clears the accumulator, NOR zero inverts it, NOR allones; ADD x loads x, NOR zero; ADD one negates, and JCC right after a JCC that was not taken always jumps.

The DAC. On every clock the tile adds the DAC value to an 8-bit sum, and uo[7] is the carry out of that addition: {uo[7], sum} = sum + value. Any 256 consecutive clocks hold exactly value ones on uo[7], spread as evenly as the bits allow; at 128 the pin alternates on every clock. The DAC runs on every clock whatever the CPU is doing, and reset sets its value to 0. A store to 63 still goes to memory too, so the host's mem[63] always holds the DAC's value.

The bus. uo[7] is the DAC output in every phase; the bus uses uo[6:0]. A CPU step is two clock cycles, an address phase and a data phase, plus a third, the store phase, when the step stores. All outputs come from flip-flops: uo_out is selected by registers, never by the clock.

Phase uo[6:0] What the host does
Address (first after reset) {WR, A[5:0]} puts mem[A] on ui_in before the next rising clock edge
Data acc[6:0] reads them
Store (only when WR was 1) acc[7] on uo[0], uo[6:1] = 0 stores mem[A] = acc

WR is 1 only in the address phase of a store (STA), where A is the store's target. The carry flag is not on a pin. After reset the CPU is in an address phase with A = 0, and the accumulator, the carry and the DAC are 0.

The three timing diagrams below show each kind of step clock by clock. They follow src/project.v; the waveforms further down show the same sequences from simulation.

Bus timing of NOR and ADD

Bus timing of STA

Bus timing of JCC

Bus timing of each kind of step. The CPU changes its outputs at the rising clock edge; the host has the rest of the clock to read them and, in an address phase, to put mem[A] on ui_in. The CPU takes ui_in at the edge that ends the data phase.

Steps per instruction. NOR, ADD and STA take 2 steps: the fetch, then the operand. JCC takes 1 step when taken and 2 when not taken (the second shows the jump target on the bus and stores nothing). A step that stores takes 3 clocks, every other step 2.

Loading a program. The program is whatever the host holds in its 64 bytes. To load one, write the bytes into the host's array and pulse rst_n; the CPU starts at address 0. A program can also be changed while it runs, and the host sees every store, so any address it watches works as an output port and any byte it updates works as an input port.

Waveforms from simulation

These are drawn from the VCD files of the cocotb tests (test/test.py), by docs/figures/waves.py. The first three tests clock the tile at 10 MHz; the melody slice is from test_host_melody_short, where host/mcpu8dac_host.py paces the clock at 400 kHz. In the windows shown, uo_out sampled once a clock is the same in the RTL and the gate-level run (37 clocks after reset, 200 clocks of the ramp), and the 26 DAC loads of the melody have the same values, at times 1.0 ns apart at most (the netlist's gate delays).

Reset and the first steps, RTL

Reset and the first steps, gate level

The first steps after reset, RTL above and REDA's gate-level netlist below. The program is NOR 3E, ADD 20, STA 3F, JCC 04 with mem[0x20] = 0x80. phase is A (address), D (data) or S (store). After ADD 20 the accumulator is 0x80; STA 3F shows WR and A = 3F (uo 0x7F) in its address phase and acc[7] = 1 on uo[0] in its store phase, and the DAC takes 0x80 at the end of the store phase. Two clocks later uo[7] starts to alternate, as it does for a value of 128.

The DAC output

Top: at a value of 128 the DAC output alternates on every clock. Bottom: the ramp program of test 4 stores 0x20, 0x40, ... 0xE0 to address 63, one store every 24 clocks; the count of ones under each step is value / 256 of its clocks (3 of 24 at 0x20, 21 of 24 at 0xE0). Gate-level run.

A slice of the melody

Notes 2 and 3 (D3, then C3) of the short melody, two half periods a note, as the host program plays it at 400 kHz in the gate-level run. A high half period of D3 lasts 3.410 ms (1,364 clocks, the D3 row of the pitch table below); the low half period and the gap after it last 11.263 ms together; C3's half period lasts 3.815 ms (1,526 clocks). The host paces the clock at exactly 400 kHz on average, so these are the table's clocks x 2.5 us. At 0xFF the output is low for one clock in 256, which the filter (bottom, the 1 kOhm / 22 nF of the listening circuit) barely shows.

REDA's own simulation and timing

These three pictures come from runs in REDA, the tool that made this layout, with the same REDA build that hardened the submitted GDS. Hardened again for these runs, it gave the same GDS byte for byte. The layout itself is under Figures, as REDA drew it.

REDA's digital simulation: reset and STA 63

Simulation, in REDA: the Digital · logic run of the MCPU8 DAC project (Icarus Verilog inside REDA, the RTL, a 10 MHz clock), in REDA's waveform view. The bench docs/figures/tb_sta63.v plays the demo board: reset, then it serves NOR 3E, ADD 20, STA 3F, JCC 04 with mem[0x20] = 0x80, and the run ends with RESULT PASS. Bus values are decimal: ui_in 62, 255, 96, 128, 191 are 0x3E, 0xFF, 0x60, 0x80, 0xBF. In the store step wr is high with adreg = 63, hi marks the store phase, dac takes 128 at its end, and pdm (uo[7]) alternates from two clocks later. REDA's view also lists the DAC's sum register, drawn as a 5-bit bus; that row is left out here.

REDA's static timing: the worst paths at ss

Static timing, in REDA: REDA's timing engine (reda-time) on the routed design, with extracted parasitics and crosstalk, the sky130_fd_sc_hd ss_100C_1v60 cells (REDA's Timing step reads the tt cells; for this run, as for the corner table, the engine was given the ss Liberty), a 10 ns clock and the inputs changing 2 ns after the edge: the case of the worst setup slack in the Results table. The worst setup path runs from ui_in[0] through the ADD's carry chain to accumulator[7] (flop g13), 11 cells, with a slack of +4.278 ns. The worst hold path is the DAC's output flop (g42) to uo_out[7], +0.531 ns. REDA states the result as one line and draws no path, so docs/figures/sta_path.py draws it from the engine's own report, docs/figures/reda-sta-ss-report.json.

REDA's mixed-signal view: uo[7] through the filter

Simulation, in REDA: two runs joined at uo[7]. REDA's Digital · logic run of the ramp program of test 4 (docs/figures/tb_ramp.v, the RTL, a 400 kHz clock) printed every change of uo[7]. Its 97 edges became a 0 V / 3.3 V piecewise-linear source (docs/figures/uo7-pwl.txt) in a REDA schematic with the listening filter, 1 kOhm and 22 nF to ground. ngspice 45, which REDA runs in the browser, then ran a 600 us transient. Green: uo[7]; yellow: the filter output. Over the second half of each step the output averages 0.851 V at 0x40, 1.650 V at 0x80 and 2.485 V at 0xC0, against 3.3 V x value / 256 = 0.825, 1.650 and 2.475 V. After 0xE0 the program wraps the DAC to 0, and the output decays with the filter's 22 us time constant. 3.3 V stands for the demo board's output high level; the pad's real level and edge rate are not modelled.

How to test

On the Tiny Tapeout demo board, with the demo board's MicroPython SDK, the board's microcontroller is the memory and the clock. Select the project and stop the automatic clock. This loop runs the CPU:

def run(mem, steps):
    for _ in range(steps):
        v = int(tt.uo_out.value)          # address phase: {DAC, WR, A}
        a, wr = v & 0x3F, v & 0x40
        tt.ui_in.value = mem[a]
        tt.clock_project_once()
        acc = int(tt.uo_out.value) & 0x7F # data phase: acc[6:0]
        tt.clock_project_once()
        if wr:
            acc |= (int(tt.uo_out.value) & 1) << 7   # store phase: acc[7]
            mem[a] = acc
            tt.clock_project_once()

def reset():
    tt.clock_project_stop()
    tt.reset_project(True)
    for _ in range(3):
        tt.clock_project_once()
    tt.reset_project(False)

The DAC, with a meter

This program loads the byte at 0x20 into the DAC and stops in a loop at address 4:

mem = [0] * 64
mem[:5] = [0x3E, 0x60, 0xBF, 0xC4, 0xC4]   # NOR allones; ADD 0x20; STA 63; JCC 4; JCC 4
mem[0x20] = 128                            # the DAC value
mem[0x3D], mem[0x3E], mem[0x3F] = 0x00, 0xFF, 0x01
reset()
run(mem, 10)
print(mem[63])                             # 128: the DAC's value

tt.ui_in.value = 0xC4                      # JCC 4, whatever address the CPU shows
tt.clock_project_PWM(10_000_000)           # now the DAC runs at 10 MHz

Once the program has stopped, the CPU only fetches JCC 4 at address 4 and jumps there again; holding ui_in at 0xC4 serves it at full speed, so the clock can run free. Connect a 10 kOhm resistor from uo[7] to a 100 nF capacitor to ground and measure the capacitor voltage with a high-impedance meter (10 MOhm or more). It settles within a few milliseconds (the time constant is 1 ms) at about V_OH x value / 256, where V_OH is the pin's output high level, 3.3 V on the demo board:

Value at 0x20 Expected voltage (V_OH = 3.3 V)
0 0 V
16 0.206 V
64 0.825 V
128 1.650 V
192 2.475 V
255 3.287 V

The steps between values are 12.9 mV. Measure V_OH itself with 255 and scale by it, since the pin's high level under the meter's load is not exactly 3.3 V. To try another value, stop the clock, reset(), change mem[0x20] and run again.

The DAC, without a meter

After run(mem, 10) above, count the ones on uo[7] over 256 clocks; the count equals the value:

ones = 0
for _ in range(128):                       # 128 steps of JCC 4, two clocks each
    for _ in range(2):
        tt.ui_in.value = 0xC4
        tt.clock_project_once()
        ones += int(tt.uo_out.value) >> 7
print(ones)                                # 128

A melody

The CPU can play the first line of "Mary Had a Little Lamb" (E D C D E E E, D D D, E G G) on the DAC. Program and song fill the 64 bytes exactly:

00: 64 BE 1F 65 A2 5F DE 1F 40 61 80 60 83 1F 3F BF
10: 1F 7E 60 D2 62 60 A2 CD BF 60 D9 60 DB C0 DE FF
20: 01 02 00 00 3C 9D 23 A8 08 B2 23 A8 3C 9D 3C 9D
30: 3C 3A 23 A8 23 A8 23 50 3C 9D 5C 8A 5C 15 00 00
Address Contents
0x00-0x1E the program
0x1F-0x21 the constants 0xFF, 0x01, 0x02
0x22 the half-period counter
0x24-0x3D the song, two bytes a note: 256 minus the delay passes per half period, 256 minus the number of half periods
0x3E the delay of the note playing
0x3F the DAC

How it plays

The whole tune is worked out by the CPU on this chip: which note comes next, its pitch, how long it lasts and the pause after it. Nothing about the music is computed anywhere else. The demo board's microcontroller only acts as the CPU's 64-byte memory: each clock it reads the address on the CPU's pins and answers with the byte stored there, and when the CPU stores a byte, it writes that byte into its array. It runs the same loop for the melody as for GCD or Fibonacci.

The 64 bytes hold the program (31 bytes), three constants, two counters, the DAC byte and the song: 13 notes of two bytes each. Step by step, the CPU:

  1. Reads the next note. The instructions at 0x00 and 0x03 are ADD with the song's address in their address field. After each note the program adds 2 to those two instruction bytes, so they point at the next note. The program rewrites its own instructions; MCPU has no other way to index memory.
  2. Sets the pitch. A note's first byte is 256 minus k, a delay count. Each half period the CPU flips the DAC between 0 and 255 by storing NOT (the DAC byte) to address 63, then counts from 256 - k up to 256 in a two-instruction loop. A half period lasts 6k + 38 clocks: for E3, k = 196 gives 1,214 clocks, which at a 400 kHz clock is 164.74 Hz against 164.81 Hz.
  3. Sets the length. A note's second byte is 256 minus the number of half periods. The CPU counts it up to 256, one count a half period: 99 half periods make a quarter note of E3, 0.3 s.
  4. Leaves a gap. It stores 0 to the DAC and runs two more loops of 256 passes. The DAC stays 0 for about 7.9 ms (3,147 clocks at 400 kHz), so repeated notes are heard as separate notes.
  5. Stops. After the last note the two ADDs point at 0x3E and 0x3F, the delay byte and the DAC byte. The DAC byte is 0 after the gap, and a length of 0 ends the song: the CPU jumps to 0x1E and stays there.

The sound is a square wave: at a DAC value of 0 the pin is low, and at 255 it is high but for one clock in 256. The program, address by address:

00  ADD song      acc = 256 - k (the address field is the song pointer)
01  STA hv
02  NOR allones
03  ADD song+1    acc = 256 - n
04  STA nv
05  ADD allones   carry = (n' != 0)
06  JCC 1E        end of the song
07  NOR allones
08  ADD 00
09  ADD two
0A  STA 00        the next note's first byte
0B  ADD one
0C  STA 03        and its second
0D  NOR allones   half period: acc = 0
0E  NOR 3F        acc = NOT dac
0F  STA 3F        dac = 0 or 255
10  NOR allones
11  ADD hv
12  ADD one       delay: count up to 256
13  JCC 12
14  ADD nv        (acc is 0 here)
15  ADD one
16  STA nv
17  JCC 0D        more half periods
18  STA 3F        dac = 0 (acc is 0): the gap
19  ADD one       256 passes
1A  JCC 19
1B  ADD one       and 256 more
1C  JCC 1B
1D  JCC 00        next note
1E  JCC 1E        the end
Note Pitch at a 400 kHz clock Half period Half periods (quarter / half note)
C3 (130.81 Hz) 131.06 Hz, +3.3 cents 1,526 clocks 78
D3 (146.83 Hz) 146.63 Hz, -2.4 cents 1,364 clocks 88 / 176
E3 (164.81 Hz) 164.74 Hz, -0.7 cents 1,214 clocks 99 / 198
G3 (196.00 Hz) 195.69 Hz, -2.7 cents 1,022 clocks 118 / 235

The clock. At a 400 kHz clock a quarter note lasts 0.3 s and the line lasts 4.9 s (1,961,965 clocks). Pitch and tempo both scale with the clock: at 200 kHz the same bytes play an octave lower and half as fast. The MicroPython loop above manages a few thousand steps a second, so it is far too slow for sound. The memory has to be served by a program that keeps up with a 400 kHz clock, about 160,000 steps a second: the fast host below.

The fast host

host/mcpu8dac_host.py serves the memory at a 400 kHz tile clock on the current demo board (TTDB v3, with an RP2350B). It has not been run on a board. It has been run in simulation against the RTL and the gate-level netlist, and its machine code has been counted against the clock period, as described below.

It is MicroPython. Its loop, serve(), is a viper function, which MicroPython compiles to machine code. The loop reads and writes the RP2350's GPIO registers directly: uo_out is GPIO 33 to 40, ui_in GPIO 17 to 24 and the project clock GPIO 16 (from tt-micropython-firmware's gpio_map_dbv3.py). Each tile clock goes like this:

  1. Wait for the clock's deadline on the RP2350's microsecond timer, then raise the clock. The deadlines are kept in quarter microseconds, 10 apart at 400 kHz. The timer counts whole microseconds, so edges come 2 or 3 us apart and average 2.5 us.
  2. Lower the clock, read uo_out and do the phase's work: in an address phase, put mem[A] on ui_in; in a store phase, write the accumulator into mem[A].
  3. Stop when the CPU shows the same address in two address phases in a row: that is the halt loop, 0x1E for the melody.

An edge that comes late, for example because of an interrupt, does not move the later deadlines, so the next clocks come sooner until the loop is on time again and pitch and tempo stay right on average. play() reports the latest edge. To play the melody, copy the file to the board (for example mpremote cp host/mcpu8dac_host.py :) and, at the board's REPL:

import mcpu8dac_host as h
# select the project first, as for any other project
song = [0x64, 0xBE, 0x1F, 0x65, 0xA2, 0x5F, 0xDE, 0x1F,
        0x40, 0x61, 0x80, 0x60, 0x83, 0x1F, 0x3F, 0xBF,
        0x1F, 0x7E, 0x60, 0xD2, 0x62, 0x60, 0xA2, 0xCD,
        0xBF, 0x60, 0xD9, 0x60, 0xDB, 0xC0, 0xDE, 0xFF,
        0x01, 0x02, 0x00, 0x00, 0x3C, 0x9D, 0x23, 0xA8,
        0x08, 0xB2, 0x23, 0xA8, 0x3C, 0x9D, 0x3C, 0x9D,
        0x3C, 0x3A, 0x23, 0xA8, 0x23, 0xA8, 0x23, 0x50,
        0x3C, 0x9D, 0x5C, 0x8A, 0x5C, 0x15, 0x00, 0x00]
mem, clocks, late_us = h.play(song)  # resets the tile, plays 4.9 s
print(clocks, late_us)  # clocks run; latest edge in us

The cycle budget. One tile clock at 400 kHz is 375 cycles of the RP2350 at its default 150 MHz. host/budget/ holds the Thumb-2 code of serve() as mpy-cross -march=armv7emsp (MicroPython 1.29.0) compiles it, disassembled with capstone, and budget.py, which counts each path through one clock. The bound charges 2 cycles for every instruction, 2 more for each taken branch and 10 more for the timer read. It is an upper bound from the instruction count, not a measurement.

Path through one tile clock Instructions Cycles, at most Of 375 at 150 MHz
Address phase (the longest) 124 268 71 %
Store phase 109 238 63 %
Data phase 103 228 61 %

The clock stays high for 19 instructions, at least 127 ns at 150 MHz, and uo_out is read after that. If the firmware runs the RP2350 at another speed, the budget scales with it: at 125 MHz one clock is 312 cycles, still above 268.

In simulation. test/test.py runs host/mcpu8dac_host.py unchanged under CPython against the tile. It swaps in a model of the four RP2350 registers serve() uses (GPIO input, GPIO set, GPIO clear and the timer), wired to the tile's pins as on the board. Each register access takes 40 ns of simulated time, and the timer counts simulated microseconds. So these tests check the program's bus protocol and its pacing; speed on the real chip is the budget above.

Test RTL Gate level
test_host_gcd: GCD(48, 18) and GCD(126, 124), 171 and 2,081 clocks pass pass
test_host_melody_short: the melody with two half periods a note, 73,783 clocks pass pass
test_host_melody_full (MELODY=full): the whole melody, 1,961,965 clocks, 4.905 s of simulated time pass not run

In each melody run, uo[7] equals the clock-exact model of the program on every clock, and the memory after the run equals the model's. Each interval between DAC loads lasts its clocks x 2.5 us of simulated time, to within 1 us. Every rising edge comes after its deadline by less than 1 us plus one 40 ns register access, the mean clock period is 2,500.0 ns, and the latest edge play() reports is 0.5 us.

The host as RP2350 firmware

host/uf2/mcpu8dac-host.uf2 does the same job as firmware for the board's RP2350B, without MicroPython. It selects the project on the chip's mux the way the board's MicroPython does, resets the tile, and serves the memory at a 400 kHz tile clock that SysTick paces to the cycle (375 cycles of 150 MHz). The source is host/uf2/src/main.rs. It has not been run on a board.

It has run on REDA's RP2350 twin, configured as an RP2350B, with the twin's pins coupled to the tile in Icarus. There were two runs, one with the RTL and one with the gate-level netlist (host/twin/), and the results were the same in both:

  • The whole melody played: 1,961,965 tile clocks, with uo[7] equal to the clock-exact model on every clock.
  • The mean clock period was 375.000 cycles (400.000 kHz); single periods ranged from 372 to 381 cycles.
  • The pitches read from uo[7] were E3 D3 C3 D3 E3 E3 E3 D3 D3 D3 E3 G3 G3, each within 3.4 cents.

Flashing it replaces the board's MicroPython firmware; to go back, flash the Tiny Tapeout MicroPython UF2 again. The steps (host/uf2/README.md has the details):

  1. Put the project's mux address into the UF2. Tiny Tapeout publishes it in the shuttle's project index:

    curl -o ttsky26e.json "https://index.tinytapeout.com/ttsky26e.json?fields=address,subtile_addr,subtile_addr_bits"
    python3 host/uf2/configure.py host/uf2/mcpu8dac-host.uf2 mcpu8dac-host-ttsky26e.uf2 --index ttsky26e.json
    
  2. Set all ui_in DIP switches off and wire the listening circuit below to uo[7].

  3. Hold the RP2350's BOOTSEL button while plugging in USB, then copy mcpu8dac-host-ttsky26e.uf2 to the RP2350 drive.

  4. The LED is on while the melody plays, and it plays again after a second. If the LED blinks fast, the UF2 was not configured.

Listening. Put a 1 kOhm resistor from uo[7] to a 22 nF capacitor to ground (a 7.2 kHz low-pass), then a 10 uF capacitor in series from that node to the input of a small amplifier or powered speaker. Headphones straight on that node through the 10 uF capacitor should be quiet but audible, and a piezo buzzer from uo[7] to ground should also play it. None of this has been tried on hardware yet.

What was checked, in simulation. cocotb runs the whole song on the RTL and on REDA's gate-level netlist. Every DAC load matches a clock-exact model of the program, and uo[7] is compared with the DAC's register model on every clock. test/melody_wav.py turns the recorded uo[7] stream (1,961,965 clocks) into what the 1 kOhm / 22 nF filter gives, writes docs/audio/melody.wav at 48 kHz, and finds each note's pitch with an FFT. The notes read E3 D3 C3 D3 E3 E3 E3 D3 D3 D3 E3 G3 G3, each within 4 cents.

Spectrogram of the melody

Spectrogram of the filtered uo[7] stream of the gate-level run at a 400 kHz clock: the 13 notes, their fundamentals and odd harmonics, and the gaps between them.

The CPU

GCD of 48 and 18 with the MCPU instructions only; a at 0x20, b at 0x21, the result ends in b:

mem = [0] * 64
mem[:14] = [0x3E, 0x21, 0x7F, 0x60, 0xC9, 0xA0, 0x7E, 0xCD, 0xC0, 0x3D, 0x7F, 0xA1, 0xC0, 0xCD]
mem[0x20], mem[0x21] = 48, 18
mem[0x3D], mem[0x3E], mem[0x3F] = 0x00, 0xFF, 0x01
reset()
run(mem, 2000)
print(mem[0x21])                           # 6

The program ends in a loop at address 13. GCD(48, 18) takes 84 steps and GCD(126, 124) 1,010, as on MCPU8. In MicroPython the loop should manage a few thousand steps per second (an estimate, not measured).

Tests to try, all checked in the cocotb tests on both the RTL and the gate-level netlist. In every test the DAC output is compared on every clock with a model of the DAC's registers.

  1. Reset. Hold rst_n low for three clocks and release it: uo_out reads 0x00 (DAC 0, WR 0, address 0). One clock later it reads 0x00.
  2. DAC value. The DAC program above with 0, 1, 64, 128, 200, 255 and 0x5A: mem[63] ends as the value, and two consecutive windows of 256 clocks each hold exactly that many ones on uo[7].
  3. DAC at 128. The output alternates on every clock.
  4. Ramp. A program adds 0x20 to a byte and stores it to 63 until it wraps: the DAC takes 0x20, 0x40, ..., 0xE0, then 0x00.
  5. Reset clears the DAC. Load 200, reset: uo[7] stays 0 for 300 clocks.
  6. GCD for (126, 124), (48, 18), (200, 75), (13, 7) and (255, 85): b ends as 2, 6, 25, 1 and 85, a ends as 0.
  7. Fibonacci. 3E 60 B0 61 C6 C5 A2 3E 61 A0 3E 62 A1 C0 with mem[0x20] = 0, mem[0x21] = 1 and the constants: the stores to 0x30 are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, then the program stops at address 5.
  8. Program load. Run part of GCD, write the Fibonacci program into the same array, pulse rst_n: the Fibonacci sequence comes out.
  9. Each instruction alone: NOR, ADD with and without carry, STA with WR on the pins and acc[7] in the store phase, JCC taken and not taken.
  10. Melody. The melody program above with two half periods a note: every DAC load at the clock the model gives. The whole song runs with MELODY=full (see above).
  11. The fast host, GCD. host/mcpu8dac_host.py serves GCD(48, 18) and GCD(126, 124) at a paced 400 kHz clock: the results are 6 and 2, and it stops on the halt loop.
  12. The fast host, melody. The same program plays the short melody: uo[7] equals the model on every clock, and each half period lasts its clocks x 2.5 us of simulated time.

External hardware

The demo board's microcontroller serves the memory. For the DAC, a 10 kOhm resistor and a 100 nF capacitor on uo[7], and a meter. For the melody, a 1 kOhm resistor, a 22 nF and a 10 uF capacitor, and an amplifier, powered speaker or headphones; or a piezo buzzer.

Results

Designed with REDA on Robutler (https://robutler.ai): synthesis, floorplan, power grid, placement, clock tree, routing, extraction, timing, DRC and LVS are REDA's own (sky130A, sky130_fd_sc_hd cells), and the GDS is submitted as it came out of REDA. Tiny Tapeout's precheck is Tiny Tapeout's own.

Check Result
cocotb tests, RTL 11 of 11 pass: reset state, GCD of five pairs, program load (GCD, then Fibonacci after a reload and reset), each instruction alone, DAC ones per 256 clocks for seven values, DAC alternation at 128, a ramp program, reset clearing the DAC, the melody program (2 half periods a note); the DAC output checked against a register model on every clock of these 9; and the fast host program serving GCD and the short melody at a paced 400 kHz clock. 2 more run only with MELODY=full
cocotb tests, gate-level netlist of REDA's layout 11 of 11 pass, the same tests (2 more with MELODY=full)
The whole melody (MELODY=full, test_melody_full), RTL and gate level pass on both: 1,961,965 clocks, every DAC load as the model gives, the same uo[7] stream from RTL and gate level; pitches E3 D3 C3 D3 E3 E3 E3 D3 D3 D3 E3 G3 G3, each within 4 cents
cocotb tests, gate level with REDA's SDF delays at ss, tt and ff the first 9 pass at each corner (the two fast-host tests and the whole melody are not run with SDF)
RP2350 firmware (host/uf2) on REDA's RP2350 twin, coupled to the tile in Icarus the whole melody on the RTL and on the gate-level netlist: 1,961,965 clocks, uo[7] equal to the model on every clock, mean clock period 375.000 cycles of 150 MHz; not run on a board
Tiny Tapeout precheck (tt-support-tools 21568ef7, local run) pass, 17 checks, 0 failures, 0 errors (Magic DRC among them)
DRC (REDA) clean, 436 of 436 rule records evaluated
LVS (REDA) match, certified, 2,496 devices
Routing 329 of 329 nets, antenna clean
Timing (REDA), 10 ns clock, ss, tt and ff corners, extracted parasitics with crosstalk met at all three: worst setup +4.278 ns (ss, inputs 2 ns late), worst hold +0.096 ns (ff)

Timing was run with REDA's timing engine on the routed netlist and its extracted parasitics with crosstalk, at three corners of the sky130_fd_sc_hd cells, once with the inputs changing at the clock edge and once with them changing 2 ns after it. One extraction (the kit's nominal wire resistance and capacitance) serves all three corners; the corner sets the cells' process, supply and temperature. Setup and hold are met at every corner at 10 ns, without a hold-repair step.

Corner Setup slack Hold slack Setup, inputs 2 ns late Hold, inputs 2 ns late
ss, 100 C, 1.60 V +5.217 ns +0.313 ns +4.278 ns +0.531 ns
tt, 25 C, 1.80 V +7.642 ns +0.151 ns +6.195 ns +0.269 ns
ff, -40 C, 1.95 V +8.509 ns +0.096 ns +6.865 ns +0.169 ns

The gate-level tests were also run with the timed cell models and an SDF that REDA wrote for each corner (cell delays, setup and hold checks, and the wire delays from the extraction, without crosstalk). Icarus applied all of it except the wire delays between the pins and the first or last cell (0.9 ps at most) and the edge-specific delay arcs of the 14 xor2 and xnor2 cells, which the cell models declare without an edge.

The host gives the inputs a whole clock cycle: ui_in is set in the address phase and read at the end of the data phase.

Area Value
Die (micro tile) 70.38 x 51.68 um (3,637 um2), core 64.86 x 46.24 um (2,999 um2), 17 rows
Standard cells 302 after synthesis (2,177 um2); 520 placed instances with taps, decaps and fill; logic, flops and clock buffers 2,382 um2, 79.4 % of the core
Flip-flops 43: the CPU's 26 (8 accumulator, 1 carry, 6 program counter, 6 address, 3 state, 1 phase, 1 store phase) and the DAC's 17 (8 value, 8 sum, 1 output)
Power grid met2 VPWR and VGND pairs at each end of the core, four met3 stripes as the power pins

Figures

MCPU8 DAC layout

Layout of the micro tile (70.38 x 51.68 um) as REDA made it, in REDA's layout view.

IO

#InputOutputBidirectional
0D0: memory data in (mem[A] in the address phase)A0 (address phase) / ACC0 (data phase) / ACC7 (store phase)
1D1: memory data in (mem[A] in the address phase)A1 (address phase) / ACC1 (data phase)
2D2: memory data in (mem[A] in the address phase)A2 (address phase) / ACC2 (data phase)
3D3: memory data in (mem[A] in the address phase)A3 (address phase) / ACC3 (data phase)
4D4: memory data in (mem[A] in the address phase)A4 (address phase) / ACC4 (data phase)
5D5: memory data in (mem[A] in the address phase)A5 (address phase) / ACC5 (data phase)
6D6: memory data in (mem[A] in the address phase)WR: store to A (address phase) / ACC6 (data phase)
7D7: memory data in (mem[A] in the address phase)DAC: pulse-density output (every phase)

Chip location

Controller Mux Mux Mux Mux Mux Mux Mux Mux Analog Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Analog Mux Mux Mux Mux Analog Mux Mux Mux Mux Mux Mux tt_um_chip_rom (Chip ROM) tt_um_factory_test (Tiny Tapeout Factory Test) tt_um_barakhoffer_chargepump27 (5V Cross-Coupled Charge Pump) tt_um_marzmmp_adama_plasticity (ADAMA-1 Plasticity Core) tt_um_asic1b_dsp (ASIC-1B Open-Source DSP Integration — Qualification Only) tt_um_ew_iqmag (ASIC-1A Signed IQ Magnitude-Squared Accelerator) tt_um_serialdev_sloth_stream (Sloth one Qwen neuron and three slices) tt_um_LnL_ringosc (Programmable Ring Oscillator) tt_um_aesa_brain (AESA Digital Brain) tt_um_kennanlau_aesa_brain_v2 (AESA Digital Brain) tt_um_jhkong_vco (Current-starved ring VCO + divider (silicon vs. simulation)) tt_um_kennanlau_beam_steer (AESA Beam Steering Engine) tt_um_tiny_breakout (Tiny Breakout) tt_um_jonahss_msac (openav1 msac: the AV1 arithmetic decoder) tt_um_VCOerik1567 (Digitally Band-Switched VCO) tt_um_hft_1 (HFT Challenge 1) tt_um_jambu_fmbearmf (jambu) tt_um_not_so_tiny_sparse_acc_ramzxc (rSPARK) tt_um_sphatika11_minitage (Mini-TAGE Branch Predictor (1x1, single TAGE table)) tt_um_2048 (Hardware-Accelerated-2048-VGA-Game) tt_um_cordic (Cordic Processor) tt_um_EV_Charging_CTRL (EV Charging Controller) tt_um_project_fpu (Parameterized_FPU_Adder_Subtractor) tt_um_dino (Dino-Inspired-VGA-Obstacle-Avoidance-Game) tt_um_systolic_mm (Systolic Array - 4x4 Matrix Multiplier) tt_um_pulse_stretcher (Programmable Digital Pulse Stretcher) tt_um_reyhaha999_skykey (SkyKey) tt_um_bh_gc_memory (Gain-cell eDRAM: 112 x 8 bits, byte writes) tt_um_fc_pong_ai (Pong vs Quantized AI) tt_um_janane2802_mac_unit (MAC Unit) tt_um_sidisnotacoder_shadowstack (Zicfiss-inspired Shadow Stack Monitor) tt_um_izaiah_thigpen_sparse_conv (SJSU Sparsity-Aware Convolution Core) tt_um_tmartins_ro_puf_v8 (RO-PUF V8 - 64 ROs Dual Ripple Counter) tt_um_tiny_breakout_pave (Tiny Breakout (Paved)) tt_um_rakesh_tiny_nfc (tiny_nfc - ISO14443A NFC Type 2 tag (mixed-signal)) tt_um_rakesh_tiny_kws (tiny_kws: PDM-mic keyword spotter with streamed GRU) tt_um_adpll_dco (ADPLL DCO test chip) tt_um_Sumedh350_dot4 (DOT4: A Custom INT8 Dot-Product Instruction for RISC-V Edge-AI) tt_um_eleva_ccro_adc (CCRO differential VCO ADC) tt_um_sidisnotacoder_approx_mult (Approximate vs. Exact 8x8 Multiplier) tt_um_joaopedro_ro_puf_v8 (RO-PUF V8 - 64 ROs Dual Ripple Counter (João Pedro)) tt_um_alu4 (4-bit ALU) tt_um_i3cbridge (Minimal I3C target to I2C bridge) tt_um_nityashah1811_cnn_accel (CNN Conv Accelerator) tt_um_armohamed_r2rvc (SKY130 Voltage Comparator Prototype) tt_um_jamesrosssharp_high_speed_comp (High Speed Comparator YOLO) tt_um_janane2802_divcounter (Glitch-Free Divider + Gated Frequency Counter) tt_um_prasa_droop_monitor (On-Chip Supply-Droop Timing Monitor) tt_um_armohamed_tdc12 (12-bit pulse-width time-to-digital converter) tt_um_zec_square1 ("SQUARE-1": VGA/audio demo) tt_um_yodalee_tinyaes (ttsky_tiny_aes) tt_um_rt5w_attn (RT5W analog attention head (QK^T + softmax, on-die SS-SGD)) tt_um_sensor_monitor (Sensor Covariance Anomaly Detector) tt_um_deeksha5334_timing_margin (On-chip timing-margin sensor) tt_um_wokwi_481584708677923841 (memecycler) tt_um_charlieplex (Single-wire 8x8 Charlieplex LED controller) tt_um_duarte_diamantino_lifi_tx (Reconfigurable LiFi Transmitter (OOK / Manchester / 4-PPM)) tt_um_mnist8 (MNIST 8x8 digit classifier) tt_um_wokwi_481583898817310721 (Tiny Tapeout Template by DSJM) tt_um_wokwi_481590988497887233 (Tiny Tapeout Template Copy) tt_um_duarte_diamantino_pid8 (8-bit Digital PID Controller) tt_um_wokwi_481590657199122433 (Tiny Tapeout Template Copy) tt_um_dinis_aes256 (AES-256 iterative GF S-box) tt_um_wokwi_481588972466141185 (Ines woki design 4) tt_um_wokwi_481591934277017601 (2-bit Magnitude Comparator with 7-Segment Display) tt_um_wokwi_481584895163029505 (Tiny Tapeout ) tt_um_duarte_diamantino_blocos (Blocos: 8x8 falling-block game on VGA) tt_um_wokwi_481849947835978753 (8-bit Arbiter PUF 2) tt_um_wokwi_481590741896846337 (Tiny Tapeout Template Copy) tt_um_wokwi_481774177156248577 (Seven_Seg_Disp_Hello_ISEL_ISEL_display_v5) tt_um_wokwi_481590548148238337 (3bitCycler) tt_um_wokwi_481592066634608641 (Tiny Tapeout - 'my hello world' Copy) tt_um_wokwi_442987575358494721 (Tiny Tapeout Template-Loibingdorfer Copy) tt_um_mbacvanski_analog_eqprop (Analog equilibrium propagation: three neurons, six learnable weights) tt_um_huanprojects_tsense (BJT temperature sensor) tt_um_tillwitt_dac8r (8-bit current-steering DAC with on-chip reference, serial trim/code interface and temperature sensor (revision 2)) tt_um_rudresphotos_sram (SKY130 SRAM 32x8 (OpenRAM, custom StrongARM sense amp)) tt_um_riskgate_ml (RiskGate-ML: Pre-Trade Risk Gateway with On-Chip ML) tt_um_tjfreeborn1_cpe_a07a05 (Fractional-order capacitors with α = 0.7 and 0.5) tt_um_bennett_miller_4_bit_arc_angel_alu (4-Bit ALU Akron Research Company Arc Angel) tt_um_polite_mini (POLITE Mini) tt_um_jlvsdlv_ecg (Sub-uVrms 1-uW GOhm-input ECG amplifier) tt_um_mbotros_diff_amp_lvt (Differential amplifier (LVT NMOS, 1.8 V)) tt_um_wokwi_481590405529284609 (Baby's First Counter) tt_um_icieq (ICIEQ Analog Gate Driver) tt_um_toksaitov_almurut2 (Almurut II) tt_um_nikhil_a_e_conv (Reconfigurable MAC-Based Convolution Engine) tt_um_rayforge_3d (RayForge-X: Analytic VGA Scene Renderer) tt_um_harshilkundety_ro_trng (Ring-Oscillator Jitter TRNG) tt_um_priority_arbiter_8bit (8-Bit Parallel-Prefix Priority Arbiter) tt_um_pranavhegdee_sparse_lif (Sparse Event-Driven LIF Neurons) tt_um_rvce_uart_crc_cmd (CRC-protected UART Command Interface) tt_um_wokwi_481521554867536897 (8-bit Arbiter PUF) tt_um_wokwi_481591140137746433 (Baby's First Counter Final) tt_um_wokwi_481770524049471489 (test) tt_um_wokwi_442977436543634433 (Nico_Design) tt_um_wokwi_481770605701073921 (2bits_MovingAverage) tt_um_dinisoliv_systolic_array (Tiny Systolic Array) tt_um_lrama_spatial_sd (Space-time sigma-delta for a 6-element array) tt_um_wokwi_481771282255144961 (Tiny Tapeout Ripple Adder) tt_um_umigv_sensorfusion (UMARV sensor fusion) tt_um_mcap_rx_uart (M-CAP digital receiver with UART) tt_um_wokwi_481771090722193409 (3 Bit Adder with 2 bit Inputs Copy) tt_um_wokwi_481771306715289601 (HEX to 7SegDisplay) tt_um_wokwi_481771457225837569 (Tiny Tapeout Template (BCD Decoder)) tt_um_wokwi_481772106444550145 (Tiny Tapeout Template DEEPASINGH) tt_um_crypto_otp (Crypto OTP) tt_um_wokwi_481770518345213953 (Tiny Tapeout Template Copy) tt_um_wokwi_480337522217648129 (TBMPPT) tt_um_openblastcore32_tt16 (OpenBlastCore32-TT16b TBLEND) tt_um_sofiainacio_adpll (All-Digital PLL Demonstrator) tt_um_wokwi_481522334865641473 (trng) tt_um_wokwi_481591026011755521 (Davod) tt_um_wokwi_481584898812076033 (Design do Mikas) tt_um_pedrorito_eq (Tiny Graphic EQ) tt_um_wokwi_481436559394914305 (SLIPT Manchester Receiver) tt_um_tmdias_traffic_light_controller (Traffic Light Controller) tt_um_wokwi_481591230948654081 (Tiny Tapeout Template Copy) tt_um_wokwi_481590770568078337 (Tiny Tapeout Template Copy) tt_um_ayush_hegde_uart_tx (8-Bit UART Transmitter (8N1, 9600 baud)) tt_um_pryzm_cordic (PRYZM CORDIC-16) tt_um_flex_mac (Flexible 8-bit Streaming MAC) tt_um_arcadia1_vco_adc (2nd-order VCO Delta-Sigma ADC) tt_um_dsx99_ro_puf (RO-PUF readout chip) tt_um_fcapz_ela_tile (fcapz_ela_tile) tt_um_1marcb_jamguard (JAMGUARD DSSS Anti-Jam Link) tt_um_sclw_dual_lfsr (Dual Cross-Coupled LFSR) tt_um_srcejon_adc_dac (8-bit ADC and DAC) tt_um_nityashah1811_snn_mnist (SNN MNIST Digit Classifier) tt_um_tmartins_ro_trng_12x8 (12x8 Ring Oscillator TRNG - Raw Bit Sampler) tt_um_im2col_tm (Bunny-CNN-Accelerator) tt_um_async_fifo (Async FIFO with Gray Code CDC (2-Flop Synchronizer)) tt_um_tmr_secded_alu (Fault-Tolerant TMR + SECDED ALU) tt_um_phaneeswar2006_prog (Dead-Time PWM Controller) tt_um_rvce_secded_ecc (SEC-DED Hamming ECC Encoder/Decoder) tt_um_cokane_soc (CoKANE NPU) Micro tile container tt_um_microtile_group_1 tt_um_alfadelta10010_pocketchords (PocketChords: SNES chord arpeggiator), micro tile slot 132/0 tt_um_xy_spirograph (XY Spirograph), micro tile slot 132/1 tt_um_leowang_micro_apu (MicroAPU), micro tile slot 132/2 tt_um_mc14500b_micro (MC14500B 1-bit Microcontroller (micro tile)), micro tile slot 132/3 tt_um_rvce_cordic (CORDIC Sine/Cosine Generator) tt_um_robutler_dbg (REDA debug tile) tt_um_quevedol_serv_tinyml (SERV TinyML SoC) tt_um_psidethename_vltpe (VL-TPE: Variable-Latency Telescopic Priority Encoder) tt_um_rohan_j_r_adaptive_adder (Data-Aware Adaptive Approximate 16-bit Adder) tt_um_sa3x3_int8int4 (SPI Precision-Scalable INT8/INT4 3x3 Systolic Array) tt_um_radmac (RadMAC) tt_um_joeycastillo_lcd (4x12 segment LCD driver) Micro tile container tt_um_microtile_group_2 tt_um_MaligayangPasko (Maligayang Pasko! (Christmas tree in a micro tile)), micro tile slot 198/0 tt_um_wokwi_481740336442682369 (Quiz Bee Buzzer Switch), micro tile slot 198/1 tt_um_pettit_micro (Micro Munch (VGA demo in a micro tile)), micro tile slot 198/2 tt_um_pettit_adpcm (Micro ADPCM (streaming audio decoder in a micro tile)), micro tile slot 198/3 Micro tile container tt_um_microtile_group_3 tt_um_wokwi_481767137105960961 (tt_um_pettit_microsnake), micro tile slot 200/0 tt_um_pettit_microcpu (MicroCPU (a bit-serial 4-bit CPU in a micro tile)), micro tile slot 200/1 tt_um_pranav0x2212_tiny_piano (Tiny Piano), micro tile slot 200/2 tt_um_micro_pio (microPIO), micro tile slot 200/3 tt_um_rishabhrkaushik_fractal_generator_gamepad_SPI (Fractal Generator with Gamepad and SPI) tt_um_howardlee_tinyscope32 (TinyScope-32) tt_um_space_brain (Space Brain) tt_um_vinay_mem_access (Self-testing atomic banked memory) tt_um_configurable_pwm (Configurable Multi-Mode PWM Generator) tt_um_htfab_presenter (VGA Presenter) tt_um_rvce_2ff_sync (2-FF Synchronizer / Clock-Domain-Crossing Demo) tt_um_vaishnavipatil5_configurable_multiplier_mac (Customizable Exact and Approximate Multiplier with MAC) Micro tile container tt_um_microtile_group_4 tt_um_astrok_micro_chiptune (Micro Chiptune), micro tile slot 937/0 tt_um_wokwi_481793265415286785 (tt_um_pettit_micropwm), micro tile slot 937/1 tt_um_urish_micro_simon (micro Simon Says memory game), micro tile slot 937/2 tt_um_robutler_mcpu8dac (MCPU8 DAC: 8-bit CPU with a sigma-delta DAC), micro tile slot 937/3 tt_um_yangzhou08_tetris (Tetris player (on-chip placement search, board features and neural network)) tt_um_yangzhou08_mnist (MNIST digit classifier (binary/ternary CNN, all weights in logic)) tt_um_yangzhou08_pusht (Push-T visuomotor policy (image moments + hardwired MLP)) tt_um_yangzhou_tetris (Tetris skyline player with serial debug scan) tt_um_pusht_servo (Push-T visual servo with serial debug scan) tt_um_compact_digit (Pooled handwritten digit classifier with serial debug scan) tt_um_dinis_chacha20_V2 (ChaCha20 1QR byte-interface baseline) tt_um_i2c_des (I2C_DES) tt_um_tskurata354_serv4_tdc (SERV4 RF4 with 16-stage TDC) tt_um_bomu_mthanson1 (BoMu resistively-loaded NMOS diff amp, 1.2V series-dropper supply + i_trim) tt_um_tinymppt (TinyMPPT) tt_um_totara_zn417q (ZN417Q-style AM receiver with differential tap) tt_um_Zero_Drift_Opamp (Zero-Drift Amplifiers) tt_um_sunrise_rv32i (32 Bit In Order 5 Stage RISC V CPU) tt_um_tarun135678_crc16 (Configurable CRC-16 Hardware Engine) tt_um_nitikac24_hchoi2927_pagerank (Markov Chain - PageRank) tt_um_vikaskumart176_fp16_nr_div (Newton-Raphson Divider) tt_um_yiminglu_tinydsp8 (TinyDSP-8) tt_um_harinarayanans2006_fifo32 (8x32 FIFO with almost-full/empty) tt_um_seeded_prng (8-bit LFSR Random Number Generator) tt_um_mealycpp_geb (GEB-ATOM: run-time splittable Keccak core) tt_um_priyaasuti_sea (SEA-24/4 Lightweight Block Cipher) tt_um_zarif_systolic (VGG16 2D Systolic Array (4-bit, weight-stationary)) tt_um_bdawg4113_armv6m (ARMv6-M style multicycle CPU) tt_um_ageorgis_aigaionpu (AigaioNPU) tt_um_leowang_tpu (tiny-tpu) tt_um_VRA_CPU (VRA CPU) tt_um_sul_tan1_nanogpu (NanoGPU) tt_um_hybrid_crypto_sel (Hybrid Crypto Selector (SIMON-32/64 + AES/SIMON selection logic)) tt_um_vga_sd_proto (SD-to-VGA Animation Player) tt_um_cursedrock17_adc (8-bit ADC) tt_um_franktype_dda (DDARaycaster) tt_um_kianv_rv32_regfile (KianV uLinux RISC-V regfile edition) tt_um_urish_simon (Simon Says memory game) tt_um_mmalpha (MMAlpha integer matrix multiplier Design02) tt_um_justice_lif (LIF Spiking Pattern Generator) tt_um_atompu_s1 (ATOMPU Silicon 1) tt_um_tinyfpga (TinyFPGA: 4x LUT4 with SPI config) tt_um_strider93_lif (LIF Neuron PE (CSNN accelerator)) Available