split out bus properties

pull/2/head
Matthew Butterick 9 years ago
parent 24317fc860
commit 3bdde5e129

@ -1,6 +1,6 @@
#lang br
(provide (prefix-out Nand- (all-defined-out)))
(require "helper.rkt")
(require "bus.rkt")
(define-input-bus a)
(define-input-bus b)

@ -0,0 +1,11 @@
#lang br
(provide (all-defined-out))
(define-values (bus bus? bus-get)
(make-impersonator-property 'bus))
(define-values (output-bus output-bus? output-bus-get)
(make-impersonator-property 'output-bus))
(define-values (input-bus input-bus? input-bus-get)
(make-impersonator-property 'input-bus))

@ -1,5 +1,5 @@
#lang br
(require racket/list (for-syntax br/syntax) racket/splicing)
(require racket/list (for-syntax br/syntax) racket/splicing "bus-properties.rkt")
(provide (all-defined-out))
(module+ test
@ -101,8 +101,6 @@ base bus:
|#
(define-values (bus bus? bus-get)
(make-impersonator-property 'bus))
(define-macro-cases define-base-bus
[#'(_macro-name ID THUNK) #'(_macro-name ID THUNK default-bus-width)]
@ -156,8 +154,8 @@ output bus:
+ cannot write
|#
(define-values (output-bus output-bus? output-bus-get)
(make-impersonator-property 'output-bus))
(define-macro (define-output-bus . _args)
(syntax-property #'(define-base-bus . _args) 'impersonate #'output-bus))
@ -188,8 +186,6 @@ input bus:
+ can write all, or bits
|#
(define-values (input-bus input-bus? input-bus-get)
(make-impersonator-property 'input-bus))
(define-macro-cases define-input-bus
[#'(_macro-name _id)

@ -1,5 +1,5 @@
#lang br
(require "helper.rkt" (for-syntax racket/syntax racket/require-transform br/syntax "helper.rkt"))
(require "bus.rkt" (for-syntax racket/syntax racket/require-transform br/syntax "bus-properties.rkt"))
(provide #%top-interaction #%module-begin #%app #%datum (all-defined-out))
(define-macro (chip-program CHIPNAME
@ -21,13 +21,13 @@
(define-macro (part PARTNAME ((BUS-LEFT . BUS-LEFT-ARGS) BUS-RIGHT-EXPR) ...)
(with-pattern
([(PARTNAME-BUS-LEFT ...) (prefix-id #'PARTNAME "-" #'(BUS-LEFT ...))]
[CHIP-MODULE-PATH (format-string "~a.hdl.rkt" #'PARTNAME)])
[PARTNAME-MODULE-PATH (format-string "~a.hdl.rkt" #'PARTNAME)])
#'(begin
(require (import-chip CHIP-MODULE-PATH)
(require (import-chip PARTNAME-MODULE-PATH)
;; need for-syntax to make phase 1 binding available
;; so we can determine during expansion which buses are `input-bus?`
;; because the pin-spec syntax is inherently ambiguous
(for-syntax (import-chip CHIP-MODULE-PATH)))
(for-syntax (import-chip PARTNAME-MODULE-PATH)))
(handle-buses ((PARTNAME-BUS-LEFT . BUS-LEFT-ARGS) BUS-RIGHT-EXPR) ...))))
@ -46,7 +46,7 @@
[((PREFIXED-WIRE . _) _)
;; we "pre-evaluate" #'PREFIXED-WIRE so we can set up the program correctly.
;; This is not ideal: usually we want evaluate runtime expressions only at runtime.
;; But in this case, it controls which identifiers we `define`
;; But in this case, it controls which identifiers we `define` as output buses
;; so there's no way around it. Runtime would be too late.
(input-bus? (syntax-local-eval #'PREFIXED-WIRE))])])
(with-pattern

Loading…
Cancel
Save