### Install wavedrompy Source: https://context7.com/wallento/wavedrompy/llms.txt Install wavedrompy using pip. Development installations include test dependencies. ```bash pip install wavedrom # Or from source pip install git+https://github.com/wallento/wavedrompy # For development with test dependencies pip install "wavedrom[test]" ``` -------------------------------- ### VHDL Syntax Coloring Example Source: https://github.com/wallento/wavedrompy/blob/master/asciidoctor-example/example.adoc Demonstrates VHDL syntax highlighting. This snippet is useful for understanding how VHDL code is presented with different colors for keywords, signals, and comments. ```vhdl proc_column_counter : process ( reset, clk ) begin if reset = '1' then col <= 0; elsif rising_edge( clk ) then if enable then if sink_endofpacket = '1' then col <= 0; elsif col = g_width - g_data_size / c_pixel_size then col <= 0; else col <= col + g_data_size / c_pixel_size; end if; end if; end if; end process proc_column_counter; ``` -------------------------------- ### Register Description Example Source: https://github.com/wallento/wavedrompy/blob/master/asciidoctor-example/example.html Describes register fields for a timing diagram, including address, bits, field name, access type, and description. ```text Address Bits Field Name Access Description 0x00000000 31:24 NU RO Not used. 23:16 VMAJ RO Version major. 15:8 VMIN RO Version minor. 7:0 VPATCH RO Version patch. 0x00000004 31:16 STATUS RO Status bits. 15 PLL_LOCKED RO PLL locked. 14 DDR_INIT_DONE RO DDR Init_done. 13:12 NU RO Not used. 11:8 GROUP_0_INTR R/W Group #0 interrupt requests. 7:4 GROUP_1_INTR R/W Group #1 interrupt requests. 3:0 GROUP_2_INTR R/W Group #2 interrupt requests. ``` -------------------------------- ### Signal Description Example Source: https://github.com/wallento/wavedrompy/blob/master/asciidoctor-example/example.html Defines signals for a timing diagram, including their name, type, and a brief description. ```text Signal name Type Description clk in Clk input reset in Reset address in Address bus read in Read signal readdata out Read data bus readvalid out Read valid signal write in Write signal writedata in Write data bus ``` -------------------------------- ### Configure Signal Waveform Rendering and Add Annotations Source: https://context7.com/wallento/wavedrompy/llms.txt Applies rendering parameters like horizontal scale and skin, and adds text annotations to the head and foot of the waveform diagram. Text supports rich formatting. ```python import wavedrom svg = wavedrom.render(""" { \"signal\": [ {\"name\": \"clk\", \"wave\": \"p....\"}, {\"name\": \"data\", \"wave\": \"x345x\", \"data\": [\"head\", \"body\", \"tail\"]}, {\"name\": \"Request\", \"wave\": \"01..0\"} ], \"config\": { \"hscale\": 2, \"skin\": \"narrow\" }, \"head\": { \"text\": [\"tspan\", [\"tspan\", {\"class\": \"h1\"}, \"DDR \"], [\"tspan\", {\"class\": \"info\"}, \"Read Transaction\"] ], \"tick\": 0 }, \"foot\": { \"text\": \"Figure 1: Bus Protocol\", \"tock\": 0 } } """) svg.saveas("annotated_waveform.svg") ``` -------------------------------- ### Render WaveDrom JSON to SVG using wavedrom.render() Source: https://context7.com/wallento/wavedrompy/llms.txt The primary entry point accepts JSON describing a signal waveform, logic assignment, or register bitfield. It auto-detects the diagram type and returns an svgwrite.Drawing object. ```python import wavedrom # Timing waveform with clock, bus, and data signals svg = wavedrom.render(""" { "signal": [ { "name": "clk", "wave": "P......" }, { "name": "bus", "wave": "x.==.=x", "data": ["head", "body", "tail", "data"] }, { "name": "wire", "wave": "0.1..0." } ] } """) svg.saveas("timing.svg") # Logic circuit (XOR from AND/OR/NOT gates) svg2 = wavedrom.render(""" { "assign": [ ["out", ["|", ["&", ["~", "a"], "b"], ["&", ["~", "b"], "a"] ] ] ] } """) svg2.saveas("xor_circuit.svg") # Register bitfield layout svg3 = wavedrom.render(""" { "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 } ] } """) svg3.saveas("register.svg") ``` -------------------------------- ### Sphinxcontrib-WaveDrom Configuration Source: https://context7.com/wallento/wavedrompy/llms.txt Configure `sphinxcontrib-wavedrom` for rendering WaveDrom diagrams within Sphinx documentation. Set `wavedrom_html_jsinline = False` to use WaveDromPy as the server-side rendering backend. ```python # sphinxcontrib-wavedrom usage: conf.py extensions = ["sphinxcontrib.wavedrom"] wavedrom_html_jsinline = False # Use server-side Python rendering via wavedrompy # In your .rst file: # .. wavedrom:: # # { "signal": [{ "name": "clk", "wave": "p...." }] } ``` -------------------------------- ### Generate 64-bit Register Diagram with Config Options Source: https://context7.com/wallento/wavedrompy/llms.txt This snippet shows how to define a multi-lane 64-bit register with specific attributes and configuration options using WaveDrom's JSON format. ```python import wavedrom svg2 = wavedrom.render(""" { \"reg\": [ { \"name\": \"data\", \"bits\": 32, \"attr\": [\"RW\", \"reset: 0x0000\"] }, { \"name\": \"addr\", \"bits\": 16, \"attr\": \"RO\", \"type\": 2 }, { \"name\": \"ctrl\", \"bits\": 8, \"attr\": \"RW\", \"type\": 5 }, { \"name\": \"flags\", \"bits\": 8, \"attr\": \"RW\", \"type\": 3 } ], \"config\": { \"hspace\": 1000, \"lanes\": 2, \"bits\": 64, \"vspace\": 100, \"fontsize\": 12 } } """) svg2.saveas("register_64bit.svg") ``` -------------------------------- ### Render WaveDrom JSON directly from and to file paths Source: https://context7.com/wallento/wavedrompy/llms.txt A convenience wrapper to open source and output files by path, render the diagram, and close both files. Supports `strict_js_features` for exact upstream JavaScript CLI output. ```python import wavedrom # Basic file-to-file render wavedrom.render_file("input/signal.json", "output/signal.svg") # With strict JS compatibility (disables Python-only label features) wavedrom.render_file( "test/files/tutorial_5.json", "output/tutorial_5.svg", strict_js_features=True ) ``` -------------------------------- ### Create Logic Circuit Diagrams with Basic and IEC Gates Source: https://context7.com/wallento/wavedrompy/llms.txt Generates logic circuit diagrams using the 'assign' key with nested arrays representing logic expressions. Supports basic gate symbols and standard IEC 60617 symbols. ```python import wavedrom # XOR from basic gates svg = wavedrom.render(""" { \"assign\": [ [\"out\", [\"|\", [\"&\", [\"~\", \"a\"], \"b\"], [\"&\", [\"~\", \"b\"], \"a\"] ] ] ]} """) svg.saveas("xor_from_gates.svg") # IEC 60617 standard gate symbols svg2 = wavedrom.render(""" { \"assign\": [ [\"z\", [\"XOR\", [\"AND\", \"a\", \"b\"], [\"INV\", \"c\"] ] ] ]} """) svg2.saveas("iec_gates.svg") ``` -------------------------------- ### wavedrom.render_file() Source: https://context7.com/wallento/wavedrompy/llms.txt A convenience wrapper for rendering diagrams directly from and to file paths. It opens the source JSON file and output SVG file by path, performs the rendering, and closes both files. ```APIDOC ## wavedrom.render_file() ### Description Convenience wrapper that opens the source JSON file and output SVG file by path, renders the diagram, and closes both. Supports `strict_js_features` to match the upstream JavaScript CLI output exactly for regression testing. ### Parameters - **input_path** (str) - Required - The file path to the input WaveDrom JSON file. - **output_path** (str) - Required - The file path where the output SVG file will be saved. - **strict_js_features** (bool) - Optional - If True, disables Python-only extensions like inline signal labels to match the original JavaScript WaveDrom behavior. ### Request Example ```python import wavedrom # Basic file-to-file render wavedrom.render_file("input/signal.json", "output/signal.svg") # With strict JS compatibility (disables Python-only label features) wavedrom.render_file( "test/files/tutorial_5.json", "output/tutorial_5.svg", strict_js_features=True ) ``` ``` -------------------------------- ### Low-level BitField Renderer for Programmatic Register Diagrams Source: https://context7.com/wallento/wavedrompy/llms.txt Use the `BitField.render()` method for direct programmatic generation of register diagrams. It accepts a list of field descriptors and an `Options` object. Ensure fields have 'name' and 'bits' keys. ```python from wavedrom.bitfield import BitField, Options fields = [ {"name": "VERSION", "bits": 8, "attr": "RO"}, {"name": "STATUS", "bits": 4, "attr": "RO", "type": 2}, {"name": "CTRL", "bits": 4, "attr": "RW", "type": 5}, { "bits": 16}, ] opt = Options( vspace=100, hspace=800, lanes=1, bits=32, hflip=False, vflip=False, fontsize=14, fontfamily="sans-serif", fontweight="normal", ) svg = BitField().render(fields, opt) svg.saveas("status_register.svg") print(f"SVG size: {svg['width']}x{svg['height']}") ``` -------------------------------- ### Render Register Bitfields in Python Source: https://github.com/wallento/wavedrompy/blob/master/README.md Create SVG representations of register bitfields using `wavedrom.render` with a JSON input that defines register names, bit counts, and attributes. The resulting SVG can be saved to a file. This is useful for documenting hardware registers. ```python import wavedrom svg = wavedrom.render( {"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 } ] } ) svg.saveas("demo3.svg") ``` -------------------------------- ### Convert JSON to SVG via Command Line Source: https://github.com/wallento/wavedrompy/blob/master/README.md Use the `wavedrompy` command-line tool to convert an input JSON file to an SVG output file. This method is an alternative to using the Python API for generating diagrams. ```bash wavedrompy --input input.json --svg output.svg ``` -------------------------------- ### AsciiDoctor Integration for WaveDrom Diagrams Source: https://context7.com/wallento/wavedrompy/llms.txt Integrate WaveDromPy with AsciiDoctor documents using shell scripts. The `wavedrompy` CLI can be used as a block macro processor to convert WaveDrom JSON blocks into inline SVG. ```bash # asciidoctor-html.sh pattern: extract wavedrom blocks and replace with SVG # In your .adoc file, use the wavedrom block macro: # [wavedrom,output_filename,svg] # ---- # { "signal": [{ "name": "clk", "wave": "p...." }] } # ---- # Generate HTML output with embedded SVGs asciidoctor \ -r asciidoctor-diagram \ -a wavedrom-path="$(which wavedrompy)" \ example.adoc \ -o example.html # Generate PDF output asciidoctor-pdf \ -r asciidoctor-diagram \ -a wavedrom-path="$(which wavedrompy)" \ example.adoc \ -o example.pdf ``` -------------------------------- ### WaveDrom.render_waveform() Source: https://context7.com/wallento/wavedrompy/llms.txt Provides direct access to the core waveform renderer. It takes a pre-parsed source dictionary, an index for multi-diagram SVG embedding, and an optional output list. This is useful for integrating WaveDromPy into larger SVG composition pipelines. ```APIDOC ## `WaveDrom.render_waveform()` — Low-level waveform renderer Direct access to the core waveform renderer. Takes a pre-parsed source dict, an index (for multi-diagram SVG embedding), and an optional output list. Useful when integrating WaveDromPy into larger SVG composition pipelines. ```python import json from wavedrom.waveform import WaveDrom source = json.loads(""" { "signal": [ { "name": "clk", "wave": "p...." }, { "name": "data", "wave": "x345x", "data": ["head", "body", "tail"] }, { "name": "Request", "wave": "01..0" } ], "config": { "hscale": 2 } } """) renderer = WaveDrom() svg = renderer.render_waveform(index=0, source=source, strict_js_features=False) svg.saveas("waveform_direct.svg") print(f"Viewbox: {svg.viewbox}") ``` ``` -------------------------------- ### WaveDrom Signals with Data and Control Source: https://github.com/wallento/wavedrompy/blob/master/asciidoctor-example/example.adoc Combines signal waveforms with data and control signals, including timing markers. Useful for detailed protocol analysis. ```json { "signal": [ { "name": "clk", "wave": "p.....|..." }, { "name": "data", "wave": "x.345x|=.x", "data": ["head", "body", "tail", "data"] }, { "name": "Request", "wave": "0.1..0|1.0" }, {}, { "name": "Acknowledge", "wave": "1.....|01." } ]} ``` -------------------------------- ### Use wavedrompy CLI to convert JSON to SVG Source: https://context7.com/wallento/wavedrompy/llms.txt The `wavedrompy` CLI command reads a WaveDrom JSON file and writes the SVG output to a file or stdout. It requires strict JSON formatting. ```bash # Write SVG to a file wavedrompy --input signal.json --svg output.svg # Short flags wavedrompy -i signal.json -s output.svg # Write SVG to stdout (default when --svg is omitted) wavedrompy --input signal.json > output.svg ``` -------------------------------- ### Render Logic Circuit Diagram in Python Source: https://github.com/wallento/wavedrompy/blob/master/README.md Generate SVG for logic circuit diagrams by passing a JSON string defining the circuit to `wavedrom.render`. The `saveas` method is used to persist the output to an SVG file. This functionality is useful for visualizing boolean logic. ```python import wavedrom svg = wavedrom.render( { "assign":[ ["out", ["|", ["&", ["~", "a"], "b"], ["&", ["~", "b"], "a"] ] ] ]} ) svg.saveas("demo2.svg") ``` -------------------------------- ### BitField.render() Source: https://context7.com/wallento/wavedrompy/llms.txt Directly renders a bitfield diagram from a list of field descriptors and options. This is a low-level renderer for programmatic register diagram generation. ```APIDOC ## `BitField.render()` — Low-level bitfield renderer Direct access to the `BitField` renderer for programmatic register diagram generation. Accepts a pre-parsed list of field descriptors and an `Options` object. Each descriptor must have `"name"` and `"bits"` keys; `"attr"`, `"type"` are optional. ```python from wavedrom.bitfield import BitField, Options fields = [ {"name": "VERSION", "bits": 8, "attr": "RO"}, {"name": "STATUS", "bits": 4, "attr": "RO", "type": 2}, {"name": "CTRL", "bits": 4, "attr": "RW", "type": 5}, { "bits": 16}, ] opt = Options( vspace=100, hspace=800, lanes=1, bits=32, hflip=False, vflip=False, fontsize=14, fontfamily="sans-serif", fontweight="normal", ) svg = BitField().render(fields, opt) svg.saveas("status_register.svg") print(f"SVG size: {svg['width']}x{svg['height']}") # SVG size: 809x105 ``` ``` -------------------------------- ### wavedrom.render() Source: https://context7.com/wallento/wavedrompy/llms.txt The primary entry point for rendering WaveDrom diagrams. It accepts a JSON or YAML-compatible string, auto-detects the diagram type, and returns a svgwrite.Drawing object. The optional strict_js_features flag can be used to disable Python-only extensions. ```APIDOC ## wavedrom.render() ### Description Accepts a JSON string (or YAML-compatible string) describing a signal waveform, logic assignment, or register bitfield. Automatically detects the diagram type via the top-level key ("signal", "assign", or "reg") and returns a `svgwrite.Drawing` object. The optional `strict_js_features` flag disables Python-only extensions like inline signal labels. ### Parameters - **json_string** (str) - Required - A string containing the WaveDrom diagram description in JSON or YAML format. - **strict_js_features** (bool) - Optional - If True, disables Python-only extensions like inline signal labels to match the original JavaScript WaveDrom behavior. ### Request Example ```python import wavedrom # Timing waveform example svg = wavedrom.render(""" { "signal": [ { "name": "clk", "wave": "P......" }, { "name": "bus", "wave": "x.==.=x", "data": ["head", "body", "tail", "data"] }, { "name": "wire", "wave": "0.1..0." } ] } """) svg.saveas("timing.svg") # Logic circuit example svg2 = wavedrom.render(""" { "assign": [ ["out", ["|", ["&", ["~", "a"], "b"], ["&", ["~", "b"], "a"] ] ] ] } """) svg2.saveas("xor_circuit.svg") # Register bitfield layout example svg3 = wavedrom.render(""" { "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 } ] } """) svg3.saveas("register.svg") ``` ### Response - **svgwrite.Drawing** - A `svgwrite.Drawing` object representing the generated SVG diagram. ``` -------------------------------- ### WaveDrom with Horizontal Scale Configuration Source: https://github.com/wallento/wavedrompy/blob/master/asciidoctor-example/example.adoc Adjusts the horizontal scaling of the diagram. Use 'hscale' to control the width of each time unit. ```json { "signal": [ { "name": "clk", "wave": "p...." }, { "name": "data", "wave": "x345x", "data": ["head", "body", "tail"] }, { "name": "Request", "wave": "01..0" } ], "config": { "hscale": 1 } } ``` -------------------------------- ### Low-level Waveform Renderer for SVG Composition Source: https://context7.com/wallento/wavedrompy/llms.txt The `WaveDrom.render_waveform()` method provides direct access to the waveform renderer. It's useful for integrating WaveDromPy into larger SVG composition pipelines. The `source` must be a pre-parsed dictionary. ```python import json from wavedrom.waveform import WaveDrom source = json.loads(""" { \"signal\": [ { \"name\": \"clk\", \"wave\": \"p....\" }, { \"name\": \"data\", \"wave\": \"x345x\", \"data\": [\"head\", \"body\", \"tail\"] }, { \"name\": \"Request\", \"wave\": \"01..0\" } ], \"config\": { \"hscale\": 2 } } """) renderer = WaveDrom() svg = renderer.render_waveform(index=0, source=source, strict_js_features=False) svg.saveas("waveform_direct.svg") print(f"Viewbox: {svg.viewbox}") ``` -------------------------------- ### Define Hardware Register Bitfield Layouts Source: https://context7.com/wallento/wavedrompy/llms.txt Describes hardware register fields with names, bit widths, and attributes. Supports basic layout and configuration options for spacing, lanes, and orientation. ```python import wavedrom # Basic register layout svg = wavedrom.render(""" { \"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 } ]} """) svg.saveas("register_basic.svg") ``` -------------------------------- ### Default WaveDrom Signals Source: https://github.com/wallento/wavedrompy/blob/master/asciidoctor-example/example.adoc Illustrates multiple signals with various waveform patterns and states. Suitable for complex timing diagrams. ```json { "signal": [ { "name": "pclk", "wave": "p......." }, { "name": "Pclk", "wave": "P......." }, { "name": "nclk", "wave": "n......." }, { "name": "Nclk", "wave": "N......." }, {}, { "name": "clk0", "wave": "phnlPHNL" }, { "name": "clk1", "wave": "xhlhLHl." }, { "name": "clk2", "wave": "hpHplnLn" }, { "name": "clk3", "wave": "nhNhplPl" }, { "name": "clk4", "wave": "xlh.L.Hx" } ]} ``` -------------------------------- ### WaveDrom with Head and Foot Text Source: https://github.com/wallento/wavedrompy/blob/master/asciidoctor-example/example.adoc Adds custom text to the header and footer of the diagram. Useful for titles, labels, and figure numbers. ```json {"signal": [ {"name":"clk", "wave": "p...." }, {"name":"data", "wave": "x345x", "data": "a b c" }, {"name":"Request", "wave": "01..0" } ], "head":{ "text":"WaveDrom example", "tick":0 }, "foot":{ "text":"Figure 100", "tock":9 } } ``` -------------------------------- ### wavedrom.render_write() Source: https://context7.com/wallento/wavedrompy/llms.txt Renders a WaveDrom diagram from a file-like object and writes the resulting SVG directly to an output file-like object. This is useful for streaming pipelines or in-memory transformations. ```APIDOC ## wavedrom.render_write() ### Description Reads a WaveDrom JSON source from a file-like object, renders it, and writes the resulting SVG directly to an output file-like object. Useful for streaming pipelines or in-memory transformations. ### Parameters - **input_stream** (file-like object) - Required - An object with a `read()` method, containing the WaveDrom diagram description. - **output_stream** (file-like object) - Required - An object with a `write()` method, where the generated SVG will be written. ### Request Example ```python import wavedrom import io source_json = """ { "signal": [ { "name": "CK", "wave": "P.......", "period": 2 }, { "name": "CMD", "wave": "x.3x=x4x=x=x=x=x", "data": "RAS NOP CAS NOP NOP NOP NOP", "phase": 0.5 }, { "name": "ADDR", "wave": "x.=x..=x........", "data": "ROW COL", "phase": 0.5 }, { "name": "DQS", "wave": "z.......0.1010z." }, { "name": "DQ", "wave": "z.........5555z.", "data": "D0 D1 D2 D3" } ] } """ input_stream = io.StringIO(source_json) output_stream = open("ddr_timing.svg", "w") wavedrom.render_write(input_stream, output_stream) output_stream.close() ``` ``` -------------------------------- ### Narrow Skin WaveDrom Signals Source: https://github.com/wallento/wavedrompy/blob/master/asciidoctor-example/example.adoc Renders signals using the 'narrow' skin configuration for a more compact display. Useful when space is limited. ```json { "signal": [ { "name": "pclk", "wave": "p......." }, { "name": "Pclk", "wave": "P......." }, { "name": "nclk", "wave": "n......." }, { "name": "Nclk", "wave": "N......." }, {}, { "name": "clk0", "wave": "phnlPHNL" }, { "name": "clk1", "wave": "xhlhLHl." }, { "name": "clk2", "wave": "hpHplnLn" }, { "name": "clk3", "wave": "nhNhplPl" }, { "name": "clk4", "wave": "xlh.L.Hx" } ], "config": { "skin": "narrow" } } ``` -------------------------------- ### Render WaveDrom JSON from file object to output stream Source: https://context7.com/wallento/wavedrompy/llms.txt Reads WaveDrom JSON from a file-like object, renders it, and writes the SVG directly to an output file-like object. Useful for streaming pipelines. ```python import wavedrom import io source_json = """ { "signal": [ { "name": "CK", "wave": "P.......", "period": 2 }, { "name": "CMD", "wave": "x.3x=x4x=x=x=x=x", "data": "RAS NOP CAS NOP NOP NOP NOP", "phase": 0.5 }, { "name": "ADDR", "wave": "x.=x..=x........", "data": "ROW COL", "phase": 0.5 }, { "name": "DQS", "wave": "z.......0.1010z." }, { "name": "DQ", "wave": "z.........5555z.", "data": "D0 D1 D2 D3" } ] } """ input_stream = io.StringIO(source_json) output_stream = open("ddr_timing.svg", "w") wavedrom.render_write(input_stream, output_stream) output_stream.close() ``` -------------------------------- ### Annotate Signal Waveforms with Edge Arrows and Labels Source: https://context7.com/wallento/wavedrompy/llms.txt Adds named event nodes to signal lanes and connects them with labeled arrows using the 'edge' key. Supports various arrow styles and text labels for timing annotations. ```python import wavedrom svg = wavedrom.render(""" { \"signal\": [ { \"name\": \"A\", \"wave\": \"01........0....\", \"node\": \".a........j\" }, { \"name\": \"B\", \"wave\": \"0.1.......0.1..\", \"node\": \"..b.......i\" }, { \"name\": \"C\", \"wave\": \"0..1....0...1..\", \"node\": \"...c....h..\" }, { \"name\": \"D\", \"wave\": \"0...1..0.....1.\", \"node\": \"....d..g...\" }, { \"name\": \"E\", \"wave\": \"0....10.......1\", \"node\": \".....ef....\" } ], \"edge\": [ \"a~b t1\", \"c-~a t2\", \"c-~>d time 3\", \"d~-e\", \"e~>f\", \"f->g\", \"g-~>h\", \"h~>i some text\", \"h~->j\" ]} """) svg.saveas("timing_with_arcs.svg") ``` -------------------------------- ### Generate Signal Waveforms with Basic and Grouped Lanes Source: https://context7.com/wallento/wavedrompy/llms.txt Defines signal waveforms using characters for logic states and bus labels. Supports grouping signals into master/slave structures for complex bus transactions. ```python import wavedrom svg = wavedrom.render(""" { \"signal\": [ { \"name\": \"pclk\", \"wave\": \"p.......\" }, { \"name\": \"Pclk\", \"wave\": \"P.......\" }, { \"name\": \"nclk\", \"wave\": \"n.......\" }, {}, { \"name\": \"clk0\", \"wave\": \"phnlPHNL\" }, { \"name\": \"clk1\", \"wave\": \"xhlhLHl.\" }, { \"name\": \"clk2\", \"wave\": \"hpHplnLn\" } ]} """) svg.saveas("clocks.svg") # Grouped signals with master/slave structure svg2 = wavedrom.render(""" { \"signal\": [ { \"name\": \"clk\", \"wave\": \"p..Pp..P\"}, [\"Master\", [\"ctrl\", {\"name\": \"write\", \"wave\": \"01.0....\"}, {\"name\": \"read\", \"wave\": \"0...1..0\"} ], {\"name\": \"addr\", \"wave\": \"x3.x4..x\", \"data\": \"A1 A2\"}, {\"name\": \"wdata\", \"wave\": \"x3.x....\", \"data\": \"D1\"} ], {}, [\"Slave\", [\"ctrl\", {\"name\": \"ack\", \"wave\": \"x01x0.1x\"} ], {\"name\": \"rdata\", \"wave\": \"x.....4x\", \"data\": \"Q2\"} ] ]} """) svg2.saveas("bus_transaction.svg") ``` -------------------------------- ### Basic WaveDrom Signal Source: https://github.com/wallento/wavedrompy/blob/master/asciidoctor-example/example.adoc Defines a single signal with a simple waveform pattern. Useful for basic signal visualization. ```json { "signal": [{ "name": "Alfa", "wave": "01.zx=ud.23.45" }] } ``` -------------------------------- ### Wavedrom Signal and Edge Definition with Phase Source: https://github.com/wallento/wavedrompy/blob/master/asciidoctor-example/example.adoc Defines signals with waveforms, nodes, and edges, including phase offsets for signals. Useful for visualizing signals with specific timing relationships. ```json { "signal": [ { "name": "A", "wave": "01..0..", "node": ".a..e.." }, { "name": "B", "wave": "0.1..0.", "node": "..b..d.", "phase":0.5 }, { "name": "C", "wave": "0..1..0", "node": "...c..f" }, { "node": "...g..h" } ], "edge": [ "b-|a t1", "a-|c t2", "b-|-c t3", "c-|->e t4", "e-|>f more text", "e|->d t6", "c-g", "f-h", "g<->h 3 ms" ] } ``` -------------------------------- ### wavedrom.render() Source: https://context7.com/wallento/wavedrompy/llms.txt A high-level function to render WaveDrom diagrams from a JSON string. It handles the parsing of the JSON and the generation of the SVG output. ```APIDOC # Multi-lane 64-bit register with config options svg2 = wavedrom.render(""" { "reg": [ { "name": "data", "bits": 32, "attr": ["RW", "reset: 0x0000"] }, { "name": "addr", "bits": 16, "attr": "RO", "type": 2 }, { "name": "ctrl", "bits": 8, "attr": "RW", "type": 5 }, { "name": "flags", "bits": 8, "attr": "RW", "type": 3 } ], "config": { "hspace": 1000, "lanes": 2, "bits": 64, "vspace": 100, "fontsize": 12 } } """) svg2.saveas("register_64bit.svg") ``` -------------------------------- ### WaveDrom Signals with Period and Phase Source: https://github.com/wallento/wavedrompy/blob/master/asciidoctor-example/example.adoc Specifies signal period and phase for precise timing control. Useful for DDR or complex clocking schemes. ```json { "signal": [ { "name": "CK", "wave": "P.......", "period": 2 }, { "name": "CMD", "wave": "x.3x=x4x=x=x=x=x", "data": "RAS NOP CAS NOP NOP NOP NOP", "phase": 0.5 }, { "name": "ADDR", "wave": "x.=x..=x........", "data": "ROW COL", "phase": 0.5 }, { "name": "DQS", "wave": "z.......0.1010z." }, { "name": "DQ", "wave": "z.........5555z.", "data": "D0 D1 D2 D3" } ]} ``` -------------------------------- ### Render Waveform Diagram in Python Source: https://github.com/wallento/wavedrompy/blob/master/README.md Use the `wavedrom.render` function to convert a JSON string defining a waveform into an SVG object. Save the SVG object to a file using the `saveas` method. Ensure the JSON is correctly formatted. ```python import wavedrom svg = wavedrom.render( { "signal": [ { "name": "CK", "wave": "P.......", "period": 2 }, { "name": "CMD", "wave": "x.3x=x4x=x=x=x=x", "data": "RAS NOP CAS NOP NOP NOP NOP", "phase": 0.5 }, { "name": "ADDR", "wave": "x.=x..=x........", "data": "ROW COL", "phase": 0.5 }, { "name": "DQS", "wave": "z.......0.1010z." }, { "name": "DQ", "wave": "z.........5555z.", "data": "D0 D1 D2 D3" } ]} ) svg.saveas("demo1.svg") ``` -------------------------------- ### WaveDrom with Increased Horizontal Scale Source: https://github.com/wallento/wavedrompy/blob/master/asciidoctor-example/example.adoc Demonstrates a larger horizontal scale for better readability of dense waveforms. 'hscale' values greater than 1 expand the diagram. ```json { "signal" : [ { "name": "clk", "wave": "p...." }, { "name": "data", "wave": "x345x", "data": ["head", "body", "tail"] }, { "name": "Request", "wave": "01..0" } ], "config" : { "hscale" : 2 } } ``` -------------------------------- ### WaveDrom Signals with Data Source: https://github.com/wallento/wavedrompy/blob/master/asciidoctor-example/example.adoc Includes data values associated with specific points on a signal. Ideal for showing bus transactions. ```json { "signal": [ { "name": "clk", "wave": "P......" }, { "name": "bus", "wave": "x.==.=x", "data": ["head", "body", "tail", "data"] }, { "name": "wire", "wave": "0.1..0." } ]} ``` -------------------------------- ### WaveDrom with Maximum Horizontal Scale Source: https://github.com/wallento/wavedrompy/blob/master/asciidoctor-example/example.adoc Shows the maximum horizontal scaling effect. 'hscale' set to 3 provides the widest representation for each time unit. ```json { "signal" : [ { "name": "clk", "wave": "p...." }, { "name": "data", "wave": "x345x", "data": ["head", "body", "tail"] }, { "name": "Request", "wave": "01..0" } ], "config" : { "hscale" : 3 } } ``` -------------------------------- ### WaveDrom with Formatted Head Text Source: https://github.com/wallento/wavedrompy/blob/master/asciidoctor-example/example.adoc Utilizes tspan elements to apply different styles and formatting to header text. Supports various text styles and colors. ```json {"signal": [ {"name":"clk", "wave": "p.....PPPPp...." }, {"name":"dat", "wave": "x....2345x.....", "data": "a b c d" }, {"name":"req", "wave": "0....1...0....." } ], "head": {"text": ["tspan", ["tspan", {"class":"error h1"}, "error "], ["tspan", {"class":"warning h2"}, "warning "], ["tspan", {"class":"info h3"}, "info "], ["tspan", {"class":"success h4"}, "success "], ["tspan", {"class":"muted h5"}, "muted "], ["tspan", {"class":"h6"}, "h6 "], "default ", ["tspan", {"fill":"pink", "font-weight":"bold", "font-style":"italic"}, "pink-bold-italic"] ] }, "foot": {"text": ["tspan", "E=mc", ["tspan", {"dy":"-5"}, "2"], ["tspan", {"dy": "5"}, ". "], ["tspan", {"font-size":"25"}, "B "], ["tspan", {"text-decoration":"overline"},"over "], ["tspan", {"text-decoration":"underline"},"under "] ] } } ``` -------------------------------- ### Wavedrom Signal and Edge Definition Source: https://github.com/wallento/wavedrompy/blob/master/asciidoctor-example/example.adoc Defines signals with their waveforms and nodes, along with edges connecting these nodes with timing information. Useful for creating complex timing diagrams. ```json { "signal": [ { "name": "A", "wave": "01........0....", "node": ".a........j" }, { "name": "B", "wave": "0.1.......0.1..", "node": "..b.......i" }, { "name": "C", "wave": "0..1....0...1..", "node": "...c....h.." }, { "name": "D", "wave": "0...1..0.....1.", "node": "....d..g..." }, { "name": "E", "wave": "0....10.......1", "node": ".....ef...." } ], "edge": [ "a~b t1", "c-~a t2", "c-~>d time 3", "d~-e", "e~>f", "f->g", "g-~>h", "h~>i some text", "h~->j" ] } ``` -------------------------------- ### Nested WaveDrom Signals Source: https://github.com/wallento/wavedrompy/blob/master/asciidoctor-example/example.adoc Defines hierarchical signals, grouping related signals under a common label. Useful for representing complex interfaces. ```json { "signal": [ { "name": "clk", "wave": "p..Pp..P"}, ["Master", ["ctrl", {"name": "write", "wave": "01.0...."}, {"name": "read", "wave": "0...1..0"} ], { "name": "addr", "wave": "x3.x4..x", "data": "A1 A2"}, { "name": "wdata", "wave": "x3.x....", "data": "D1" } ], {}, ["Slave", ["ctrl", {"name": "ack", "wave": "x01x0.1x"} ], { "name": "rdata", "wave": "x.....4x", "data": "Q2"} ] ]} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.