YouTube2Text

From Nand to Tetris in 12 steps — Transcript

by GoogleTalksArchive · 10,375 words · 1,745 segments · language en · Watch on YouTube

Full transcript

  1. 0:02Welcome everyone to today's tech talk.
  2. 0:05I'd like to mention that we are going to
  3. 0:07be external, so please hold any
  4. 0:08confidential questions, not that there
  5. 0:10would be any for this talk possibly, but
  6. 0:13till the end. We're very pleased today
  7. 0:15to have with us Professor Shimon
  8. 0:17Schocken.
  9. 0:18Shimon
  10. 0:20is a professor of information
  11. 0:22technologies and founding dean of Efi
  12. 0:25Arazi School of Computer Science in
  13. 0:27Herzliya, Israel. That's near Tel Aviv.
  14. 0:30Previously, Shimon was at NYU and IDC in
  15. 0:33Israel.
  16. 0:34Today's talk will describe a new
  17. 0:36approach and a new course that aims to
  18. 0:37demystify the integrated function of
  19. 0:39computer systems using a hands-on
  20. 0:41approach. Please join me in welcoming
  21. 0:43Shimon Schocken.
  22. 0:49Thank you, Jeff.
  23. 0:51A company like Google has to contend
  24. 0:55with many different disciplines in
  25. 0:56computer science, whether it's
  26. 0:58distributed processing or database
  27. 1:00management, operating systems,
  28. 1:03grid computing, GUI,
  29. 1:06graph theory,
  30. 1:08and so on. But at the end, all these
  31. 1:10different topics gel into one grand
  32. 1:14theme,
  33. 1:15search.
  34. 1:17I guess I'm talking
  35. 1:18about the core business of Google.
  36. 1:21And this in a nutshell is one of the
  37. 1:22biggest differences between academic
  38. 1:24programs and and real life. In in real
  39. 1:27life,
  40. 1:28most of the interesting problems and
  41. 1:29opportunities that we see
  42. 1:31present themselves as multidisciplinary
  43. 1:34themes, and it's kind of difficult to
  44. 1:35draw lines and and and and show where
  45. 1:38the algorithm ends and the
  46. 1:39implementation starts or where where's
  47. 1:42database management, where's
  48. 1:43object-oriented programming, everything
  49. 1:44everything is kind of
  50. 1:46gelled together. And yet academic
  51. 1:49programs are structured around topics.
  52. 1:51They have to be structured around around
  53. 1:52topics, and each topic is covered by a
  54. 1:55standalone course taught by typically a
  55. 1:57different professor
  56. 1:59and accompanied by a thousand-page
  57. 2:01textbook.
  58. 2:03And as a result of that, students are
  59. 2:04becoming increasingly more and more
  60. 2:06specialized in niche pockets and and and
  61. 2:10areas in computer science,
  62. 2:12and and increasingly they miss the
  63. 2:15forest for the trees. They they fail to
  64. 2:18appreciate all the interfaces and and
  65. 2:22contracts that lurk in the background
  66. 2:24and create the very fabric that that
  67. 2:27that that makes what applied computer
  68. 2:29science is is all about.
  69. 2:31So, that's where this talk enters the
  70. 2:33picture.
  71. 2:34Noam Nisan and myself, both of us were
  72. 2:36program directors at
  73. 2:39two different universities, and we felt
  74. 2:42that computer science programs should
  75. 2:44have also, in addition to the core
  76. 2:46courses and so on, they should have some
  77. 2:48theme-oriented courses.
  78. 2:51And the grandest theme of all that we
  79. 2:53could think of was building a computer
  80. 2:56system, a general-purpose computer
  81. 2:58hardware and software from scratch.
  82. 3:01And this ended up indeed being being a
  83. 3:03very stimulating and and empowering
  84. 3:06activity for the students because it's
  85. 3:08an act of creation, of creating
  86. 3:10something from nothing.
  87. 3:12So, what I'm going to do in the next
  88. 3:14hour is fast forward through this
  89. 3:16course, which is actually an approach to
  90. 3:18teaching applied computer science,
  91. 3:21and try to convince you that it can be
  92. 3:22done.
  93. 3:23In fact, and it can be done in one
  94. 3:25semester.
  95. 3:27In fact, I'm I'm and I'm not talking
  96. 3:28about half-baked ideas. I'm talking
  97. 3:30about
  98. 3:32a course and that has been published. I
  99. 3:34mean, the
  100. 3:35book came out about a year and a half
  101. 3:37ago by MIT Press that accompanies this
  102. 3:40book this course, and the course has
  103. 3:43been taught in several different
  104. 3:44universities, and I think by now more
  105. 3:46than a thousand students have taken it
  106. 3:47and
  107. 3:48have been quite happy campers. So, so
  108. 3:52the course works, and um
  109. 3:54and here's what we do. We basically we
  110. 3:56start the course by telling the students
  111. 3:59that
  112. 4:00that God gave us um
  113. 4:03NAND,
  114. 4:04and and if you want, you can throw in
  115. 4:06also a constant. And then God said, "Now
  116. 4:10go build a computer." And when when man
  117. 4:13asked how,
  118. 4:14God answered, "One step at a time." And
  119. 4:17in fact, this is a very important
  120. 4:18element in our course. The the students
  121. 4:21are going to be engaged in very complex,
  122. 4:23fantastically complex
  123. 4:25engineering projects, both hardware and
  124. 4:27software,
  125. 4:29but we have laid out all the designs of
  126. 4:32these projects, and we did it in a very
  127. 4:33sort of stepwise fashion, and and
  128. 4:35modularity
  129. 4:37is is a key virtue in this course and
  130. 4:40something that is an important part of
  131. 4:42the education that the students are
  132. 4:43gaining from the course.
  133. 4:45So, this is the
  134. 4:47explicit um
  135. 4:49goal of the course. You know, let's
  136. 4:51start from nothing and end up with a
  137. 4:52computer. The computer that we will
  138. 4:54build, as you will soon see, has the
  139. 4:56touch and feel of of a simple PDA,
  140. 5:00and you can write all sorts of pro- it's
  141. 5:02a general-purpose computer. You can
  142. 5:03write all sorts of programs for it.
  143. 5:05But the implicit agenda is to understand
  144. 5:08the key hardware and software
  145. 5:10abstractions and interfaces that make
  146. 5:11make the field. And also to appreciate
  147. 5:15the history and and method of computer
  148. 5:17science,
  149. 5:18which is kind of gained as you as you go
  150. 5:20along in in the lectures of this course.
  151. 5:23It It's a It's a lot of fun
  152. 5:26taking this course and building the
  153. 5:27computer, and the students do it with a
  154. 5:29great deal of
  155. 5:30motivation.
  156. 5:32The methodology of this course is very
  157. 5:34strict
  158. 5:35because otherwise, there's no way that
  159. 5:37you can finish it once in one semester.
  160. 5:39So, first of all, it's constructive. We
  161. 5:40don't talk much. We we build a lot of
  162. 5:42stuff. The lectures are not very
  163. 5:44important, but
  164. 5:46uh they're kind of a nice add-on to the
  165. 5:49projects. I mean, there's a set of
  166. 5:50projects, weekly projects in which you
  167. 5:53you build gradually the whole the whole
  168. 5:56thing.
  169. 5:57Um
  170. 5:58The course is self-contained. The only
  171. 6:00thing that you need in order to take it
  172. 6:01is programming, which is surprising. I
  173. 6:03mean, you don't have to know anything
  174. 6:04about architecture,
  175. 6:05virtual machines, or or whatnot. It's uh
  176. 6:08All the knowledge that that you need to
  177. 6:10know in the course is is self-contained
  178. 6:12in the textbook and the course.
  179. 6:14All the plans for building the computer
  180. 6:18architecture and the software hierarchy
  181. 6:20are given
  182. 6:21in the form of APIs in our website. And
  183. 6:24the course is also extremely focused. We
  184. 6:26don't deal with anything which is
  185. 6:27unnecessary for the purpose of building
  186. 6:29this computer. We just want to build a
  187. 6:31computer
  188. 6:32that can with which you can play Tetris
  189. 6:34or Space Invaders and kind of stay
  190. 6:36alive, you know, we don't want to make
  191. 6:37it too fancy because otherwise, there's
  192. 6:39no way that we will will be able to do
  193. 6:41it in one semester.
  194. 6:43So,
  195. 6:44so this is this is what the students
  196. 6:46see, but actually behind the scene, what
  197. 6:49they get is a whole
  198. 6:52slew of of of different things. And what
  199. 6:55you see here are those topics that I
  200. 6:57talked about before, which are covered
  201. 6:59in many different courses in the
  202. 7:00program,
  203. 7:01but here finally, they converge
  204. 7:04together. Okay, so we have topics from
  205. 7:07very different areas in computer
  206. 7:08science, but all of them come to play
  207. 7:11um
  208. 7:12very vividly in the context of of
  209. 7:14building this computer.
  210. 7:17Here are some screenshots of the
  211. 7:20computer when it's finally running. So,
  212. 7:24these are programs that the students
  213. 7:25wrote for the computers that they built.
  214. 7:27As you will see in a minute, the
  215. 7:28computer has a screen and a keyboard
  216. 7:30interface. So, this is a simple data
  217. 7:32processing program.
  218. 7:34Here is a Pong
  219. 7:36screenshot, Space Invaders. I will demo
  220. 7:39some of these in few minutes. Hangman,
  221. 7:42and so on.
  222. 7:44So, the course map is as follows. We
  223. 7:46have two grand pieces, hardware and
  224. 7:49software,
  225. 7:50and um
  226. 7:52the interface that sort of links them
  227. 7:54together is obviously the machine
  228. 7:55language that that puts this whole
  229. 7:58structure together.
  230. 7:59And um
  231. 8:01what you see here are
  232. 8:03those P's are they stand for you can
  233. 8:06call it instructional unit. An
  234. 8:07instructional unit is a lecture, a
  235. 8:10project,
  236. 8:12and a chapter in the book. So, if you
  237. 8:14just go through these units week by
  238. 8:16week, you end up building the machine.
  239. 8:18So, we start with some um
  240. 8:21we build something like 10 or 12, I
  241. 8:23forgot, elementary logic gates, AND, OR,
  242. 8:25XOR, and so on. Then we put them
  243. 8:27together and we build a
  244. 8:29a little ALU and CPU.
  245. 8:32And then we build a memory system.
  246. 8:35Then we jump up to P4, where we
  247. 8:37introduce the machine language. We write
  248. 8:39some programs for the machine language.
  249. 8:41Having learned the machine language, we
  250. 8:42step back and build the hardware
  251. 8:45architecture that realizes this language
  252. 8:47using the various chipsets that uh that
  253. 8:51we built below.
  254. 8:53And then in the second part of the
  255. 8:54course, we build an assembler,
  256. 8:57a VM,
  257. 8:59and a compiler for
  258. 9:01a very simple Java-like language that we
  259. 9:03have
  260. 9:04formulated. And and then we use the same
  261. 9:07language to also write a little
  262. 9:08operating system
  263. 9:10for this machine.
  264. 9:11And finally, we write some some games
  265. 9:13like Tetris and uh
  266. 9:15and Snake and so on for this computer.
  267. 9:18So, the P's are these instructional
  268. 9:20units. Each unit is self-contained,
  269. 9:24and it's extremely self-contained in the
  270. 9:26sense that you can actually teach this
  271. 9:27course in any order that you wish, which
  272. 9:29sounds a little bit crazy, but if you
  273. 9:31want, I mean, you can start here. You
  274. 9:32can start with a VM because the
  275. 9:34interface below is very well defined,
  276. 9:36and
  277. 9:37every one of these boxes here is an
  278. 9:39abstraction that is implemented using
  279. 9:40the services of the abstraction below
  280. 9:42it. And and these interfaces are well
  281. 9:44defined in the course, so you don't
  282. 9:46really have to teach or do the hardware.
  283. 9:48You can do just the software or the
  284. 9:50other way around.
  285. 9:52So, what I'll do next is I'll walk you
  286. 9:54through a typical project. So,
  287. 9:56what we see here are five different
  288. 9:57projects and uh uh
  289. 10:00the tools that we use in order to build
  290. 10:03all these things
  291. 10:04is first of all a very simple dialect of
  292. 10:06HDL that you can learn in 1 hour.
  293. 10:09And a test description language that we
  294. 10:12have designed for the purpose of this
  295. 10:13project for this course.
  296. 10:15And also a hardware simulator which we
  297. 10:17built and can be downloaded freely
  298. 10:20from our website. All the software that
  299. 10:21we developed for this course and there's
  300. 10:23a lot of software that accompanies it is
  301. 10:25open source.
  302. 10:27Can run on both Windows and Unix and
  303. 10:29available from our website.
  304. 10:31So, these are the tools that we use and
  305. 10:34um
  306. 10:35let's take for example some elementary
  307. 10:37logic gates.
  308. 10:38And um
  309. 10:41in the first project, what you do is
  310. 10:44well, NAND is God given.
  311. 10:46So, we start with that and using this we
  312. 10:48build a not.
  313. 10:50And using not we build a true.
  314. 10:53And then
  315. 10:55we build and
  316. 10:57and or.
  317. 10:59And obviously every gate here is
  318. 11:01designed using the gates that have been
  319. 11:03designed previously.
  320. 11:04And then we build a mux and um
  321. 11:07and so on. About 12 gates all together.
  322. 11:09Okay? So, let's focus on on one of these
  323. 11:12gates, let's say and
  324. 11:14and actually build it. So, um
  325. 11:18we tell the students that here is here
  326. 11:19is and and is a black box. Here's the
  327. 11:21gate diagram of and and the
  328. 11:24the truth table of this operation.
  329. 11:26And we also give them an HDL program
  330. 11:28stub. And the stub consists of the input
  331. 11:31and the output of the gate, you know,
  332. 11:33that's the API of the gate and a
  333. 11:36comment.
  334. 11:37And finally, we give them a test script.
  335. 11:40And the test script is written in our
  336. 11:42testing language.
  337. 11:44This is something that you load into the
  338. 11:46hardware simulator and essentially what
  339. 11:48it says it tells the simulator
  340. 11:50look for a file called and.hdl, this
  341. 11:52one, load it into the simulator, then
  342. 11:54create an output file called and.out.
  343. 11:57Let's ignore the comparator for a minute
  344. 11:59and then
  345. 12:00whenever you see the word output, I want
  346. 12:02you to output the current values of A, B
  347. 12:05and out. And then starts the actual
  348. 12:07simulation. Okay? So, we have four steps
  349. 12:09here. Set A to zero, set B to zero, eval
  350. 12:13evaluate the logic of the gate and
  351. 12:15output something out. Well, what you
  352. 12:16output is this, A, B and out and so on.
  353. 12:19And you just walk the simulators through
  354. 12:20all the possibilities of this very
  355. 12:22simple gate.
  356. 12:24And
  357. 12:25the contract is that when you run
  358. 12:27well, you have to write the HDL that
  359. 12:30will make this test work. And and
  360. 12:32generate
  361. 12:33generate this, the compare file up
  362. 12:35there. So, um
  363. 12:37the compare file or the truth table in
  364. 12:39this case is also given to the students
  365. 12:40as a text file. So, when you run your
  366. 12:42HDL, your modified HDL on our TST
  367. 12:46your output should be the same as our
  368. 12:47compare file. That's the deal. Okay? So,
  369. 12:51the student goes home and
  370. 12:53here is he starts he or she they start
  371. 12:55with something like that.
  372. 12:56And at some point they figure out the
  373. 12:59gate logic
  374. 13:01up there and then they simply
  375. 13:05implement it in some, you know, back of
  376. 13:06the envelope drawing or something like
  377. 13:08that. In fact, the simulator
  378. 13:13in the next version of the simulator you
  379. 13:14can also draw these gates graphically
  380. 13:17and have them
  381. 13:18and and and produce the HDL from it
  382. 13:20automatically. But basically what what
  383. 13:22the student does, they they draw this
  384. 13:24picture and then they
  385. 13:26they render it in in in a textual form
  386. 13:28in HDL.
  387. 13:30So, basically we need two gates, NAND
  388. 13:32and not. NAND and not. And here are the
  389. 13:35connections and
  390. 13:37the NAND outputs it's the output into
  391. 13:40pipes it into X and then the not um
  392. 13:44has the X feed its in gate and
  393. 13:47out going to out and you know, that's
  394. 13:49it. That's that's how
  395. 13:51this gate is implemented.
  396. 13:53So, here's an example of how it's being
  397. 13:55done in the hardware simulator
  398. 13:57that we provide. So, what we see here,
  399. 14:00well, that's a different gate. It's it's
  400. 14:02XOR gate. Okay? So, here's the diagram.
  401. 14:05Here is
  402. 14:06the HDL program that the student has
  403. 14:08written or the program that was
  404. 14:09generated from the diagram.
  405. 14:11And here's the test script with a lot of
  406. 14:13white space added to make it more
  407. 14:15readable.
  408. 14:16Um
  409. 14:18and what you see here are the various
  410. 14:20steps in the in the test script. Some
  411. 14:23some some steps end with a with a comma,
  412. 14:27some with a semicolon. The comma is kind
  413. 14:29of a micro step and the and the
  414. 14:31semicolon is a big step. So, that
  415. 14:33whenever you click
  416. 14:35um
  417. 14:36this control here up here
  418. 14:39it executes
  419. 14:41all the commands in the test script up
  420. 14:43to the next semicolon.
  421. 14:45So, that's what we do here. We we walk
  422. 14:47the simulator. I mean, this is
  423. 14:48PowerPoint. In a minute you will see it
  424. 14:50for real.
  425. 14:51But we walk it through the various steps
  426. 14:53and at some point we say, well, show me
  427. 14:56what what came out from the simulation.
  428. 14:58Well, here's the output file. If you
  429. 15:00look at the output file, it seems like
  430. 15:02it has
  431. 15:03the correct functionality of XOR. So,
  432. 15:05you're happy. You can also compare it to
  433. 15:07the compare file and make sure that that
  434. 15:09your chip works.
  435. 15:11So, that's the first project in which we
  436. 15:12build 12 such chips. That's week one.
  437. 15:16And here's another example of of a chip,
  438. 15:19a 16-bit adder. The computer by the way
  439. 15:21is 16-bit. So, here is um the
  440. 15:24implementation of a 16-bit adder using
  441. 15:27full adders. If you focus on one of one
  442. 15:30of them, well, here's the full adder
  443. 15:31chip consisting of three half adders.
  444. 15:34Half adder consists of XOR and an AND.
  445. 15:37XOR consists of well, here's a better
  446. 15:39implementation of XOR than the one you
  447. 15:41saw earlier.
  448. 15:42If you click AND, you get um
  449. 15:45what we saw before, NAND
  450. 15:48and if you click not,
  451. 15:50actually this is what we No, if you
  452. 15:51click not, we get the not implementation
  453. 15:54from NAND.
  454. 15:55If you click NAND, well, the buck stops
  455. 15:57here.
  456. 15:58And NAND is primitive and God given.
  457. 16:01So, it's implemented in Java. Okay? The
  458. 16:04the simulator is implemented in Java and
  459. 16:06it has a whole suite of of primitive
  460. 16:09Java-based implementations of of chips.
  461. 16:12So, if there's no HDL program
  462. 16:15the simulator resorts to
  463. 16:17to one of its um
  464. 16:19chip files, so to speak, the NAND.the
  465. 16:22chip.java files
  466. 16:23that provide the functionality of this
  467. 16:25chip.
  468. 16:27We mentioned history. So, you know,
  469. 16:29that's that's an example of of a great
  470. 16:31place where you can talk you can talk
  471. 16:33about, you know, people like George
  472. 16:34Boole and Claude Shannon and
  473. 16:36discuss how great ideas, which were
  474. 16:38quite abstract 150 years ago, became
  475. 16:41extremely practical
  476. 16:44when electrical engineering started and
  477. 16:47all of the sudden, you know, Shannon
  478. 16:49discovered that he could use the algebra
  479. 16:51of Boolean algebra in order to
  480. 16:53describe the behavior of of logic gates.
  481. 16:56So,
  482. 16:57these great connections that sort of
  483. 16:59overarch
  484. 17:00different periods in history
  485. 17:02they they come to life. They can come to
  486. 17:04life in a course like that and that's in
  487. 17:06my lectures, that's what I do. I spend
  488. 17:07half of every lecture talking about the
  489. 17:09historical context of these things.
  490. 17:11Because other than that, you don't have
  491. 17:13to talk much because everything is is in
  492. 17:14the project. The students go home and
  493. 17:15they just do the project.
  494. 17:17Um
  495. 17:19and and they get most of their
  496. 17:20educational value from the projects, not
  497. 17:22from the lectures.
  498. 17:24Here's another anatomy of of a RAM chip.
  499. 17:26I don't have time to go through it, but
  500. 17:28basically it's kind of a top-down
  501. 17:31recursion, if you will.
  502. 17:33And just a few comments about the
  503. 17:35simulator.
  504. 17:36Um
  505. 17:37as we said, NAND is primitive.
  506. 17:40But in general,
  507. 17:41this computer is made up of about 30
  508. 17:44different chips.
  509. 17:45And at some point we had an insight that
  510. 17:48what we should do perhaps is implement
  511. 17:50all these chips in Java and put them in
  512. 17:51the simulator also.
  513. 17:53So, that if if
  514. 17:55if you start if the simulator starts to
  515. 17:57evaluate the logic of the chip, it finds
  516. 17:59some chip chip part, it looks for for an
  517. 18:01HDL
  518. 18:02file that provides the functionality of
  519. 18:05this chip chip part. Failing to find
  520. 18:07this file, it looks for a Java file that
  521. 18:10implements this chip file
  522. 18:12this chip behavior and then it uses it.
  523. 18:15Now, this means that because everything
  524. 18:17is was was predefined in Java, you don't
  525. 18:19have to build all the chips in order to
  526. 18:21build anyone
  527. 18:22of the higher level chips. So, if you
  528. 18:24want to build, let's say a RAM
  529. 18:26you can just use the register, demux and
  530. 18:29mux and you have a RAM
  531. 18:31RAM chip working because
  532. 18:33if you didn't write those lower level
  533. 18:35the
  534. 18:36the register, demux and and mux,
  535. 18:38the simulator will use the Java classes
  536. 18:40instead.
  537. 18:41So, this gave gave us tremendous
  538. 18:43freedom. You don't have to write
  539. 18:44everything. You can
  540. 18:46develop those chips in any order that
  541. 18:49you wish or if the student gets stuck in
  542. 18:51something, if for some reason the
  543. 18:52student cannot implement a mux or a
  544. 18:54demux, that's okay. They can still
  545. 18:57complete the definition of the chip and
  546. 18:59simulate it and test it and maybe get
  547. 19:01partial credit for the project. But but
  548. 19:04they, you know,
  549. 19:05local catastrophes are never never
  550. 19:08global. That this this is the meaning of
  551. 19:10this strategy here.
  552. 19:12Um
  553. 19:13And you also get behavioral simulation
  554. 19:14of the chip and um
  555. 19:17all sorts of other things that that I
  556. 19:18don't have to discuss. I don't have time
  557. 19:19to discuss. So, we'll we'll skip it
  558. 19:21maybe for questions at the end if we
  559. 19:22have time.
  560. 19:23All right. So, this is elementary logic
  561. 19:25gates and um
  562. 19:28moving along, we build an ALU.
  563. 19:30The ALU consists of what we saw it, half
  564. 19:33adder, full adder and adder. And then we
  565. 19:35use the adder to to build a full-blown
  566. 19:37ALU.
  567. 19:38And the ALU has two
  568. 19:4016-bit inputs and six control bits that
  569. 19:43that instruct the ALU what to do. And
  570. 19:45also it emits two two bits
  571. 19:49that that are used by the control unit
  572. 19:51of the later on.
  573. 19:53So, we have six control bits and all
  574. 19:56together given these six control bits
  575. 20:00we the ALU is designed to compute all
  576. 20:03these
  577. 20:04nice functions.
  578. 20:05Um
  579. 20:07and what you have here is pretty good
  580. 20:09functionality for an assembly language
  581. 20:11um
  582. 20:12without multiplication.
  583. 20:14We implement multiplication in software
  584. 20:17as you will see in a minute. Um so,
  585. 20:19let's focus on the control bits.
  586. 20:21Um
  587. 20:22here are these six control bits and um
  588. 20:25they have those funny names because they
  589. 20:26imply on what they do. So, ZX means
  590. 20:30um ignore the X input, just make it
  591. 20:32zero. And NX means convert the X input.
  592. 20:36Remember, X and Y are 16-bit. Z and ZY
  593. 20:38and NY do the same for Y. Then if if F
  594. 20:41is one, compute X + Y, else compute X
  595. 20:45and Y.
  596. 20:46And if NO
  597. 20:47NO is one, convert the the out,
  598. 20:49otherwise leave it alone.
  599. 20:51It turns out that given this um
  600. 20:54uh given this setting here
  601. 20:57with different combinations of of bits
  602. 20:59um of asserting these six control bits,
  603. 21:02you get all the functionality on the
  604. 21:03right. Okay, so you can you can compute
  605. 21:05zero, one, minus one, X
  606. 21:07Y not, X not, Y and so on and so forth.
  607. 21:10In fact, we have six control bits, so
  608. 21:12actually we can implement 64 functions
  609. 21:16but most of them are are undocumented
  610. 21:18features of this ALU. Okay, so we are
  611. 21:21we described only these functions. If
  612. 21:23you're a real hacker
  613. 21:24you can you can discover some other very
  614. 21:26nice functions that this this ALU can
  615. 21:28can compute. This is
  616. 21:31I really like this ALU. I mean, this is
  617. 21:33uh it's it's a logical ALU. You know,
  618. 21:36developing it is is a piece of cake
  619. 21:38because
  620. 21:38in order to develop it, all you have to
  621. 21:40do is implement the behavior that you
  622. 21:43see up there. You have to either zero
  623. 21:44the input or negate it. That's it.
  624. 21:46That's all you have to do.
  625. 21:48And then all the rest of the of the
  626. 21:50functionality of the ALU is determined
  627. 21:52by this very clever
  628. 21:54table that Noam Nisan, my colleague,
  629. 21:56figured out. So,
  630. 21:58the ALU is really a piece of cake to to
  631. 22:01develop and once you you have it uh it's
  632. 22:04a small step to develop a full-blown
  633. 22:06CPU.
  634. 22:08Here we see how the ALU fits in the big
  635. 22:09picture. We see the six control bits. We
  636. 22:11now call them Cs, C1 to C6.
  637. 22:15And um
  638. 22:17we have this table that we saw before,
  639. 22:18but we add one more detail. One of the
  640. 22:21inputs of the ALU can come either from
  641. 22:23an A register
  642. 22:25or from the RAM. So, we have a
  643. 22:26multiplexer there controlled by a
  644. 22:28seventh control bit, the A.
  645. 22:31And finally, you have So, you have all
  646. 22:33these
  647. 22:34functionality. A is is the A register.
  648. 22:38It's an address register that can act
  649. 22:40also as a data register. D is a strictly
  650. 22:43a data register. M
  651. 22:45is the currently selected register in
  652. 22:48the RAM. Okay, so you have all these
  653. 22:50mnemonics available to you when when
  654. 22:52when you get to write the um
  655. 22:54the assembly language.
  656. 22:56All right, then we go on and we build a
  657. 22:58memory system.
  658. 23:00Um
  659. 23:01we start with DF
  660. 23:03data flip-flops
  661. 23:04and we
  662. 23:05we we build a a bit um
  663. 23:09storage unit. Then we put a bunch of
  664. 23:11bits together, 16 bits together, we get
  665. 23:13a register. We do it in HDL, obviously.
  666. 23:16Then we use a multiplexer and
  667. 23:18demultiplexer to build a RAM 8.
  668. 23:21Um I don't show you all the details
  669. 23:22because we don't have time. We put we
  670. 23:25stack eight of these together, we get a
  671. 23:26RAM 64.
  672. 23:28Two, three more steps, you get RAM 32K
  673. 23:31which is what we need for for our
  674. 23:32computer. Okay, so it's not a very
  675. 23:34efficient implementation, but it works.
  676. 23:37Um
  677. 23:39then we
  678. 23:41we play with the machine language. So,
  679. 23:42the machine language is something that
  680. 23:43we invented and we have two commands
  681. 23:46only in the machine language. The first
  682. 23:48one is called A instruction
  683. 23:50and we use it to set the A register to a
  684. 23:53certain 15-bit value.
  685. 23:55Um so, in binary
  686. 23:58uh this is the instruction. Uh the op
  687. 24:00code is zero and then you have a 15-bit
  688. 24:03constant which the architecture uses in
  689. 24:05order to set
  690. 24:07um So, this is the constant that goes
  691. 24:09into the A register.
  692. 24:11And then we have a C instruction
  693. 24:13uh which is the major sort of working
  694. 24:15horse of this language. And the language
  695. 24:17the syntax of the C instruction is kind
  696. 24:18of high level.
  697. 24:20Uh destination equals some computation
  698. 24:23with an optional jump. Okay, so
  699. 24:26computation is one of these mnemonics
  700. 24:29that you saw before. So, we can tell the
  701. 24:31ALU compute D or D + 1 or M - 1 and so
  702. 24:35on.
  703. 24:36And then
  704. 24:37destination can be any of these
  705. 24:39combinations. So, the output of the ALU
  706. 24:41actually
  707. 24:43is wired simultaneously into the D, into
  708. 24:47the A, and into the RAM. And using
  709. 24:49different control bits, we can open
  710. 24:51different subsets of these three
  711. 24:53containers to accept the output of the
  712. 24:55ALU. So, these are the various outputs
  713. 24:58of the ALU.
  714. 24:59And
  715. 25:01and here are the jump possibilities. We
  716. 25:02have eight of them, which is all we
  717. 25:04need, all the possible jump conditions.
  718. 25:06And the jump is always conditioned not
  719. 25:09always, but it's conditioned on the
  720. 25:11output of the ALU. So, this is this
  721. 25:13means jump if the output was greater
  722. 25:15than zero, jump if the output was equal
  723. 25:17equal zero, and so on. We are missing
  724. 25:20two control bits that go down here,
  725. 25:22which provide the
  726. 25:24uh the results Well, well, they are they
  727. 25:26are one if the ALU is positive or zero.
  728. 25:30And and that's how we implement uh
  729. 25:33the materialized jumps, so to speak.
  730. 25:36So, that's a C instruction.
  731. 25:38And
  732. 25:39the binary mapping of this instruction
  733. 25:41is the following. The op code is one.
  734. 25:43Then we have two unused bits, which we
  735. 25:46set to one by default, by convention.
  736. 25:49And then we have the seven control bits
  737. 25:51of the ALU, which make up the comp
  738. 25:53field, the three control bits of
  739. 25:55destination, the three control bits of
  740. 25:57jump.
  741. 25:58And here are the values of of these
  742. 26:01things.
  743. 26:02And that's what you need when you when
  744. 26:03you write the assembler for this
  745. 26:04machine. You you're going to see
  746. 26:06programs written in the syntax at the
  747. 26:08top. And in order to run these programs,
  748. 26:10you have to first translate them into
  749. 26:13their binary equivalents, and you do it
  750. 26:15using
  751. 26:16Basically, these two pages is all these
  752. 26:18two slides is all you need in order to
  753. 26:19implement the assembler. Well, a little
  754. 26:21bit more than that because you also need
  755. 26:22a symbol table
  756. 26:24which I haven't discussed.
  757. 26:26So, that's the machine language and
  758. 26:28finally, we put all these things
  759. 26:29together and we get a computer.
  760. 26:32Actually, we start with a CPU.
  761. 26:34Um everything here is standard. We did
  762. 26:37it already. We we we did the ALU.
  763. 26:40Uh we developed the registers when we
  764. 26:42when we built the the memory system. Uh
  765. 26:46the multiplexers are from project one.
  766. 26:48So, you just put them together. So,
  767. 26:50essentially, an instruction comes in,
  768. 26:5216-bit instruction. Using HDL, you split
  769. 26:55it into various fields and you you sort
  770. 26:58of
  771. 26:58you just you just pipe these fields into
  772. 27:00different locations of the computer. So,
  773. 27:02some of these bits are control bits that
  774. 27:04open up different
  775. 27:06different registers. Other bits uh feed
  776. 27:08the ALU and tell the ALU what to do. Uh
  777. 27:11other fields control the jump or or the
  778. 27:13PC, the program counter
  779. 27:16uh logic and so on. So,
  780. 27:18you know, writing this CPU is a matter
  781. 27:21of it's one page of HDL.
  782. 27:23Here it is. Okay, this is the um
  783. 27:26uh the HDL one HDL implementation of of
  784. 27:29the ALU.
  785. 27:30Looks a little bit forbidding, but um
  786. 27:32it's it's really quite simple.
  787. 27:34Um finally, you take the CPU
  788. 27:36um and you take the two memory systems
  789. 27:39that that we built earlier.
  790. 27:41I forgot to say this this computer it's
  791. 27:43a von Neumann machine
  792. 27:45but it's also called, I think, a Harvard
  793. 27:47architecture in which
  794. 27:49the
  795. 27:50uh the instruction memory and the data
  796. 27:51and the data memory are separate, two
  797. 27:53separate units because it's a simple
  798. 27:54it's the simplest architecture to build.
  799. 27:56So, you put all these things together
  800. 27:59and you get a computer that realizes the
  801. 28:01machine language that we described
  802. 28:03before. So, the HDL of this
  803. 28:07architecture is um
  804. 28:09just three lines of code. Okay, that's
  805. 28:12project five. In project five, you build
  806. 28:14the CPU and um
  807. 28:16and the computer.
  808. 28:17Um
  809. 28:18in fact, one you know, one goal that I
  810. 28:20that I have in life is is trying to fit
  811. 28:23everything on one page or
  812. 28:25one slide. And and I we managed to do it
  813. 28:27in this course. All the all the HDL
  814. 28:29programs are no longer than one page of
  815. 28:30code. In some cases, just a few lines of
  816. 28:32code.
  817. 28:33Uh if if you if you can get to do it, it
  818. 28:35means that you you design something
  819. 28:36which is well designed because it's
  820. 28:38modular.
  821. 28:39Um
  822. 28:41Now, this is just one computer model.
  823. 28:43You know, one can build many other
  824. 28:44computer models, dedicated computers
  825. 28:46that do only one thing and whatnot. So,
  826. 28:49different instructors can come up with
  827. 28:50different ideas.
  828. 28:52And and different students can come up
  829. 28:54with different ideas. And
  830. 28:56so, here I guess we'll talk about von
  831. 28:58Neumann and who made this thing possible
  832. 29:00and and Turing
  833. 29:02although we talk about Turing later on
  834. 29:03in the course and we'll probably talk
  835. 29:05about Andy Grove and other people who
  836. 29:07made it fast and explain, you know,
  837. 29:11what to do in order to make it fast,
  838. 29:12which is something which we don't we
  839. 29:13don't we don't really discuss in the
  840. 29:15course too much. In fact,
  841. 29:17we are very careful
  842. 29:19not to give the impression to the
  843. 29:20students that this is, you know, that
  844. 29:22this is the holy grail. The
  845. 29:24In fact, in every lecture, every chapter
  846. 29:26in the book, we end up with a section
  847. 29:29that talks about all the things that we
  848. 29:30didn't cover, all the things that have
  849. 29:32to be covered, all the things that
  850. 29:34that make it efficient. And um
  851. 29:37in fact, most of the interesting stuff
  852. 29:38in computer science is is making these
  853. 29:40things work efficiently and and quickly
  854. 29:42and smoothly. So, all these things are
  855. 29:45you know, beyond the scope of this
  856. 29:46course, at least the student understand
  857. 29:49where they you know, why they are
  858. 29:50important and and how they hook to um
  859. 29:54to uh to the core material in in
  860. 29:55computer science.
  861. 29:58Okay, we haven't talked about input and
  862. 29:59output. So, here is how they enter the
  863. 30:01picture.
  864. 30:02Uh our memory
  865. 30:04uh space has um a screen memory map
  866. 30:07which hooks to um to a window on the PC
  867. 30:10screen and it also has a keyboard memory
  868. 30:12map which is just a single word in
  869. 30:14memory 16-bit
  870. 30:16which captures the uh the Unicode of of
  871. 30:18the key which is currently pressed.
  872. 30:20Um I can I can demo some of these
  873. 30:22things. Uh um
  874. 30:26So, here is my here's my our CPU. Well,
  875. 30:29this is a CPU emulator. Basically, it's
  876. 30:31a computer emulator. It's not the
  877. 30:32hardware simulator, it's an emulator of
  878. 30:35this specific computer that has two
  879. 30:37separate memory spaces.
  880. 30:38And I can load a program into it written
  881. 30:41in machine language.
  882. 30:43So, let's do this one.
  883. 30:45Uh
  884. 30:48Okay, this program uh here's here's the
  885. 30:50code. Um I'm going to input something
  886. 30:53here in RAM zero.
  887. 30:57This program is designed to draw
  888. 31:00uh a rectangle on the on the upper left
  889. 31:02uh corner of the screen. The width of of
  890. 31:06the rectangle is going to be 16 bits
  891. 31:0816 pixels and the depth is the contents
  892. 31:11of of RAM zero which now happens to be
  893. 31:1450. So, I can
  894. 31:16sort of step through the program.
  895. 31:18And uh
  896. 31:20you see the lines starting piling up.
  897. 31:23Let's do it quickly.
  898. 31:24Uh
  899. 31:26So, you see it actually going through a
  900. 31:28loop and drawing this uh
  901. 31:31rectangle up here.
  902. 31:32Now, if you were a hacker
  903. 31:35I guess one thing which would be quite
  904. 31:37interesting is this special address
  905. 31:39there 16384. What you know, what
  906. 31:41where in the world this address comes
  907. 31:43from? So, this is something which which
  908. 31:44is worth uh exploring. So, the the
  909. 31:47program ended.
  910. 31:49Well, we always end our programs with an
  911. 31:50infinite loop. Okay, so that's that's
  912. 31:52how you see the program ended.
  913. 31:54And uh if you want to explore what's
  914. 31:56going on, you can stop the simulation.
  915. 31:59Let's take a look at this address here
  916. 32:0016384. So, I have this little uh
  917. 32:03binocular here
  918. 32:04and I can enter addresses here 16384.
  919. 32:09And let's see what's Oh, and lo and
  920. 32:11behold there's a minus one there, you
  921. 32:14know, in the middle of a desert of
  922. 32:15zeros.
  923. 32:17Well, minus one in binary
  924. 32:21is um 16 ones. Okay? So, this is
  925. 32:24actually the screen image of uh this
  926. 32:26These are the 16 pixels. That's what
  927. 32:28turns on 16 pixels that make up a row in
  928. 32:32this um
  929. 32:33in this image. And uh
  930. 32:36So, it looks like you know, this is the
  931. 32:38area that's the low memory. That's the
  932. 32:41These are the 8K that control the
  933. 32:43screen. So, if I go down I don't know
  934. 32:45somewhere here
  935. 32:47and I pick up just a random address in
  936. 32:49and write minus one here
  937. 32:52you get this little line up there. Okay?
  938. 32:55So, if you want if you want to write
  939. 32:56graphics applications for this computer
  940. 32:59low level, that's what you have to do.
  941. 33:01You have to actually go in use assembly
  942. 33:03language and um and and turn on and off
  943. 33:06the right uh
  944. 33:08bits. And we have a couple of programs
  945. 33:10um to to get the students up to speed
  946. 33:12with this language. You know, we don't
  947. 33:14want them to learn this language, just
  948. 33:15to feel it. So, a typical program would
  949. 33:18be something like um
  950. 33:19uh have the user
  951. 33:21click
  952. 33:23uh any key on the keyboard. And when the
  953. 33:25user clicks something, blacken the
  954. 33:26screen. Just make the screen black. And
  955. 33:29when he releases uh the key, make it
  956. 33:31white again. Okay? Now, how you make it
  957. 33:33black and white is up to you. You can
  958. 33:34either do it in spiral which would be
  959. 33:36nice or just do it in a silly way from
  960. 33:38left to right. Uh so, the students get
  961. 33:41get quite creative with these little
  962. 33:43programs.
  963. 33:44All right. So, that's it. And moving
  964. 33:47along, just to sum up um the hardware
  965. 33:51um
  966. 33:52that's the chipset that we built around
  967. 33:5430 different chips. And uh if you put
  968. 33:57them all together, you get the computer
  969. 33:59up and running.
  970. 34:00Um just to show you how a typical
  971. 34:02project looks like.
  972. 34:04Um
  973. 34:07Here is let's say um
  974. 34:09project two.
  975. 34:11Uh so, that's the project where we build
  976. 34:13combinational chips. Let's take a look
  977. 34:15at the ALU. So, you know, that's the
  978. 34:17ALU.
  979. 34:18Uh
  980. 34:22Here is the uh HDL stub. Lots of
  981. 34:25documentation describing the ALU logic.
  982. 34:27That's what we give the students. Here
  983. 34:29is the API of the ALU, the six control
  984. 34:31bits, um the two uh bits that it emits,
  985. 34:35um
  986. 34:36the two inputs uh X and Y, X and Y.
  987. 34:39And this comment that the students don't
  988. 34:42enjoy uh seeing, that's what they have
  989. 34:43to fill in.
  990. 34:45And then in addition to this stub, we
  991. 34:46give them um a test file
  992. 34:49that they can, you know, hook into the
  993. 34:50uh simulator and it will test their
  994. 34:52their their ALU design.
  995. 34:54And then we also give them a compare
  996. 34:56file which shows uh the results that we
  997. 34:59want to see for every combination of of
  998. 35:01bits and and control bits and and
  999. 35:02inputs. Not every, but for some of them.
  1000. 35:05So, um so, once again, the projects are
  1001. 35:07very
  1002. 35:08um
  1003. 35:09well documented and all the materials
  1004. 35:11are there.
  1005. 35:12And um you just have to go out and build
  1006. 35:14it.
  1007. 35:16All right. So, um moving along
  1008. 35:19I'll spend about 10-15 minutes about the
  1009. 35:21software hierarchy and then we'll open
  1010. 35:23up for questions. Uh so, uh we're done
  1011. 35:26with the hardware
  1012. 35:28um and here's the software. So, the
  1013. 35:29first thing that we do
  1014. 35:30is we write an assembler for the
  1015. 35:33assembly language that we uh specified.
  1016. 35:35And um so, essentially, you have to
  1017. 35:37start with a program that looks like
  1018. 35:39this. You know, this is a typical
  1019. 35:40program in assembly.
  1020. 35:42Uh typically, you you set the the A
  1021. 35:44register to some address and then this
  1022. 35:46address selects uh a register in in the
  1023. 35:49um memory unit and then
  1024. 35:52take this register, add it to D, put it
  1025. 35:54back into this register and so on. Okay,
  1026. 35:56that's the typical
  1027. 35:57uh programming style in this language.
  1028. 35:59And we have labels.
  1029. 36:01Um
  1030. 36:03You you may be surprised, you know, why
  1031. 36:04are the labels surrounded by parentheses
  1032. 36:06and not it might would make more sense
  1033. 36:08to just write label colon. Okay? Well,
  1034. 36:13it's always nice to uh when you compile
  1035. 36:15something, it's always nice to know um
  1036. 36:17where you're at after you read the first
  1037. 36:19token in every line. So,
  1038. 36:21when you write an assembler for this
  1039. 36:23language, all you have to do is look at
  1040. 36:24the first uh character in every line. If
  1041. 36:27it if it's a left paren, you know, that
  1042. 36:29you have a label. Um
  1043. 36:32So, it's not maybe very uh beautiful,
  1044. 36:34but it's it makes compilation easier.
  1045. 36:36So, essentially, you have to start
  1046. 36:39in a program like this and end up with a
  1047. 36:41binary program like that. You have to
  1048. 36:42implement a symbol table which we
  1049. 36:44discuss in the course and uh but beyond
  1050. 36:46that, you just use the uh the binary
  1051. 36:48maps that I showed earlier
  1052. 36:50and and you have an assembler.
  1053. 36:53Um
  1054. 36:54And here we will probably talk about Ada
  1055. 36:55Lovelace and Babbage and people like
  1056. 36:58that.
  1057. 36:59And we also have a visual assembler that
  1058. 37:01the students can play with and can can
  1059. 37:03download from our website. And then they
  1060. 37:05have to build it. They don't have to
  1061. 37:06build all this GUI, but they have to
  1062. 37:07build an assembler that using a command
  1063. 37:09line can convert an ASM file into a hack
  1064. 37:12file written in binary. The computer, by
  1065. 37:15the way, is called Hack.
  1066. 37:17Um
  1067. 37:18we talked about the CPU emulator.
  1068. 37:20Uh so, that's the assembler and moving
  1069. 37:22along
  1070. 37:23we build a VM implementation.
  1071. 37:26Well, before we build a VM
  1072. 37:27implementation, we have to introduce the
  1073. 37:29VM abstraction.
  1074. 37:31And um we start off with this
  1075. 37:33uh
  1076. 37:34glorious picture that actually
  1077. 37:37um
  1078. 37:38it describes, I think, the modern
  1079. 37:40architecture of
  1080. 37:41the architecture of a modern compiler,
  1081. 37:43two-tier compiler, front end, back end.
  1082. 37:46You know, the front end compiles into
  1083. 37:48some intermediate language like uh
  1084. 37:50bytecode or um
  1085. 37:52IL. And then you take this intermediate
  1086. 37:54language and you compile it further,
  1087. 37:56that's the back end, into whatever you
  1088. 37:58want, you know, whatever platform you
  1089. 38:00want to
  1090. 38:01uh to use. Um
  1091. 38:03And also this this this slide is is also
  1092. 38:06a good picture of this whole course
  1093. 38:08because what you do is in the first six
  1094. 38:10projects, you build this platform here.
  1095. 38:13And then the next projects next two
  1096. 38:15projects, you build a VM implementation.
  1097. 38:17Then we build a compiler and finally uh
  1098. 38:20we um
  1099. 38:21we build a little operating system which
  1100. 38:23extends uh the bare language, the the
  1101. 38:25Jack language that that is high level.
  1102. 38:28We'll we'll talk about it later on. So,
  1103. 38:31um so, what we do in the course is we do
  1104. 38:32those red parts, at least in this
  1105. 38:34project.
  1106. 38:35We have a VM emulator that we give the
  1107. 38:37students written in Java.
  1108. 38:39A pretty fancy program that I will demo
  1109. 38:41in a minute. And then they have to
  1110. 38:43implement our VM language themselves uh
  1111. 38:46into um
  1112. 38:47um and into They have to implement it
  1113. 38:50and write a program that translates from
  1114. 38:52the VM code into hack native code,
  1115. 38:55machine language.
  1116. 38:57So, here we'll probably talk about
  1117. 38:59Turing and universal Turing machines and
  1118. 39:01the concept of implementing, you know,
  1119. 39:04the logic of one machine on another
  1120. 39:06using one machine to emulate the code of
  1121. 39:08another machine and
  1122. 39:09and doing all this on top of your
  1123. 39:11personal computer and which runs on top
  1124. 39:13of Windows or Unix or whatever it is.
  1125. 39:15So, it's a fantastic
  1126. 39:17you know,
  1127. 39:19sequence of abstraction, implementation,
  1128. 39:21abstraction, implementation,
  1129. 39:22abstraction, implementation. It's
  1130. 39:24and understanding it, I think, is a very
  1131. 39:26deep insight in in computer science.
  1132. 39:28Um
  1133. 39:30So, here's the VM language. It's a
  1134. 39:32typical VM language similar to Java's uh
  1135. 39:35bytecode. Um we have stack-based
  1136. 39:38arithmetic commands. We have pop and
  1137. 39:40push.
  1138. 39:41We have some program flow commands and
  1139. 39:44the VM language also implements the
  1140. 39:46function abstraction which
  1141. 39:48So, you can write a program that
  1142. 39:50consists of many functions
  1143. 39:52which will make the
  1144. 39:54implementation of the compiler later on
  1145. 39:56much easier because all the function
  1146. 39:59calling
  1147. 40:00and returning logic is implemented at
  1148. 40:02the VM level.
  1149. 40:06So,
  1150. 40:07here's a program written in C, a program
  1151. 40:09that multiplies two numbers and here is
  1152. 40:12the same program written in our VM
  1153. 40:13language. In the middle is a pseudo code
  1154. 40:16in which we retain the names of the
  1155. 40:18variables. On the right is the actual VM
  1156. 40:21language that that we use.
  1157. 40:23We have a local segment, argument
  1158. 40:25segment, local variables, argument
  1159. 40:27variables, constants and
  1160. 40:30statics.
  1161. 40:31And here is the VM emulator
  1162. 40:34um
  1163. 40:35which is a fairly
  1164. 40:37Well, it it looks it looks
  1165. 40:39scary but it's actually it's not.
  1166. 40:42What we see here
  1167. 40:43we see a
  1168. 40:44Here's a VM program.
  1169. 40:46Here's the stack, working stack. The
  1170. 40:48working stack is actually the tip of
  1171. 40:51of the global stack. So, these two
  1172. 40:53numbers, 15 and 8, are you know, these
  1173. 40:56two numbers here.
  1174. 40:57That's where the next number will go if
  1175. 40:59you do a push and all the numbers above
  1176. 41:01here are frames of functions that are
  1177. 41:04waiting for the current function to
  1178. 41:07stop execution.
  1179. 41:09And here we have our virtual memory
  1180. 41:11segments where we hold
  1181. 41:13various families or types of actually
  1182. 41:15kinds of variables in in a typical
  1183. 41:17object-oriented program.
  1184. 41:20So, you know, this is where we hold the
  1185. 41:22current object data.
  1186. 41:24This is the arguments of the current
  1187. 41:26function, the local variables, static
  1188. 41:28variables of the class.
  1189. 41:31We haven't talked about these these
  1190. 41:34abstractions yet because we didn't
  1191. 41:35introduce the high-level language but we
  1192. 41:37don't really have to.
  1193. 41:39We can write the VM implementation
  1194. 41:40without even understanding the
  1195. 41:42higher-level language and it's good
  1196. 41:43because you never know when you write a
  1197. 41:45VM implementation it should serve
  1198. 41:47multiple languages so you don't have to
  1199. 41:48commit yourself to one language in
  1200. 41:50particular.
  1201. 41:53Some people asked us you know, where did
  1202. 41:55we get the inspiration for this GUI? So,
  1203. 41:58it's from this picture here.
  1204. 42:01And
  1205. 42:02in project 7 and 8 you have to implement
  1206. 42:06the VM language over the hack platform.
  1207. 42:08So, basically you have to write a
  1208. 42:09translator that translates from the left
  1209. 42:11to the right.
  1210. 42:13It's it's not a simple project. It's
  1211. 42:15actually separated into two separate
  1212. 42:17projects.
  1213. 42:18One deal dealing with syntax and the
  1214. 42:20other one with code generation.
  1215. 42:23And um
  1216. 42:26And that's how we
  1217. 42:27we implement the VM.
  1218. 42:31Next we
  1219. 42:32we introduce our programming language
  1220. 42:34Jack. So, here's here's a little piece
  1221. 42:37of code written in Jack.
  1222. 42:38This is actually part of our operating
  1223. 42:40system. We have a class called math that
  1224. 42:42includes all sorts of useful functions.
  1225. 42:44So, here's a function that computes
  1226. 42:45factorial.
  1227. 42:47Here's a function that computes E.
  1228. 42:49And this is written in in our own
  1229. 42:51language in Jack and in the next stage
  1230. 42:54of of the course the students will write
  1231. 42:56a compiler
  1232. 42:57for this language.
  1233. 42:59But actually first they write a Jack
  1234. 43:00program and
  1235. 43:03so I will demo it one of these programs
  1236. 43:05and um
  1237. 43:07So, here's here's the VM emulator.
  1238. 43:11So, I'm going to load a program
  1239. 43:14um
  1240. 43:16Let's take one of these. I have some
  1241. 43:17selected student projects here. We'll
  1242. 43:19take Space Invaders.
  1243. 43:20Um
  1244. 43:22So, I loaded a Space Invaders program.
  1245. 43:24The student wrote this program in Jack
  1246. 43:27and he used all sorts of abstractions
  1247. 43:29like you know, spaceship and
  1248. 43:31the gun that shoots a spaceship and game
  1249. 43:34session and so on. And then the student
  1250. 43:36translated it into into the VM language
  1251. 43:38and once you translate into VM you can
  1252. 43:41load it into the simulator and and run
  1253. 43:43it
  1254. 43:43and that's what I'll do now. So, when
  1255. 43:45you start running it
  1256. 43:49Well, um
  1257. 43:51Wait.
  1258. 43:52Actually, I think I'd like to start
  1259. 43:54running it
  1260. 43:55uh
  1261. 43:57with uh
  1262. 43:59Yeah, you can you can be fairly
  1263. 44:02elaborate about the simulation. You can
  1264. 44:03actually simulate
  1265. 44:05uh
  1266. 44:07everything that kind of happens in the
  1267. 44:09computer and you can you can also see
  1268. 44:11the
  1269. 44:12the data moving from one place to
  1270. 44:13another which can be useful. Right now
  1271. 44:15it's it's a little bit too too fast. I
  1272. 44:18can stop it and do it step-wise so you
  1273. 44:19can see every step in isolation. Here
  1274. 44:21you see a you know, some stack-oriented
  1275. 44:25algebra going on and um
  1276. 44:28So, you can actually see everything
  1277. 44:30running at any level of detail that you
  1278. 44:32want. So, this is pretty pretty tedious
  1279. 44:34so I'll stop it here
  1280. 44:36and we'll just take a look at the at the
  1281. 44:38program flow
  1282. 44:40without data moving around. So, you see
  1283. 44:42the program running
  1284. 44:44and in fact, you know, it takes
  1285. 44:45something like 10,000 program 10,000
  1286. 44:48commands to get executed before anything
  1287. 44:49happens because you know, this is real
  1288. 44:50computer. There's an operating system
  1289. 44:53which is also implemented in Jack and
  1290. 44:55translated into the VM level.
  1291. 44:57So, it takes a lot of work just to get
  1292. 44:59things done just to get started. You
  1293. 45:01know, the operating system has to set up
  1294. 45:03all sorts of arrays and so on for its
  1295. 45:05own internal computations.
  1296. 45:07But it's kind of fun to see it
  1297. 45:09you know,
  1298. 45:10working and um
  1299. 45:12So, at some point I will just stop this.
  1300. 45:14I will cancel all the animation.
  1301. 45:17No animation and we just start running
  1302. 45:19the program.
  1303. 45:21Um
  1304. 45:23So, here's the program in all its glory.
  1305. 45:25And um
  1306. 45:27So, I'm I'm playing now and I'm getting
  1307. 45:29killed.
  1308. 45:30Uh
  1309. 45:33I'm not very good at that.
  1310. 45:35Uh So, you know, I should tell you Well,
  1311. 45:38I hope you appreciate the fact that you
  1312. 45:39know, everything that you see here
  1313. 45:42was implemented by the student. You
  1314. 45:44know,
  1315. 45:45the graphics, the everything. So, um
  1316. 45:49When we first built this machine, when
  1317. 45:51we got to this level, this is like 6
  1318. 45:53years ago,
  1319. 45:54the first program that we wrote was
  1320. 45:56square and it was a square that you
  1321. 45:58could move on the screen by the four
  1322. 46:00arrow keys, right, left, up and down.
  1323. 46:02That's
  1324. 46:03all all the things that you could do.
  1325. 46:06But when it started running, you know, I
  1326. 46:08was so excited. So, I sat there in my
  1327. 46:09room and I was
  1328. 46:11moving this square around for 2 hours,
  1329. 46:13right, left, up, down.
  1330. 46:16And then my son, who was 8 years old, he
  1331. 46:18comes into my office and he he looks at
  1332. 46:20me sort of glued to the screen looking
  1333. 46:22at the stupid square.
  1334. 46:24And he says, "Dad, what are you doing?"
  1335. 46:26So, I'm saying, "Leave me alone. I'm
  1336. 46:27playing a computer game."
  1337. 46:29And he looks at me, you know, and says,
  1338. 46:31"These are the games that you play? Come
  1339. 46:33to my room. I'll show you some games,
  1340. 46:34you know."
  1341. 46:38Maybe he will some point he will
  1342. 46:40appreciate.
  1343. 46:43So, that's that's uh
  1344. 46:45So, all we have to do really is write
  1345. 46:48write the compiler and the the OS.
  1346. 46:52The compiler project consists of two
  1347. 46:54projects.
  1348. 46:56In the first project we do syntax
  1349. 46:58analysis. So, we start with a
  1350. 47:00Jack code
  1351. 47:02and um
  1352. 47:04we translate actually we parse the Jack
  1353. 47:06code
  1354. 47:07into XML.
  1355. 47:09We found out that XML is a great way to
  1356. 47:12describe uh
  1357. 47:13code
  1358. 47:14because the students know XML from other
  1359. 47:16courses and
  1360. 47:18when you load this thing into the um
  1361. 47:21into any browser
  1362. 47:23the browser knows exactly what to do
  1363. 47:25with it and renders it nicely.
  1364. 47:27So, that's the In the first project we
  1365. 47:29do this.
  1366. 47:31Um
  1367. 47:32And in the second project we take this
  1368. 47:35XML file as a point of departure
  1369. 47:38and then we we walk you know, through
  1370. 47:40this tree in depth-first traversal
  1371. 47:43and we generate code. So, you know, we
  1372. 47:45go all the way down, you find five so
  1373. 47:47you say push five. Then you go here,
  1374. 47:50push Y. Then you go there, push X.
  1375. 47:53Then you you go up here and you do Well,
  1376. 47:57you want to multiply but multiply is not
  1377. 47:58a primitive part of the VM language so
  1378. 47:59you have to call a function that
  1379. 48:01multiplies and then you push four
  1380. 48:03and so on and forth so forth. Okay? So,
  1381. 48:05it's a basically you know, the basic
  1382. 48:07algorithm of
  1383. 48:08generating code from from from a parse
  1384. 48:10tree.
  1385. 48:12Let me just
  1386. 48:13give you a brief uh
  1387. 48:16um
  1388. 48:18overview of the projects themselves. So,
  1389. 48:19here's compiler one
  1390. 48:22in which we do syntax analysis.
  1391. 48:25Um So, we give the students uh
  1392. 48:28some classes written in Jack. For
  1393. 48:30example, oh, that's the square game that
  1394. 48:31I talked about before. So, here's the
  1395. 48:33main class of this game.
  1396. 48:35So, you know, that's the Jack code. We
  1397. 48:37give it to the students and then we tell
  1398. 48:39them, "Well, if you do it right, well,
  1399. 48:41first of all you have to tokenize it."
  1400. 48:42So, here's the same code
  1401. 48:44uh tokenized. Okay? And we also throw in
  1402. 48:47some labels that we give the students as
  1403. 48:50directive. They have to use it in their
  1404. 48:51code. The nice thing about writing in
  1405. 48:54XML is that you know, if you use a
  1406. 48:56browser you can do things like that and
  1407. 48:58then open it up.
  1408. 49:00And then
  1409. 49:02you take this
  1410. 49:03you take this tokenized list and you
  1411. 49:05write a parser on top of it and then the
  1412. 49:08result becomes this
  1413. 49:10written in XML.
  1414. 49:12So, here is the same program, the main
  1415. 49:14class written in XML, ready to ready for
  1416. 49:16code generation.
  1417. 49:18So, once again you can close it and you
  1418. 49:20know, open whatever you want and explore
  1419. 49:22it and also talk about
  1420. 49:24you know, the um
  1421. 49:26the the morphology of a program. So, we
  1422. 49:29have a class here, that's the name of
  1423. 49:31the class, that's the left paren and
  1424. 49:33paren. Here are the subroutine
  1425. 49:35declaration. You you open them up
  1426. 49:37and uh and focus on, you know, whatever
  1427. 49:39you want. So, once again, the projects
  1428. 49:42are um
  1429. 49:43uh
  1430. 49:44have a lot of documentation and text and
  1431. 49:46test uh
  1432. 49:47unit testing and many different steps um
  1433. 49:51that the students have to go through.
  1434. 49:53And uh and that's how they write the
  1435. 49:54compiler.
  1436. 49:56Um
  1437. 49:58Okay, before we go on, you know, I have
  1438. 50:00only two or three more slides to go.
  1439. 50:02I I I guess I should mention one thing.
  1440. 50:05A lot of people who hear this talk uh
  1441. 50:07don't believe that you can do it in one
  1442. 50:08semester because it looks like too much.
  1443. 50:11And yet um I was I was a dean and a
  1444. 50:14program director for 10 years
  1445. 50:16uh in Israel and um
  1446. 50:18and because I I was a program director,
  1447. 50:20students always came to complain to me
  1448. 50:22about courses that were too hard and so
  1449. 50:23on and and I always tried to figure out
  1450. 50:25why, you know, when someone comes in and
  1451. 50:27said, "You know, this course is is very
  1452. 50:29hard." So, I'm trying to understand why
  1453. 50:30it is hard.
  1454. 50:32In, you know, 90 cases out of 100, the
  1455. 50:34course is hard because the homework was
  1456. 50:36not well specified. You know, there was
  1457. 50:38some word which was missing. There was
  1458. 50:41some sentence which was um confusing.
  1459. 50:44And therefore, the material is not
  1460. 50:46always what's difficult. What's
  1461. 50:47difficult is is is that someone,
  1462. 50:50typically the instructor or whoever
  1463. 50:51wrote the projects, which sometimes are
  1464. 50:53not the instructor but the teaching
  1465. 50:54assistant,
  1466. 50:56in some cases doesn't know English or
  1467. 50:57Hebrew very well. They end up, you know,
  1468. 50:59creating uh chaos. And um and therefore,
  1469. 51:02uh it turns out that if you work very
  1470. 51:04hard on on building all the tools that
  1471. 51:06you need and all the project materials
  1472. 51:08and the unit testing and the test
  1473. 51:10programs and test scripts and so on, if
  1474. 51:12you build all these tools,
  1475. 51:13uh the projects become, you know, a
  1476. 51:15pleasure to actually implement. So, we
  1477. 51:18spent
  1478. 51:195 years building all these things and
  1479. 51:21and bringing them to to a point where
  1480. 51:23you can actually build a compiler in 2
  1481. 51:25weeks.
  1482. 51:27Um
  1483. 51:29operating system. So, when you look at
  1484. 51:31the typical Jack program, of which we
  1485. 51:33have an example here,
  1486. 51:35well, a lot of stuff in this program is
  1487. 51:37not primitive Jack. You know, things
  1488. 51:38like
  1489. 51:40keyboard, output, array, these are not
  1490. 51:42part of the primitive language. So, you
  1491. 51:44have to implement them somehow. So,
  1492. 51:47basically, we implemented them in an
  1493. 51:48operating system
  1494. 51:50um that has these uh bunch of classes.
  1495. 51:53Uh and every one of these classes has an
  1496. 51:54API. So, here is here's the math API.
  1497. 51:57Actually, it's not everything but some
  1498. 51:59of the functionality that we want the
  1499. 52:01students to implement.
  1500. 52:03And here is uh a string API
  1501. 52:05uh for string processing, arrays, uh
  1502. 52:08output for uh text output, um
  1503. 52:12screen for um graphics,
  1504. 52:15um
  1505. 52:16memory for memory management,
  1506. 52:18um
  1507. 52:20so, we also implement the algorithms for
  1508. 52:22allocating memory, deallocating memory,
  1509. 52:25uh peek, poke, and so on.
  1510. 52:27And um
  1511. 52:29you need them when you need these things
  1512. 52:30when you write the compiler. For
  1513. 52:32instance, when you do a new for object,
  1514. 52:33you have to allocate
  1515. 52:36memory for the new object. So, you use
  1516. 52:38the services of of the operating system
  1517. 52:39for that.
  1518. 52:40Um keyboard, and I think this is it.
  1519. 52:43Well, we also have some miscellaneous
  1520. 52:45stuff. Um and then then we have to uh
  1521. 52:48actually build it or you don't have to
  1522. 52:50build everything, but we end up
  1523. 52:52building, you know, two or three classes
  1524. 52:54of this um operating system.
  1525. 52:57Now, this stuff is is quite similar to
  1526. 53:00early early versions of Unix because um
  1527. 53:03everything here is written in Jack, just
  1528. 53:05like Unix was written in C.
  1529. 53:07And basically, the way you implement it,
  1530. 53:09actually, it's like reverse engineering
  1531. 53:11uh Unix. It's like Linux. Because what
  1532. 53:13we do is we give the students the
  1533. 53:14operating system implemented. And then
  1534. 53:17we tell them, "You have to take one
  1535. 53:18class at a time
  1536. 53:20and implement it using the services of
  1537. 53:22the other classes. You can assume the
  1538. 53:23other classes are implemented and then
  1539. 53:25use them to implement this uh class and
  1540. 53:28then gradually you you build the whole
  1541. 53:30thing." Okay? Uh
  1542. 53:33So, it's it's a nice software
  1543. 53:35engineering uh experience.
  1544. 53:37Um so, to recap what we did, uh we
  1545. 53:40started with uh primitive logic gates
  1546. 53:43and we end up building a computer that
  1547. 53:45can play um here's an example of Pong
  1548. 53:47that I haven't demonstrated, actually a
  1549. 53:49fancy version of Pong.
  1550. 53:51So, we begin with logic and we build a
  1551. 53:54chipset and then on top of it we build a
  1552. 53:56computer architecture, machine language,
  1553. 53:58assembly,
  1554. 53:59VM,
  1555. 54:01high-level language and operating
  1556. 54:02system, and finally an application.
  1557. 54:05Now, when you think about a game like
  1558. 54:07Space Invaders or or Pong
  1559. 54:09or Snake, typically, it's something like
  1560. 54:1215 object-oriented uh operations to
  1561. 54:15implement it in in a high-level
  1562. 54:16language.
  1563. 54:17Um
  1564. 54:18and then every one of these uh
  1565. 54:21uh operations when when it ends up being
  1566. 54:23something like 250 lines of Jack code,
  1567. 54:26that's the typical size of a Jack
  1568. 54:27application.
  1569. 54:28And then when you compile it into VM,
  1570. 54:31it's about one one to four. You get
  1571. 54:33about 1,000 of lines of VM code. Then
  1572. 54:35you throw in the operating system and uh
  1573. 54:38uh at some point you get about 30,000
  1574. 54:41lines of hack code
  1575. 54:43for this uh little program and and you
  1576. 54:45see all these steps very vividly.
  1577. 54:47And then every every one of these lines
  1578. 54:49is a 16-bit uh word. So, you get about
  1579. 54:52half a million bits. Every one of these
  1580. 54:54bits is implemented with four um
  1581. 54:56um uh NAND gates. So, you get 2 million
  1582. 55:00logic gates working together
  1583. 55:02to create this uh illusion of uh a Pong
  1584. 55:05game or something like that. And then
  1585. 55:07this level, I guess we have one god.
  1586. 55:09Um so, um
  1587. 55:11we tell the students
  1588. 55:13uh that God gave us a zero and NAND and
  1589. 55:16everything else was done by humans and
  1590. 55:18that's that's what this course uh seeks
  1591. 55:20to illustrate.
  1592. 55:22Um
  1593. 55:24Maybe just one more slide.
  1594. 55:27Well, first of all, the course is
  1595. 55:29extremely focused and that's um
  1596. 55:32one reason why we managed to do it in
  1597. 55:34one semester.
  1598. 55:35Uh in fact, when we built it, we decided
  1599. 55:38to include only the topics that you need
  1600. 55:40in order to build a computer.
  1601. 55:42Turned out that uh this uh this was a
  1602. 55:45subset of some of the most beautiful um
  1603. 55:47things in computer science.
  1604. 55:49Uh that students see in many other
  1605. 55:51courses in the program.
  1606. 55:52So, focus helps.
  1607. 55:54And also um
  1608. 55:56uh not dealing with unnecessary stuff
  1609. 55:58also helps. So,
  1610. 56:00all these things are not covered in the
  1611. 56:01course, but they are great uh ideas for
  1612. 56:05uh further projects, you know, for more
  1613. 56:07things to do.
  1614. 56:08The final chapter in the book um is
  1615. 56:11called uh more fun to go. And in the
  1616. 56:14more fun to go chapter, what we do is we
  1617. 56:17tell them, "Well, you know, you don't
  1618. 56:18like to see um
  1619. 56:20uh multiplication in in software? Well,
  1620. 56:22why don't you go
  1621. 56:24and uh play with the architecture with
  1622. 56:26with the hardware and try to make the
  1623. 56:28ALU also multiply. It's not a big deal
  1624. 56:30to do it. But then if you do it, you
  1625. 56:32have to also to you have to add some
  1626. 56:34functionality to the and um and then a
  1627. 56:37few other things have to change uh in
  1628. 56:40the hierarchy. So, that's a great
  1629. 56:42exercise. Okay? Or if you want to uh you
  1630. 56:44know, if you want to the biggest bang
  1631. 56:46for the buck um is to optimize the VM.
  1632. 56:49If you look at the VM implementation,
  1633. 56:51you know, many things have to can be
  1634. 56:52optimized and and all of a sudden your
  1635. 56:54programs will run 100 times faster. So,
  1636. 56:56you want to go out and do it. If you
  1637. 56:58don't like our graphics, why don't you
  1638. 57:00go out and implement your own sprites?
  1639. 57:02So, um every one of these limitations is
  1640. 57:05actually, you know, it's a trigger for
  1641. 57:07innovation, for creativity. Uh so, once
  1642. 57:10you are very, you know, when when you
  1643. 57:12put it on the table, um it becomes
  1644. 57:15something that you can fix.
  1645. 57:17Um and also, the course is extremely
  1646. 57:19well managed. You know, all the DTIs,
  1647. 57:21all the APIs are given, numerous test
  1648. 57:23files and programs, and
  1649. 57:25unit testing, and so on.
  1650. 57:27Okay, I'll skip uh one more slide. I'll
  1651. 57:30just put the URL
  1652. 57:32and uh
  1653. 57:35and open up for questions.
  1654. 57:42Yes. So, can you
  1655. 57:46Uh is it possible to build a screen in
  1656. 57:49in hardware, in HDL? Yes. In fact, in
  1657. 57:52every semester, we have uh one team of
  1658. 57:55brave students who actually implement it
  1659. 57:57in FPGA.
  1660. 58:00Uh using They take our HDL,
  1661. 58:03translate it into uh VHDL, and and then
  1662. 58:07they try to build it on on FPGA, which
  1663. 58:09which is not it's not a simple project,
  1664. 58:10but it can be done. So, one more
  1665. 58:12question. So, so let's say you play Pong
  1666. 58:14on your HDL simulator. You can do that,
  1667. 58:16right?
  1668. 58:16Yeah. Uh so, uh
  1669. 58:18how many instructions per second can
  1670. 58:20your simulated CPU do? How fast is the
  1671. 58:22simulator?
  1672. 58:23Well, I don't remember the numbers, but
  1673. 58:24it's fast enough to see things moving on
  1674. 58:26the screen quite uh smoothly. Okay,
  1675. 58:28thank you.
  1676. 58:29Yeah, this was actually our goal. Yeah.
  1677. 58:41Uh what age group were the students in
  1678. 58:43this case and
  1679. 58:44Say it again? Uh what age group were the
  1680. 58:46students in this case and about how
  1681. 58:47young do you think this could be taught?
  1682. 58:48Cuz I mean, I'm seeing it's pitched as a
  1683. 58:50sort of a you you know, university
  1684. 58:51sophomore level, but is this something
  1685. 58:53you could introduce in high school?
  1686. 58:56Yeah, I'm not sure if I understood all
  1687. 58:58all the words in your question, but
  1688. 58:59essentially, um
  1689. 59:01this course can be can be treated it's a
  1690. 59:04very flexible course. You can either use
  1691. 59:06it as a capstone course that comes at
  1692. 59:08the end of the program at the senior
  1693. 59:10level,
  1694. 59:11or you can use it as a as a course that
  1695. 59:13can be taught immediately after
  1696. 59:14programming.
  1697. 59:15And in fact, you know, I taught this
  1698. 59:17course at Harvard last year. They called
  1699. 59:19it CS 101.
  1700. 59:21And they had a CS
  1701. 59:23uh 100, I think, which was programming,
  1702. 59:25and then uh students uh went directly
  1703. 59:27into this course. It was an elective
  1704. 59:28course.
  1705. 59:29But they did it without uh doing any
  1706. 59:31other course uh in the program.
  1707. 59:33Now, having done this course, it's a lot
  1708. 59:36of fun to take an architecture course or
  1709. 59:37compilers course where you can actually
  1710. 59:39do, you know, all the nasty stuff that
  1711. 59:41we had, you know, under the table.
  1712. 59:43Okay?
  1713. 59:55Uh I think the previous question
  1714. 59:56actually hit on some of this, but I was
  1715. 59:58actually thinking
  1716. 59:59deaf, so you have to repeat the
  1717. 1:00:00question. Uh I was actually thinking
  1718. 1:00:01younger than high school. I was
  1719. 1:00:03thinking, you know, 10 to 12 years old
  1720. 1:00:04right after you've had your first, you
  1721. 1:00:05know, class in Logo or whatever they're
  1722. 1:00:07teaching at that age.
  1723. 1:00:08I agree completely. Yeah, in fact, in
  1724. 1:00:09Israel, they teach it in some high
  1725. 1:00:11schools.
  1726. 1:00:12And um
  1727. 1:00:14we we had I had a chat with uh Jeff
  1728. 1:00:16before the talk, Jeff Waltz,
  1729. 1:00:18and um he mentioned that this course is
  1730. 1:00:21cuz sort of, you know, it's like going
  1731. 1:00:22back to basics. If you remember how
  1732. 1:00:24computers looked like 10, 15 years ago,
  1733. 1:00:27they were, you know, in a level where
  1734. 1:00:29you could actually dig in and and and
  1735. 1:00:30figure out everything. And that's that's
  1736. 1:00:32what we try to do here. We try to
  1737. 1:00:34to create an artifact which is
  1738. 1:00:36completely open for exploration.
  1739. 1:00:38So, in fact, it's very, I think, uh
  1740. 1:00:40lends itself very nicely to
  1741. 1:00:42the mind of a young person
  1742. 1:00:44who wants to explore.
  1743. 1:00:51Okay?
  1744. 1:00:52All right, thank you very much.
  1745. 1:00:53Thank you, Shimon. Thank you.

About this transcript

This page contains the full transcript of From Nand to Tetris in 12 steps by GoogleTalksArchive, generated from the public captions YouTube serves with the video. The transcript has 10,375 words across 1,745 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.