diff --git a/beautiful-racket/br/demo/hdl/tst.rkt b/beautiful-racket/br/demo/hdl-tst.rkt similarity index 53% rename from beautiful-racket/br/demo/hdl/tst.rkt rename to beautiful-racket/br/demo/hdl-tst.rkt index 3afdaf3..eeca7a3 100644 --- a/beautiful-racket/br/demo/hdl/tst.rkt +++ b/beautiful-racket/br/demo/hdl-tst.rkt @@ -1,7 +1,7 @@ #lang br (module reader br - (require br/reader-utils "tst/parser.rkt" "tst/tokenizer.rkt") + (require br/reader-utils "hdl-tst/parser.rkt" "hdl-tst/tokenizer.rkt") (define-read-and-read-syntax (source-path input-port) - #`(module hdl-mod br/demo/hdl/tst/expander + #`(module hdl-mod br/demo/hdl-tst/expander #,(parse source-path (tokenize input-port))))) diff --git a/beautiful-racket/br/demo/hdl/tst/expander.rkt b/beautiful-racket/br/demo/hdl-tst/expander.rkt similarity index 94% rename from beautiful-racket/br/demo/hdl/tst/expander.rkt rename to beautiful-racket/br/demo/hdl-tst/expander.rkt index 17e189d..3639879 100644 --- a/beautiful-racket/br/demo/hdl/tst/expander.rkt +++ b/beautiful-racket/br/demo/hdl-tst/expander.rkt @@ -19,7 +19,7 @@ [#'output (shared-syntax 'output)]) #'(begin (provide (all-defined-out)) - (define shared-procname (dynamic-require _filename-string 'shared-procname)) + (define shared-procname (dynamic-require (findf file-exists? (list _filename-string (format "~a.rkt" _filename-string))) 'shared-procname)) (display-header '_colid ... '_outid) (define _colid (make-parameter 0)) ... (define (_outid) diff --git a/beautiful-racket/br/demo/hdl-tst/hdlprint.rkt b/beautiful-racket/br/demo/hdl-tst/hdlprint.rkt new file mode 100644 index 0000000..cf1c527 --- /dev/null +++ b/beautiful-racket/br/demo/hdl-tst/hdlprint.rkt @@ -0,0 +1,19 @@ +#lang racket + + +(define (hdlprint val fmt) + (match-define (list _ radix-letter number-strings) (regexp-match #px"^%(.)(.*)$" fmt)) ; like %B1.16.1 + (match-define (list left-margin width right-margin) (map string->number (string-split number-strings "."))) + (define radix (case radix-letter + [("B") 2])) + (string-append (make-string left-margin #\space) + (if (number? val) + (~r val #:min-width width #:pad-string "0" #:base radix) + (~a val #:min-width width #:pad-string " " #:align 'center)) + (make-string right-margin #\space))) + +(module+ test +(require rackunit) +(define a 123) +(check-equal? (hdlprint a "%B1.16.1") " 0000000001111011 ") +(check-equal? (hdlprint "out" "%B1.16.1") " out ")) diff --git a/beautiful-racket/br/demo/hdl/tst/parser.rkt b/beautiful-racket/br/demo/hdl-tst/parser.rkt similarity index 100% rename from beautiful-racket/br/demo/hdl/tst/parser.rkt rename to beautiful-racket/br/demo/hdl-tst/parser.rkt diff --git a/beautiful-racket/br/demo/hdl/tst/tokenizer.rkt b/beautiful-racket/br/demo/hdl-tst/tokenizer.rkt similarity index 100% rename from beautiful-racket/br/demo/hdl/tst/tokenizer.rkt rename to beautiful-racket/br/demo/hdl-tst/tokenizer.rkt diff --git a/beautiful-racket/br/demo/hdl/And.hdl b/beautiful-racket/br/demo/hdl/And.hdl.rkt similarity index 100% rename from beautiful-racket/br/demo/hdl/And.hdl rename to beautiful-racket/br/demo/hdl/And.hdl.rkt diff --git a/beautiful-racket/br/demo/hdl/And.tst b/beautiful-racket/br/demo/hdl/And.tst index 9e35d74..0eed34b 100644 --- a/beautiful-racket/br/demo/hdl/And.tst +++ b/beautiful-racket/br/demo/hdl/And.tst @@ -1,4 +1,4 @@ -#lang br/demo/hdl/tst +#lang br/demo/hdl-tst /* and */