diff --git a/embddr/vcd.scm b/embddr/vcd.scm index df39352..41d934a 100644 --- a/embddr/vcd.scm +++ b/embddr/vcd.scm @@ -123,8 +123,9 @@ ;;; ;;; Parse VCD header ;;; Returns values of timescale and association list (tag . ( ...)) +;;; Predicate: (need-signal? ) ;;; -(define (read-header port) +(define* (read-header port need-signal?) (let next-cmd ((timescale #f) (scope '()) (tags+signals '())) @@ -149,18 +150,20 @@ (else 'bits))) (width (string->number (third cmd))) (tag (fourth cmd)) - (vname (string-concatenate - (insert-between - (cddddr cmd) " ")))) + (name (string-concatenate + (insert-between + (cddddr cmd) " ")))) (next-cmd timescale scope - (let ((tag+sig (assoc tag tags+signals)) - (sig (signal-new (reverse scope) - vname type width '()))) - (if tag+sig - (begin - (set-cdr! tag+sig (cons sig (cdr tag+sig))) - tags+signals) - (cons (cons tag `(,sig)) tags+signals)))))) + (let ((sig (signal-new (reverse scope) + name type width '()))) + (if (need-signal? sig) + (let ((tag+sig (assoc tag tags+signals))) + (if tag+sig + (begin + (set-cdr! tag+sig (cons sig (cdr tag+sig))) + tags+signals) + (cons (cons tag `(,sig)) tags+signals))) + tags+signals))))) ((string-ci= "$upscope" (first cmd)) (next-cmd timescale (cdr scope) tags+signals)) @@ -299,9 +302,9 @@ ;;; Parse whole VCD ;;; Returns list of time stamps and list of lists ( valuse ...) ;;; -(define (vcd-parse port) +(define* (vcd-parse port #:optional (need-signal? (lambda (s) #t))) (call-with-values - (lambda () (read-header port)) + (lambda () (read-header port need-signal?)) (cut read-data port <...>))) ;;;