|
|
@ -104,23 +104,25 @@ base bus:
|
|
|
|
(define-values (bus bus? bus-get)
|
|
|
|
(define-values (bus bus? bus-get)
|
|
|
|
(make-impersonator-property 'bus))
|
|
|
|
(make-impersonator-property 'bus))
|
|
|
|
|
|
|
|
|
|
|
|
(define-cases #'define-base-bus
|
|
|
|
(define-macro-cases define-base-bus
|
|
|
|
[#'(_macro-name _id _thunk) #'(_macro-name _id _thunk default-bus-width)]
|
|
|
|
[#'(_macro-name ID THUNK) #'(_macro-name ID THUNK default-bus-width)]
|
|
|
|
[#'(_macro-name _id _thunk _bus-width-in)
|
|
|
|
[#'(_macro-name ID THUNK _bus-width-in)
|
|
|
|
(inject-syntax ([#'_id-thunk (suffix-id #'_id "-val")]
|
|
|
|
(with-pattern
|
|
|
|
[#'_bus-type (or (syntax-property caller-stx 'impersonate) #'bus)])
|
|
|
|
([_id-thunk (suffix-id #'ID "-val")]
|
|
|
|
#`(splicing-let ([_id-thunk _thunk]
|
|
|
|
[_bus-type (or (syntax-property caller-stx 'impersonate) #'bus)])
|
|
|
|
|
|
|
|
#`(splicing-let ([_id-thunk THUNK]
|
|
|
|
[bus-width _bus-width-in])
|
|
|
|
[bus-width _bus-width-in])
|
|
|
|
(define _id
|
|
|
|
(define ID
|
|
|
|
(begin
|
|
|
|
(begin
|
|
|
|
(unless (<= bus-width max-bus-width)
|
|
|
|
(unless (<= bus-width max-bus-width)
|
|
|
|
(raise-argument-error 'id (format "bus width <= max width ~a" max-bus-width) bus-width))
|
|
|
|
(raise-argument-error 'id (format "bus width <= max width ~a" max-bus-width) bus-width))
|
|
|
|
(impersonate-procedure
|
|
|
|
(impersonate-procedure
|
|
|
|
(let ([reader (make-bus-reader 'id bus-width)])
|
|
|
|
(let ([reader (make-bus-reader 'id bus-width)])
|
|
|
|
(procedure-rename (λ args (apply reader (_id-thunk) args)) (string->symbol (format "~a, a bus of width ~a" '_id bus-width))))
|
|
|
|
(procedure-rename (λ args (apply reader (_id-thunk) args)) (string->symbol (format "~a, a bus of width ~a" 'ID bus-width))))
|
|
|
|
#f _bus-type #t)))
|
|
|
|
#f _bus-type #t)))
|
|
|
|
#,(when (syntax-property caller-stx 'writer)
|
|
|
|
#,(when (syntax-property caller-stx 'writer)
|
|
|
|
(inject-syntax ([#'_id-write (suffix-id #'_id "-write")])
|
|
|
|
(with-pattern
|
|
|
|
|
|
|
|
([_id-write (suffix-id #'ID "-write")])
|
|
|
|
#'(define _id-write
|
|
|
|
#'(define _id-write
|
|
|
|
(let ([writer (make-bus-writer 'id-write bus-width)])
|
|
|
|
(let ([writer (make-bus-writer 'id-write bus-width)])
|
|
|
|
(λ args
|
|
|
|
(λ args
|
|
|
@ -157,7 +159,7 @@ output bus:
|
|
|
|
(define-values (output-bus output-bus? output-bus-get)
|
|
|
|
(define-values (output-bus output-bus? output-bus-get)
|
|
|
|
(make-impersonator-property 'output-bus))
|
|
|
|
(make-impersonator-property 'output-bus))
|
|
|
|
|
|
|
|
|
|
|
|
(define #'(define-output-bus . _args)
|
|
|
|
(define-macro (define-output-bus . _args)
|
|
|
|
(syntax-property #'(define-base-bus . _args) 'impersonate #'output-bus))
|
|
|
|
(syntax-property #'(define-base-bus . _args) 'impersonate #'output-bus))
|
|
|
|
|
|
|
|
|
|
|
|
(module+ test
|
|
|
|
(module+ test
|
|
|
@ -189,7 +191,7 @@ input bus:
|
|
|
|
(define-values (input-bus input-bus? input-bus-get)
|
|
|
|
(define-values (input-bus input-bus? input-bus-get)
|
|
|
|
(make-impersonator-property 'input-bus))
|
|
|
|
(make-impersonator-property 'input-bus))
|
|
|
|
|
|
|
|
|
|
|
|
(define-cases #'define-input-bus
|
|
|
|
(define-macro-cases define-input-bus
|
|
|
|
[#'(_macro-name _id)
|
|
|
|
[#'(_macro-name _id)
|
|
|
|
#'(_macro-name _id default-bus-width)]
|
|
|
|
#'(_macro-name _id default-bus-width)]
|
|
|
|
[#'(_macro-name _id _bus-width)
|
|
|
|
[#'(_macro-name _id _bus-width)
|
|
|
|