VCD File Format #
VCD files contain:
- Header (date, version, timescale)
- Scope and variable declarations
- Initial values
- Timestamped value changes
Example:
$date Thu Jan 30 2026 $end
$version Sparkle HDL $end
$timescale 1ns $end
$scope module top $end
$var wire 16 ! signal_name $end
$upscope $end
$enddefinitions $end
$dumpvars
b0000000000000000 !
$end
#0
#1
b0000000000001010 !
Signal identifier in VCD (!, ", #, $, etc.)
Equations
- Sparkle.Backend.VCD.makeIdentifier idx = String.singleton (Char.ofNat (33 + idx))
Instances For
Convert BitVec to binary string for VCD
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Format VCD value for output
Equations
- Sparkle.Backend.VCD.formatVCDValue (Sparkle.Backend.VCD.VCDValue.bit a) id = toString (Sparkle.Backend.VCD.boolToVCD a) ++ toString id
- Sparkle.Backend.VCD.formatVCDValue (Sparkle.Backend.VCD.VCDValue.vector a_1) id = toString "b" ++ toString (Sparkle.Backend.VCD.bitVecToBinary a_1) ++ toString " " ++ toString id
Instances For
VCD Writer State #
Tracks variables and their values over time for VCD generation.
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Create a new VCD writer
Equations
Instances For
VCD Header Generation #
Generate VCD header
Equations
- One or more equations did not get rendered due to their size.
Instances For
Generate variable declarations
Equations
- One or more equations did not get rendered due to their size.
Instances For
VCD Trace Generation #
Generate timestamped value changes from Signal simulations.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
def
Sparkle.Backend.VCD.sampleBitVecSignal
{dom : Core.Domain.DomainConfig}
{n : Nat}
(sig : Core.Signal.Signal dom (BitVec n))
(varId : String)
(cycles : Nat)
:
Sample a BitVec signal over time
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
Sparkle.Backend.VCD.sampleBoolSignal
{dom : Core.Domain.DomainConfig}
(sig : Core.Signal.Signal dom Bool)
(varId : String)
(cycles : Nat)
:
Sample a Bool signal over time
Equations
- Sparkle.Backend.VCD.sampleBoolSignal sig varId cycles = List.map (fun (t : Nat) => { time := t, varId := varId, value := Sparkle.Backend.VCD.VCDValue.bit (sig.atTime t) }) (List.range cycles)
Instances For
Generate initial value dump
Equations
- One or more equations did not get rendered due to their size.
Instances For
Group trace entries by time
Equations
- One or more equations did not get rendered due to their size.
Instances For
Generate timestamped value changes
Equations
- One or more equations did not get rendered due to their size.
Instances For
High-Level VCD Generation API #
Generate complete VCD file from trace entries
Equations
- One or more equations did not get rendered due to their size.
Instances For
Write VCD file to disk
Equations
- Sparkle.Backend.VCD.writeVCDFile filename content = do IO.FS.writeFile { toString := filename } content IO.println (toString "VCD file written to: " ++ toString filename)