Skip to content

Commit

Permalink
feat: update project tt_um_wokwi_413387065339458561 from squidgeefish…
Browse files Browse the repository at this point in the history
…/TT09

Commit: 5ede2c18b39face5fe607c45c25e8b98460c4e2c
Workflow: https://github.com/squidgeefish/TT09/actions/runs/11765625081
  • Loading branch information
TinyTapeoutBot committed Nov 10, 2024
1 parent ccb0b9c commit 77197e5
Show file tree
Hide file tree
Showing 9 changed files with 21,478 additions and 3,706 deletions.
6 changes: 3 additions & 3 deletions projects/tt_um_wokwi_413387065339458561/commit_id.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"app": "Tiny Tapeout tt09 b176ed7c",
"app": "Tiny Tapeout tt09 a48b1c74",
"repo": "https://github.com/squidgeefish/TT09",
"commit": "04b1334077ec436e3985650993383e09b9d8657b",
"workflow_url": "https://github.com/squidgeefish/TT09/actions/runs/11637208872",
"commit": "5ede2c18b39face5fe607c45c25e8b98460c4e2c",
"workflow_url": "https://github.com/squidgeefish/TT09/actions/runs/11765625081",
"sort_id": 1730502951064,
"openlane_version": "OpenLane2 2.1.9",
"pdk_version": "open_pdks bdc9412b3e468c102d01b7cf6337be06ec6e9c9a"
Expand Down
24 changes: 21 additions & 3 deletions projects/tt_um_wokwi_413387065339458561/docs/info.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,30 @@ You can also include images in this folder and reference them in the markdown. E

## How it works

4-bit ripple carry adder. Adds `IN[3:0]` to `IN[7:4]` and outputs to `OUT[4:0]` with the carry bit as the high bit.
This is a converter from the SPI-style APA102 LED protocol to the single-line WS2812 protocol.

It's hard-coded to seven LEDs because I needed to set a limit, and this is clearly the simplest possible way to replace the Arduino Micro performing the same task on my [5n4ck3y-7r clone](https://squidgeefish.com/projects/cloning-5n4ck3y-7r/).

It clocks the SPI data on input bit 0 (clock) and bit 1 (data) and waits until it sees a string of 32 low bits to signal a valid start condition. At this point, it starts saving data into an internal shift register, handing that register's contents over to the WS2812 output data feed once all seven LEDs' values have been received. It continues clocking along until recognizing a stop condition (unconditionally 32 bits after the last LED value), at which point it goes back to waiting for a valid start condition.
In order to address area concerns, I wound up cutting this down a bit - the internal mirror register was removed entirely, and the SPI reader now also handles discarding the first 8 bits of each 32-bit pixel value. Further tweaks that traded wiring complexity for combinatorics did not make it any better, unfortunately.

I wrote the SPI-parsing and bit-shuffling code from scratch, but the WS2812 output module is lifted from [this TT05 submission](https://github.com/Gatsch/jku-tt06-ledcontroller/blob/main/src/led.v). I did modify it to read the data stream MSB-first rather than LSB-first since that made my life a lot easier in bit-twiddler land.

Note that the first byte of each APA102 packet encodes an intensity, which I am ignoring since WS2812s do not support such a feature.

## How to test

Set the input DIP switches to hold each nybble. Output will show up on the OUT bus; if you're hooked up to the 7-segment display you might be hopelessly confused.
The way I will be testing this is by attaching `ui_in[0]` to SCK and `ui_in[1]` to SDO on a DEFCON badge that used APA102 LEDs. Attach `uo_out[0]` to drive a string of at least seven WS2812s. I suspect that level shifters will be needed since TinyTapeout ICs run at around 1.8V?

Alternatively, you could probably stream something over in MicroPython.

If you're hand-crafting your packets, a few notes:
- A packet stream must start with a 32-bit start packet (0x00000000)
- APA102s reserve the first byte for intensity: `0b11100000 | <5-bit intensity>`. We're ignoring this completely.
- APA102 color order for the remaining three bytes is Blue, Green, Red.

There is also a random feature added in to fill space - there should be a continuous UART output of "Arglius Barglius" on `uo_out[1]` at approximately 115200 baud; this can be read out with a serial bridge or sufficiently advanced logic analyzer.

## External hardware

Might want to connect a normal row of LEDs to the output bus rather than the 7-segment display.
Some sort of SPI driver is necessary, as is a string of at least seven WS2812 LEDs (or I suppose a logic analyzer can verify it if you're allergic to blinkies).
47 changes: 27 additions & 20 deletions projects/tt_um_wokwi_413387065339458561/info.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
# Tiny Tapeout project information (Wokwi project)
# Tiny Tapeout project information
project:
wokwi_id: 413387065339458561 # Set this to the ID of your Wokwi project (the number from the project's URL)
title: "4-Bit Adder?" # Project title
title: "APA102 to WS2812 Translator" # Project title
author: "Squidgeefish" # Your name
discord: "" # Your discord username, for communication and automatically assigning you a Tapeout role (optional)
description: "4-bit adder with carry output" # One line description of what your project does
language: "Wokwi" # other examples include SystemVerilog, Amaranth, VHDL, etc
clock_hz: 0 # Clock frequency in Hz (or 0 if not applicable)
description: "Convert a 7-LED APA102 stream to a WS2812-compatible one" # One line description of what your project does
language: "Verilog" # other examples include SystemVerilog, Amaranth, VHDL, etc
clock_hz: 25000000 # Clock frequency in Hz (or 0 if not applicable)

# How many tiles your design occupies? A single tile is about 167x108 uM.
tiles: "1x1" # Valid values: 1x1, 1x2, 2x2, 3x2, 4x2, 6x2 or 8x2
tiles: "1x2" # Valid values: 1x1, 1x2, 2x2, 3x2, 4x2, 6x2 or 8x2

top_module: "tt_um_wokwi_413387065339458561"

source_files:
- "project.v"
- "apa102_in.v"
- "led.v"
- "uart.v"


# The pinout of your project. Leave unused pins blank. DO NOT delete or add any pins.
pinout:
# Inputs
ui[0]: "IN0_0"
ui[1]: "IN0_1"
ui[2]: "IN0_2"
ui[3]: "IN0_3"
ui[4]: "IN1_0"
ui[5]: "IN1_1"
ui[6]: "IN1_2"
ui[7]: "IN1_3"
ui[0]: "APA102_CK"
ui[1]: "APA102_SD"
ui[2]: ""
ui[3]: ""
ui[4]: ""
ui[5]: ""
ui[6]: ""
ui[7]: ""

# Outputs
uo[0]: "OUT0"
uo[1]: "OUT1"
uo[2]: "OUT2"
uo[3]: "OUT3"
uo[4]: "OUT4"
uo[0]: "WS2812_OUT"
uo[1]: "UART_OUT"
uo[2]: ""
uo[3]: ""
uo[4]: ""
uo[5]: ""
uo[6]: ""
uo[7]: ""
Expand Down
Loading

0 comments on commit 77197e5

Please sign in to comment.