• Stars
    star
    140
  • Rank 261,473 (Top 6 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created over 5 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Turn WaveDrom timing diagrams into ASCII art

asciiwave: WaveDrom to ASCII art

This utility reads WaveDrom JSON files like this:

{ signal: [
  { name: "clk",  wave: "P......" },
  { name: "bus",  wave: "x.==.=x", data: ["head", "body", "tail", "data"] },
  { name: "wire", wave: "0.1..0." }
]}

And produces ASCII art like this:

$ ./asciiwave example/step3.json
      ┏──┐  ┏──┐  ┏──┐  ┏──┐  ┏──┐  ┏──┐  ┏──┐  
clk : β”›  └──┛  └──┛  └──┛  └──┛  └──┛  └──┛  └──
      xxxxxxxxxxxxβ•±    β•²β•±          β•²β•±    β•²xxxxxx
bus : xxxxxxxxxxxxβ•²headβ•±β•²   body   β•±β•²tailβ•±xxxxxx
      ┐           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           
wire: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 └───────────

WaveDrom would usually render a PNG or SVG like the below:

However, PNGs can not be pasted into comments in your HDL project!

asciiwave requires the json5 library from PyPI, as a lot of WaveJSON samples floating around on the internet rely on non-vanilla-JSON features like unquoted keys, single-quoted strings and trailing commas. The jsonschema library is also required, for input validation. These can be obtained via:

$ pip3 install json5 jsonschema

asciiwave features a watch mode (-w), which will continously poll a file on disk, and redraw whenever the file changes. This can be used interactively alongside a text editor.

$ ./asciiwave --watch example/step4.json

             β”Œβ”€β”€β”  β”Œβ”€β”€β”  β”Œβ”€β”€β”  β”Œβ”€β”€β”  β”Œβ”€β”€β”  β”Œβ”€β”€β”  β”†β”Œβ”€β”€β”  β”Œβ”€β”€β”  β”Œβ”€β”€β”  
clk        : β”˜  β””β”€β”€β”˜  β””β”€β”€β”˜  β””β”€β”€β”˜  β””β”€β”€β”˜  β””β”€β”€β”˜  β””β”€β”€β”†β”˜  β””β”€β”€β”˜  β””β”€β”€β”˜  └──
             xxxxxxxxxxxxβ•±    β•²β•±    β•²β•±    β•²xxxxxx┆╱          β•²xxxxxx
Data       : xxxxxxxxxxxxβ•²headβ•±β•²bodyβ•±β•²tailβ•±xxxxxx┆╲   data   β•±xxxxxx
             ┐           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”†β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     
Request    : β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β””β”€β”€β”€β”€β”€β”†β”˜           └─────

             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”†β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
Acknowledge: β”˜                                   β”†β””β”€β”€β”€β”€β”€β”˜           

Watching file example/step4.json
Ctrl-C to exit

There are simple command-line options for formatting:

$ ./asciiwave --hscale=4 --graphics=tall example/step4.json
             β”Œβ”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”    β”†β”Œβ”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”    
             β”‚    β”‚    β”‚    β”‚    β”‚    β”‚    β”‚    β”‚    β”‚    β”‚    β”‚    β”‚    ┆│    β”‚    β”‚    β”‚    β”‚    β”‚    
clk        : β”˜    β””β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”†β”˜    β””β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”˜    └────
             xxxxxxxxxxxxxxxxxxxxβ•±        β•²β•±        β•²β•±        β•²xxxxxxxxxx┆╱                  β•²xxxxxxxxxx
             xxxxxxxxxxxxxxxxxxxx   head      body      tail   xxxxxxxxxx┆        data        xxxxxxxxxx
Data       : xxxxxxxxxxxxxxxxxxxxβ•²        β•±β•²        β•±β•²        β•±xxxxxxxxxx┆╲                  β•±xxxxxxxxxx
             ┐                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”†β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         
             β”‚                   β”‚                             β”‚         ┆│                   β”‚         
Request    : β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”†β”˜                   └─────────

             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”†β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
             β”‚                                                           ┆│         β”‚                   
Acknowledge: β”˜                                                           β”†β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   

$ ./asciiwave --hscale=1 --graphics=tiny example/step4.json
clk        : β”Œβ”€β”_β”Œβ”€β”_β”Œβ”€β”_β”Œβ”€β”_β”Œβ”€β”_β”Œβ”€β”_β”†β”Œβ”€β”_β”Œβ”€β”_β”Œβ”€β”_
Data       : xxxxxxxx<he><bo><ta>xxxx┆< data >xxxx
Request    : ┐_______β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”___β”†β”Œβ”€β”€β”€β”€β”€β”€β”€β”___

Acknowledge: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”†β”___β”Œβ”€β”€β”€β”€β”€β”€β”€

WaveJSON Subset

asciiwave does not implement the full gamut of WaveJSON features. It supports:

  • wave commands: 1hHu 0lLd pPnN =2345 zx |
  • The hscale config property: the width of each time unit is hscale * 2 + 2 characters. This is overridden by the --hscale command line parameter.
  • The period signal property: this can be a floating point number. The width of each wave time unit is multiplied by period and rounded down.
  • The phase signal property: this can be a floating point number. The signal is advanced (positive) or retarded (negative) by this number of periods.
  • The data signal property: either an array of strings, or a single string containing whitespace-separated values.

Graphics

asciiwave defines its graphics like this:

graphics_default = [
  "0+1-rfxz< >|UuDd",
  " β”Œβ”€β”β”β”“x_β•± ╲┆╭┄  ",
  "β”€β”˜ β””β”›β”—x β•² ╱┆  β•°β”„"
]

The first line is a key which maps asciiwave's internal representation of wire state to columns of the graphics; the following lines contain the actual graphics. These can be modified if you can't use the Unicode box drawing characters, or have found better-looking characters.

The height is not fixed at 2 lines; any positive number of lines will do. However, the width of each wire state is limited to one column, to simplify rendering (this will be fixed)

More Repositories

1

PicoDVI

Bitbanged DVI on the RP2040 Microcontroller
C
1,218
star
2

Hazard3

3-stage RV32IMACZb* processor with debug
Verilog
607
star
3

RISCBoy

Portable games console, designed from scratch: CPU, graphics, PCB, and the kitchen sink
C
246
star
4

Pico-DVI-Sock

A DVI Sock board for Pico
177
star
5

Ship-Sandbox

Sinking ship simulation written in C++
C++
81
star
6

PicoStation3D

3D games console based on RP2040 and iCE40 UP5k
C
45
star
7

libfpga

Reusable Verilog 2005 components for FPGA designs
Verilog
32
star
8

NorForkConditionally

What's the simplest CPU you can build?
C++
30
star
9

DVI-PMOD

DVI PMOD adapter (HDMI connector)
28
star
10

Snowflake-FPGA

A cheap iCE40 development board, designed on and for Raspberry Pi
Shell
26
star
11

SmolDVI

Low-area DVI experiment for iCE40 UP5k and HX1k FPGAs
Verilog
25
star
12

Hazard2

Smol 2-stage RISC-V processor in nMigen
Python
23
star
13

ChristmasSoC

Dual-core RISC-V SoC with JTAG, atomics, SDRAM
Verilog
23
star
14

OpenDAP

C++
20
star
15

Pi400-Pico-Plate

20
star
16

TwoWireDebug

Yet Another Debug Transport
Verilog
18
star
17

DOOMSoC

A SoC for DOOM
Verilog
15
star
18

Hazard5

5-stage RISC-V CPU, originally developed for RISCBoy
Verilog
14
star
19

FibreOpticFPGA

Line coding and clock recovery for a fibre optic link, running on a Spartan 6 FPGA
Verilog
10
star
20

HyperRam

simple hyperram controller
Verilog
9
star
21

Bico

Dual-RP2040 development board with built-in debug
8
star
22

PiBook

RPi Compute Module-based tiny laptop
KiCad Layout
8
star
23

Hazard3-SWD-SoC

Example Hazard3 + OpenDAP RISC-V SWD SoC integration
Verilog
6
star
24

OpenILA

Internal Logic Analyser for FPGA Projects
SMT
5
star
25

fpgascripts

Loose collection of scripts for FPGA work
Python
5
star
26

Procedural-Grapher

Draws pretty 3D graphs, and interprets a scripting language. My first C++ project
C++
4
star
27

rvcpp

C++
4
star
28

shadertoy

C++
4
star
29

picosystem-experiments

C
3
star
30

bloxelcraft

C++
3
star
31

GuitarPedal

Open-source guitar effects processor
Eagle
2
star
32

Mars-Lander

Simulation of the physics and control of a Mars lander
C++
2
star
33

cpplisp

Another simple Lisp interpreter - in C++ this time :)
C++
2
star
34

Multimeter

open-source multimeter, logic analyser and TV remote
C++
2
star
35

CQCAD

Monorepo for a random selection of parts designed in CadQuery
Python
2
star
36

Hazard1

Minimal RV32I processor with register file in RAM
Verilog
2
star
37

micro

Arduino, AVRs and PICs, who knows what else
Arduino
1
star
38

scripts

Useful and pointless scripts (i.e. all of them)
Python
1
star
39

terrain

C++
1
star
40

jslisp

javascript lisp interpreter
1
star
41

shinyrobots

C++
1
star
42

gameboy

A gameboy emulator written in C (eventually!)
C
1
star
43

ComputeModuleBootInstaller

NSIS installer for Raspberry Pi Compute Module boot flasher
NSIS
1
star