burnish
parent
1826f8a00f
commit
545b4229fb
@ -1,27 +0,0 @@
|
||||
// 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;
|
@ -1,43 +0,0 @@
|
||||
// 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;
|
@ -1,49 +0,0 @@
|
||||
// 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;
|
@ -1,17 +0,0 @@
|
||||
#lang s-exp hdl-demo/expander
|
||||
|
||||
#|
|
||||
CHIP Not {
|
||||
IN in;
|
||||
OUT out;
|
||||
|
||||
PARTS:
|
||||
Nand(a=in, b=in, out=out);
|
||||
}
|
||||
|#
|
||||
|
||||
(chip-program Not
|
||||
(in-spec (in))
|
||||
(out-spec (out))
|
||||
(part Nand (a in) (b in) (out out)))
|
||||
|
@ -1,34 +0,0 @@
|
||||
#lang s-exp hdl-tst-demo/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 hdl-demo-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,29 +0,0 @@
|
||||
// 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,29 +0,0 @@
|
||||
// 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,6 +1,8 @@
|
||||
#lang br
|
||||
(require "parser.rkt" "tokenizer.rkt")
|
||||
(provide read-syntax)
|
||||
(define (read-syntax source-path input-port)
|
||||
#`(module hdl-mod hdl-demo/expander
|
||||
#,(parse source-path (tokenize input-port))))
|
||||
(define (read-syntax src ip)
|
||||
(strip-context
|
||||
(with-syntax ([PT (parse src (tokenize ip))])
|
||||
#'(module hdl-mod hdl-demo/expander
|
||||
PT))))
|
||||
|
Loading…
Reference in New Issue