Appearance
Spec: Timing Diagram Export
Overview
Enable exporting simulation signal history as standardized timing diagrams in multiple formats (SVG, PNG, WaveDrom JSON, VCD) for use in documentation, reports, and external analysis tools.
Motivation
The existing Logic History and Oscilloscope views are great for interactive analysis, but users need to include timing diagrams in reports, presentations, and documentation. Standard export formats also allow interoperability with professional waveform viewers (GTKWave, WaveDrom).
Requirements
Functional Requirements
- SVG Export: Vector timing diagram suitable for documentation and web embedding.
- PNG Export: Raster timing diagram at configurable resolution/DPI.
- WaveDrom JSON Export: Standard WaveDrom format for interactive web rendering.
- VCD Export: Value Change Dump format compatible with GTKWave and ModelSim.
- Signal Selection: Choose which signals to include in the export.
- Time Range: Export full simulation or a selected time window.
- Signal Ordering: Drag to reorder signals in the export.
- Signal Grouping: Group related signals with separators/labels.
- Annotation Support: Add markers, labels, and measurement cursors to the exported diagram.
- Bus Signal Rendering: Multi-bit buses shown as hex/decimal values between transitions.
- Clock Pattern Recognition: Automatically render clock signals with the standard zigzag pattern.
- Customizable Appearance: Colors, line widths, font sizes, background (white/transparent).
- Batch Export: Export timing diagrams for multiple test cases at once.
Non-Functional Requirements
- SVG export produces clean, editable SVG (compatible with Inkscape/Illustrator).
- PNG export supports up to 4K resolution (3840px width).
- VCD files are compatible with GTKWave 3.x+.
- Export completes in under 2 seconds for 100 signals × 10000 time steps.
Design
Export Pipeline
LogicHistoryRecorder Data
→ Signal Selection & Filtering
→ Time Range Clipping
→ Format-Specific Renderer
→ SVG: Vector drawing primitives
→ PNG: Rasterize SVG or draw directly
→ WaveDrom: JSON structure generation
→ VCD: Text-based value change format
→ File OutputWaveDrom Output Example
json
{
"signal": [
{ "name": "CLK", "wave": "p........" },
{ "name": "DATA", "wave": "x.345x.=.", "data": ["A", "B", "C", "D"] },
{ "name": "EN", "wave": "01.....0." },
{ "name": "OUT", "wave": "x..345x.." }
],
"head": { "text": "Memory Read Cycle" },
"config": { "hscale": 2 }
}VCD Output Example
$timescale 1ns $end
$scope module circuit $end
$var wire 1 ! CLK $end
$var wire 1 " DATA $end
$var wire 1 # EN $end
$upscope $end
$enddefinitions $end
#0
0!
x"
0#
#10
1!
#20
0!
1"
1#SVG Rendering
- Each signal gets a horizontal track with name label on the left.
- Digital signals: rectangular waveforms with rise/fall transitions.
- Bus signals: hex value labels between transition points.
- Time axis at bottom with tick marks.
- Grid lines (optional, configurable).
Export Dialog
┌───────────────────────────────────────┐
│ Export Timing Diagram │
├───────────────────────────────────────┤
│ Format: ○ SVG ○ PNG ○ WaveDrom ○ VCD │
│ │
│ Signals: [✓] CLK │
│ [✓] DATA[7:0] │
│ [ ] ADDR[15:0] │
│ [✓] WR_EN │
│ │
│ Time Range: [0ns] to [500ns] │
│ Resolution: [1920px] width (PNG) │
│ │
│ [Preview] [Export] [Cancel] │
└───────────────────────────────────────┘Implementation Tasks
- Create
DigitalWorks.Core/Export/TimingDiagram/namespace. - Implement signal data extraction from
LogicHistoryRecorder. - Implement SVG timing diagram renderer.
- Implement PNG renderer (rasterize from SVG or direct Win2D render).
- Implement WaveDrom JSON generator.
- Implement VCD file format writer.
- Add bus signal value formatting (binary/hex/decimal).
- Create export dialog with signal selection and preview.
- Implement time range selection and zoom.
- Add annotation/marker support in exported diagrams.
- Integrate with menu (File → Export → Timing Diagram).
Risks & Open Questions
- Should the timing diagram viewer be a standalone window (like oscilloscope) or a panel?
- How to handle very long simulations — downsampling or pagination?
- Should export support animation (GIF/APNG) for presentations?
- LaTeX/TikZ-timing export for academic papers?
Priority
Medium — High documentation value, enables professional-quality outputs.