aboutsummaryrefslogtreecommitdiff
path: root/chips/Register.hdl
diff options
context:
space:
mode:
authorYuchen Pei <me@ypei.me>2018-01-20 15:41:49 +0100
committerYuchen Pei <me@ypei.me>2018-01-20 15:41:49 +0100
commitd3a0cc3a8ba6dfeb64d3faeffdeb6845b60e5840 (patch)
treed58df9ec2480e2a9ec6240f9c797f83d1a0b1056 /chips/Register.hdl
parent3571f998b28fbc8d9250ba04c983935f10a16c15 (diff)
rearranged the dir for github
- removed tools and pdfs - rearranged the projects dirs - added md files - other minor changes
Diffstat (limited to 'chips/Register.hdl')
-rw-r--r--chips/Register.hdl34
1 files changed, 34 insertions, 0 deletions
diff --git a/chips/Register.hdl b/chips/Register.hdl
new file mode 100644
index 0000000..f4ec7ee
--- /dev/null
+++ b/chips/Register.hdl
@@ -0,0 +1,34 @@
+// 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/03/a/Register.hdl
+
+/**
+ * 16-bit register:
+ * If load[t] == 1 then out[t+1] = in[t]
+ * else out does not change
+ */
+
+CHIP Register {
+ IN in[16], load;
+ OUT out[16];
+
+ PARTS:
+ // Put your code here:
+ Bit (in=in[0], load=load, out=out[0]);
+ Bit (in=in[1], load=load, out=out[1]);
+ Bit (in=in[2], load=load, out=out[2]);
+ Bit (in=in[3], load=load, out=out[3]);
+ Bit (in=in[4], load=load, out=out[4]);
+ Bit (in=in[5], load=load, out=out[5]);
+ Bit (in=in[6], load=load, out=out[6]);
+ Bit (in=in[7], load=load, out=out[7]);
+ Bit (in=in[8], load=load, out=out[8]);
+ Bit (in=in[9], load=load, out=out[9]);
+ Bit (in=in[10], load=load, out=out[10]);
+ Bit (in=in[11], load=load, out=out[11]);
+ Bit (in=in[12], load=load, out=out[12]);
+ Bit (in=in[13], load=load, out=out[13]);
+ Bit (in=in[14], load=load, out=out[14]);
+ Bit (in=in[15], load=load, out=out[15]);
+}