touchups
parent
e85bf68fa7
commit
7dcce997d0
@ -1,62 +1,63 @@
|
|||||||
#lang br
|
#lang br
|
||||||
(require (for-syntax br/syntax br/scope))
|
(require (for-syntax br/syntax br/scope racket/string)
|
||||||
(provide #%top-interaction #%module-begin #%datum #;(rename-out [my-top #%top]) #%app
|
"hdlprint.rkt" rackunit racket/file)
|
||||||
(all-defined-out) (all-from-out br))
|
(provide #%top-interaction #%module-begin #%datum #%app (all-defined-out))
|
||||||
|
|
||||||
(require br/demo/hdl-tst/hdlprint rackunit racket/file (for-syntax racket/string))
|
|
||||||
|
|
||||||
(define-for-syntax chip-prefix #f)
|
(define-for-syntax chip-prefix #f)
|
||||||
|
|
||||||
|
|
||||||
(define-macro (tst-program ARG ...)
|
(define-macro (tst-program ARG ...)
|
||||||
(let-syntax-pattern ([compare (shared-syntax #'compare)]
|
(let-shared-id (compare output-file)
|
||||||
[of (shared-syntax #'of)])
|
#'(begin ARG ...
|
||||||
#'(begin ARG ... (close-output-port of) (compare) )))
|
(close-output-port output-file)
|
||||||
|
(compare))))
|
||||||
|
|
||||||
|
|
||||||
(define-macro (load-expr CHIPFILE-STRING)
|
(define-macro (load-expr CHIPFILE-STRING)
|
||||||
(let ()
|
|
||||||
(set! chip-prefix (string-replace (syntax->datum #'CHIPFILE-STRING) ".hdl" ""))
|
(set! chip-prefix (string-replace (syntax->datum #'CHIPFILE-STRING) ".hdl" ""))
|
||||||
(let-syntax-pattern ([CHIPFILE.RKT (format-string "~a.rkt" #'CHIPFILE-STRING)])
|
(let-syntax-pattern ([CHIPFILE.RKT (format-string "~a.rkt" #'CHIPFILE-STRING)])
|
||||||
#'(require CHIPFILE.RKT))))
|
#'(require CHIPFILE.RKT)))
|
||||||
|
|
||||||
|
|
||||||
(define-macro (output-file-expr OUTPUT-FILE-STRING)
|
(define-macro (output-file-expr OUTPUT-FILE-STRING)
|
||||||
(let-syntax-pattern ([ofname (shared-syntax #'ofname)]
|
(let-shared-id (output-file output-filename)
|
||||||
[of (shared-syntax #'of)])
|
|
||||||
#'(begin
|
#'(begin
|
||||||
(define ofname OUTPUT-FILE-STRING)
|
(define output-filename OUTPUT-FILE-STRING)
|
||||||
(define of (open-output-file ofname #:mode 'text #:exists 'replace)))))
|
(define output-file (open-output-file output-filename #:exists 'replace)))))
|
||||||
|
|
||||||
|
|
||||||
(define-macro (compare-to-expr COMPARE-FILE-STRING)
|
(define-macro (compare-to-expr COMPARE-FILE-STRING)
|
||||||
(let-syntax-pattern ([compare (shared-syntax 'compare)]
|
(let-shared-id (compare output-filename)
|
||||||
[ofname (shared-syntax 'ofname)])
|
|
||||||
#'(define (compare)
|
#'(define (compare)
|
||||||
(check-equal? (file->lines ofname) (file->lines COMPARE-FILE-STRING)))))
|
(check-equal? (file->lines output-filename) (file->lines COMPARE-FILE-STRING)))))
|
||||||
|
|
||||||
|
|
||||||
(define-macro (output-list-expr (COL-NAME FORMAT-SPEC) ...)
|
(define-macro (output-list-expr (COL-NAME FORMAT-SPEC) ...)
|
||||||
(let-syntax-pattern ([(COL-ID ...) (prefix-ids "" #'(COL-NAME ...))]
|
(let-shared-id (output output-file eval-result eval-thunk)
|
||||||
[(CHIP-COL-ID ...) (prefix-ids chip-prefix "-" #'(COL-NAME ...))]
|
(let-syntax-pattern ([(COL-ID ...) (suffix-ids #'(COL-NAME ...))]
|
||||||
[output (shared-syntax 'output)]
|
[(CHIP-COL-ID ...) (prefix-ids chip-prefix "-" #'(COL-NAME ...))])
|
||||||
[of (shared-syntax 'of)]
|
|
||||||
[eval-result (shared-syntax 'eval-result)]
|
|
||||||
[eval-thunk (shared-syntax 'eval-thunk)])
|
|
||||||
#'(begin
|
#'(begin
|
||||||
(define (output COL-ID ...)
|
(define (output COL-ID ...)
|
||||||
(fprintf of (format "~a\n" (string-join (list (hdlprint COL-ID FORMAT-SPEC) ...) "|"
|
(fprintf output-file
|
||||||
|
(format "~a\n" (string-join (list (hdlprint COL-ID FORMAT-SPEC) ...) "|"
|
||||||
#:before-first "|"
|
#:before-first "|"
|
||||||
#:after-last "|"))))
|
#:after-last "|"))))
|
||||||
(define eval-result #f)
|
(define eval-result #f)
|
||||||
(define eval-thunk (λ () (list (CHIP-COL-ID) ...)))
|
(define (eval-thunk) (list (CHIP-COL-ID) ...))
|
||||||
(output COL-NAME ...))))
|
(output COL-NAME ...)))))
|
||||||
|
|
||||||
|
|
||||||
(define-macro (set-expr IN-BUS IN-VAL)
|
(define-macro (set-expr IN-BUS IN-VAL)
|
||||||
(let-syntax-pattern ([CHIP-IN-BUS-ID-WRITE (prefix-id chip-prefix "-" (suffix-id #'IN-BUS "-write"))])
|
(let-syntax-pattern ([CHIP-IN-BUS-ID-WRITE (prefix-id chip-prefix "-" (suffix-id #'IN-BUS "-write"))])
|
||||||
#'(CHIP-IN-BUS-ID-WRITE IN-VAL)))
|
#'(CHIP-IN-BUS-ID-WRITE IN-VAL)))
|
||||||
|
|
||||||
|
|
||||||
(define-macro (eval-expr)
|
(define-macro (eval-expr)
|
||||||
(let-syntax-pattern ([eval-result (shared-syntax 'eval-result)]
|
(let-shared-id (eval-result eval-thunk)
|
||||||
[eval-thunk (shared-syntax 'eval-thunk)])
|
|
||||||
#'(set! eval-result (eval-thunk))))
|
#'(set! eval-result (eval-thunk))))
|
||||||
|
|
||||||
|
|
||||||
(define-macro (output-expr)
|
(define-macro (output-expr)
|
||||||
(let-syntax-pattern ([output (shared-syntax 'output)]
|
(let-shared-id (output eval-result)
|
||||||
[eval-result (shared-syntax 'eval-result)])
|
|
||||||
#'(apply output eval-result)))
|
#'(apply output eval-result)))
|
||||||
|
Loading…
Reference in New Issue