|
|
@ -5,40 +5,46 @@
|
|
|
|
(define #'(chip-program "CHIP" _arg ...)
|
|
|
|
(define #'(chip-program "CHIP" _arg ...)
|
|
|
|
#'(chip _arg ...))
|
|
|
|
#'(chip _arg ...))
|
|
|
|
|
|
|
|
|
|
|
|
(provide pin-spec-in)
|
|
|
|
(provide pin-spec)
|
|
|
|
(define #'(pin-spec-in "IN" _pin-list ";")
|
|
|
|
(define #'(pin-spec _label _pin-list ";")
|
|
|
|
#'_pin-list)
|
|
|
|
#'_pin-list)
|
|
|
|
|
|
|
|
|
|
|
|
(provide pin-spec-out)
|
|
|
|
|
|
|
|
(define #'(pin-spec-out "OUT" _pin-list ";")
|
|
|
|
|
|
|
|
#'_pin-list)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(require (for-syntax sugar/debug))
|
|
|
|
(require (for-syntax sugar/debug))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-for-syntax (remove-separators stx-or-list sep)
|
|
|
|
|
|
|
|
(for/list ([item (in-list (if (list? stx-or-list)
|
|
|
|
|
|
|
|
stx-or-list
|
|
|
|
|
|
|
|
(syntax->list stx-or-list)))]
|
|
|
|
|
|
|
|
#:when (not (equal? sep (syntax->datum item))))
|
|
|
|
|
|
|
|
item))
|
|
|
|
|
|
|
|
|
|
|
|
(provide pin-list)
|
|
|
|
(provide pin-list)
|
|
|
|
(define #'(pin-list . _pin-or-commas)
|
|
|
|
(define #'(pin-list . _pin-or-commas)
|
|
|
|
(for/list ([stx (in-list (syntax->list #'_pin-or-commas))]
|
|
|
|
(remove-separators #'_pin-or-commas ","))
|
|
|
|
#:when (not (equal? "," (report (syntax->datum stx)))))
|
|
|
|
|
|
|
|
stx))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(begin-for-syntax
|
|
|
|
(begin-for-syntax
|
|
|
|
(define (expand-macro mac)
|
|
|
|
(define (expand-macro mac)
|
|
|
|
(syntax-disarm (report (local-expand mac 'expression #f)) #f)))
|
|
|
|
(syntax-disarm (local-expand mac 'expression #f) #f)))
|
|
|
|
|
|
|
|
|
|
|
|
(provide part-spec)
|
|
|
|
(provide part-spec)
|
|
|
|
(define #'(part-spec "PARTS:" _part-list)
|
|
|
|
(define #'(part-spec "PARTS:" _part-list)
|
|
|
|
#'_part-list)
|
|
|
|
#'_part-list)
|
|
|
|
|
|
|
|
|
|
|
|
(provide part-list)
|
|
|
|
(provide part-list)
|
|
|
|
(define #'(part-list _part ";")
|
|
|
|
(define #'(part-list . _part-or-semicolons)
|
|
|
|
#'_part)
|
|
|
|
(inject-syntax ([#'(part ...) (remove-separators #'_part-or-semicolons "'")])
|
|
|
|
|
|
|
|
#'(begin part ...)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(require (for-syntax sugar/list))
|
|
|
|
|
|
|
|
(define-for-syntax (ugly-processing stx)
|
|
|
|
|
|
|
|
(slice-at (remove-separators (remove-separators stx ",") "=") 2))
|
|
|
|
|
|
|
|
|
|
|
|
(provide part)
|
|
|
|
(provide part)
|
|
|
|
(define #'(part _partname "(" _pin-in "=" _val-id "," _pin-in2 "=" _val-id2 "," out "=" _pin-out ")")
|
|
|
|
(define #'(part _partname "(" _pin-id-etc ... out "=" _pin-out ")" ";")
|
|
|
|
|
|
|
|
(with-syntax ([((_pin-in _val-id) ...) (ugly-processing #'(_pin-id-etc ...))])
|
|
|
|
#'(begin
|
|
|
|
#'(begin
|
|
|
|
(define _pin-out (call-part _partname [_pin-in _val-id][_pin-in2 _val-id2]))))
|
|
|
|
(define _pin-out (call-part _partname [_pin-in _val-id] ...)))))
|
|
|
|
|
|
|
|
|
|
|
|
(define #'(chip _chipname "{"
|
|
|
|
(define #'(chip _chipname "{"
|
|
|
|
_input-pins
|
|
|
|
_input-pins
|
|
|
@ -50,12 +56,13 @@
|
|
|
|
#'(begin
|
|
|
|
#'(begin
|
|
|
|
(provide _chipname)
|
|
|
|
(provide _chipname)
|
|
|
|
(define _chipname
|
|
|
|
(define _chipname
|
|
|
|
(make-keyword-procedure
|
|
|
|
(procedure-rename
|
|
|
|
|
|
|
|
(make-keyword-procedure
|
|
|
|
(λ (kws kw-args . rest)
|
|
|
|
(λ (kws kw-args . rest)
|
|
|
|
(define kw-pairs (map cons kws kw-args))
|
|
|
|
(define kw-pairs (map cons kws kw-args))
|
|
|
|
(let ([_input-pin (cdr (assq (string->keyword (format "~a" '_input-pin)) kw-pairs))] ...)
|
|
|
|
(let ([_input-pin (cdr (assq (string->keyword (format "~a" '_input-pin)) kw-pairs))] ...)
|
|
|
|
_part
|
|
|
|
_part
|
|
|
|
(values _output-pin ...))))))))
|
|
|
|
(values _output-pin ...)))) '_chipname)))))
|
|
|
|
|
|
|
|
|
|
|
|
(provide call-part)
|
|
|
|
(provide call-part)
|
|
|
|
(define #'(call-part _Part [_pin-in _val-id] ...)
|
|
|
|
(define #'(call-part _Part [_pin-in _val-id] ...)
|
|
|
|