wifasoi / WaveDromTikZ

An implementation of WaveDrom which outputs TikZ for use in LaTeX documents.
MIT License
41 stars 5 forks source link

Bitfield draw error #5

Open yarkomar18 opened 1 week ago

yarkomar18 commented 1 week ago

Bitfield can’t be drawn, the script gives an error :(

[
    { "name": "IPO",   "bits": 8, "attr": "RO" },
    {                  "bits": 7 },
    { "name": "BRK",   "bits": 5, "attr": "RW", "type": 4 },
    { "name": "CPK",   "bits": 1 },
    { "name": "Clear", "bits": 3 },
    { "bits": 8 }
]

./wavedromtikz.py wavedrom bitfield.drom

Traceback (most recent call last):
  File "./wavedromtikz.py", line 875, in <module>
    args.func(args)
  File "./wavedromtikz.py", line 836, in print_render_wavedrom
    wavedrom = render_wavedrom(yaml.safe_load(input_file.read()))
  File "./wavedromtikz.py", line 817, in render_wavedrom
    hscale = wavedrom.get("config", {}).get("hscale",1)
AttributeError: 'list' object has no attribute 'get'

But simple timing diagrams with no problem, thank you very much for that!

wifasoi commented 1 week ago

Your wavedrom definition is not correct (quickly checked via: https://wavedrom.com/editor.html). it should be:

{ reg:[
    { "name": "IPO",   "bits": 8, "attr": "RO" },
    {                  "bits": 7 },
    { "name": "BRK",   "bits": 5, "attr": "RW", "type": 4 },
    { "name": "CPK",   "bits": 1 },
    { "name": "Clear", "bits": 3 },
    { "bits": 8 }
]}

So I'm expect a dictionary, and you gave me a list.. so the code will trow a fit at you when try to fetch the config :D As this is just a simple script, I don't do a formatting check on the wavedrom input (I should but I don't have much time now). Anywhay I'll leave this issue open as a todo.