131 Tetris

131 : Tetris

Design render

How it works

Tetris on a 640x480 VGA screen, in a 1x2 tile.

The 10x20 board is drawn at (220,40) in 20x20-pixel cells, with a grey frame and black grid lines. Every new piece gets a random colour (red, orange, yellow, green, cyan, blue or magenta, never the same as the piece before), independent of its shape, and keeps it after it locks, until game over. Above the board, S### is the score and H### is the best score since reset (both up to 999). Points come from cleared lines: clearing 1, 2, 3 or 4 lines (a TETRIS) at once scores 1, 3, 5 or 8 points, multiplied by the level + 1. A title screen shows "PRESS ANY BUTTON TO START". When a new piece cannot be placed, the board turns grey and "GAME OVER" blinks.

Pieces are picked at random from the 7 tetrominoes. Rotation is clockwise. If a rotation is blocked, it tries one column to the left, then one to the right. Each input acts once per event and never repeats while held: left, right and rotate move or turn the piece once, and down moves it one row. With ui[4] = 0 an event is every flip of the input (DIP switches, VGA Playground keys 0-3); with ui[4] = 1 it is only a press (push buttons). The piece falls one row every 10 frames at the start, and one frame faster for every 10 cleared lines, down to every 2 frames.

How it fits in one tile:

  • The VGA position is counted in 20-pixel cells (vga_cells.v), so finding the board cell of a pixel needs no division. The sync timing is the same as the standard 640x480 shell.
  • The board is a shift register of 20 rows (3 bits per cell: empty or piece type) that turns by one row every clock. A full turn takes 20 clocks. The row at its head is always the VGA x position modulo 20, so no address counter, read multiplexer or write enables are needed.
  • During vertical blanking the game logic works on the head row only:
    • collision tests and locking handle one cell at a time as its row passes;
    • clearing a line copies each row from the one above it (the next 10 bits of the register), starting at the lowest full row.
  • Piece shapes come from a small ROM indexed by type and rotation. The score is kept in BCD, so there are no dividers.

How to test

Connect a TinyVGA PMOD and a VGA monitor, and run the clock at 25.175 MHz (25 MHz also works). Connect the inputs (active high) to ui[0] left, ui[1] right, ui[2] rotate and ui[3] down. Set ui[4] to 0 for switches or 1 for push buttons. Flip or press any input to start a game. In the VGA Playground, keys 0-3 control the game.

External hardware

TinyVGA PMOD, a VGA monitor, and four switches or push buttons.

IO

#InputOutputBidirectional
0Left buttonR1
1Right buttonG1
2Rotate buttonB1
3Down (one row)VGA vsync
4Input mode: 0 = act on every flip, 1 = act on pressR0
5G0
6B0
7VGA hsync

Chip location

Controller Mux Mux Mux Mux Mux Mux Mux Mux Mux Analog Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Analog Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux tt_um_chip_rom (Chip ROM) tt_um_factory_test (Tiny Tapeout Factory Test) tt_um_ORIEL_TTPROJECT0110 (TTPROJECT0110) tt_um_josue_vga_playground (Josue VGA Playground) tt_um_wokwi_476352934999963649 (1stdesign) tt_um_ISHIKAI_SARADC (ISHI-KAI's SAR-ADC) tt_um_fommil_polkadot_E4M3 (polkadot) tt_um_keropiyo_am_radio_2 (Keropiyo Tiny AM Radio) tt_um_camiheres_CAMILA (3312) tt_um_wokwi_476709498841751553 (kfl_RF_2026 - Radio channel activity monitor) tt_um_wokwi_476707868817515521 (Tiny Tapeout compuertas) tt_um_wokwi_476709230859236353 (Tiny Tapeout Template Copy) tt_um_evaristocaribeiro_notredamefootballasic (Notre Dame Football ASIC) tt_um_wokwi_476708995522037761 tt_um_fabianpg3_comb_filter (Simple comb filter using PMODs AD1 & DA3) tt_um_malex1269_rana_dorada (Rana Dorada Run) tt_um_wokwi_414120404427608065 (Tiny Tapeout 9 Template Copy) tt_um_wokwi_476709817739990017 (Tiny Tapeout Template RB) tt_um_wokwi_476706197982687233 tt_um_DaysiB_VERILOG (VERILOG) tt_um_wokwi_476709947486621697 (Tiny Tapeout Template Copy PWM Generator) tt_um_wokwi_476698583341509633 (Vale's first wokwi design) tt_um_ESTJETM_MULTIFACE (MUTIFACE) tt_um_vga_nancoo (TTSKY-Verilog-example) tt_um_3d2yy_moving_sine_wave (Animated VGA Sine Wave) tt_um_delariveragustavo_Proyecto002 (ALgoritmo_redes_neuronales) tt_um_wokwi_476709198626006017 (7C) tt_um_NullZero_VGApsyOp (VGA psyco Operation) tt_um_wokwi_476698697037596673 (TT_edwin) tt_um_lurayd_iscpe (In-Situ Self-Configuring Protocol Engine) tt_um_wokwi_476711029635064833 (tpu(bidir) Copy) tt_um_sr_ga1_srb2149 (SR-GA1) tt_um_wokwi_476707442795703297 (8-bit random number generator Copy) tt_um_wokwi_476712167456626689 (p_cont) tt_um_XzT07_VGAPLAY (Xzt VGA PLayground) tt_um_wokwi_476711048900554753 (Ameth project) tt_um_wokwi_476712026836276225 (ALERTA TEMPRANA TINY) tt_um_wokwi_476712711844844545 (david) tt_um_Dany_IEEE (IEEE Ecuador) tt_um_rebeccargb_universal_decoder (Universal Binary to Segment Decoder) tt_um_rebeccargb_hardware_utf8 (Hardware UTF Encoder/Decoder) tt_um_rebeccargb_intercal_alu (INTERCAL ALU) tt_um_rebeccargb_vga_pride (VGA Pride) tt_um_lulago3003_flappy (Flappy Luis) tt_um_samyak_krish_morse_codec (A Binary-Tree-Based Dual-Mode Morse Communication Engine with Pulse-Duration Encoding) tt_um_approximate_mac (Configurable Approximate MAC) tt_um_mylesbell_snn (Analogue SNN Building Blocks) tt_um_derrykervin_cardmcu_c0 (CardMCU C0) tt_um_urish_simon (Simon Says memory game) tt_um_brayanc24_tinyplc8 (TinyPLC-8 Conveyor Controller) tt_um_fernandodli_jumpgame (jump game) tt_um_breakout (Tiny Breakout + Pong + Pacman) tt_um_nikodemetrashvili20_ro_puf (Three-arm ring-oscillator PUF) tt_um_davispe1_invaders (VGA Space Invaders) tt_um_rv32_linux_soc (RV32 Linux SoC) tt_um_mario_levels (Mario goes ASIC) tt_um_scim_core (CIMTinyTO: Stochastic & Digital CIM Accelerator) tt_um_disdi_swdcap (swdcap: SWD debug port with EIO) tt_um_trewlyvuive_4bitcomp (A simple 4 bit cpu) tt_um_chiuhanhui_bit_clock (6-Digit 7-Segment Clock with Alarm) tt_um_filthyfil_hack (tt_um_hack_computer) tt_um_marvinbrth_opamp_rrio_cgm_3v3 (SKY130 Rail-to-Rail OpAmp) tt_um_SpiralBL0CK_rot13_encoder (ROT 13 ENCODER + DISPAY ON DISPAY 4 BIT MODE) tt_um_mattvenn_radio (433 MHz OOK radio) tt_um_vermiscore_vco_div (5GHz VCO with /8 divider) tt_um_wokwi_477581406276581377 (Tiny Tapeout Template Copy- Abdul Hayee) tt_um_maxeland07_tiny_tiny_tapeout_macro_edition_1x1 (Tiny Tiny Tapeout: macro edition (1x1)) tt_um_hades (HADES: Hamming-Aware Decode, Execute, and Search) tt_um_barrylee911_adc3542_ddr (ADC3543 DDR receiver) tt_um_4Bit_SAR_ADC (4-Bit Successive Approximation ADC) tt_um_wokwi_478038518092558337 (Tiny Tapeout Template Copy) tt_um_wokwi_478038621459129345 (Artun giray) tt_um_wokwi_478037100343886849 (cagan chip) tt_um_wokwi_478036861577773057 (Tiny Tapeout Template Copy) tt_um_wokwi_478036932742578177 tt_um_wokwi_478037039748756481 (Something Something silicon chip) tt_um_wokwi_478042985279383553 (XNOR RVK) tt_um_wokwi_478036927610842113 (Tiny Tapeout Logic Gate) tt_um_wokwi_478037204062810113 (Tiny Tapeout Template Copy Nikita) tt_um_so_reire_logic_lock (Logic lock) tt_um_wokwi_478043151738796033 (Random Counter First Prototype) tt_um_wokwi_478042268037466113 (Tiny Tapeout Template Copy) tt_um_wokwi_478039138791084033 (Tiny Tapeout Template Copy) tt_um_wokwi_478036906126551041 tt_um_surchechil_synth (8-Key Synthesizer) tt_um_wokwi_478043455160104961 (Tiny Tapeout Template Copy) tt_um_wokwi_478043218042387457 (durucopy Copy) tt_um_wokwi_478043215439819777 (first wokwi of anatolian wildcats Copy) tt_um_wokwi_478039055652604929 (4bit adder) tt_um_wokwi_478038895761488897 (first logic circuit) tt_um_wokwi_478038774162269185 (Tiny Tapeout Demo) tt_um_zarovs_nbody (Three-Body Gravity) tt_um_wokwi_478037038902554625 (Thomas' first Wokwi design) tt_um_wokwi_478036840448956417 (markuss_k_pirmais_dizains) tt_um_wokwi_478038673447552001 (Calculator or something like it) tt_um_wokwi_478038425613358081 (Tiny Tapeout Project) tt_um_wokwi_478043109964551169 (Milan's Binary to Decimal converter) tt_um_wokwi_478036961347742721 (Chipathon design -IB) tt_um_wokwi_478039519079320577 (Tiny Tapeout GDS design) tt_um_supply_sense (VDDSense) tt_um_wokwi_478043632806772737 (logic) tt_um_kyrylo_nazarevych_bpx1 (BPX-1 branch prediction coprocessor) tt_um_dzoniss1_game_paddle_and_ball (Tetris) tt_um_wokwi_478036939583493121 (Lori Project) tt_um_sintijatretjaka_vga_paddle_ball (Arkanoid) tt_um_wokwi_478043552421858305 (Tiny Tapeout Vlad Chip) tt_um_wokwi_478037171260183553 (Chipathon wokwi chip) tt_um_vga_example (F1 Reflex Precision Trainer) tt_um_wokwi_478043680146855937 (shift-reg) tt_um_NTT_Core (SHA-3 Engine) tt_um_wokwi_478044708451072001 (chipathon proj1) tt_um_wokwi_478036986642552833 (Tiny Tapeout Template Copy_Daniil) tt_um_wokwi_478045464495575041 (Dzhuris_Counter_2) tt_um_wokwi_478048769996161025 (My first chip) tt_um_wokwi_478050669678730241 (Said AZErobot) tt_um_wokwi_478051494759391233 (Murad chip) tt_um_wokwi_478036993243342849 (Vlad's first Wokwi design) tt_um_wokwi_478037026420301825 (A_Project_3,4,6) tt_um_wokwi_478046004567955457 (Tiny Tapeout Template Copy) tt_um_ervinsg_game_test (Grid chase) tt_um_wokwi_478045321881850881 (Tiny Tapeout - Ibrahim Alizada) tt_um_vanessa_riscv (RISC-V 32-bit Single-Cycle) tt_um_nubavocadofarmer_systolic_tpu (2x2 Systolic TPU) tt_um_wokwi_478140301155680257 (Binary Counter) tt_um_mpriede_moonlight_sonata_player_vga (Moonlight Sonata player (VGA)) tt_um_ICHIKEN_SARADC (ICHIKEN's SAR-ADC) tt_um_richardvarens_maze (VGA Maze) tt_um_autocomp (autocomp) tt_um_syverh_spi_mac (SPI int8 dot-product accelerator) tt_um_ktm0228_opamp_trim (trimmed op-amp) tt_um_gregac_tiny_nn (Tiny Neural Network Accelerator) tt_um_gigeresk_mocarabe (Mocarabe: a programmable time-multiplexed CGRA) tt_um_siameee_alu (32-bit 8-Operation ALU) tt_um_pettit_lisa (LISA Microcontroller with TTLC (Ver 3)) tt_um_florianmodel_entropy_probe (Physical entropy measurement probe) tt_um_wokwi_478885686308451329 (Tiny Tapeout simple 4-bit adder) tt_um_deterministe_MariusL00 (Deterministe 3x3 - Strict Logic) tt_um_npu_MariusL00 (TinyNPU 3x3 - Educational) tt_um_jlcabral_tinyhash_8 (TinyHash-8) tt_um_tmcdonagh_guitar_pedal (Silicon Guitar Pedal) tt_um_pwrgovx (PwrGov-X: Telemetry-Driven Power Governor) tt_um_mattvenn_tron (Tron) tt_um_repellant_gen (Frequeny generator) tt_um_trip_accelerator (TRIP Sparse Dot-Product Accelerator (1x1)) tt_um_int4_matrix_multiplier (Resource-Shared 4x4 INT4 Matrix Multiplier) tt_um_sahil_qspi_sram (QSPI_SRAM) tt_um_ternara_tau_seed (Ternara tau seed) tt_um_wokwi_479138492474757121 (Uri's 2 bit counter) tt_um_pcm_ternary_mlp (Ternary MLP Inference Tile) tt_um_pcm_bigint (128-bit Bit-Serial Integer Accumulator) tt_um_wokwi_479214376021836801 (My First Tiny Tape out - AND Gate) tt_um_cordic_dsp (ReCORDIC: Reconfigurable CORDIC + FIR/IIR DSP) tt_um_markgarnold_lnsalu (LNS ALU compatible with RISC-V) tt_um_cl_hw_silicon_fft16 (16-point streaming FFT with OFDM symbol timing) tt_um_toxicfox_phoenix (Phoenix-v2) tt_um_wokwi_479633362230032385 (TT TA-SC timing tests) tt_um_talivick_digit_reader (INT8 systolic array coprocessor with on-chip learning and a touch LCD) tt_um_wokwi_445109034894292993 (Core64) tt_um_millerresearch_descrypt (DEScrypt: DES encryption and decryption) tt_um_fppic (Four Protocol Peripheral Interface Chip (FPPIC)) tt_um_vga_kfl_slHyp (Salto al hiperespacio) tt_um_pablojlm_zenith (Zenith-Core) tt_um_stary_dragonsharkwolf_fcontrol (FControl) tt_um_vga_diiegofp (VGA Moving Logo) tt_um_aveliz_vendingmachine (Vending Machine Control) tt_um_analog_ic_bg_26 (Analog Bandgap) tt_um_rj_gift (GIFT-64 Lightweight Block Cipher) tt_um_rj_present (PRESENT-80 Lightweight Block Cipher) tt_um_rj_simon (SIMON 128/128 bit-serial block cipher) tt_um_wokwi_479982572339554305 (Joseph's first Wokwi design - SC26) tt_um_wokwi_479985668941097985 (Tiny Tapeout Workshop HVz) tt_um_adamchilders_bouncy_cat (Bouncy Cat) tt_um_wokwi_479985645701501953 (Tiny Tapeout Template Copy) tt_um_wokwi_479982211910382593 (nyancat-player) tt_um_wokwi_479982436927475713 (Tiny Tapeout - 7seg dice) tt_um_wokwi_479985299307507713 (prn13) tt_um_wokwi_479980686722843649 (Ido first Wokwi design) tt_um_tiny_escape_room (Tiny Escape Room) tt_um_wokwi_479983652965408769 (Tiny Tapeout First Project) tt_um_johnzzhang_prism (Prism) tt_um_wokwi_479986606136461313 (Tiny Tapeout Template-Loibingdorfer_s_hegde) tt_um_wokwi_479980845635608577 (Wokwi_V1_design) tt_um_stass_scheme78 (Scheme-78: the 1978 MIT SIMPLE Lisp processor) tt_um_wokwi_479986781939685377 (7-segment "Tiny Tapeout" display (tt07) Copy (2)) tt_um_wokwi_479981089969591297 (Leaky Integrate-and-Fire Neuron) tt_um_wokwi_479980961736058881 (Tiny Tapeout Template Copy) tt_um_wokwi_479980512638218241 (mwoz Tiny Tapeout) tt_um_hack_cpu (Kuba Hack CPU clone) tt_um_chickenwhisperer_bb5 (Busy Beaver 5) tt_um_wokwi_479978581726129153 (Wren's Tiny Tapeout) tt_um_jadonk_boris_minsky (Minsky Machine (bbb.io/minsky)) tt_um_wokwi_413387186248679425 (Drew's First Wokwi Design) tt_um_shriharinarayan_sar_adc (8-bit SAR ADC) tt_um_stass_scheme79 (Scheme-79: the 1979 MIT Lisp chip) tt_um_kaursome10_run_nn (BWSI bASICs MNIST NN) tt_um_p_sensing_ANG (P-Sensing Analog Circuit) tt_um_jeffadickson_tinytmr (TinyTMR: fault-injectable triple modular redundant I/O) tt_um_hale_attn_scorer (Attention Scorer) tt_um_wokwi_480322745306619905 (Vaccine vial heat monitor) tt_um_brago_pomodoro (VGA Pomodoro Timmer) tt_um_wokwi_480327772005238785 (Configurable Digital Password Lock) tt_um_lmdp0411_motor_ctrl (Controlador de Motor con Encoder en cuadratura 4X) tt_um_JimeRivera_tt_um_mi_proyecto (tt_um_mi_proyecto) tt_um_wokwi_480368365343888385 (MORSE_TRANSLATER) tt_um_wokwi_480341348151312385 (Tiny Tapeout Template - Solar Panel Project rev2) tt_um_peterm_weebiano (Weeb-iano) tt_um_wokwi_480337892997339137 (Elevator Controller) tt_um_sparkypaz_viterbi (Viterbi decoder 8 states) tt_um_wokwi_480339851441967105 (MedAlert) tt_um_emerson_pepa (PEPA) tt_um_wokwi_480341489261360129 (IEEE Erick Gonzalez) tt_um_wokwi_480341879231024129 (Project 1) tt_um_wokwi_480322171653539841 (Erick´s first wowki design) tt_um_wokwi_480327812501259265 (SOMOS GALILEO ) tt_um_pwmGen (PWM Generator) tt_um_wokwi_482143790097210369 (Motor) tt_um_alexandersactic_spi (FSM SPI) tt_um_cesarJHF_CalcuChiquita (Laprueba) tt_um_wokwi_480322479285932033 tt_um_axelazo_tetris (Tetris) tt_um_wokwi_480322247263234049 (Alejandro’s first Wokwi design) tt_um_wokwi_480343326236850177 (prueba) tt_um_wokwi_480401624547774465 (Juan Proyect 2) tt_um_wokwi_480363877961503745 (aviationjose) tt_um_diego_barillas (Discos giratorios) tt_um_jfcolmenarest_jfct (jfct) tt_um_wokwi_480343128405120001 (Diseño1 Jostyne en Woki Copy (2)) tt_um_wokwi_480431450556273665 (Conversor_BCD) tt_um_mattvenn_r2r_dac_3v3 (Analog 8 bit 3.3v R2R DAC) tt_um_atc (analog-to-time converter) tt_um_cnn_accel (CNN IM2COL accelerator) tt_um_crissag53_cpu4 (4-bit Mini Processor) tt_um_b2b (Band to band filter) tt_um_alfadelta10010_alphaone_soc (AlphaOneSoC) tt_um_chiranjitpatel_sar_adc (Bandgap-referenced 8-bit SAR ADC + temperature sensor) tt_um_pchri03_imp_soc (Imp SoC) tt_um_ShSi333_ta_wnn (Protein secondary structure WNN with on-chip Tsetlin learning) tt_um_wokwi_480058974335861761 (iSD MD 2026) tt_um_mihail_ivan_ov_multiply_accumulate_mac_unit (Multiply-Accumulate (MAC) unit) tt_um_regulated_pump (Pump_doubler) tt_um_wereng_analog_2x2 (smartDense-tt-1a) tt_um_kyrylo_nazarevych_sense (SXA-1 standard-cell sensor exploration array) tt_um_atikshgupta06_rps (Rock Paper Scissors Referee + Ring Oscillator) tt_um_wokwi_482017400365844481 (LED Pattern Sequencer) tt_um_pavansaradhyaec23_cachetaghitmiss (Cache Tag Hit/Miss Controller) tt_um_dtc130 (A 6-bit Digital-to-Time Converter with On-Chip Characterization) tt_um_silicon_edge_ns_sar_adc (NS SAR ADC) tt_um_wokwi_476708940031385601 (01_10_2026_4221to8421converter_doneinclass) tt_um_wokwi_477606428220989441 (7segEncoder_with_priority_check) tt_um_wokwi_478036988590808065 tt_um_bpaiz_multiplier (signed multiplier) tt_um_wokwi_478038774502008833 (Deivids First template) tt_um_wokwi_479985847235750913 (FirstTiny) tt_um_wokwi_479057132409419777 (Ghazal_TinyTapeout Copy) tt_um_wokwi_478037064629376001 (Gustav`s design) tt_um_wokwi_479404015319023617 (JGs first Wokwi Design) tt_um_janiss94_chipathon_logos (Chipathon Logos) tt_um_wokwi_476712002646673409 (Johana Tiny TAPEOUT_1) tt_um_wokwi_476698443791693825 (Lizmari´s first Wokwi design) tt_um_wokwi_476711704035237889 (Obed's sec wokwi project Copy) tt_um_widdakay_lockin_impedance (Lock-in Impedance Front End) tt_um_wokwi_480340178463509505 tt_um_wokwi_476711924172274689 (RENE Secret Safe - Tiny Tapeout Copy Copy) tt_um_wokwi_478037144820303873 (STANLEY_FIRST_WOKWI DESIGN) tt_um_wokwi_480343062074287105 (Semaforo_1_1 Copy (3)) tt_um_wokwi_480338044733654017 (Sistema de seguridad de temperatura) tt_um_wokwi_479071141067305985 (TA project) tt_um_wokwi_478044658852360193 (Tiny Tapeout) tt_um_wokwi_476698859317350401 (Tiny Tapeout Template Andres) tt_um_wokwi_479056958744194049 (Tiny Tapeout Template Copy) tt_um_wokwi_480320760817179649 (Tiny Tapeout Template Copy) tt_um_maxeland07_vulkos_chip_build (Vulkos chip build) tt_um_wokwi_476709649981429761 (Truth Table LED Copy fot test) tt_um_wokwi_480341701522527233 (Traductor) tt_um_wokwi_478036821984564225 (Tiny Tapeout Template Copy) tt_um_audris123_4_bit_binary_counter (pwm to binary) tt_um_ttsky26d_analog_compute (ttsky26d_analog_compute) tt_um_dram3t (3T gain cell DRAM) tt_um_alu_secuencial (ALU con sumador de 8bits y divisor haciendo uso de un pipeline) tt_um_vishnu1355_vco_dsm (Ring-VCO Delta-Sigma ADC with on-chip shift-add linearization) tt_um_bovi_one_bit_plc (One-bit PLC) tt_um_osrodas007_3shield_dycde_v1 (osrodas007_3shield_dycde_v1) tt_um_libokuohai_8bit_8klasse_art (8-Bit für die 8. Klasse) tt_um_pettit_microcomputer (MicroComputer (the MicroCPU with its memory, stack and ports)) tt_um_2048_vga_game (2048 sliding tile puzzle game (VGA)) tt_um_silicon_art_vga_screensaver (VGA Screensaver with Silicon Art ROM) Available