Public » Elements of Computing
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

Line endings

Changeset e9eb938ea0cf

Parent 11efdfcdf41d

by Profile picture of Benjamin PollackBenjamin Pollack

Changes to 10 files · Browse files at e9eb938ea0cf Showing diff from parent 11efdfcdf41d Diff from another changeset...

Change 1 of 1 Show Entire File 03/​a/​Bit.hdl Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
@@ -1,18 +1,18 @@
-// 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/Bit.hdl - -/** - * 1-bit register. - * If load[t]=1 then out[t+1] = in[t] - * else out does not change (out[t+1]=out[t]) - */ - -CHIP Bit { - IN in, load; - OUT out; - - PARTS: - // Put your code here: -} +// 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/Bit.hdl + +/** + * 1-bit register. + * If load[t]=1 then out[t+1] = in[t] + * else out does not change (out[t+1]=out[t]) + */ + +CHIP Bit { + IN in, load; + OUT out; + + PARTS: + // Put your code here: +}
Change 1 of 1 Show Entire File 03/​a/​PC.hdl Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@@ -1,24 +1,24 @@
-// 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/PC.hdl - -/** - * A 16-bit counter with load and reset control bits. - * if (reset[t]==1) out[t+1] = 0 - * else if (load[t]==1) out[t+1] = in[t] - * else if (inc[t]==1) out[t+1] = out[t] + 1 (integer addition) - * else out[t+1] = out[t] - */ - -CHIP PC { - IN in[16],load,inc,reset; - OUT out[16]; - - PARTS: - // Put your code here: -} - - - - +// 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/PC.hdl + +/** + * A 16-bit counter with load and reset control bits. + * if (reset[t]==1) out[t+1] = 0 + * else if (load[t]==1) out[t+1] = in[t] + * else if (inc[t]==1) out[t+1] = out[t] + 1 (integer addition) + * else out[t+1] = out[t] + */ + +CHIP PC { + IN in[16],load,inc,reset; + OUT out[16]; + + PARTS: + // Put your code here: +} + + + +
Change 1 of 1 Show Entire File 03/​a/​RAM64.hdl Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
@@ -1,19 +1,19 @@
-// 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/RAM64.hdl - -/** - * Memory of 64 registers, each 16 bit-wide. Out hold the value - * stored at the memory location specified by address. If load=1, then - * the in value is loaded into the memory location specified by address - * (the loaded value will be emitted to out after the next time step.) - */ - -CHIP RAM64 { - IN in[16], load, address[6]; - OUT out[16]; - - PARTS: - // Put your code here: +// 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/RAM64.hdl + +/** + * Memory of 64 registers, each 16 bit-wide. Out hold the value + * stored at the memory location specified by address. If load=1, then + * the in value is loaded into the memory location specified by address + * (the loaded value will be emitted to out after the next time step.) + */ + +CHIP RAM64 { + IN in[16], load, address[6]; + OUT out[16]; + + PARTS: + // Put your code here:  } \ No newline at end of file
Change 1 of 1 Show Entire File 03/​a/​RAM8.hdl Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
@@ -1,19 +1,19 @@
-// 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/RAM8.hdl - -/** - * Memory of 8 registers, each 16 bit-wide. Out holds the value - * stored at the memory location specified by address. If load=1, then - * the in value is loaded into the memory location specified by address - * (the loaded value will be emitted to out after the next time step.) - */ - -CHIP RAM8 { - IN in[16], load, address[3]; - OUT out[16]; - - PARTS: - // Put your code here: +// 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/RAM8.hdl + +/** + * Memory of 8 registers, each 16 bit-wide. Out holds the value + * stored at the memory location specified by address. If load=1, then + * the in value is loaded into the memory location specified by address + * (the loaded value will be emitted to out after the next time step.) + */ + +CHIP RAM8 { + IN in[16], load, address[3]; + OUT out[16]; + + PARTS: + // Put your code here:  } \ No newline at end of file
Change 1 of 1 Show Entire File 03/​a/​Register.hdl Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
@@ -1,18 +1,18 @@
-// 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: -} +// 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: +}
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
@@ -1,19 +1,19 @@
-// 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/b/RAM16K.hdl - -/** - * Memory of 16K registers, each 16 bit-wide. Out holds the value - * stored at the memory location specified by address. If load=1, then - * the in value is loaded into the memory location specified by address - * (the loaded value will be emitted to out after the next time step.) - */ - -CHIP RAM16K { - IN in[16], load, address[14]; - OUT out[16]; - - PARTS: - // Put your code here: +// 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/b/RAM16K.hdl + +/** + * Memory of 16K registers, each 16 bit-wide. Out holds the value + * stored at the memory location specified by address. If load=1, then + * the in value is loaded into the memory location specified by address + * (the loaded value will be emitted to out after the next time step.) + */ + +CHIP RAM16K { + IN in[16], load, address[14]; + OUT out[16]; + + PARTS: + // Put your code here:  } \ No newline at end of file
Change 1 of 1 Show Entire File 03/​b/​RAM4K.hdl Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
@@ -1,19 +1,19 @@
-// 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/b/RAM4K.hdl - -/** - * Memory of 4K registers, each 16 bit-wide. Out hold the value - * stored at the memory location specified by address. If load=1, then - * the in value is loaded into the memory location specified by address - * (the loaded value will be emitted to out after the next time step.) - */ - -CHIP RAM4K { - IN in[16], load, address[12]; - OUT out[16]; - - PARTS: - // Put your code here: +// 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/b/RAM4K.hdl + +/** + * Memory of 4K registers, each 16 bit-wide. Out hold the value + * stored at the memory location specified by address. If load=1, then + * the in value is loaded into the memory location specified by address + * (the loaded value will be emitted to out after the next time step.) + */ + +CHIP RAM4K { + IN in[16], load, address[12]; + OUT out[16]; + + PARTS: + // Put your code here:  } \ No newline at end of file
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
@@ -1,19 +1,19 @@
-// This file is part of the materials accompanying the book -// "The Elements of Computing Systems" by Nisan and Schocken, -// MIT Press. Book site: www.idc.ac.il/tecs -// File name: projects/03/b/RAM512.hdl - -/** - * Memory of 512 registers, each 16 bit-wide. Out holds the value - * stored at the memory location specified by address. If load=1, then - * the in value is loaded into the memory location specified by address - * (the loaded value will be emitted to out after the next time step.) - */ - -CHIP RAM512 { - IN in[16], load, address[9]; - OUT out[16]; - - PARTS: - // Put your code here: +// This file is part of the materials accompanying the book +// "The Elements of Computing Systems" by Nisan and Schocken, +// MIT Press. Book site: www.idc.ac.il/tecs +// File name: projects/03/b/RAM512.hdl + +/** + * Memory of 512 registers, each 16 bit-wide. Out holds the value + * stored at the memory location specified by address. If load=1, then + * the in value is loaded into the memory location specified by address + * (the loaded value will be emitted to out after the next time step.) + */ + +CHIP RAM512 { + IN in[16], load, address[9]; + OUT out[16]; + + PARTS: + // Put your code here:  } \ No newline at end of file
 
1
2
3
4
5
6
7
8
9
10
 
 
 
 
 
 
 
 
 
 
11
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
 
@@ -1,11 +1,11 @@
-// 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/04/Fill.asm - -// Runs an infinite loop that listens to the keyboard input. -// When a key is pressed (any key), the program blackens the screen, -// i.e. writes "black" in every pixel. When no key is pressed, the -// program clears the screen, i.e. writes "white" in every pixel. - +// 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/04/Fill.asm + +// Runs an infinite loop that listens to the keyboard input. +// When a key is pressed (any key), the program blackens the screen, +// i.e. writes "black" in every pixel. When no key is pressed, the +// program clears the screen, i.e. writes "white" in every pixel. +  // Put your code here. \ No newline at end of file
 
1
2
3
4
5
6
7
8
 
 
 
 
 
 
 
 
9
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
 
@@ -1,9 +1,9 @@
-// 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/04/Mult.asm - -// Multiplies R0 and R1 and stores the result in R2. -// (R0, R1, R2 refer to RAM[0], RAM[1], and RAM[3], respectively.) - +// 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/04/Mult.asm + +// Multiplies R0 and R1 and stores the result in R2. +// (R0, R1, R2 refer to RAM[0], RAM[1], and RAM[3], respectively.) +  // Put your code here. \ No newline at end of file