IB
Computer Science
Arduino
This covers what is in the book from page 61 onwards
We're going to talk about computer organization and computer Architecture.
What is architecture in terms on computing?
Can refer, depending on the context to:
Here we're going to focus on the later and we're going to talk about how hardware is place in the machines to do what they do.
As a first approach we can think of any machine as a input/output machine. This is an abstraction but works.
This is true to lots of machines frome phones to microwave ovens, to laundry machines, even can be mechanical (in a piano)
The input of a device is something that gives the machine information and the output is some kind of decision that comes out the machine as a conclusion.
In one of the mechanical examples a ringbell, if we press the button (input) the bell rings (output).
There are some cases where the information is bi-directional (comes and goes in both ways). In this case we usually talk not about input-output but "communication"
Let's do a list of physical inputs of any device and physical outputs of any device and communication systems of any device.
Ideas in the spoiler section
Device: Phone
Inputs:
Outputs:
Communication:
(wired)
Device: Laptop
Inputs:
Outputs:
Communication:
Wired
Wireless
Other input sensors:
http://academy.cba.mit.edu/classes/input_devices/index.html
Other output sensors:
http://academy.cba.mit.edu/classes/output_devices/index.html
These machines have been existing and have been studied since the 19th century (Ada Lovelace) but the main part was done in the first half of the 20th century.
In the 1940s the first computers were born. Computers that had the size of rooms.
Harvard machine
CPU stands for "Central Processor Unit" and it refers to the hardware component of a computer that makes the calculations.
Regarding the design of these CPUs we can find several "paradigms". These paradigms are ways to do things and we usually need to know what paradigms are we using so we can make choices between those paradigms.
Remember that paradigm is an idea that we want to adhere to. Something that we want to achieve even if the reality is not that perfect.
For example the IB expects the student to behave with the IB profile. This is a paradigm to assest the grades of the student in the end.
Usually there is no "good paradigm" or "bad paradigm" because usually each of them has some advantages and disadvantages.
Sometimes these paradigms, these "boxes" fall short when defining some new technology so sometimes they fade away. One of this "breaking paradigm" is quantum computing. (more about it here)
Quantum computing since doesn't work with 1s an 0s is so different that some ideas about computing need to be redone if that technology takes over.
Each type of CPU has some kind of "Fundamental operations" set to work properly. Those "Fundamental operations" are the bricks of any algorithm that the CPU (or CPU cores) are going to operate.
Usually we have several layers of compilers to transform automatically the complex operation that we want to do into these fundamental operations.
Depending of the approach to these there are (were) two types of architecture
This approach says that the instruction should be few and very optimized. This has the advantage of allowing easily multi-coring and set several CPU in paralel.
Nowadays you can see it in microcontrollers.
you can find more about it here
This category exist as an non-established antonym of RISC. Meaning "everything that is not RISC". But the main concept is that the CPU should have as many instructions posible as it can so you can use it directly.
You can read more about it here
Nowadays we have for example the X64 type of microprocessors that are widely used. They work with a fairly large set of instructions buuut they are optimized to work only with a subset of all of these instructions. Are they still CISC if they are not optimized for the full set of instructions? Are they RISC?
In our case our Arduino works in a RISC model.
RISC and CISC models are not something assest directly in the IB exams but I think that "paradigm" is a good concept to handle this and other concepts and explaining through this lense can help the student to understand more easily other concepts.
(page 241) from the book
We can see a set of fundamental operations like these:
We can think that RISC computers work with these and maybe a couple more that are compounds of these instructions.
(going back to page 62)
Inside the CPU we have several important objects.
Then we have the memories divided in
There are several types of Primary memory. Mainly we have RAM (Random Access Memories) and ROM (Read Only Memories) and also we usually have "cachés".
(This part is just a summary. Students are expected to improve this part)
We saw what was stored in the MAR and then sent to the RAM to retrieve/write the data
https://youtu.be/7J7X7aZvMXQ?si=8cLvppz2aKTsI1Sz&t=548
This is the part of the microprocessor that actuallly makes the operations at very fast speed doing arithmetical, logic or input/output operations.
Mircroprocessors (such us intel core i5) are more powerful but they need other chips around them in order to work. Microcontrollers (like the chip embedded in an arduino) are less powerful but they need less stuff around. They are more self contained.
Microprocessors go always into a motherboard that is a computer. Microcontrollers are a whole entity that can operate on their own. Microcontrollers have small microprocessors. Also microcontrollers are associated with other kind of hardware interface. We usually say that a laundry machine has a microcontroller rather than a full computer, even if the line is sometimes blurry.
In our case, the Arduinos that we are using they are a microcontroller a Harvard archictecture, RISC microcontroller.
Some of the microprocessors can be multi core to improve performance. That can be applied to microprocessors (nowadays almost any microprocessor has multiple cores). There is a limitation around 8-10 cores usually in this kind of architecture because you need to coordinate them. Each of the processors works with an entity of instructions called thread.
Also you can apply it into some microcontrollers and GPUs can have even hundreds of cores. Nvidia do a lot of stuff with this.
With the explanation of these parts we can read about the machine instruction cycle in page 68-69
We have 4 parts of the Machine Instruction Cycle
This is something that happens around the clock (we will see what is the concept of clock) indefinetly.
Decode and encode
Encode can be understood as encrypt but is not strictly the same. When we encode information in low level computer science, we are making signals shorter. (4 entries, 2 exits)
Decode also can be understood as decrypt but is not strickly the same. When we decode information in low level computer science, we are making signals longer. (2 inputs, 4 outputs)
Regarding memory there are 2 main architectures.
In the image is the "Memory Unit". Most microprocessors of laptops use this kind of architecture.
(source: wikipedia)
Our microcontrollers use this kind of architecture, so they don't have just "a RAM" but they have a Flash and SRAM and a EEPROM. We will see it in detail in the datasheet.
This information also not included directly in IB syllabus I think that gives some context and usefulness for the information of the ALU and the types of memory.
All of these becomes useful to read datasheets. Datasheets tells us many information regarding a specific component.
Here is the datasheet of the CPU of my computer
In our case we have these arduinos that we are going to explore a bit. They have this processor: ATmega328P. We can check it out that from the main Arduino page
And this ATmega328P has a datasheet that specify everything on it and how it works.
Here is the link to the datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf
If you go to the page 6 you can see an overview of the chip here:
If you go to page 9 you can see this, that is inside of the CPU
And you will see that we have Data SRAM, we have an EEPROM(Electrically Erasable Programmable Read-Only Memory) that is a kind of ROM memory. You can see a tutorial applied to arduino here(Spa).
Usually the cycle of a computer runs very fast. We measure it in how many times happen in a second. We have these clocks in order of MHz (1 000 000 times in a second) or GHZ (1 000 000 000 times in a second).
Cache can occurr in CS in different contexts
In software is some data that is hold somewhere temporarely to have it at hand. For example browsers have a cache of the images that you have visited so if you visit the same page you don't need to download again the same image.
The other context is the same concept but in hardware
Cache in RAM
Cache in RAM is going to store the most common instructions so if they're needed again they are in a place that is easier to access. Static RAM is an example of Cache. Is a more expensive and faster type of ram and it's saved for just a small caché of common instructions.
Dynamic RAM is slower (but bigger an cheaper) RAM.
L1 caché is placed in the CPU
L2 caché is placed in the RAM
Cache in the CPU can be (from a fast look into the intel chipsets) very small, around 12MB, but it's still very useful because it's only going to contain very commonly used instructions
The idea of having a cache is to speed up calculations so the processor doesn't have to go to the RAM to fetch the next instruction/data and come back.
Each instruction has a set of bits. Typically 8-16-32-64. It's a bit misleading because you may use 8 bit processors for some stuff and it's ok. Nowadays the laptops use 64 bit architecture.
This "size of the word" is used to talk about how big can be the memory registers and the instructions themselves.
GPUs are mainly done for 3D rendering systems.
When we have to render something in 3D (like a box) we need to put the elements of the box into the frame (that will be the screen). To do that, the computer (the GPU) needs to do the calculations of all the lines that goes from the edges of the box to the camera and find the intersection with the plane of the point of view. That's a lot of geometrical calculations that needs to be done.
image from the branch education video that you can see later
They are more less simple geometrical calculations but they are many of them. That's why the architecture of a GPU is one that has many threads of execution as possible at the cost that the precision is not that good. A GPU usually have lots of cores rathern than a handful of them that is common in a CPU.
In this video of branch education you can see mor information about this.
https://www.youtube.com/watch?v=C8YtdC8mxTU
Explanation in detail of these types of architecture in Spanish:
http://cv.uoc.edu/annotation/8255a8c320f60c2bfd6c9f2ce11b2e7f/619469/PID_00218274/PID_00218274.html
Using a jetson: https://www.youtube.com/watch?v=pmDLOdDabRo&t=35s
Primary memory is defined by being directly accessible direcly by the CPU.
Mainly we have RAM (Random Access Memories) and ROM (Read Only Memories) and also we usually have "cachés".
RAM is way smaller than secondary memory in size but faster in terms of accessing. Also the RAM is held by capacitors that loose their data once the power is off.
Secondary memory is defined by not being accesible directly by the CPU. We usually need to move the information from the RAM to the secondary memory back and forth.
Types of secondary memory:
To read a CD/DVD/Blu-ray we need an optical unit. A CD/DVD/Blue-ray reader.
Reference:
https://www.spiceworks.com/tech/devops/articles/what-is-bios/