Hacking on the PDP1 Raspberry Pi Emulator - Computerphile

Hacking on the PDP1 Raspberry Pi Emulator - Computerphile

Computerphile

0:00 First we will look a little bit into the history of these machines and uh

0:04 we uh we use the PDP1 here as sort of our central uh starting point.

0:10 The PDP1 um designed in like the 8 the late 50s 59 uh

0:16 sold starting in 1960 and about 50 were built and sold by deck.

0:22 Um, and I think it's a very good uh starting

0:25 point to explore this whole history if you're interested because um,

0:29 we then have a couple of PDP models branching out

0:32 from this, but there's also a history to the PDP-1.

0:35 So,

0:36 so the deck is a digital electronics corporation.

0:39 Digital equipment corporation.

0:41 Equipment corporation.

0:42 Okay.

0:42 And they were obviously a computer manufacturer in America.

0:44 Yeah.

0:44 They didn't call it computers back then because

0:46 that evoked uh notions of IBM style like

0:50 payroll business machines very hard to access like

0:55 you give your punch punch cards to someone and so on and these are uh

1:01 a different tradition very interactive and more personal

1:05 and the PDP1 uh was sort of the first one that you could buy in that lineage.

1:12 The PDP1 was an 18- bit machine.

1:14 You can see it here.

1:15 18 bits and 4 kilows of memory originally.

1:19 So a word is again 18 bits.

1:21 Didn't have any bytes yet.

1:22 That came in the mid60s.

1:25 So after the PDP1 which was a little bit more experimental.

1:28 Deck was a startup essentially at that point.

1:30 When they had more customers,

1:32 they had different needs and the company was expanding.

1:35 So the first model after the PDP1 was surprisingly not the two or three.

1:39 That was like an old business strategy that didn't pan out.

1:42 Um, but it was actually a PDP4, uh,

1:45 which was also an 18- bit machine, but not really not compatible with the PDP1.

1:52 Like they had the same peripherals to some degree, but not quite.

1:55 And they reused these uh, architectures again.

1:59 They built new machines that were more or less compatible.

2:02 So the seven was the next.

2:03 And that one is perhaps a bit famous for being

2:05 the machine that Unix was developed on by Ken Thompson.

2:09 1969.

2:10 Uh they again built in a machine in that uh family the 9 and the 15.

2:17 Uh we're not going to talk about that.

2:19 Those just kind of different capacities or Yeah.

2:21 So essentially they they rededicated like they flipped one bit from being

2:27 an address bit uh from being an instruction bit to being an address bit.

2:30 So you get 8 kilows of memory on the PDP4 and in this family,

2:35 but you get only half of the instruction space.

2:38 Um, and so in Unix, uh, you see that, um,

2:41 because the kernel has 4 kilobytes of memory and the user

2:44 has 4 kilobytes of memory and with a PDP1, you would only have like 4 kil time

2:50 sharing on a PDP1 was done a bit differently.

2:53 Um,

2:54 so yeah, kilows is a new one to me, but I

2:57 Yeah, people are not used to kilow, 24 words then.

3:00 Yeah.

3:00 Okay.

3:01 Right.

3:02 Um so that was uh sort of the first thing

3:05 that uh uh that they built and afterwards uh came the PDP5.

3:11 What sort of things were these used for?

3:12 Were they were they what who were their customers?

3:16 Um so the idea initial idea was to make a more a cheaper uh PDP-1

3:21 essentially and also use it for things like

3:23 process control lab equipment that sort of stuff.

3:26 um things where the computer is part of a system and not just the system

3:31 itself crunching numbers like uh like

3:33 a mainframe would do uh like doing scientific

3:36 I don't know weather simulations or whatever

3:38 and eventually you you'd have uh the result

3:41 but it was something that you know talk to talk to the real world

3:46 and so there was a smaller uh uh family um which is

3:52 kind of a stripped down 18- bit family condensed into 12 bits.

3:57 That's the PDP 5, 8, and 12.

4:01 Uh so these are very minimal and really

4:03 just to like more more of the lab equipment

4:06 type and uh process control even though people did

4:10 time sharing and such on the PDP8 as well.

4:13 Um and it's a very popular machine.

4:16 There's a big PDP8 fan community.

4:18 Um and the PDP8 was the first uh that Oscar made.

4:23 And on the other end we have the PDP 6 and the PDP 10.

4:28 So the PDP 6 and 10 uh were 36bit machines uh meant for time

4:33 sharing such that multiple users could use the machine at the same time.

4:37 Also sort of designed to run lisp well which was a popular programming

4:42 language uh in AI circles and around MIT where these machines came to be.

4:49 Um, and yeah, so so that is like

4:53 the the on the wide end of the word size 36 bits.

4:58 I'm just going to ask a question if that's

5:00 all right because obviously you've mentioned the word AI, right?

5:02 And we're now talking about the 1960s.

5:04 I mean, this is, you know, become massive nowadays, but it isn't this, you know,

5:08 what we're going through now wasn't the start of AI, was

5:11 right.

5:11 uh AI at the time at that time meant something like um

5:15 symbolic differentiation or chess programming um stuff like this um so symbolic

5:22 AI good oldfashioned AI not the neural networks uh I mean the neural

5:27 networks uh go back quite some time but this was not really

5:31 what people uh did because the computers weren't there yet so this is

5:35 sort of the uh the PDP family and there's one important piece

5:39 missing which is the PDP11 introduced in 1969 like around uh 70

5:46 and this kind of uh pulled everything or almost everything together a bit.

5:51 So uh it's a single architecture that is uh that has small machines

5:56 PDP 1105 for things like what a PDP8 would do maybe um but also

6:02 bigger machines um maybe a PDP1140 which ran Unix or on the bigger

6:08 on the higher end a PDP170 which was quite um yeah quite a capable machine.

6:15 Um it did not quite replace the the PDP 6 and 10 uh style machines.

6:20 Um but they later uh built the vax the like a 32-bit

6:27 reinterpretation of the PDP11 but this was 16 bits and so they had

6:31 this these two uh as their flagships uh essentially and this became like

6:37 ancient history which is why people don't know so much about them anymore.

6:41 And these are very familiar.

6:42 These have bytes like bite addressing which people take

6:46 for granted these days but these don't have bytes yet.

6:48 These are all word addressed.

6:50 Um so that those B I mean they they were pioneering machines those ones

6:55 but basically we're going to have a look at what came before.

6:58 Yeah.

6:58 I mean everyone was pioneering at the time had no choice but uh

7:02 yeah people had to figure out uh what computers should be like.

7:05 Um, for instance, Gordon Bell,

7:07 who was the architect on essentially all of them except for the PDP1, uh,

7:13 said this this 18- bit line was a mistake because it was

7:16 not compatible with the with the 18- bit PDP-1 and they didn't,

7:20 uh, appreciate the like portable software yet, being able to run,

7:25 being able to write, right?

7:26 they they thought oh well you just write the program

7:29 for the new computer and then but yeah uh

7:32 software quality like the the value of software was

7:34 not uh was not on people's minds apparently back then

7:38 and and I suppose um when I say pioneering I think I guess I

7:42 mean they laid some of the foundations that we still use today but yeah

7:45 yeah like the PDP11 uh and vax are

7:48 like very normal computers from today's stand points

7:51 of view you can you can read PDP10 assembly

7:55 or vax assembly and it's it's not too foreign.

7:58 Whereas when you go back to these older machines,

8:01 it becomes a bit less familiar.

8:02 Um but on the other hand, they are also very simple.

8:06 Uh like the PDP1 is not a complicated machine for instance.

8:09 Um so you can still understand it.

8:11 It just takes a little shift in the perspective perhaps.

8:15 Mhm.

8:15 And so there's also prehistory which we're not going to cover,

8:17 but the PDP1 had uh was preceded by the TX0 and these were one of machines.

8:25 Now that we're talking about,

8:26 these were like production machines that were sold, even if maybe not too many.

8:31 Um, but the earlier stuff only existed uh once.

8:35 So the TX0 was also an 18- bit machine, but much simpler than the PDP1.

8:40 Um, there is also a TX2,

8:43 which was a bigger uh 36-bit machine uh famous for being

8:48 the machine that Sketchpad uh was written on by Ivan Sutherland.

8:53 uh the uh first CAD system, you might say.

8:56 Um and this it goes uh back a little further

9:01 to the memory test computer which was really part of project whirlwind.

9:08 So whirlwind one was there was that machine um originally to do um cockpit

9:18 simulation but it didn't really pan out

9:20 and they built a digital computer instead.

9:22 uh I call it the first uh microcontroller except it took up a whole building

9:27 but essentially that was the idea to have

9:28 a computer that interacts with the real world.

9:30 So this is where it starts.

9:32 What what era is that then?

9:34 uh well when one was operational more

9:36 or less or became operational during 1950 and

9:41 so it's kind of post-war kind of things

9:43 right they had difficulty with uh finances because the war stopped and uh

9:48 well luckily for them the cold war started so they got money again

9:52 and uh that is how the whirlwind 2 you might call it

9:55 but it's perhaps better known as the computer of the sage system uh

10:00 the an FA Q7 um that was like a a bigger version

10:08 of the whirlwind one essentially built all over the US for airspace monitoring.

10:13 Um it was never it never really had a purpose because shortly after they

10:17 had intercon uh intercontinental uh missiles and like

10:23 they never got to use it essentially.

10:25 So yeah, this is uh the the history that we're talking about

10:31 and the whirlwind one was what what core memory was invented for here.

10:35 We got modems and like displays were already were on the whirlwind

10:41 and this kind of uh goes down into the tree.

10:45 So we have this whole uh history

10:47 of interactive controller type um personal perhaps uh computers.

10:53 And so again the PDP1 is uh sort of our central

10:58 piece here and uh we will now look a little

11:03 bit into what the computer how it works and what

11:06 to do with it how to use it using the PDP1.

11:09 Um we're first going to look a bit at the front panel,

11:12 what it shows and how to use it.

11:14 And then we'll use it to uh draw the circle

11:18 uh that uh uses the algorithm that Marvin Minsky discovered.

11:23 Um and also the Minskyron which is based

11:26 on that uh algorithm which is a very uh nice

11:30 looking demo and it's also you can play

11:31 with the switches and uh it's very satisfying to play with.

11:35 So what you see on the panel,

11:37 all these lights are almost all of the state that the the PDP1 has.

11:41 All the internal flip-flops are visible as lights on the panel,

11:45 which you need because if the machine isn't working,

11:48 and back in the day, the machine was not working quite a bit.

11:52 Um, you have to make it work again and you have to see uh the machine state.

11:57 Um, this panel doesn't have all the lights.

11:59 there was an IO panel and peripherals would have more lights and so on.

12:03 But this shows everything important really.

12:06 So we have two registers up here, the program counter and the memory address.

12:10 Program counter is the same as you would expect today.

12:13 It's the address at which to fetch the next instru instruction.

12:17 Memory address is the register that holds the address

12:20 for the memory word that is being addressed by the computer.

12:25 So it's just an address and the memory buffer is the data

12:28 that either came out of memory or was written back into memory.

12:32 So at the end of a memory cycle uh the MB register

12:36 would show what is in memory at that location shown at memory address.

12:41 And the accumulator and inout register are what the programmer uses.

12:45 And as you can as you can tell from the name

12:47 in out is also connected to the uh peripheral equipment IO stuff.

12:51 So the accumulator is the arithmetic

12:54 register that control with with your program

12:56 uh more or less and IO was also used for uh

13:00 like as an auxiliary register also when we display a point it

13:04 will be x and y coordinates one register is x one is y

13:07 and uh the address in the uh in the basic machine is

13:11 12 bits here but we have a memory extension we can use

13:15 up to 64 uh kilohz 12 only gives you 4 kohz and uh

13:20 64 kil other words for the maximum what a PDP1 could do.

13:25 So here we have uh like a run light and a cycle light and so on.

13:28 These uh run is obviously when the machine is running it's not running yet.

13:32 And this is internal flip-flops that we're not

13:34 going to uh go into in much detail.

13:36 Uh the power switch obviously turns off

13:39 the power and on again the sense switches

13:42 could be used by a program just to read like general uh inter user interaction.

13:47 you can read them and the program flags are kind of similar.

13:51 They can be set and read by the program to its will

13:55 and they can also be connected to some uh peripheral uh equipment like

13:59 when you uh use the light pen and it sees a spot uh

14:02 it might uh light uh set the program flag for the pen here.

14:07 Uh and we have the instruction register

14:09 so five bits that encodes the instruction.

14:11 So now let's uh put something into memory.

14:13 We have the Minsky circle algorithm here.

14:16 Um, it's not a lot of words.

14:19 And we have the symbolic assembly on the right here.

14:22 And I just wrote down the binary code,

14:26 an octal, uh, that encodes these instructions.

14:30 So, um, you have to know octal, of course.

14:34 Oh.

14:34 Oh, and on the left we have the the address

14:36 where this where we put this into memory.

14:38 So, because yeah, just to remind me, that's base eight, isn't it?

14:42 Octal.

14:42 Is that right?

14:43 So, three bits are one octal digit.

14:45 It's very easy to u like it it's very quick uh to get into really.

14:50 So if you have the upper bit that's a four.

14:53 If you have the middle bit that's a two

14:55 and if you have the lower bit that's a one.

14:57 And so if you have multiple you just add them.

15:00 So that's five.

15:01 And at some point you just don't think about it anymore.

15:04 You just read octal and toggle in binary or you read binary.

15:08 Um so let's do a couple of instructions manually with the front panel.

15:13 We start at address 1 0 0 and the word that's supposed to go here

15:18 is 7 all up six which is four and two one and the rest zeros.

15:26 Now uh pressing deposit up uh puts this into memory.

15:32 We see memory address 1 0 0 and memory buffer 7 6 1 0 0.

15:39 Oh, actually I made a mistake.

15:40 That's the second instruction.

15:41 That's no problem.

15:42 We could just change the address and put it in location 101 instead.

15:47 Easy.

15:48 But now we have to do the first instruction of course.

15:50 So that is two 0 0 1 1 3.

15:58 So 2 0 0 1 1 3.

16:01 Uh so you can already tell it's easy to make mistakes and that is

16:05 why I don't really want to do this on the front panel so much.

16:07 It's very tedious.

16:09 Um but just to make sure uh that we also check the examine uh switch.

16:15 Let's look at our previous previous word and uh press examine.

16:20 And then we see our six uh 761 again.

16:24 So now let's do the rest not

16:26 on the front panel but actually using the debugger DDT.

16:30 DDT is the debugger and it's uh it's an insecticide.

16:34 So a debugger.

16:36 So I have DDT mounted as a paper tape in the reader.

16:39 It will be above the front panel here.

16:42 We have it on screen.

16:44 Um and when you press read in the machine knows the format

16:48 of the tape and goes through it and you can see

16:53 the address being counted up here where things is things are

16:57 being put into memory and eventually it's going to jump into DDT.

17:02 Okay.

17:04 So now we're interacting with a typewriter here.

17:07 Would that have been the sort of speed a paper tape to to run or is it?

17:09 Yes, it's the original speed like uh there are different numbers given

17:13 but uh 400 lines per second is is about right something like 300 400.

17:20 Um okay so now let's confirm that what

17:23 we have put into memory is indeed correct.

17:26 So uh at address 10 0 0 we have

17:30 exactly the instruction uh that I wanted to put there.

17:34 And by pressing backspace we can check

17:36 the next one and equals gives us the octal.

17:41 And so now I just do the rest.

17:43 Um I can do sum in octal directly.

17:49 This will be the next instruction.

17:52 and and the next one and the rest one uh the other

17:58 ones I will just do symbolically because that's something DDT can also do.

18:02 So we are now at 104 and that is supposed to be DAC 114 deposit accumulator.

18:12 Okay, so now we finished uh putting this into memory

18:15 using DDT and we see um by examining uh

18:18 successive locations that uh we have this code in memory

18:22 now which is the one that I want to execute.

18:24 DDT was quite popular on other machines as well.

18:27 There is a whole tradition of these interactive debuggers.

18:30 It doesn't start with DDT but uh DDT is fairly wellnown.

18:34 Okay, so we now finished putting the program into memory.

18:37 Uh we can examine the memory locations with DDT and we see

18:41 the code which is the one I uh wanted to put in there.

18:44 And now we want to start this program.

18:46 Uh one way to do it is with the front panel.

18:48 So we stop DDT because we're still running.

18:52 So run is now off.

18:53 And we put in our start address which is 1 0 0.

18:56 Hit start.

18:58 And there we see the circle.

19:00 So what's happening there?

19:01 It's kind of the equivalent of find a point,

19:03 print a dot there, move a bit, print a dot there.

19:06 Um right it starts with a single point and essentially

19:11 with a little bit of uh approximate trigonometry you you would

19:15 move the point uh with a small angle but if

19:18 you approximate it it spirals out because it's just an approximation.

19:23 So Marvin Minsk's discovery was that uh you don't calculate

19:27 the new point from the pre previous point but that the x

19:30 and y coordinates are sort of linked and if you

19:33 do the math you find out that it actually remains stable.

19:37 So that was a very cool discovery and there is a program called the Minskyron

19:41 obviously named after Raminsky which is three

19:44 of these circles kind of linked together.

19:47 So one oscillator is is connected to the second one, the second to the third,

19:52 and the third one again to the one to the first.

19:55 And you have settings on the switches which control them.

19:58 And you have a very cool demo.

20:00 And this is exactly what we're going to do now.

20:03 So um we we'll put the

20:08 So this is where we use the magic of the emulator to load it back in.

20:11 Right.

20:11 Right.

20:12 Uh oh, actually no.

20:13 Uh let's do one one thing first.

20:15 We want to perhaps punch this onto paper tape because we like

20:18 this program and want to run it again without toggling it in again.

20:21 So, we go back into DDT, which is at 600 0.

20:26 So, stop the machine, start there.

20:28 We're back in DDT.

20:30 And now we uh punch a tape.

20:32 Uh we start with a title, capital L, and we might call it circle.

20:38 And we see it punched on the paper tape as as just so you can read it.

20:43 Uh, so you know what that tape is, right?

20:45 With tap, we go into punching words now.

20:48 And our words start at 1 0 0 and it goes up to 114.

20:55 And now we see the words being punched.

20:57 And we just have to give it our starting location now, which is 100 or 10 0.

21:02 There it is.

21:03 And now we can like rip off the tape.

21:06 Uh, which we do with the emulator here.

21:09 Uh, so you're basically saving that, right?

21:12 program.

21:13 Exactly.

21:13 So, we now storing that the file already existed.

21:16 It's fine.

21:17 So, uh we now have our paper tape which came out

21:21 of the machine and now we want to put it back into the reader.

21:25 So, here we go.

21:26 There it is.

21:27 And obviously, we still have it in memory, but it doesn't really matter.

21:31 So, just read in the tape goes in and it jumps into the circle program.

21:36 Ah, so that last instruction on the tape is basically run, right?

21:39 It it just executes the instruction from uh from paper tape really

21:44 and on the tape I think we've done a video on paper tape

21:46 and computer file before but each line is basically some code is it

21:51 yeah one word is three lines and there's different formats like readin has

21:55 a special hardware format but it's not the most space efficient and so there's

22:00 more efficient loaders but yeah uh but that's how it works and that's how

22:04 you would perhaps program the machine and punch a program onto tape and Yeah,

22:09 very interactive and nice to use.

22:11 Um, you could of course use an assembler, but that's a bit more uh involved.

22:17 Okay, so now let's uh go into the Minskyron.

22:20 So we uh load this demo tape here and read it in.

22:25 Takes a while.

22:28 Uh that's the snowflake, but we don't want that.

22:31 Uh we want Minskyron.

22:32 It starts at 5 0 and it needs some initial switches.

22:36 If we if we start like this, it's just very noisy

22:39 because all these shifts that are done in the Minsky algorithm

22:43 which is a very easy division by a by a number

22:47 power of two number um we can set these shifts now.

22:51 So let's just try something.

22:53 So you just randomly well more or less random.

22:56 I have some intuition but not too much.

22:58 Um but you can see how we

23:00 have this feedback between these three oscillators now.

23:04 And if you observe it for a while it will go crazy.

23:07 Or if you change the switches you can just change

23:10 them and hit start and you get a different pattern.

23:13 And you can you can really have

23:15 fun uh exploring all these possible patterns here.

23:18 And sometime like this is the the typical display

23:21 after after some time it was would just go crazy.

23:25 Say PDP1 you're drunk go home.

23:27 Yeah exactly.

23:29 Uh but it's very very fun to explore

23:32 for sure and I can really recommend doing that.

23:35 There's a very good website where you can do it as well.

23:37 Um Masvak Minskron.

23:40 If you Google Minskron you will find it easily.

23:43 Um so kind of in a chaotic mode right now.

23:47 Let's see.

23:50 But yeah, this is this is what you can do

23:52 with a with this very simple circle like just goes character by character.

24:04 So we get that uh compare against the uh end of the string marker

24:08 and uh until that is the case we just uh print the character on screen.

24:13 So to see that in action, uh let's call the B command and give

Study with Looplines Download Captions Watch on YouTube