|
| 1 | +# Tiny Tapeout FPGA Compilation Server |
| 2 | + |
| 3 | +A lightweight Go server that compiles Verilog projects using Yosys and nextpnr-ice40, streaming output in real-time. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Receives Verilog source files via HTTP POST |
| 8 | +- Compiles using Yosys + nextpnr-ice40 + icepack |
| 9 | +- Streams compilation output in real-time using Server-Sent Events (SSE) |
| 10 | +- Returns the compiled bitstream (.bin file) on success |
| 11 | + |
| 12 | +## Quick Start |
| 13 | + |
| 14 | +**Start the server:** |
| 15 | +```bash |
| 16 | +docker-compose up --build |
| 17 | +``` |
| 18 | + |
| 19 | +**Check health:** |
| 20 | +```bash |
| 21 | +curl http://localhost:8080/health |
| 22 | +``` |
| 23 | + |
| 24 | +**Test the API:** |
| 25 | +```bash |
| 26 | +make test-api |
| 27 | +``` |
| 28 | + |
| 29 | +You should see streaming output from yosys, nextpnr, and icepack! |
| 30 | + |
| 31 | +**Stop the server:** |
| 32 | +```bash |
| 33 | +docker-compose down |
| 34 | +``` |
| 35 | + |
| 36 | +## Building |
| 37 | + |
| 38 | +```bash |
| 39 | +docker build -t fpga-compiler . |
| 40 | +``` |
| 41 | + |
| 42 | +Or using docker-compose: |
| 43 | + |
| 44 | +```bash |
| 45 | +docker-compose build |
| 46 | +``` |
| 47 | + |
| 48 | +## Running |
| 49 | + |
| 50 | +```bash |
| 51 | +docker run -p 8080:8080 fpga-compiler |
| 52 | +``` |
| 53 | + |
| 54 | +Or using docker-compose: |
| 55 | + |
| 56 | +```bash |
| 57 | +docker-compose up |
| 58 | +``` |
| 59 | + |
| 60 | +## API |
| 61 | + |
| 62 | +### POST /api/compile |
| 63 | + |
| 64 | +Compiles Verilog files and returns the bitstream. |
| 65 | + |
| 66 | +**Request Body:** |
| 67 | + |
| 68 | +```json |
| 69 | +{ |
| 70 | + "sources": { |
| 71 | + "project.v": "module project_top(...); ... endmodule", |
| 72 | + "other.v": "module other(...); ... endmodule" |
| 73 | + }, |
| 74 | + "topModule": "tt_um_project_name" |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +**Response:** |
| 79 | + |
| 80 | +Server-Sent Events stream with JSON messages: |
| 81 | + |
| 82 | +```json |
| 83 | +{"type": "command", "command": "yosys", "args": ["..."]} |
| 84 | +{"type": "stdout", "data": "Output text..."} |
| 85 | +{"type": "stderr", "data": "Error text..."} |
| 86 | +{"type": "success", "data": "base64:...bitstream data..."} |
| 87 | +{"type": "error", "message": "Error message"} |
| 88 | +``` |
| 89 | + |
| 90 | +### GET /health |
| 91 | + |
| 92 | +Health check endpoint. |
| 93 | + |
| 94 | +## Environment Variables |
| 95 | + |
| 96 | +- `PORT` - Server port (default: 8080) |
| 97 | + |
| 98 | +## Development |
| 99 | + |
| 100 | +```bash |
| 101 | +# Install dependencies |
| 102 | +go mod download |
| 103 | + |
| 104 | +# Run locally (requires yosys, nextpnr-ice40, icepack installed) |
| 105 | +go run main.go |
| 106 | +``` |
0 commit comments