Repository navigation
Expand file tree
/
Copy pathtutorial.html
More file actions
116 lines (115 loc) · 27.3 KB
/
Copy pathtutorial.html
File metadata and controls
116 lines (115 loc) · 27.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hitchhiker's Guide to the WaveDrom (signal)</title>
<meta name="description" content="Interactive WaveDrom tutorial covering timing diagrams, clocks, groups, period/phase, arrows, and programmatic JavaScript WaveJSON.">
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="icon" type="image/svg+xml" href="images/favicon.svg">
<script>(function(){var d=document.documentElement,q=new URLSearchParams(location.search),t=q.get("theme");try{t=t||localStorage.getItem("wavedrom-ds-theme")}catch(e){}if(t==="light"||t==="dark")d.dataset.theme=t})();</script>
<link rel="preload" href="assets/fonts/jura-latin-700-normal.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="assets/fonts/pt-sans-latin-400-normal.woff2" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="assets/css/zelenograd-fonts.css">
<link rel="stylesheet" href="assets/css/zelenograd.css">
<link rel="stylesheet" href="assets/css/codemirror.css">
<link rel="stylesheet" href="assets/css/zelenograd.style.css">
<link rel="stylesheet" href="assets/css/site.css">
<script src="skins/default.js"></script>
<script src="skins/dark.js"></script>
<script src="skins/narrow.js"></script>
<script src="skins/lowkey.js"></script>
<script src="wavedrom.min.js"></script>
<script defer src="assets/js/site.js"></script>
</head>
<body>
<div class="ds-page" data-proto="zelenograd"><a class="ds-skip" href="#main">Skip to content</a><header class="ds-header"><a class="ds-brand" href="index.html"><img class="ds-logo" src="images/logo.svg" width="24" height="24" alt="" aria-hidden="true"/><span>WaveDrom</span></a><nav class="ds-nav" aria-label="Primary"><ul><li><a href="index.html" aria-current="undefined">Home</a></li><li><a href="editor.html" aria-current="undefined">Editor</a></li><li><a href="tutorial.html" aria-current="page">Timing</a></li><li><a href="tutorial-reg.html" aria-current="undefined">Registers</a></li><li><a href="tutorial2.html" aria-current="undefined">Schematics</a></li><li><a href="ecosystem.html" aria-current="undefined">Ecosystem</a></li></ul></nav><div class="ds-header-tools"><a class="ds-btn ds-btn-ghost" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=J6WR5E7TJGSY2&lc=US&item_name=WaveDrom&item_number=website¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted" target="_blank" rel="noopener">Donate</a><a class="ds-btn ds-btn-ghost" href="https://github.com/wavedrom/wavedrom" target="_blank" rel="noopener">GitHub</a><button type="button" class="ds-btn ds-btn-ghost" data-action="theme" aria-label="Cycle color theme (auto, light, dark)"><span class="ds-theme-label">Theme: auto</span></button></div></header><main class="ds-main" id="main"><section class="ds-hero"><div><p class="ds-kicker">Documentation · WaveJSON Guide</p><h1>Hitchhiker's Guide to the WaveDrom (signal)</h1><p class="ds-lead">Step-by-step reference for authoring digital timing diagrams (signal) and programmatic JavaScript WaveJSON.</p><div class="ds-actions"><a class="ds-btn ds-btn-primary" href="editor.html">Open Editor</a><a class="ds-btn ds-btn-ghost" href="tutorial-reg.html">Registers Tutorial →</a><a class="ds-btn ds-btn-ghost" href="tutorial2.html">Logic Schematics →</a></div></div></section><section class="ds-section" id="the-signal"><header class="ds-section-head"><span class="ds-section-num">1</span><p class="ds-kicker">Timing · Basics</p><h2>Signals & States</h2></header><div class="ds-prose"><p>The signal array defines waveform lanes. Each lane requires a name and a wave string where every character represents one clock period. A dot (.) extends the previous state; 0/1 draw binary levels; z draws high-impedance; x draws unknown; = and digits 2–9 draw colored data segments.</p></div><figure class="ds-editor ds-split" data-live="tutSignal"><div class="ds-panel ds-editor-src"><div class="ds-cm wd-lazy-cm" data-editor="tutSignal" data-eager="1" tabindex="0" role="region" aria-label="WaveJSON source editor: tutSignal"><pre class="wd-code-preview"><code>{signal: [
{name: 'Alfa', wave: '01.zx=ud.23.456789'}
]}</code></pre></div><div class="wd-ed-foot"><span class="ds-readout wd-status" data-readout="tutSignal"><span class="ds-readout-v">ok</span></span><a class="wd-open-link" href="editor.html?%7Bsignal%3A%20%5B%0A%20%20%7Bname%3A%20'Alfa'%2C%20wave%3A%20'01.zx%3Dud.23.456789'%7D%0A%5D%7D" title="Open this snippet in the full WaveDrom Editor">Open in Editor →</a></div></div><div class="ds-panel ds-editor-out ds-diagram-wave"><div class="ds-diagram-body" data-diagram="tutSignal"></div></div><figcaption>Fig. 1.1 — Single-bit and multi-state signal wave characters.</figcaption></figure></section><section class="ds-section" id="adding-clock"><header class="ds-section-head"><span class="ds-section-num">2</span><p class="ds-kicker">Timing · Clocks</p><h2>Clocks & Gating</h2></header><div class="ds-prose"><p>Clock characters transition twice per cycle: p/n for positive/negative polarity, P/N for edge arrows. Combine clock characters with 0/1 levels to model clock gating.</p></div><figure class="ds-editor ds-split" data-live="timingClock"><div class="ds-panel ds-editor-src"><div class="ds-cm wd-lazy-cm" data-editor="timingClock" data-eager="0" tabindex="0" role="region" aria-label="WaveJSON source editor: timingClock"><pre class="wd-code-preview"><code>{signal: [
{name: 'pclk', wave: 'p.......'},
{name: 'Pclk', wave: 'P.......'},
{name: 'nclk', wave: 'n.......'},
{name: 'Nclk', wave: 'N.......'},
{},
{name: 'gate', wave: '0.1...0.'},
{name: 'gclk', wave: '0.p...0.'}
]}</code></pre></div><div class="wd-ed-foot"><span class="ds-readout wd-status" data-readout="timingClock"><span class="ds-readout-v">ok</span></span><a class="wd-open-link" href="editor.html?%7Bsignal%3A%20%5B%0A%20%20%7Bname%3A%20'pclk'%2C%20wave%3A%20'p.......'%7D%2C%0A%20%20%7Bname%3A%20'Pclk'%2C%20wave%3A%20'P.......'%7D%2C%0A%20%20%7Bname%3A%20'nclk'%2C%20wave%3A%20'n.......'%7D%2C%0A%20%20%7Bname%3A%20'Nclk'%2C%20wave%3A%20'N.......'%7D%2C%0A%20%20%7B%7D%2C%0A%20%20%7Bname%3A%20'gate'%2C%20wave%3A%20'0.1...0.'%7D%2C%0A%20%20%7Bname%3A%20'gclk'%2C%20wave%3A%20'0.p...0.'%7D%0A%5D%7D" title="Open this snippet in the full WaveDrom Editor">Open in Editor →</a></div></div><div class="ds-panel ds-editor-out ds-diagram-wave"><div class="ds-diagram-body" data-diagram="timingClock"></div></div><figcaption>Fig. 2.1 — Positive/negative clocks, edge markers, and gated clock.</figcaption></figure></section><section class="ds-section" id="the-groups"><header class="ds-section-head"><span class="ds-section-num">3</span><p class="ds-kicker">Timing · Hierarchy</p><h2>Groups, Spacers & Gaps</h2></header><div class="ds-prose"><p>Group related signals in nested arrays starting with a group label string. Insert an empty object <code>{}</code> for a horizontal spacer lane, or <code>|</code> inside a wave string for a time gap.</p></div><div class="wd-stack"><figure class="ds-editor ds-split" data-live="tutGroups"><div class="ds-panel ds-editor-src"><div class="ds-cm wd-lazy-cm" data-editor="tutGroups" data-eager="0" tabindex="0" role="region" aria-label="WaveJSON source editor: tutGroups"><pre class="wd-code-preview"><code>{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: 'xxxxx4.x', data: 'Q2'}
]
]}</code></pre></div><div class="wd-ed-foot"><span class="ds-readout wd-status" data-readout="tutGroups"><span class="ds-readout-v">ok</span></span><a class="wd-open-link" href="editor.html?%7Bsignal%3A%20%5B%0A%20%20%7Bname%3A%20'clk'%2C%20wave%3A%20'p..Pp..P'%7D%2C%0A%20%20%5B'Master'%2C%0A%20%20%20%20%5B'ctrl'%2C%0A%20%20%20%20%20%20%7Bname%3A%20'write'%2C%20wave%3A%20'01.0....'%7D%2C%0A%20%20%20%20%20%20%7Bname%3A%20'read'%2C%20%20wave%3A%20'0...1..0'%7D%0A%20%20%20%20%5D%2C%0A%20%20%20%20%7Bname%3A%20'addr'%2C%20wave%3A%20'x3.x4..x'%2C%20data%3A%20'A1%20A2'%7D%2C%0A%20%20%20%20%7Bname%3A%20'wdata'%2C%20wave%3A%20'x3.x....'%2C%20data%3A%20'D1'%7D%0A%20%20%5D%2C%0A%20%20%7B%7D%2C%0A%20%20%5B'Slave'%2C%0A%20%20%20%20%5B'ctrl'%2C%0A%20%20%20%20%20%20%7Bname%3A%20'ack'%2C%20wave%3A%20'x01x0.1x'%7D%0A%20%20%20%20%5D%2C%0A%20%20%20%20%7Bname%3A%20'rdata'%2C%20wave%3A%20'xxxxx4.x'%2C%20data%3A%20'Q2'%7D%0A%20%20%5D%0A%5D%7D" title="Open this snippet in the full WaveDrom Editor">Open in Editor →</a></div></div><div class="ds-panel ds-editor-out ds-diagram-wave"><div class="ds-diagram-body" data-diagram="tutGroups"></div></div><figcaption>Fig. 3.1 — Hierarchical Master/Slave signal groups with nested control buses.</figcaption></figure><figure class="ds-editor ds-split" data-live="timing"><div class="ds-panel ds-editor-src"><div class="ds-cm wd-lazy-cm" data-editor="timing" data-eager="0" tabindex="0" role="region" aria-label="WaveJSON source editor: timing"><pre class="wd-code-preview"><code>{signal: [
{name: 'clk', wave: 'p.....|...'},
{name: 'dat', wave: 'x.345x|=.x', data: ['head', 'body', 'tail', 'data']},
{name: 'req', wave: '0.1..0|1.0'},
{},
{name: 'ack', wave: '1.....|01.'}
],
head: {text: 'Request / acknowledge', tick: 0},
foot: {text: 'Figure 1'}
}</code></pre></div><div class="wd-ed-foot"><span class="ds-readout wd-status" data-readout="timing"><span class="ds-readout-v">ok</span></span><a class="wd-open-link" href="editor.html?%7Bsignal%3A%20%5B%0A%20%20%7Bname%3A%20'clk'%2C%20wave%3A%20'p.....%7C...'%7D%2C%0A%20%20%7Bname%3A%20'dat'%2C%20wave%3A%20'x.345x%7C%3D.x'%2C%20data%3A%20%5B'head'%2C%20'body'%2C%20'tail'%2C%20'data'%5D%7D%2C%0A%20%20%7Bname%3A%20'req'%2C%20wave%3A%20'0.1..0%7C1.0'%7D%2C%0A%20%20%7B%7D%2C%0A%20%20%7Bname%3A%20'ack'%2C%20wave%3A%20'1.....%7C01.'%7D%0A%5D%2C%0Ahead%3A%20%7Btext%3A%20'Request%20%2F%20acknowledge'%2C%20tick%3A%200%7D%2C%0Afoot%3A%20%7Btext%3A%20'Figure%201'%7D%0A%7D" title="Open this snippet in the full WaveDrom Editor">Open in Editor →</a></div></div><div class="ds-panel ds-editor-out ds-diagram-wave"><div class="ds-diagram-body" data-diagram="timing"></div></div><figcaption>Fig. 3.2 — Gap markers (|), spacer lane ({}), and data labels.</figcaption></figure><div class="ds-prose"><p>When using WaveJSON as a protocol or sequencer specification, a single waveform often represents multiple phases, repeatable sub-sequences, or variable-length wait intervals. A top-level <code>gaps</code> string places diagram-wide vertical markers across every lane at once—space-separated per cycle using <code>.</code> (none), <code>0 1 2 3 |</code> (dividers), <code>[ ] ( ) )( (( ))</code> (phase/sequence brackets), and <code>s</code> (full-height squiggle gap). See <a class="ds-link" href="https://observablehq.com/@drom/sekvenco" target="_blank" rel="noopener">Sekvenco (WaveJSON as executable spec) →</a>.</p></div><figure class="ds-editor ds-split" data-live="tutGaps"><div class="ds-panel ds-editor-src"><div class="ds-cm wd-lazy-cm" data-editor="tutGaps" data-eager="0" tabindex="0" role="region" aria-label="WaveJSON source editor: tutGaps"><pre class="wd-code-preview"><code>{signal: [
{name: 'clk', wave: 'p..........'},
{name: 'req', wave: '01..0.1..0.'},
{name: 'data', wave: 'x345x.678x.', data: ['A', 'B', 'C', 'D', 'E', 'F']}
],
gaps: '. ( . . ) s [ . . ] .'
}</code></pre></div><div class="wd-ed-foot"><span class="ds-readout wd-status" data-readout="tutGaps"><span class="ds-readout-v">ok</span></span><a class="wd-open-link" href="editor.html?%7Bsignal%3A%20%5B%0A%20%20%7Bname%3A%20'clk'%2C%20%20wave%3A%20'p..........'%7D%2C%0A%20%20%7Bname%3A%20'req'%2C%20%20wave%3A%20'01..0.1..0.'%7D%2C%0A%20%20%7Bname%3A%20'data'%2C%20wave%3A%20'x345x.678x.'%2C%20data%3A%20%5B'A'%2C%20'B'%2C%20'C'%2C%20'D'%2C%20'E'%2C%20'F'%5D%7D%0A%5D%2C%0Agaps%3A%20'.%20(%20.%20.%20)%20s%20%5B%20.%20.%20%5D%20.'%0A%7D" title="Open this snippet in the full WaveDrom Editor">Open in Editor →</a></div></div><div class="ds-panel ds-editor-out ds-diagram-wave"><div class="ds-diagram-body" data-diagram="tutGaps"></div></div><figcaption>Fig. 3.3 — Sequence brackets and full-height squiggle gap via top-level gaps.</figcaption></figure></div></section><section class="ds-section" id="period-and-phase"><header class="ds-section-head"><span class="ds-section-num">4</span><p class="ds-kicker">Timing · Multi-Rate</p><h2>Period, Phase & Config</h2></header><div class="ds-prose"><p>Use period to stretch a lane across multiple base cycles and phase to shift transitions (for example, 0.5 for half-cycle DDR alignment). Use config.hscale to adjust horizontal scaling and head/foot for cycle numbers.</p></div><div class="wd-stack"><figure class="ds-editor ds-split" data-live="tutPeriodPhase"><div class="ds-panel ds-editor-src"><div class="ds-cm wd-lazy-cm" data-editor="tutPeriodPhase" data-eager="0" tabindex="0" role="region" aria-label="WaveJSON source editor: tutPeriodPhase"><pre class="wd-code-preview"><code>{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'}
]}</code></pre></div><div class="wd-ed-foot"><span class="ds-readout wd-status" data-readout="tutPeriodPhase"><span class="ds-readout-v">ok</span></span><a class="wd-open-link" href="editor.html?%7Bsignal%3A%20%5B%0A%20%20%7Bname%3A%20'CK'%2C%20%20%20wave%3A%20'P.......'%2C%20period%3A%202%7D%2C%0A%20%20%7Bname%3A%20'CMD'%2C%20%20wave%3A%20'x.3x%3Dx4x%3Dx%3Dx%3Dx%3Dx'%2C%20data%3A%20'RAS%20NOP%20CAS%20NOP%20NOP%20NOP%20NOP'%2C%20phase%3A%200.5%7D%2C%0A%20%20%7Bname%3A%20'ADDR'%2C%20wave%3A%20'x.%3Dx..%3Dx........'%2C%20data%3A%20'ROW%20COL'%2C%20phase%3A%200.5%7D%2C%0A%20%20%7Bname%3A%20'DQS'%2C%20%20wave%3A%20'z.......0.1010z.'%7D%2C%0A%20%20%7Bname%3A%20'DQ'%2C%20%20%20wave%3A%20'z.........5555z.'%2C%20data%3A%20'D0%20D1%20D2%20D3'%7D%0A%5D%7D" title="Open this snippet in the full WaveDrom Editor">Open in Editor →</a></div></div><div class="ds-panel ds-editor-out ds-diagram-wave"><div class="ds-diagram-body" data-diagram="tutPeriodPhase"></div></div><figcaption>Fig. 4.1 — DDR read transaction using period: 2 and phase: 0.5.</figcaption></figure><figure class="ds-editor ds-split" data-live="tutConfig"><div class="ds-panel ds-editor-src"><div class="ds-cm wd-lazy-cm" data-editor="tutConfig" data-eager="0" tabindex="0" role="region" aria-label="WaveJSON source editor: tutConfig"><pre class="wd-code-preview"><code>{signal: [
{name: 'clk', wave: 'p....'},
{name: 'Data', wave: 'x345x', data: 'a b c'},
{name: 'Head', wave: '01..0'}
],
config: {hscale: 2},
head: {text: 'hscale = 2', tick: 0, every: 2},
foot: {text: 'cycles', tock: 9}
}</code></pre></div><div class="wd-ed-foot"><span class="ds-readout wd-status" data-readout="tutConfig"><span class="ds-readout-v">ok</span></span><a class="wd-open-link" href="editor.html?%7Bsignal%3A%20%5B%0A%20%20%7Bname%3A%20'clk'%2C%20%20wave%3A%20'p....'%7D%2C%0A%20%20%7Bname%3A%20'Data'%2C%20wave%3A%20'x345x'%2C%20data%3A%20'a%20b%20c'%7D%2C%0A%20%20%7Bname%3A%20'Head'%2C%20wave%3A%20'01..0'%7D%0A%5D%2C%0Aconfig%3A%20%7Bhscale%3A%202%7D%2C%0Ahead%3A%20%7Btext%3A%20'hscale%20%3D%202'%2C%20tick%3A%200%2C%20every%3A%202%7D%2C%0Afoot%3A%20%7Btext%3A%20'cycles'%2C%20tock%3A%209%7D%0A%7D" title="Open this snippet in the full WaveDrom Editor">Open in Editor →</a></div></div><div class="ds-panel ds-editor-out ds-diagram-wave"><div class="ds-diagram-body" data-diagram="tutConfig"></div></div><figcaption>Fig. 4.2 — Horizontal scaling (hscale: 2) with head tick and foot tock counters.</figcaption></figure></div></section><section class="ds-section" id="arrows"><header class="ds-section-head"><span class="ds-section-num">5</span><p class="ds-kicker">Timing · Causality</p><h2>Arrows, Edges & Handshakes</h2></header><div class="ds-prose"><p>Attach single-character node identifiers along a lane via the <code>node</code> property, then connect nodes in the <code>edge</code> array using spline (<code>~></code>) or straight (<code>-></code>) arrow syntax with optional labels.</p></div><div class="wd-stack"><figure class="ds-editor ds-split" data-live="timingArrows"><div class="ds-panel ds-editor-src"><div class="ds-cm wd-lazy-cm" data-editor="timingArrows" data-eager="0" tabindex="0" role="region" aria-label="WaveJSON source editor: timingArrows"><pre class="wd-code-preview"><code>{signal: [
{name: 'clk', wave: 'p.......'},
{name: 'req', wave: '01..0...', node: '.a..b...'},
{name: 'ack', wave: '0..1..0.', node: '...c..d.'}
],
edge: [
'a~>c t_ack',
'b~>d t_rel'
]}</code></pre></div><div class="wd-ed-foot"><span class="ds-readout wd-status" data-readout="timingArrows"><span class="ds-readout-v">ok</span></span><a class="wd-open-link" href="editor.html?%7Bsignal%3A%20%5B%0A%20%20%7Bname%3A%20'clk'%2C%20wave%3A%20'p.......'%7D%2C%0A%20%20%7Bname%3A%20'req'%2C%20wave%3A%20'01..0...'%2C%20node%3A%20'.a..b...'%7D%2C%0A%20%20%7Bname%3A%20'ack'%2C%20wave%3A%20'0..1..0.'%2C%20node%3A%20'...c..d.'%7D%0A%5D%2C%0Aedge%3A%20%5B%0A%20%20'a~%3Ec%20t_ack'%2C%0A%20%20'b~%3Ed%20t_rel'%0A%5D%7D" title="Open this snippet in the full WaveDrom Editor">Open in Editor →</a></div></div><div class="ds-panel ds-editor-out ds-diagram-wave"><div class="ds-diagram-body" data-diagram="timingArrows"></div></div><figcaption>Fig. 5.1 — Request-to-acknowledge causal arrows with timing labels.</figcaption></figure><div class="ds-prose"><p>In ready/valid protocols, tracing which cycle actually transfers a beat versus when a sender is stalled quickly turns dense if drawn with arrows alone. Placing <code>over</code> and <code>under</code> bars directly on the handshake lanes keeps the causal story readable at a glance: <code>over</code> marks each active beat from assertion to acceptance with a corner serif at the transfer edge, while <code>under</code> flags backpressure stall cycles (digits <code>1..8</code> select color, <code>.</code> extends, <code>0</code> ends). See <a class="ds-link" href="https://observablehq.com/@drom/handshake-annotation" target="_blank" rel="noopener">ObservableHQ Handshake Annotation notebook →</a>.</p></div><figure class="ds-editor ds-split" data-live="tutHandshake"><div class="ds-panel ds-editor-src"><div class="ds-cm wd-lazy-cm" data-editor="tutHandshake" data-eager="0" tabindex="0" role="region" aria-label="WaveJSON source editor: tutHandshake"><pre class="wd-code-preview"><code>{signal: [
{name: 'clk', wave: 'p..........'},
{name: 'valid', wave: '01...01..0.', over: '03.4.06..0.'},
{name: 'ready', wave: '10101.0.1..', under: '0202002.0..'},
{name: 'data', wave: 'x3.4.x6..x.', data: ['D0', 'D1', 'D2']}
],
head: {text: 'Valid / Ready Handshake — over & under Annotations', tick: 0}
}</code></pre></div><div class="wd-ed-foot"><span class="ds-readout wd-status" data-readout="tutHandshake"><span class="ds-readout-v">ok</span></span><a class="wd-open-link" href="editor.html?%7Bsignal%3A%20%5B%0A%20%20%7Bname%3A%20'clk'%2C%20%20%20wave%3A%20'p..........'%7D%2C%0A%20%20%7Bname%3A%20'valid'%2C%20wave%3A%20'01...01..0.'%2C%20over%3A%20%20'03.4.06..0.'%7D%2C%0A%20%20%7Bname%3A%20'ready'%2C%20wave%3A%20'10101.0.1..'%2C%20under%3A%20'0202002.0..'%7D%2C%0A%20%20%7Bname%3A%20'data'%2C%20%20wave%3A%20'x3.4.x6..x.'%2C%20data%3A%20%5B'D0'%2C%20'D1'%2C%20'D2'%5D%7D%0A%5D%2C%0Ahead%3A%20%7Btext%3A%20'Valid%20%2F%20Ready%20Handshake%20%E2%80%94%20over%20%26%20under%20Annotations'%2C%20tick%3A%200%7D%0A%7D" title="Open this snippet in the full WaveDrom Editor">Open in Editor →</a></div></div><div class="ds-panel ds-editor-out ds-diagram-wave"><div class="ds-diagram-body" data-diagram="tutHandshake"></div></div><figcaption>Fig. 5.2 — Valid/ready handshake beats (over with transfer serif) and stall cycles (under).</figcaption></figure></div></section><section class="ds-section" id="piecewise"><header class="ds-section-head"><span class="ds-section-num">6</span><p class="ds-kicker">Timing · Analog</p><h2>Piecewise-Linear (PWL) Waveforms</h2></header><div class="ds-prose"><p>Pass <code>['pw', {d: '...'}]</code> as a lane wave to draw piecewise-linear and smooth analog waveforms using SVG path commands (<code>M/L/H/V/Q/T/A</code>) in cycle (X) and logic-level (Y: 0..1) coordinates. See <a class="ds-link" href="https://observablehq.com/@drom/piecewise" target="_blank" rel="noopener">ObservableHQ PWL notebook →</a> for more examples.</p></div><figure class="ds-editor ds-split" data-live="tutPwl"><div class="ds-panel ds-editor-src"><div class="ds-cm wd-lazy-cm" data-editor="tutPwl" data-eager="0" tabindex="0" role="region" aria-label="WaveJSON source editor: tutPwl"><pre class="wd-code-preview"><code>{signal: [
{name: 'clk', wave: 'p.......'},
{name: 'slew', wave: ['pw', {d: 'M 0,0 h 1 l 0.5,1 h 2 l 0.5,-1 h 1 l 0.5,1 h 2.5'}]},
{name: 'rc', wave: ['pw', {d: 'M 0,0 Q 0.4,1 2,1 Q 2.4,0 4,0 Q 4.4,1 6,1 Q 6.4,0 8,0'}]},
{name: 'ramp', wave: ['pw', {d: 'M 0,0 L 2,1 2,0 4,1 4,0 6,1 6,0 8,1'}]},
{name: 'sine', wave: ['pw', {d: 'M 0,0.5 q 0.5,1 1,0 t 1,0 1,0 1,0 1,0 1,0 1,0 1,0'}]}
]}</code></pre></div><div class="wd-ed-foot"><span class="ds-readout wd-status" data-readout="tutPwl"><span class="ds-readout-v">ok</span></span><a class="wd-open-link" href="editor.html?%7Bsignal%3A%20%5B%0A%20%20%7Bname%3A%20'clk'%2C%20%20wave%3A%20'p.......'%7D%2C%0A%20%20%7Bname%3A%20'slew'%2C%20wave%3A%20%5B'pw'%2C%20%7Bd%3A%20'M%200%2C0%20h%201%20l%200.5%2C1%20h%202%20l%200.5%2C-1%20h%201%20l%200.5%2C1%20h%202.5'%7D%5D%7D%2C%0A%20%20%7Bname%3A%20'rc'%2C%20%20%20wave%3A%20%5B'pw'%2C%20%7Bd%3A%20'M%200%2C0%20Q%200.4%2C1%202%2C1%20Q%202.4%2C0%204%2C0%20Q%204.4%2C1%206%2C1%20Q%206.4%2C0%208%2C0'%7D%5D%7D%2C%0A%20%20%7Bname%3A%20'ramp'%2C%20wave%3A%20%5B'pw'%2C%20%7Bd%3A%20'M%200%2C0%20L%202%2C1%202%2C0%204%2C1%204%2C0%206%2C1%206%2C0%208%2C1'%7D%5D%7D%2C%0A%20%20%7Bname%3A%20'sine'%2C%20wave%3A%20%5B'pw'%2C%20%7Bd%3A%20'M%200%2C0.5%20q%200.5%2C1%201%2C0%20t%201%2C0%201%2C0%201%2C0%201%2C0%201%2C0%201%2C0%201%2C0'%7D%5D%7D%0A%5D%7D" title="Open this snippet in the full WaveDrom Editor">Open in Editor →</a></div></div><div class="ds-panel ds-editor-out ds-diagram-wave"><div class="ds-diagram-body" data-diagram="tutPwl"></div></div><figcaption>Fig. 6.1 — Slew-limited transitions, RC exponential charge/discharge, sawtooth ramp, and sine wave.</figcaption></figure></section><section class="ds-section" id="javascript"><header class="ds-section-head"><span class="ds-section-num">7</span><p class="ds-kicker">Advanced · Scripting</p><h2>Programmatic WaveJSON (JavaScript)</h2></header><div class="ds-prose"><p>WaveJSON is evaluated as a JavaScript expression. For repetitive or algorithmic waveforms—such as Gray counters, LFSR sequences, or parameterized bus bursts—return a WaveJSON object from an immediately invoked function expression (IIFE).</p></div><figure class="ds-editor ds-split" data-live="grayCode"><div class="ds-panel ds-editor-src"><div class="ds-cm wd-lazy-cm" data-editor="grayCode" data-eager="0" tabindex="0" role="region" aria-label="WaveJSON source editor: grayCode"><pre class="wd-code-preview"><code>(function (bits, ticks) {
const lanes = [];
for (let i = 0; i < bits; i++) {
let wave = '';
for (let j = 0; j < ticks; j++) {
wave += ((j >> i) ^ (j >> (i + 1))) & 1;
}
lanes.push({name: 'g' + i, wave});
}
return {signal: lanes};
})(4, 16)</code></pre></div><div class="wd-ed-foot"><span class="ds-readout wd-status" data-readout="grayCode"><span class="ds-readout-v">ok</span></span><a class="wd-open-link" href="editor.html?(function%20(bits%2C%20ticks)%20%7B%0A%20%20const%20lanes%20%3D%20%5B%5D%3B%0A%20%20for%20(let%20i%20%3D%200%3B%20i%20%3C%20bits%3B%20i%2B%2B)%20%7B%0A%20%20%20%20let%20wave%20%3D%20''%3B%0A%20%20%20%20for%20(let%20j%20%3D%200%3B%20j%20%3C%20ticks%3B%20j%2B%2B)%20%7B%0A%20%20%20%20%20%20wave%20%2B%3D%20((j%20%3E%3E%20i)%20%5E%20(j%20%3E%3E%20(i%20%2B%201)))%20%26%201%3B%0A%20%20%20%20%7D%0A%20%20%20%20lanes.push(%7Bname%3A%20'g'%20%2B%20i%2C%20wave%7D)%3B%0A%20%20%7D%0A%20%20return%20%7Bsignal%3A%20lanes%7D%3B%0A%7D)(4%2C%2016)" title="Open this snippet in the full WaveDrom Editor">Open in Editor →</a></div></div><div class="ds-panel ds-editor-out ds-diagram-wave"><div class="ds-diagram-body" data-diagram="grayCode"></div></div><figcaption>Fig. 7.1 — 4-bit, 16-cycle Gray code generator written as a JavaScript IIFE.</figcaption></figure></section></main><footer class="ds-footer"><div class="ds-footer-cols"><div><h4>Specification</h4><ul><li><a href="editor.html">Online Editor</a></li><li><a href="tutorial.html">Timing Diagrams Tutorial</a></li><li><a href="tutorial-reg.html">Register & Bitfield Tutorial</a></li><li><a href="tutorial2.html">Logic Schematics Tutorial</a></li><li><a href="ecosystem.html">Ecosystem Directory</a></li><li><a href="schema/wavedrom.json">WaveJSON Schema (JSON)</a></li></ul></div><div><h4>Live Design Views</h4><ul><li><a href="https://wavedrom.live" target="_blank" rel="noopener">wavedrom.live (VCD viewer) →</a></li><li><a href="https://wavedrom.live/docs/#what-is-waveql" target="_blank" rel="noopener">WaveQL Query Language →</a></li><li><a href="https://marketplace.visualstudio.com/items?itemName=drom.vcdrom" target="_blank" rel="noopener">VCDrom (VSCode Marketplace) →</a></li><li><a href="https://open-vsx.org/extension/drom/vcdrom" target="_blank" rel="noopener">VCDrom (Open VSX) →</a></li><li><a href="https://marketplace.visualstudio.com/items?itemName=drom.rtlviz" target="_blank" rel="noopener">RTL Viz (VSCode Marketplace) →</a></li><li><a href="https://open-vsx.org/extension/drom/rtlviz" target="_blank" rel="noopener">RTL Viz (Open VSX) →</a></li><li><a href="https://github.com/wavedrom/vcd-samples" target="_blank" rel="noopener">Public VCD Samples →</a></li></ul></div><div><h4>Project & Community</h4><ul><li><a href="https://github.com/wavedrom/wavedrom" target="_blank" rel="noopener">Source on GitHub →</a></li><li><a href="https://github.com/wavedrom/wavedrom.github.io/releases" target="_blank" rel="noopener">Desktop Releases (NW.js) →</a></li><li><a href="images/SNUG2016_WaveDrom.pdf">SNUG 2016 Paper (PDF)</a></li><li><a href="https://groups.google.com/group/wavedrom" target="_blank" rel="noopener">User Group →</a></li><li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=J6WR5E7TJGSY2&lc=US&item_name=WaveDrom&item_number=website¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted" target="_blank" rel="noopener">Donate (PayPal) →</a></li><li><a href="privacy/index.html">Privacy Policy</a></li></ul></div></div><div class="ds-footer-meta"><span>WaveDrom · MIT License · Digital Timing Diagrams & Hardware Documentation</span><span class="ds-num">v3.9.0</span></div></footer><aside class="wd-consent" id="wd-consent" role="region" aria-label="Analytics consent" hidden="hidden"><p class="wd-consent-text">Optional analytics (GA4) help measure documentation usage. No diagram data leaves your browser. <a class="ds-link" href="privacy/index.html">Privacy policy</a></p><div class="wd-consent-actions"><button type="button" class="ds-btn ds-btn-primary" data-consent="accept">Accept</button><button type="button" class="ds-btn ds-btn-ghost" data-consent="decline">Decline</button></div></aside></div>
</body>
</html>