tag:blogger.com,1999:blog-10123487633050117632024-03-14T01:42:58.278-06:00Nand2TetrisLearning Computers from the ground up by building a working virtual Computeriamfritchhttp://www.blogger.com/profile/15241175673946734127noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-1012348763305011763.post-19085913111120430292013-10-08T02:01:00.000-06:002013-10-08T02:01:37.956-06:00Mux Gate<br />
Truth Table<br />
a b sel | f(a,b,sel)<br />
---------------------<br />
0 0 0 | 0<br />
0 0 1 | 0<br />
0 1 0 | 0<br />
0 1 1 | 1<br />
1 0 0 | 1<br />
1 0 1 | 0<br />
1 1 0 | 1<br />
1 1 1 | 1<br />
<br />
Boolean Expression<br />
<br />
<br />
----------------------------------------<br />
CHIP Mux<br />
{<br />
IN a, b, sel;<br />
OUT out;<br />
<br />
PARTS:<br />
Not(in=sel, out=selNot);<br />
And(a=selNot, b=a, out=out1);<br />
And(a=sel, b=b, out=out2);<br />
Or(a=out1, b=out2, out=out);<br />
}<br />
----------------------------------------iamfritchhttp://www.blogger.com/profile/15241175673946734127noreply@blogger.com1tag:blogger.com,1999:blog-1012348763305011763.post-88874641055242690242013-05-09T11:54:00.002-06:002013-05-09T11:56:04.225-06:00Or16 GateTruth Table<br />
a[x] | b[x] | f(a[x],b[x])<br />
----------------------------<br />
0 | 0 | 0<br />
0 | 1 | 1<br />
1 | 0 | 1<br />
1 | 1 | 1<br />
<br />
--------------------------------------------------<br />
CHIP Or16<br />
{<br />
IN a[16], b[16];<br />
OUT out[16];<br />
<br />
PARTS:<br />
Or(a=a[0], b=b[0], out=out[0]);<br />
Or(a=a[1], b=b[1], out=out[1]);<br />
Or(a=a[2], b=b[2], out=out[2]);<br />
Or(a=a[3], b=b[3], out=out[3]);<br />
Or(a=a[4], b=b[4], out=out[4]);<br />
Or(a=a[5], b=b[5], out=out[5]);<br />
Or(a=a[6], b=b[6], out=out[6]);<br />
Or(a=a[7], b=b[7], out=out[7]);<br />
Or(a=a[8], b=b[8], out=out[8]);<br />
Or(a=a[9], b=b[9], out=out[9]);<br />
Or(a=a[10], b=b[10], out=out[10]);<br />
Or(a=a[11], b=b[11], out=out[11]);<br />
Or(a=a[12], b=b[12], out=out[12]);<br />
Or(a=a[13], b=b[13], out=out[13]);<br />
Or(a=a[14], b=b[14], out=out[14]);<br />
Or(a=a[15], b=b[15], out=out[15]);<br />
}<br />
--------------------------------------------------<br />
<br />
Again you just take 2 arrays of 16 bits and OR each set of 2 bits from each array with the same index.iamfritchhttp://www.blogger.com/profile/15241175673946734127noreply@blogger.com0tag:blogger.com,1999:blog-1012348763305011763.post-39657675342950523312013-05-08T18:41:00.001-06:002013-05-09T11:55:51.311-06:00And16 GateTruth Table<br />
a[x] | b[x] | f(a[x],b[x])<br />
----------------------------<br />
0 | 0 | 0<br />
0 | 1 | 0<br />
1 | 0 | 0<br />
1 | 1 | 1<br />
<br />
--------------------------------------------------<br />
CHIP And16<br />
{<br />
IN a[16], b[16];<br />
OUT out[16];<br />
<br />
PARTS:<br />
And(a=a[0], b=b[0], out=out[0]);<br />
And(a=a[1], b=b[1], out=out[1]);<br />
And(a=a[2], b=b[2], out=out[2]);<br />
And(a=a[3], b=b[3], out=out[3]);<br />
And(a=a[4], b=b[4], out=out[4]);<br />
And(a=a[5], b=b[5], out=out[5]);<br />
And(a=a[6], b=b[6], out=out[6]);<br />
And(a=a[7], b=b[7], out=out[7]);<br />
And(a=a[8], b=b[8], out=out[8]);<br />
And(a=a[9], b=b[9], out=out[9]);<br />
And(a=a[10], b=b[10], out=out[10]);<br />
And(a=a[11], b=b[11], out=out[11]);<br />
And(a=a[12], b=b[12], out=out[12]);<br />
And(a=a[13], b=b[13], out=out[13]);<br />
And(a=a[14], b=b[14], out=out[14]);<br />
And(a=a[15], b=b[15], out=out[15]);<br />
}<br />
--------------------------------------------------<br />
<br />
Same as the 1 bit AND gate but you take 2 sets of 16 bits and AND each set of 2 bits from each array with the same index.iamfritchhttp://www.blogger.com/profile/15241175673946734127noreply@blogger.com0tag:blogger.com,1999:blog-1012348763305011763.post-49416047649778328442013-05-08T18:38:00.003-06:002013-05-09T11:55:22.025-06:00Not16 GateTruth Table<br />
in[x] | f(in[x])<br />
-----------------<br />
0 | 1<br />
1 | 0<br />
<br />
----------------------------------------<br />
CHIP Not16<br />
{<br />
IN in[16];<br />
OUT out[16];<br />
<br />
PARTS:<br />
Not(in=in[0], out=out[0]);<br />
Not(in=in[1], out=out[1]);<br />
Not(in=in[2], out=out[2]);<br />
Not(in=in[3], out=out[3]);<br />
Not(in=in[4], out=out[4]);<br />
Not(in=in[5], out=out[5]);<br />
Not(in=in[6], out=out[6]);<br />
Not(in=in[7], out=out[7]);<br />
Not(in=in[8], out=out[8]);<br />
Not(in=in[9], out=out[9]);<br />
Not(in=in[10], out=out[10]);<br />
Not(in=in[11], out=out[11]);<br />
Not(in=in[12], out=out[12]);<br />
Not(in=in[13], out=out[13]);<br />
Not(in=in[14], out=out[14]);<br />
Not(in=in[15], out=out[15]);<br />
}<br />
----------------------------------------<br />
<br />
Not too much different then a 1 bit NOT gate you just take 2 sets of 16 bits and NOT each set of 2 bits from each array with the same index.iamfritchhttp://www.blogger.com/profile/15241175673946734127noreply@blogger.com0tag:blogger.com,1999:blog-1012348763305011763.post-27470673076554736882013-05-08T04:41:00.002-06:002013-05-08T16:14:03.017-06:00Xor Gate<br />
Truth Table<br />
a b | f(a,b)<br />
------------<br />
0 0 | 0<br />
0 1 | 1<br />
1 0 | 1<br />
1 1 | 0<br />
<br />
Boolean Expression<br />
(!x*y)+(x*!y)<br />
<br />
----------------------------------------<br />
<br />
CHIP Xor<br />
{<br />
IN a, b;<br />
OUT out;<br />
<br />
PARTS:<br />
Not(in=a, out=aNot);<br />
Not(in=b, out=bNot);<br />
And(a=aNot, b=b, out=out1);<br />
And(a=a, b=bNot, out=out2);<br />
Or(a=out1, b=out2, out=out);<br />
}<br />
<br />
----------------------------------------<br />
<br />
Another that might seem hard at first but adding a few gates together does the trick. Seeing as you want to know when its one or the other and not both the first and gate returns a 1 only if y is 1 and x is not, and the second does the the opposite returns a 1 if x is 1 and y is not. Then its just a matter of outputing a 1 if either AND gate returned a 1.iamfritchhttp://www.blogger.com/profile/15241175673946734127noreply@blogger.com0tag:blogger.com,1999:blog-1012348763305011763.post-48476433427622074932013-05-08T04:25:00.001-06:002013-05-08T16:13:40.171-06:00Or GateTruth Table<br />
a b | f(a,b)<br />
------------<br />
0 0 | 0<br />
0 1 | 1<br />
1 0 | 1<br />
1 1 | 1<br />
<br />
Boolean Expresions<br />
a+b<br />
<br />
---------------------------------------------<br />
CHIP Or<br />
{<br />
IN a, b;<br />
OUT out;<br />
<br />
PARTS:<br />
Not(in=a, out=aNot);<br />
Not(in=b, out=bNot);<br />
Nand(a=aNot, b=bNot, out=out);<br />
}<br />
---------------------------------------------<br />
<br />
At first this one might seem difficult but since we have the NAND gate the opposite of what we want we just take the opposite of each in and then NAND the results.iamfritchhttp://www.blogger.com/profile/15241175673946734127noreply@blogger.com0tag:blogger.com,1999:blog-1012348763305011763.post-255217702835087982013-05-06T13:26:00.001-06:002013-05-08T16:13:23.864-06:00And GateTruth Table<br />
a b | f(a,b)<br />
-------------<br />
0 0 | 0<br />
0 1 | 0<br />
1 0 | 0<br />
1 1 | 1<br />
<br />
Boolean Expression<br />
x*y<br />
<br />
----------------------------------------<br />
CHIP And<br />
{<br />
IN a, b;<br />
OUT out;<br />
<br />
PARTS:<br />
Nand(a=a, b=b, out=out1);<br />
Not(in=out1, out=out);<br />
}<br />
----------------------------------------<br />
<br />
Seeing as we started with the opposite of this gate the NAND and that we just created the NOT gate its as simple as taking the opposite(NOT) of the NAND gate.iamfritchhttp://www.blogger.com/profile/15241175673946734127noreply@blogger.com2tag:blogger.com,1999:blog-1012348763305011763.post-89217843188567866832013-05-05T04:28:00.001-06:002017-11-21T14:55:41.307-07:00Not GateTruth Table<br />
in | f(in)<br />
--------<br />
0 | 1<br />
1 | 0<br />
<br />
Boolean Expressions<br />
!x<br />
<br />
----------------------------------------<br />
CHIP Not<br />
{<br />
IN in;<br />
OUT out;<br />
<br />
PARTS:<br />
Nand(a=in, b=in, out=out);<br />
}<br />
----------------------------------------<br />
<br />
Fairly simple gate<br />
For TRUE(1), TRUE and TRUE is TRUE making the <u>N</u>AND gate return FALSE(0)<br />
For FALSE(0, FALSE and FALSE is FASLE making the <u>N</u>AND gate return TRUE(0)<br />
Out Becomes the opposite of in.iamfritchhttp://www.blogger.com/profile/15241175673946734127noreply@blogger.com0tag:blogger.com,1999:blog-1012348763305011763.post-27708177163369106162013-05-05T04:22:00.001-06:002013-05-06T13:36:24.675-06:00Nand2Tetris Hardware Simulator<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiwuxFt4gkIJ9UVrlDbNPgC3lITs14a2ci9BHOHpFlHS2mDlMqDAkMBsyNNrQ01jB8BHr9S6Qic6m01HiczufnjQ5nJMOTwbwn37YOI4arRZyPDC4MprhKO-CDzv3JROcd3W2rAkGk1o_N/s1600/Nand2Tetris+-+Hardware+Simulator.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiwuxFt4gkIJ9UVrlDbNPgC3lITs14a2ci9BHOHpFlHS2mDlMqDAkMBsyNNrQ01jB8BHr9S6Qic6m01HiczufnjQ5nJMOTwbwn37YOI4arRZyPDC4MprhKO-CDzv3JROcd3W2rAkGk1o_N/s640/Nand2Tetris+-+Hardware+Simulator.png" width="640" /></a></div>
<br />iamfritchhttp://www.blogger.com/profile/15241175673946734127noreply@blogger.com0