Skip to main content

Computer structure and programming

What is a computer? Computer is an electronic device that manipulate data. It has the ability to store, retrieve and process data. 

Computer Structure

Most computers in the modern world use the Von Neumann structure among other models such as the Harvard Model. The Von Neumann structure consists of 3 main parts, Input Output devices aka peripherals, CPU and Memory. 

Von Neumann architecture
Von Neumann Architecture

1. Input / Output devices
The Input devices include devices such as keyboards, mouses (or mice), sensors, and scanners. The Output devices include speakers, monitors and printers. 

2. Memory unit
The Memory unit sometimes called "Main Memory" stores the data and instructions from the input devices and the Central Processing Unit. It works closely with the CPU to execute calculations. There are 2 types of memories: RAM and ROM.

1. RAM (Main Memory)
Random Access Memory, commonly abbreviated as RAM stores the data and instructions that the CPU requires. When the computer is powered off, all the data is lost.

2. ROM
Read-only Memory, referred ROM stores the software that initializes the system. ROM retains data when the computer is powered off.

3. CPU (Central Processing Unit)
The CPU is the part of the computer that controls the manipulation of data. In the CPU, there are 2 parts: Control Unit (CU) and Arithmetic / Logic Unit (ALU). ALU performs logarithmic operations while the CU coordinates the activities of the CPU. The CU also has registers which are quick, small storages that store data like the fetch, decode, execute instructions. 
The registers include: 
  • Program Counter (PC) - Keeps track of the memory address of the next instruction. After data is fetched from the memory and before it is decoded, the PC updates.
  • Memory Address Register (MAR) - Stores the memory address of the data to be fetched from or will be stored in.
  • Memory Data Register (MDR) - Stores a copy of the value in the memory location specified by the MAR.
  • Accumulator Register (ACC) - Stores the data from MAR or the intermediate results from the ALU.
  • Current instruction register (CIR) - Stores the data from MAR if the data is an instruction.
The CPU fetches the data from the memory using buses, such as the address bus (between MAR and memory), data bus (between MDR and memory) and the control bus.
The instruction in the CIR is decoded by the decode unit after the PC updates itself to the next instruction location. The decode unit has an opcode (operation code), operand (address or data) and their  corresponding instruction. For example, 0000-0000 is to end the program.  
The CPU also has system clock which sends a signal like a metronome that synchronizes the circuits. The frequency of the clock signal is called the clock speed. 

How does programming work?

Programming is the process of writing programs that tells the computer how to do a specific task. Tying to the structure of computers, it is the process of providing instructions that is stored in the memory. Each instruction in the CPU has fetch, decode and execute cycle. The instructions are written in binary. Everything is stored as binary in the computer because the data in computer is stored in micro transistors. 1 micro transistor stores 1 bit of data and 8 bits combined makes up a byte.
The first generation programming language is machine language which uses binary to write program. The second generation is Assembly which shortens the binary code with words but still has to write the same number of instructions as the machine language. The next generation is called a high level language which include an array of programming languages that programmers use today. The first one however is Fortran which was developed by IBM. The revelation here was that you could write one instruction (function) in Fortran which can be interpreted as multiple instructions in the CPU and it was cross platform which allowed the code to be executed in different computers. One of the most popular high level languages now is Python. The reason why it is popular is because:
  • Python is expressive and can get things done with fewer lines of code as compared to other languages.
  • Python is popular. It has an extensive set of libraries for Mathematics, graphics, AI, Machine Learning, etc.
  • Python is free and open source, so you get to see everything and use it without restrictions.
  • Python is portable. The same code runs in different platforms without modifications.

Comments

Popular posts

Discrete Mathematics - Inference Rules for Propositional Logic

Cloud Computing Introduction | Definition, Benefits and Deployment Strategies

What is Amazon EC2? Definition, Types and Pricing

Mastering Decoupled Cloud Architecture with Messaging and Queueing | Amazon SNS and SQS