37 ChipTune

37 : ChipTune

  • Author: Wallace Everest
  • Description: Vintage 8-bit sound generator
  • GitHub repository
  • Clock: 1789773 Hz

How it works

ChipTune implements an 8-bit Programmable Sound Generator (PSG). Input is from a serial UART interface. Output is PWM audio.

Overview

This project replicates the Audio Processing Unit (APU) of vintage video games.

Statistics

  • Tiles: 2x2
  • DFF: 417
  • Total Cells: 2549
  • Utilization: 32%

TinyTapeout 4 Configuration

TT04 devices from the eFabless Multi-Project Wafer (MPW) shuttle are delivered in QFN-64 packages, mounted on a daughterboard for breakout.

Based on data from:

  • https://github.com/efabless/caravel_board/blob/main/hardware/breakout/caravel-M.2-card-QFN/caravel-M.2-card-QFN.pdf
  • https://github.com/TinyTapeout/tt-multiplexer/blob/main/docs/INFO.md
  • https://open-source-silicon.slack.com/archives/C016N88BX44/p1688915892223379

MPRJ_IO Pin Assignments

Signal Name Dir QFN PCB
mprj_io[0] jtag in 31
mprj_io[1] sdo out 32
mprj_io[2] sdi in 33
mprj_io[3] csb in 34
mprj_io[4] sck in 35
mprj_io[5] user_clk out 36
mprj_io[6] clk in 37
mprj_io[7] rst_n in 41
mprj_io[8] ui_in[0] in 42
mprj_io[9] ui_in[1] in 43
mprj_io[10] ui_in[2] in 44
mprj_io[11] ui_in[3] in 45
mprj_io[12] ui_in[4] in 46
mprj_io[13] ui_in[5] in 48
mprj_io[14] ui_in[6] in 50
mprj_io[15] ui_in[7] in 51
mprj_io[16] uo_out[0] out 53
mprj_io[17] uo_out[1] out 54
mprj_io[18] uo_out[2] out 55
mprj_io[19] uo_out[3] out 57
mprj_io[20] uo_out[4] out 58
mprj_io[21] uo_out[5] out 59
mprj_io[22] uo_out[6] out 60
mprj_io[23] uo_out[7] out 61
mprj_io[24] uio[0] bid 62
mprj_io[25] uio[1] bid 2
mprj_io[26] uio[2] bid 3
mprj_io[27] uio[3] bid 4
mprj_io[28] uio[4] bid 5
mprj_io[29] uio[5] bid 6
mprj_io[30] uio[6] bid 7
mprj_io[31] uio[7] bid 8
mprj_io[32] sel_ena in 11
mprj_io[33] spare 12
mprj_io[34] sel_inc in 13
mprj_io[35] spare 14
mprj_io[36] sel_rst_n in 15
mprj_io[37] spare 16

APU Operation

The audio portion of the project consists of two rectangular pulse generators, a triangle wave generator, and a noise generator. Each module is controlled by four 8-bit registers. Configurable parameters are the frequency, duty cycle, sweep, decay, and note duration.

An explanation of register functions can be found on the NESDEV website. Only the lower 4-bits of the address are decoded.

  • https://www.nesdev.org/wiki/APU

UART Operation

  • A register address and data are recovered from two consecutive serial bytes.
  • A byte with the msb=0 is considered the first byte with 7-bits of data.
  • A byte with msb=1 is considered the second byte with the remaining 1-bit of data and a 6-bit address.
  • A ready flag is generated after receiving the second byte.
Byte 1                             Byte 2
Start D0 D1 D2 D3 D4 D5 D6 0 Stop  Start D7 A0 A1 A2 A3 A4 A5 1 Stop

Pin Assignments

Signal Name Signal Name
clk 12 MHz ena spare
rst_n spare uio_oe[7:0] spare
ui_in[0] spare uo_out[0] blink
ui_in[1] spare uo_out[1] link
ui_in[2] rx uo_out[2] tx
ui_in[3] spare uo_out[3] pwm
ui_in[4] spare uo_out[4] square1
ui_in[5] spare uo_out[5] square2
ui_in[6] spare uo_out[6] triangle
ui_in[7] spare uo_out[7] noise
uio_in[7:0] spare uio_out[7:0] spare
  • CLK is a 1.789733 MHz clock
  • BLINK is an LED status indicator with a 1 Hz rate
  • LINK is an LED activity indicator of the RX signal
  • PWM is the pulse-width modulated audio output
  • RX is a UART input (9600,8,N,1)
  • TX generates a frame synchonization character (0x80)

How to test

The ChipTune project can be interfaced to a computer COM port (9600,n,8,1). An analog PWM filter and audio driver are needed for the test rig.

The following serial strings will activate example functions:

# Square 1
08 82 30 80 00 84 00 86 #Clear
27 83 02 81 7E 85 08 86 #PlaySmallJump
27 83 02 81 7C 84 09 86 #PlayBigJump
13 83 1E 81 3A 84 0A 86 #PlayBump
19 83 1E 81 0A 84 08 86 #PlayFireballThrow
4B 83 1F 81 6F 85 08 86 #PlaySmackEnemy
1C 83 1E 81 7E 85 08 86 #PlaySwimStomp
08 82 3F 81 17 84 01 86 #400Hz
# Square 2
30 88 08 8A 00 8C 00 8E #Clear
18 89 7F 8A 71 8C 08 8E #PlayTimerTick
0D 89 7F 8A 71 8C 08 8E #PlayCoinGrab
1F 89 14 8B 79 8D 0A 8E #PlayBlast
7F 88 5D 8A 71 8C 08 8E #PlayPowerUpGrab
3F 89 08 8A 17 8C 01 8E #400Hz
# Triangle
00 91 00 92 00 94 00 96 #Clear
00 92 0B 95 00 96 40 91 #400Hz
# Noise
30 98 00 9A 00 9C 00 9E #Clear
00 9A 00 9E 05 9D 3F 98 #300Hz

External hardware

Computer COM port

Picture

IO

#InputOutputBidirectional
0Blink
1Link
2RXTX
3PWM
4Square1
5Square2
6Triangle
7Noise

Chip location

Controller Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux tt_um_chip_rom (Chip ROM) tt_um_factory_test (TinyTapeout 04 Factory Test) tt_um_vga_clock (VGA clock) tt_um_seven_segment_seconds (7 segment seconds) tt_um_marno_factorize (Number Factorizer) tt_um_sorter (Odd even sorter) tt_um_bulls_and_cows (The Bulls and Cows game) tt_um_loopback (TinyTapeout 04 Loopback Test Module) tt_um_devinatkin_arduino_vga (VGA Output for Arduino) tt_um_wokwi_371604537887211521 (Digital Cipher & Interlock System) tt_um_urish_simon (Simon Says game) tt_um_wokwi_372184284115580929 (YKM 7-seg driver) tt_um_currymottled (Configurable PID Block) tt_um_yeokm1_pwm_audio (PWM audio) tt_um_dcb277_ALU (4-bit ALU) tt_um_rgb_mixer (RGB Mixer) tt_um_loopback (TinyTapeout 04 Loopback Test Module) tt_um_algofoogle_raybox_zero (raybox-zero) tt_um_morningjava_top (ChipTune) tt_um_loopback (TinyTapeout 04 Loopback Test Module) tt_um_eldritch_pwm_peripheral (OpenSource PWM Peripheral) tt_um_phansel_laplace_lut (Experiment Number Six: Laplace LUT) tt_um_ks_pyamnihc (Karplus-Strong String Synthesis) tt_um_dlmiles_tt04_poc_usbdev (USB Device) tt_um_thorkn_pwmaudio (Audio-PWM-Synth) tt_um_wokwi_374029622762967041 (German Traffic Light) tt_um_dandy_dance (Dandy VGA) tt_um_robojan_top (Tiny Breakout) tt_um_vc_cpu (VC 16-bit CPU) tt_um_MichaelBell_nanoV (Risc-V Nano V) tt_um_urish_usb_cdc (USB CDC (Serial)) tt_um_tiny_processor (Tiny processor) tt_um_f_hal_fft (fft-4-tt) tt_um_tomkeddie_a (LED Panel Driver) tt_um_wokwi_370722051572189185 (OSU Counter) tt_um_wokwi_370796071922577409 (Even digits) tt_um_wokwi_370709383347782657 (Traffic light) tt_um_wokwi_371425977920989185 (Tutorial4) tt_um_riceshelley_tinyFPGA (Grain-Flex-FPGA) tt_um_mgyenik_bfcpu (BFCPU) tt_um_machinaut_systolic (AI Decelerator) tt_um_wokwi_374140166551523329 (Tiny (3-bit) LFSR) tt_um_jk2102 (Pulsed Plasma Thruster (PPT) Controller) tt_um_jayraj4021_SAP1_cpu (SAP-1 CPU) tt_um_wokwi_370533670565165057 (Impulse counter) tt_um_ashleyjr_delay_line (Delay Line) tt_um_simplepiano (Simple Piano) tt_um_wokwi_374292646686728193 (Ripple-Carry Adder) tt_um_led_multiplexer_display (Led Multiplexer Display) tt_um_mjbella_led_matrix_driver (LED Matrix Driver) tt_um_fifo_stevej (8-bit FIFO with depth 16.) tt_um_robojan_pong_top (Pong) tt_um_wokwi_374962052813090817 (8 panel display"") tt_um_wokwi_370690644715216897 (Traffic Light) tt_um_wokwi_374494377414857729 (Model Railway turntable polarity controller) tt_um_wokwi_347144898258928211 (Customizable UART string tx) tt_um_wokwi_347497504164545108 (7-Seg 'Tiny Tapeout' Display) tt_um_wokwi_347140425276981843 (UART character tx) tt_um_wokwi_347417602591556180 (Padlock) tt_um_noritsuna_8bitcounter_AI (8bits Counter by AI) tt_um_fm_transmitter (FM Transmitter) tt_um_wokwi_369864099838656513 (Test 4x4 memory) tt_um_htfab_rotfpga2 (ROTFPGA v2) tt_um_losaias (Arithmetic logic unit of four operations between two 8-bit numbers) tt_um_fir_top (FIR Filter) tt_um_santacrc_tamagotchi (Tamagotchi) tt_um_4_LUT_Baungarten (LFMPDM (Lightning Fast Matrix Programmable Design Module)) tt_um_RELOG_10M_Juan_Garcial (7 SEGMENTS CLOCK) tt_um_MultiPatternLEDSequencer_RSYO3000 (Multi Pattern LED Sequencer) tt_um_pwm (Generador de PWM) tt_um_chip_SP_measure_delay (Multi stage path for delay measurements.) tt_um_chip_SP_Soy_de_Zacapa (ASCII Text Printer Circuit) tt_um_fing_synchronizer_hga (Clock synchronizer) tt_um_db_PWM (Simple PWM Generator) tt_um_RS_Vfreq (CLK Frequency Divider) tt_um_ja_TrafficLight (UIS Traffic Light) tt_um_adder_NestorMatajira (4 bit adder ) tt_um_ALU_NicolasOrcasitas (8-bit ALU) tt_um_ccollatz_SergioOliveros (Collatz Conjecture) tt_um_wokwi_370011087462055937 (8 bit 4 data sorting network) tt_um_wokwi_374968111036708865 (BCD to 7 segments) tt_um_wokwi_374967675785369601 (4 bit full adder) tt_um_wokwi_374974793636964353 (Circuito Religioso) tt_um_wokwi_374815911155542017 (Demultiplexor NAND) tt_um_wokwi_374903567624066049 (Sumador/Sustractor de 3 bit con acarreo y prestamo) tt_um_wokwi_374515580784897025 (Hardware Lock) tt_um_wokwi_374909346558831617 (Custom falling and rising edge detection) tt_um_alu (4-bit-alu) tt_um_pong_neopixel (Angardo's pong) tt_um_LEOGLM_hamming_code_top ((11,7) hamming code encoder and decoder with UART) tt_um_adriannovosel_top (Impulse counter) tt_um_wokwi_374969806854695937 (State machine of an impulse counter) tt_um_wokwi_375061599421794305 (Logic Circuit 1) tt_um_biased_trng (Variable Duty-Cycle TRNG) tt_um_top (Modem Multimodo) tt_um_wokwi_372347167704674305 (SAR ADC Backend) tt_um_wokwi_375176944142127105 (FCFM 7-segment display) tt_um_rodrigomunoz1_rotempsensor_top (another ring oscillator based temperature sensor) tt_um_USM_temp_sens_hyst (RO-based temperature sensor with hysteresis) tt_um_FSM (Microrobotics FSM) tt_um_wokwi_375042398768251905 (MINI ALU) tt_um_wokwi_374778387606763521 (PWM Quisquilloso) tt_um_CPU (CPU 8 bit) tt_um_simple_processor_pablopabota (A Risc-V Instruction memory i2c programmer) tt_um_wokwi_375246321309880321 (IFSC 6-bit Locker) tt_um_wokwi_375217288209912833 (Randomizer and status checker) tt_um_wokwi_375245713375900673 (Simulador de cruzamento de semáforo) tt_um_wokwi_374636462642973697 (Full_adder_carry_juang_garzons) tt_um_ternaryPC_radixconvert (4-trit balanced ternary program counter and convertor) tt_um_darkfsegura_collatz (uDATAPATH_Collatz) tt_um_wokwi_375174630101280769 (Adder) tt_um_wokwi_375163050120587265 (Binary to 7 segment) tt_um_wokwi_375165100039571457 (Neuron) tt_um_silva (Later) tt_um_shift (serializer) tt_um_alu4_alonso59 (4-bits 1-channel PWM and ALU 4 bits) tt_um_mod_u_cnt_BCD (up-down counter with parallel load and BCD output) tt_um_ciro (Later) tt_um_control (Contador con carga) tt_um_onehot (onehot_decoder) tt_um_santiago (CDMA Transmitter/Receiver) tt_um_divider_urielcho (clock divider) tt_um_pwl_RaulprTech (reciprocal) tt_um_fabian (Later) tt_um_thezoq2_tmng (Time Multiplexed Nand-gate) tt_um_uninorte (Octal classifier) tt_um_dlmiles_muldiv4 (MULDIV unit (4-bit signed/unsigned)) tt_um_rs_write_decodifier_fjrn_cinvestav (RS Write Decodifier) tt_um_BounceFSM_RSX92 (Password FSM) tt_um_priority_decoder_Juan_Garcial (Priority e) tt_um_FreqMeter_Juan_Garcial (frecuencimeter) tt_um_sahrdayalfsr (lfsr random number generator) tt_um_i2c (i2c_6 bits) tt_um_wokwi_375227079413963777 (Fastest Finger) tt_um_wokwi_375300958229329921 (Fastest Finger (Clocked)) tt_um_zeptobars (Oscillators II) tt_um_rebot449_lingret_ALU_Top (Simple ALU) tt_um_loopback (TinyTapeout 04 Loopback Test Module) tt_um_wokwi_375288605206694913 (Adjustable Frequency LED Chaser) tt_um_wokwi_375310871188385793 (Simple QSPI DAC) tt_um_quardinlyttle_top (AQALU) tt_um_wokwi_375326293008530433 (Simple TMR) tt_um_chiplet_jtag (Poor Person's Boundary Scan) tt_um_wokwi_375248885704300545 (Probador de lógica básico) tt_um_rejunity_telluride2023_neuron (LIF Neuron, Telluride 2023) tt_um_kpwebb_adder (rusty_adder) Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available