@@ -46,6 +46,7 @@ interface SimulateOptions {
4646 screenshotFile ?: string ;
4747 timeoutExitCode ?: string ;
4848 quiet ?: boolean ;
49+ vcdFile ?: string ;
4950}
5051
5152export function simulateCommand ( program : Command ) : void {
@@ -64,6 +65,7 @@ export function simulateCommand(program: Command): void {
6465 . option ( '--screenshot-file <path>' , 'Screenshot output file' , 'screenshot.png' )
6566 . option ( '--timeout-exit-code <code>' , 'Exit code on timeout' , '42' )
6667 . option ( '-q, --quiet' , 'Suppress status messages' )
68+ . option ( '--vcd-file <path>' , 'Output path for VCD (logic analyzer) file' )
6769 . action ( ( projectPath : string , options : SimulateOptions , command : Command ) => {
6870 return runSimulation ( projectPath , options , command ) ;
6971 } ) ;
@@ -96,6 +98,7 @@ async function runSimulation(projectPath: string, options: SimulateOptions, comm
9698 const screenshotFile = options . screenshotFile ?? 'screenshot.png' ;
9799 const timeoutExitCode = parseInt ( options . timeoutExitCode ?? '42' , 10 ) ;
98100 const timeoutNanos = timeout * millis ;
101+ const vcdFile = options . vcdFile ;
99102
100103 const token = requireToken ( ) ;
101104
@@ -351,6 +354,23 @@ async function runSimulation(projectPath: string, options: SimulateOptions, comm
351354 // wait for the screenshot to be saved, if any
352355 await screenshotPromise ;
353356 } finally {
357+ // Export VCD if requested
358+ if ( vcdFile ) {
359+ try {
360+ const result = await client . readVCD ( ) ;
361+ if ( result . sampleCount > 0 ) {
362+ writeFileSync ( vcdFile , result . vcd ) ;
363+ if ( ! quiet ) {
364+ console . log ( `VCD file written to: ${ vcdFile } ` ) ;
365+ }
366+ } else if ( ! quiet ) {
367+ console . log ( 'No logic analyzer data to export' ) ;
368+ }
369+ } catch ( err ) {
370+ console . error ( 'Error exporting VCD:' , ( err as Error ) . message ) ;
371+ }
372+ }
373+
354374 client . close ( ) ;
355375 }
356376}
0 commit comments