rewrite hdl-test language
parent
f9f79d63f6
commit
5a78b92d92
@ -0,0 +1,5 @@
|
||||
| a | b | out |
|
||||
| 0 | 0 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 |
|
||||
| 1 | 1 | 1 |
|
@ -0,0 +1,29 @@
|
||||
// This file is part of www.nand2tetris.org
|
||||
// and the book "The Elements of Computing Systems"
|
||||
// by Nisan and Schocken, MIT Press.
|
||||
// File name: projects/01/Or.tst
|
||||
|
||||
load Or.hdl,
|
||||
output-file Or.out,
|
||||
compare-to Or.cmp,
|
||||
output-list a%B3.1.3 b%B3.1.3 out%B3.1.3;
|
||||
|
||||
set a 0,
|
||||
set b 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 0,
|
||||
set b 1,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 1,
|
||||
set b 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 1,
|
||||
set b 1,
|
||||
eval,
|
||||
output;
|
@ -0,0 +1,5 @@
|
||||
| a | b | out |
|
||||
| 0 | 0 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 |
|
||||
| 1 | 1 | 0 |
|
@ -1,54 +1,62 @@
|
||||
#lang br
|
||||
(require (for-syntax br/syntax))
|
||||
(provide #%top-interaction #%module-begin #%datum (rename-out [my-top #%top]) #%app
|
||||
(all-defined-out))
|
||||
|
||||
; #%app and #%datum have to be present to make #%top work
|
||||
(define #'(my-top . id)
|
||||
#'(begin
|
||||
(displayln (format "got unbound identifier: ~a" 'id))
|
||||
(procedure-rename (λ xs (cons 'id xs)) (string->symbol (format "undefined:~a" 'id)))))
|
||||
|
||||
(define #'(tst-program _arg ...) #'(begin _arg ...))
|
||||
|
||||
(begin-for-syntax
|
||||
(define-scope blue))
|
||||
|
||||
(define #'(header-expr _filename (_colid ... _outid))
|
||||
(with-syntax* ([filename-string (symbol->string (syntax->datum #'_filename))]
|
||||
[procname (string->symbol (cadr (regexp-match #rx"^(.*)\\.hdl$"(symbol->string (syntax->datum #'_filename)))))])
|
||||
(with-blue-binding-form (output)
|
||||
#'(begin
|
||||
(provide (all-defined-out))
|
||||
(define procname
|
||||
(dynamic-require (findf file-exists?
|
||||
(list filename-string (format "~a.rkt" filename-string))) 'procname))
|
||||
(display-header '_colid ... '_outid)
|
||||
(define _colid (make-parameter 0)) ...
|
||||
(define (_outid)
|
||||
(keyword-apply procname
|
||||
(map (compose1 string->keyword symbol->string) (list '_colid ...))
|
||||
(list (_colid) ...) null))
|
||||
|
||||
(define (output)
|
||||
(display-values (_colid) ... (_outid)))))))
|
||||
|
||||
(define #'(display-header _sym ...)
|
||||
#'(begin
|
||||
(apply display-values (list _sym ...))
|
||||
(apply display-dashes (list _sym ...))))
|
||||
|
||||
(define (vals->text vals) (string-join (map ~a vals) " | "))
|
||||
|
||||
(define (display-values . vals) (displayln (vals->text vals)))
|
||||
|
||||
(define (display-dashes . vals)
|
||||
(displayln (make-string (string-length (vals->text vals)) #\-)))
|
||||
|
||||
(define #'test-expr #'begin)
|
||||
|
||||
(define #'eval-expr #'void)
|
||||
|
||||
(define #'(output-expr)
|
||||
(with-blue-identifiers (output)
|
||||
#'(output)))
|
||||
(require (for-syntax br/syntax br/scope))
|
||||
(provide #%top-interaction #%module-begin #%datum #;(rename-out [my-top #%top]) #%app
|
||||
(all-defined-out) (all-from-out br))
|
||||
|
||||
(require br/demo/hdl-tst/hdlprint rackunit racket/file (for-syntax racket/string))
|
||||
|
||||
(define-for-syntax chip-prefix #f)
|
||||
|
||||
(define-macro (tst-program ARG ...)
|
||||
(let-syntax-pattern ([compare (shared-syntax #'compare)]
|
||||
[of (shared-syntax #'of)])
|
||||
#'(begin ARG ... (close-output-port of) (compare) )))
|
||||
|
||||
(define-macro (load-expr CHIPFILE-STRING)
|
||||
(let ()
|
||||
(set! chip-prefix (string-replace (syntax->datum #'CHIPFILE-STRING) ".hdl" ""))
|
||||
(let-syntax-pattern ([CHIPFILE.RKT (format-string "~a.rkt" #'CHIPFILE-STRING)])
|
||||
#'(require CHIPFILE.RKT))))
|
||||
|
||||
(define-macro (output-file-expr OUTPUT-FILE-STRING)
|
||||
(let-syntax-pattern ([ofname (shared-syntax #'ofname)]
|
||||
[of (shared-syntax #'of)])
|
||||
#'(begin
|
||||
(define ofname OUTPUT-FILE-STRING)
|
||||
(define of (open-output-file ofname #:mode 'text #:exists 'replace)))))
|
||||
|
||||
(define-macro (compare-to-expr COMPARE-FILE-STRING)
|
||||
(let-syntax-pattern ([compare (shared-syntax 'compare)]
|
||||
[ofname (shared-syntax 'ofname)])
|
||||
#'(define (compare)
|
||||
(check-equal? (file->lines ofname) (file->lines COMPARE-FILE-STRING)))))
|
||||
|
||||
(define-macro (output-list-expr (COL-NAME FORMAT-SPEC) ...)
|
||||
(let-syntax-pattern ([(COL-ID ...) (prefix-ids "" #'(COL-NAME ...))]
|
||||
[(CHIP-COL-ID ...) (prefix-ids chip-prefix "-" #'(COL-NAME ...))]
|
||||
[output (shared-syntax 'output)]
|
||||
[of (shared-syntax 'of)]
|
||||
[eval-result (shared-syntax 'eval-result)]
|
||||
[eval-thunk (shared-syntax 'eval-thunk)])
|
||||
#'(begin
|
||||
(define (output COL-ID ...)
|
||||
(fprintf of (format "~a\n" (string-join (list (hdlprint COL-ID FORMAT-SPEC) ...) "|"
|
||||
#:before-first "|"
|
||||
#:after-last "|"))))
|
||||
(define eval-result #f)
|
||||
(define eval-thunk (λ () (list (CHIP-COL-ID) ...)))
|
||||
(output COL-NAME ...))))
|
||||
|
||||
(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"))])
|
||||
#'(CHIP-IN-BUS-ID-WRITE IN-VAL)))
|
||||
|
||||
(define-macro (eval-expr)
|
||||
(let-syntax-pattern ([eval-result (shared-syntax 'eval-result)]
|
||||
[eval-thunk (shared-syntax 'eval-thunk)])
|
||||
#'(set! eval-result (eval-thunk))))
|
||||
|
||||
(define-macro (output-expr)
|
||||
(let-syntax-pattern ([output (shared-syntax 'output)]
|
||||
[eval-result (shared-syntax 'eval-result)])
|
||||
#'(apply output eval-result)))
|
||||
|
@ -1,19 +1,23 @@
|
||||
#lang racket
|
||||
|
||||
(provide hdlprint)
|
||||
|
||||
(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)))
|
||||
(cond
|
||||
[(number? val)
|
||||
(define radix (case radix-letter
|
||||
[("B") 2]))
|
||||
(string-append (make-string left-margin #\space)
|
||||
(~r val #:min-width width #:pad-string "0" #:base radix)
|
||||
(make-string right-margin #\space))]
|
||||
[(string? val) (~a val #:min-width (+ left-margin width right-margin) #:pad-string " " #:align 'center)]
|
||||
[else (error 'unknown-value)]))
|
||||
|
||||
(module+ test
|
||||
(require rackunit)
|
||||
(define a 123)
|
||||
(check-equal? (hdlprint a "%B1.16.1") " 0000000001111011 ")
|
||||
(check-equal? (hdlprint "out" "%B1.16.1") " out "))
|
||||
(require rackunit)
|
||||
(define a 123)
|
||||
(check-equal? (hdlprint a "%B1.16.1") " 0000000001111011 ")
|
||||
(check-equal? (hdlprint "out" "%B1.16.1") " out ")
|
||||
(check-equal? (hdlprint "out" "%B3.1.3") " out ")
|
||||
(check-equal? (hdlprint "in" "%B3.1.3") " in "))
|
||||
|
@ -1,20 +1,22 @@
|
||||
#lang brag
|
||||
|
||||
tst-program : header-expr test-expr*
|
||||
tst-program : load-expr output-file-expr compare-to-expr output-list-expr /";" test-expr*
|
||||
|
||||
header-expr : load-expr table-expr /";"
|
||||
load-expr : /"load" ID /","
|
||||
|
||||
@load-expr : /"load" ID /","
|
||||
output-file-expr : /"output-file" ID /","
|
||||
|
||||
/table-expr : /"output-list" columns
|
||||
compare-to-expr : /"compare-to" ID /","
|
||||
|
||||
@columns : ID [/"," columns]
|
||||
output-list-expr : /"output-list" column [column]+
|
||||
|
||||
test-expr : step-expr+ /";"
|
||||
/column : ID FORMAT-STRING
|
||||
|
||||
@step-expr : (set-expr | @eval-expr | output-expr) [/","]
|
||||
@test-expr : step-expr+ /";"
|
||||
|
||||
/set-expr : /"set" ID VAL
|
||||
@step-expr : (set-expr | eval-expr | output-expr) [/","]
|
||||
|
||||
set-expr : /"set" ID VAL
|
||||
|
||||
eval-expr : /"eval"
|
||||
|
||||
|
@ -0,0 +1,5 @@
|
||||
| a | b | out |
|
||||
| 0 | 0 | 0 |
|
||||
| 0 | 1 | 0 |
|
||||
| 1 | 0 | 0 |
|
||||
| 1 | 1 | 1 |
|
@ -0,0 +1,5 @@
|
||||
| a | b | out |
|
||||
| 0 | 0 | 0 |
|
||||
| 0 | 1 | 0 |
|
||||
| 1 | 0 | 0 |
|
||||
| 1 | 1 | 1 |
|
@ -1,14 +1,31 @@
|
||||
#lang br/demo/hdl-tst
|
||||
|
||||
/* and */
|
||||
|
||||
load And.hdl,
|
||||
output-list a, b, out;
|
||||
set a 0, set b 0,
|
||||
eval, output;
|
||||
set a 0, set b 1,
|
||||
eval, output;
|
||||
set a 1, set b 0,
|
||||
eval, output;
|
||||
set a 1, set b 1,
|
||||
eval, output;
|
||||
#lang br/demo/hdl-tst
|
||||
|
||||
// This file is part of www.nand2tetris.org
|
||||
// and the book "The Elements of Computing Systems"
|
||||
// by Nisan and Schocken, MIT Press.
|
||||
// File name: projects/01/And.tst
|
||||
|
||||
load And.hdl,
|
||||
output-file And.out,
|
||||
compare-to And.cmp,
|
||||
output-list a%B3.1.3 b%B3.1.3 out%B3.1.3;
|
||||
|
||||
set a 0,
|
||||
set b 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 0,
|
||||
set b 1,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 1,
|
||||
set b 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 1,
|
||||
set b 1,
|
||||
eval,
|
||||
output;
|
||||
|
@ -0,0 +1,5 @@
|
||||
| in | sel | a | b |
|
||||
| 0 | 0 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 0 |
|
||||
| 1 | 0 | 1 | 0 |
|
||||
| 1 | 1 | 0 | 1 |
|
@ -0,0 +1,5 @@
|
||||
| in | sel | a | b |
|
||||
| 0 | 0 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 0 |
|
||||
| 1 | 0 | 1 | 0 |
|
||||
| 1 | 1 | 0 | 1 |
|
@ -0,0 +1,27 @@
|
||||
// This file is part of www.nand2tetris.org
|
||||
// and the book "The Elements of Computing Systems"
|
||||
// by Nisan and Schocken, MIT Press.
|
||||
// File name: projects/01/DMux.tst
|
||||
|
||||
load DMux.hdl,
|
||||
output-file DMux.out,
|
||||
compare-to DMux.cmp,
|
||||
output-list in%B3.1.3 sel%B3.1.3 a%B3.1.3 b%B3.1.3;
|
||||
|
||||
set in 0,
|
||||
set sel 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel 1,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set in 1,
|
||||
set sel 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel 1,
|
||||
eval,
|
||||
output;
|
@ -0,0 +1,9 @@
|
||||
| in | sel | a | b | c | d |
|
||||
| 0 | 00 | 0 | 0 | 0 | 0 |
|
||||
| 0 | 01 | 0 | 0 | 0 | 0 |
|
||||
| 0 | 10 | 0 | 0 | 0 | 0 |
|
||||
| 0 | 11 | 0 | 0 | 0 | 0 |
|
||||
| 1 | 00 | 1 | 0 | 0 | 0 |
|
||||
| 1 | 01 | 0 | 1 | 0 | 0 |
|
||||
| 1 | 10 | 0 | 0 | 1 | 0 |
|
||||
| 1 | 11 | 0 | 0 | 0 | 1 |
|
@ -0,0 +1,43 @@
|
||||
// This file is part of www.nand2tetris.org
|
||||
// and the book "The Elements of Computing Systems"
|
||||
// by Nisan and Schocken, MIT Press.
|
||||
// File name: projects/01/DMux4Way.tst
|
||||
|
||||
load DMux4Way.hdl,
|
||||
output-file DMux4Way.out,
|
||||
compare-to DMux4Way.cmp,
|
||||
output-list in%B2.1.2 sel%B2.2.2 a%B2.1.2 b%B2.1.2 c%B2.1.2 d%B2.1.2;
|
||||
|
||||
set in 0,
|
||||
set sel %B00,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel %B01,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel %B10,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel %B11,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set in 1,
|
||||
set sel %B00,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel %B01,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel %B10,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel %B11,
|
||||
eval,
|
||||
output;
|
@ -0,0 +1,45 @@
|
||||
#lang br/demo/hdl-tst
|
||||
|
||||
// This file is part of www.nand2tetris.org
|
||||
// and the book "The Elements of Computing Systems"
|
||||
// by Nisan and Schocken, MIT Press.
|
||||
// File name: projects/01/DMux4Way.tst
|
||||
|
||||
load DMux4Way.hdl,
|
||||
output-file DMux4Way.out,
|
||||
compare-to DMux4Way.cmp,
|
||||
output-list in%B2.1.2 sel%B2.2.2 a%B2.1.2 b%B2.1.2 c%B2.1.2 d%B2.1.2;
|
||||
|
||||
set in 0,
|
||||
set sel %B00,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel %B01,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel %B10,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel %B11,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set in 1,
|
||||
set sel %B00,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel %B01,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel %B10,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel %B11,
|
||||
eval,
|
||||
output;
|
@ -0,0 +1,5 @@
|
||||
| a | b | sum | carry |
|
||||
| 0 | 0 | 0 | 0 |
|
||||
| 0 | 1 | 1 | 0 |
|
||||
| 1 | 0 | 1 | 0 |
|
||||
| 1 | 1 | 0 | 1 |
|
@ -0,0 +1,5 @@
|
||||
| a | b | sum | carry |
|
||||
| 0 | 0 | 0 | 0 |
|
||||
| 0 | 1 | 1 | 0 |
|
||||
| 1 | 0 | 1 | 0 |
|
||||
| 1 | 1 | 0 | 1 |
|
@ -0,0 +1,31 @@
|
||||
#lang br/demo/hdl-tst
|
||||
|
||||
// This file is part of www.nand2tetris.org
|
||||
// and the book "The Elements of Computing Systems"
|
||||
// by Nisan and Schocken, MIT Press.
|
||||
// File name: projects/02/HalfAdder.tst
|
||||
|
||||
load HalfAdder.hdl,
|
||||
output-file HalfAdder.out,
|
||||
compare-to HalfAdder.cmp,
|
||||
output-list a%B3.1.3 b%B3.1.3 sum%B3.1.3 carry%B3.1.3;
|
||||
|
||||
set a 0,
|
||||
set b 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 0,
|
||||
set b 1,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 1,
|
||||
set b 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 1,
|
||||
set b 1,
|
||||
eval,
|
||||
output;
|
@ -0,0 +1,9 @@
|
||||
| a | b | sel | out |
|
||||
| 0 | 0 | 0 | 0 |
|
||||
| 0 | 0 | 1 | 0 |
|
||||
| 0 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 1 | 1 |
|
||||
| 1 | 0 | 0 | 1 |
|
||||
| 1 | 0 | 1 | 0 |
|
||||
| 1 | 1 | 0 | 1 |
|
||||
| 1 | 1 | 1 | 1 |
|
@ -0,0 +1,9 @@
|
||||
| a | b | sel | out |
|
||||
| 0 | 0 | 0 | 0 |
|
||||
| 0 | 0 | 1 | 0 |
|
||||
| 0 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 1 | 1 |
|
||||
| 1 | 0 | 0 | 1 |
|
||||
| 1 | 0 | 1 | 0 |
|
||||
| 1 | 1 | 0 | 1 |
|
||||
| 1 | 1 | 1 | 1 |
|
@ -0,0 +1,49 @@
|
||||
// This file is part of www.nand2tetris.org
|
||||
// and the book "The Elements of Computing Systems"
|
||||
// by Nisan and Schocken, MIT Press.
|
||||
// File name: projects/01/Mux.tst
|
||||
|
||||
load Mux.hdl,
|
||||
output-file Mux.out,
|
||||
compare-to Mux.cmp,
|
||||
output-list a%B3.1.3 b%B3.1.3 sel%B3.1.3 out%B3.1.3;
|
||||
|
||||
set a 0,
|
||||
set b 0,
|
||||
set sel 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel 1,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 0,
|
||||
set b 1,
|
||||
set sel 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel 1,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 1,
|
||||
set b 0,
|
||||
set sel 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel 1,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 1,
|
||||
set b 1,
|
||||
set sel 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set sel 1,
|
||||
eval,
|
||||
output;
|
@ -0,0 +1,3 @@
|
||||
| in | out |
|
||||
| 0 | 1 |
|
||||
| 1 | 0 |
|
@ -0,0 +1,3 @@
|
||||
| in | out |
|
||||
| 0 | 1 |
|
||||
| 1 | 0 |
|
@ -0,0 +1,34 @@
|
||||
#lang s-exp br/demo/hdl-tst/expander
|
||||
|
||||
|
||||
#|
|
||||
load Not.hdl,
|
||||
output-file Not.out,
|
||||
compare-to Not.cmp,
|
||||
output-list in%B3.1.3 out%B3.1.3;
|
||||
set in 0,
|
||||
eval,
|
||||
output;
|
||||
set in 1,
|
||||
eval,
|
||||
output;
|
||||
|
||||
|#
|
||||
|
||||
(require br/demo/hdl-tst/hdlprint rackunit racket/file)
|
||||
(require "Not.hdl.rkt") ; load Not.hdl,
|
||||
(define of (open-output-file "Not.out" #:mode 'text #:exists 'replace)) ; output-file Not.out,
|
||||
(define (output in out) ; output-list in%B3.1.3 out%B3.1.3;
|
||||
(fprintf of (format "~a\n" (string-join (list (hdlprint in "%B3.1.3") (hdlprint out "%B3.1.3")) "|" #:before-first "|" #:after-last "|"))))
|
||||
(define eval-result #f)
|
||||
(define eval-thunk (λ () (list (Not-in) (Not-out)))) ; output-list in%B3.1.3 out%B3.1.3;
|
||||
(output "in" "out") ; put names at top of output
|
||||
(Not-in-write 0) ; set in 0,
|
||||
(set! eval-result (eval-thunk)) ; eval,
|
||||
(apply output eval-result) ; output;
|
||||
(Not-in-write 1) ; set in 1,
|
||||
(set! eval-result (eval-thunk)) ; eval,
|
||||
(apply output eval-result) ; output;
|
||||
(close-output-port of)
|
||||
(display (file->string "Not.out"))
|
||||
(check-equal? (file->lines "Not.out") (file->lines "Not.cmp")) ; compare-to Not.cmp,
|
@ -1,10 +1,14 @@
|
||||
#lang br/demo/hdl-tst
|
||||
|
||||
/* Not */
|
||||
|
||||
load Not.hdl,
|
||||
output-list in, out;
|
||||
output-file Not.out,
|
||||
compare-to Not.cmp,
|
||||
output-list in%B3.1.3 out%B3.1.3;
|
||||
|
||||
set in 0,
|
||||
eval, output;
|
||||
eval,
|
||||
output;
|
||||
|
||||
set in 1,
|
||||
eval, output;
|
||||
eval,
|
||||
output;
|
||||
|
@ -0,0 +1,5 @@
|
||||
| a | b | out |
|
||||
| 0 | 0 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 |
|
||||
| 1 | 1 | 1 |
|
@ -0,0 +1,5 @@
|
||||
| a | b | out |
|
||||
| 0 | 0 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 |
|
||||
| 1 | 1 | 1 |
|
@ -0,0 +1,29 @@
|
||||
// This file is part of www.nand2tetris.org
|
||||
// and the book "The Elements of Computing Systems"
|
||||
// by Nisan and Schocken, MIT Press.
|
||||
// File name: projects/01/Or.tst
|
||||
|
||||
load Or.hdl,
|
||||
output-file Or.out,
|
||||
compare-to Or.cmp,
|
||||
output-list a%B3.1.3 b%B3.1.3 out%B3.1.3;
|
||||
|
||||
set a 0,
|
||||
set b 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 0,
|
||||
set b 1,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 1,
|
||||
set b 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 1,
|
||||
set b 1,
|
||||
eval,
|
||||
output;
|
@ -1,14 +1,30 @@
|
||||
#lang br/demo/hdl-tst
|
||||
|
||||
/* or */
|
||||
// This file is part of www.nand2tetris.org
|
||||
// and the book "The Elements of Computing Systems"
|
||||
// by Nisan and Schocken, MIT Press.
|
||||
// File name: projects/01/Or.tst
|
||||
|
||||
load Or.hdl,
|
||||
output-list a, b, out;
|
||||
set a 0, set b 0,
|
||||
eval, output;
|
||||
set a 0, set b 1,
|
||||
eval, output;
|
||||
set a 1, set b 0,
|
||||
eval, output;
|
||||
set a 1, set b 1,
|
||||
eval, output;
|
||||
output-file Or.out,
|
||||
compare-to Or.cmp,
|
||||
output-list a%B3.1.3 b%B3.1.3 out%B3.1.3;
|
||||
|
||||
set a 0,
|
||||
set b 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 0,
|
||||
set b 1,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 1,
|
||||
set b 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 1,
|
||||
set b 1,
|
||||
eval,
|
||||
output;
|
||||
|
@ -0,0 +1,5 @@
|
||||
| a | b | out |
|
||||
| 0 | 0 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 |
|
||||
| 1 | 1 | 0 |
|
@ -0,0 +1,5 @@
|
||||
| a | b | out |
|
||||
| 0 | 0 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 |
|
||||
| 1 | 1 | 0 |
|
@ -0,0 +1,29 @@
|
||||
// This file is part of www.nand2tetris.org
|
||||
// and the book "The Elements of Computing Systems"
|
||||
// by Nisan and Schocken, MIT Press.
|
||||
// File name: projects/01/Xor.tst
|
||||
|
||||
load Xor.hdl,
|
||||
output-file Xor.out,
|
||||
compare-to Xor.cmp,
|
||||
output-list a%B3.1.3 b%B3.1.3 out%B3.1.3;
|
||||
|
||||
set a 0,
|
||||
set b 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 0,
|
||||
set b 1,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 1,
|
||||
set b 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 1,
|
||||
set b 1,
|
||||
eval,
|
||||
output;
|
@ -1,12 +1,31 @@
|
||||
#lang br/demo/hdl-tst
|
||||
|
||||
// This file is part of www.nand2tetris.org
|
||||
// and the book "The Elements of Computing Systems"
|
||||
// by Nisan and Schocken, MIT Press.
|
||||
// File name: projects/01/Xor.tst
|
||||
|
||||
load Xor.hdl,
|
||||
output-list a, b, out;
|
||||
set a 0, set b 0,
|
||||
eval, output;
|
||||
set a 0, set b 1,
|
||||
eval, output;
|
||||
set a 1, set b 0,
|
||||
eval, output;
|
||||
set a 1, set b 1,
|
||||
eval, output;
|
||||
output-file Xor.out,
|
||||
compare-to Xor.cmp,
|
||||
output-list a%B3.1.3 b%B3.1.3 out%B3.1.3;
|
||||
|
||||
set a 0,
|
||||
set b 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 0,
|
||||
set b 1,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 1,
|
||||
set b 0,
|
||||
eval,
|
||||
output;
|
||||
|
||||
set a 1,
|
||||
set b 1,
|
||||
eval,
|
||||
output;
|
||||
|
Loading…
Reference in New Issue