Saturday, October 29

CHAPTER 4: MIPS (Million Instructions Per Second)

Well hello! *do i need to introduce myself??

       For this chapter, I will be the one who will explain to you what is MIPS. So, what you will learn here is:

      1. MIPS Architecture
      2. Register       3. Comment (#)      4. Assembly Instruction     5. Memory Operand


4.1 MIPS Architecture
          
    - a unit of computing speed equivalent to a million instructions per second.
    - an early RISC processor. RISC processors typically support fewer and much simpler instructions.

4.2 Register

    - limited number of special location built directly into the hardware
    - needd to perform the operation (cannot perform without it)
    - very fast since registers are directly in hardware
    - only 32 registers in MIPS
  • why? smaller the register, faster the performance
    - 1 register is 32 bits wide (32 bits = a word)
    - register preceded by $ in assembly language instruction
    - two formats for addressing:
  • using register number e.g. $0 through $31
  • using equivalent names e.g. $t1, $sp

    - special registers Lo and Hi used to store result of multiplication and division
  • not directly addressable: contents accessed with special instruction mfhi ("move from Hi") and mflo ("move from Lo")   
    - stack grows from high memory to low memory

4.3 Comment

      In programming language, we create comment by putting '//' at the front. Hence,in assembly language (coding in MIPS), we use put '#' (hashtag) before the words.

#comment

    - hash (#) is used for MIPS comments
  • anything from hash mark to the end of line is a comment
  • will be ignored in the coding

4.4 Assembly Instructions

    - in assembly language, instruction is a statement
    - each instruction is executed exactly one with a simple command
    

     Syntax of instructions:

     The arrangement of coding ::       1(ON)  2(Ds),3(S1),4(S2)

     1(ON) ---> operation name (ADD, SUB, etc)
     2(S0)  ---> operand for getting result or we called it ('destination')
     3(S1)  ---> 1st operand for operation called ('source1')
     4(S2)  ---> 1st operand for operation called ('source2')

     example :   add  $s0,$s1,$s2 
    
     - Syntax is rigid
  • 1 operator (add,sub, etc), 3 operands >> to keep hardware simple and fast

     :: Addition in assembly
         Example:               add  $s0,$s1,$s2  (in MIPS)
         is equal to:            a = b + c (in C)
   
     :: Subtraction in assembly
         Example:               sub  $s3,$s4,$s5  (in MIPS)
         is equal to:            d = e - f (in C)

4.5 Memory Operand
    
     - Main memory used for omposite data
     - To apply arithmetic operations
  • load values from memory into registers
  • store result from register to emory
     - memory is byte addressed
  • each address identifies an 8-bit byte
     - words are aligned in memory
  • address must be a multiple of 4

That's all from me. Hope you enjoys reading mine! Ppyong~


                

[EXTRA] CHAPTER 6: LANGUAGE OF THE COMPUTERS - Instruction Set Architecture (ISA)

Based on what I have introduced in the previous post, this time it will be about instruction set. If all I talked about was briefly the languages that computers use, now I will share about how it is being laid out in programs.


The high-level language is used to write out the Instruction Set Architecture (ISA). But first,

WHAT IS AN INSTRUCTION SET?

Instruction set is basically a set of commands that is to be carried out by the Central Processing Unit (CPU) of the computer in terms of machine language.

Simple instructions are made up of bit strings. Inside every instructions there are several important specifications that needs to be encoded.

1. Opcode

The first 6-bit of an instruction set is the opcode (“operation code”). It tells us what operation the CPU must carry out. Mnemonic language is used rather than hexadecimal code for simplicity and readability. 

2. Parameters

The rest of the instruction set contains parameters for the operation to work on. It can have registers, values and etc.


Now, ISA is the main interface between programming language and software with the main hardware component inside a computer. ISAs have unique assembly language that specifies how the program will run in a computer. 


WHERE INSTRUCTIONS ARE STORED?


Since instructions are sets of bit strings, there are mostly many instructions for every program and this requires some space in the memory. Inside the memory, the instructions are lined up in a consecutive manner with an address for each line of instruction. 

The relationship between CPU and Memory

Besides memory, a register also holds data temporarily. Registers can retrieve data whenever it is needed like how a memory works, though only a small volume can be stored. 

Example of instruction set:

MIPS Instruction Set

It uses 32-bit instructions which has R-Type Instructions, I-Type Instructions and J-Type Instructions. The opcode identifies the instruction which allow us to identify the instruction type.

x86 Instruction Set

It is one of the series of computer microprocessor developed by Intel for Intel 8086 CPU. It provides backward compatibility for older piece of hardware or software without the need to modify. Therefore x86 is the most prevalent ISA for desktop use. 



Glossary:

Mnemonic language: In assembly language, mnemonic is used to abbreviate various operations.
Parameters: Characteristics to customize a program.
Address: A unique number given to specify a particular set of instruction in memory.
Registers: Very small volume of memory located in the CPU itself.
Bit string: A sequence of bits that is represented by binary data. 


References:

Source 1
Source 2
Source 3

Picture credits:

https://www.eeweb.com/electronics-quiz/instruction-set-architecture
http://blog.biicode.com/bitscan-cpp-library-bit-strings/
http://math.hws.edu/javanotes/c1/s1.html


Ok so hope that summarizes what ISA is all about. Feel free to check out other topics for this syllabus! Your comments are highly welcome.

Til' next time, thanks for reading!

Friday, October 28

CHAPTER 3 : DIGITAL LOGIC SIMULATOR

Definition :

  • A logic simulator is a computer program that allows designers and experimenters to conduct virtual tests of complex digital circuitry before working with any hardware.

Multimedia logic : is a drag and drop out logic design software. You can draw your logic design on the white canvas and then we cam simulate the circuit.




YOU CAN WATCH THIS VIDEO FOR YOUR REFERENCES !!!






There are some links for you guys to get the software with FREE !!!







  • After downloaded and installed the software, you open it and will show you this :









  • Then, you can draw your own logic design on the white canvas using "Palette" :




                                                                                 


SIMPLE STEP ON HOW TO CREATE A SIMPLE "OR" CIRCUIT

STEP 1 : Find logic OR in the palette, click the OR gate and place it(click) on the canvas.







STEP 2: Find the switch and click the switch, place on the canvas near the input of the gate.
The switch would like the figure below.


The purpose of using the switch is to test the truth table. If the switch is flipped up, it means 1 and 0 if it is flipped down.










STEP 3: Find the LED icon and place it front of the output of the gate.
Do not confuse with the 7 LED Segment!












STEP 4: To connect the component, use wire icon to connect each dot to the respective gate. Click at one end and drag to the other end.










STEP 5: Labels the input and output accordingly. Find icon capital A(that refers to Text label) and click next to the input. To edit the text, click the mouse palette on the palette(it will indicate as a selector) and double click the label Text to open Text properties. Type the input label on Text box. Click OK.














STEP 6: Simulate the logic by clicking the Simulate menu, choose Run. Or you can just click the Play button to run the simulation.

Test OR truth table by clicking the switch to see whether LED will light on if the condition met. In this logic, only when the switches is set to 1 then LED will light RED.







To stop the simulation, press STOP button.
This circuit can be saved into .lgi file or printed by using the file menu.




References :



CHAPTER 2 : DIGITAL LOGIC



LOGIC DESIGN

  • Digital electronics operate with only two voltage levels
         * high voltage and low voltage
  • Computer used binary system (0,1).
  • Combinational logic block contains no memory.
  • Logic block with n inputs, there are 2n entries (possibility) in the truth table.

TRUTH TABLES






BOOLEAN ALGEBRA



  • Boolean algebra laws





GATES

  • Logic blocks are built from gates that implement basic logic functions.
  • Any logical function can be constructed using AND gates, OR gates, and inversion.
  • Two common inverting gates are called NOR and NAND.

DECODER



  • Use decoder to build larger components.
  • The most common type of decoder has an n-bit input and 2n-bit outputs, where only one output is asserted for each input combination.
  • This decoder translates the n-bit input into a signal that corresponds to the binary value of the n-bit input.
  • The outputs are shows a 3-bit decoder and the truth table. This decoder is called a 3-to-8 decoder.
  • Since there are 3 inputs and 8 (2 power of 3) outputs. There is also a logic element called an encoder that performs the inverse function of a decoder, taking n inputs and producing an n-bit output.


MULTIPLEXER (Selector)

  • The output is one of the inputs that is selected by a control.



  • Multiplexers can be created with an arbitrary number of data inputs.
  • If there are only two inputs, the selector is a single signal that selects one of the inputs.
  • If it is true (1) and the other if it is false (0). If there are n data inputs, there will need to be [log2n] selector inputs.


  • To associate the inputs with selector values, we often label the data inputs numerically.

ARITHMETIC LOGIC UNIT (ALU)

  • ALU – perform arithmetic operation (addition, subtraction and logical operation : AND, OR).
  • Constructs an ALU from four hardware building blocks (AND and OR gates, inverters, and multiplexors) and illustrates how combinational logic works.
  • MIPS word is 32 bits wide, so need 32-bit-wide ALU (connect 32 1-bit ALUs ).


1-Bit ALU












This adder is called a full adder; it is also called a (3,2) adder because it has 3 inputs and 2 outputs. An adder with only the a and b inputs is called a (2,2) adder or half-adder.







Specify the outputs of this "black box" based on its inputs, as in truth tables.


CHAPTER 6: LANGUAGE OF THE COMPUTERS - INTRO

In this blog post, we will look into the language that is use in computers. Roughly, computers have 2 major types of programming languages - low-level and high-level.

The Central Processing Unit (CPU) of a computer reads a computer programming language known as the machine code or machine language. Machine language are known as low-level language. The term "low" is represented because they are very close to how different hardware of the computer communicates with each other. It does not need any conversion or translation to execute instructions set.

Picture source: https://www.learnnpractice.com/generation-programming-languages.html
Machine language is a type of computer programming language that consists of binary and hexadecimal instructions which can be executed directly by the CPU. It is also the only language computer hardware understands. However, the binary notation are hard for humans to understand.

Even though low-level languages do not require any compiler to translate the instructions, some do need a simple processor called "assembler" to convert it to machine code and that is known as Assembly Language. Assembly language makes machine language more readable to humans. Instead of using long binary notation, assembly language uses a set of symbols and letters. Low-level language are categorized into first-generation and second-generation programming language. Assembly language is the second-generation as it no longer use 1s and 0s to write instructions.

Picture source: http://www.slideserve.com/karlyn/machine-assembly-language

Now for high-level language. High-level language are much more understandable to humans as it uses English and mathematical symbols in its instructions. Programming language is often referred to high-level language as it is mostly used by programmers nowadays such as C++, Java, Fortran and Python.

Being a low-level language, both machine code and assembly language are hardware specific and not portable. Meaning, the program can only be run on one specific computer and needs to be modified to run in other computers. 

Where as high-level language, they are portable and hence, are able to run on multiple computer system without modification. However, modification may be necessary due to different operating systems such as  for Windows which are typically different for Mac.

Unfortunately, high-level language is not directly understood by computers and needs to be translated into machine code. There are 2 ways to how it can be translated which are either compiled or interpreted. 

Compiling is a translation of the whole set of instruction into machine code as a compiled code (such as an .exe extension), prior to the insertion of input data during execution. Simply said, the result from compiling can be run as many times afterwards without having to compile them again. Example of compiled languages are C language and its derivatives - C++ and C#, COBOL and Fortran.

Interpretation on the other hand means the high-level program is interpreted line by line to produce an output data. Therefore for every execution, it is required to interpret the code again and again as there is no compiled code to use. Example of interpreted languages are Java, Perl, Python and Ruby. 

Alright, that's all for the introduction! Hope all the terms are well-written out.

Do comment if you have any doubts as we are all still learning as well! Til' the next post, keep computing! ;)

References:

Source 1
Source 2
Source 3

Wednesday, October 26

CHAPTER 8: MEMORY ORGANIZATION (PART 2)


A memory unit which is fast and small memory can be called as the cache memory. If the active portions of program or data are placed in fast and small memory, the average memory access time can be reduced. So it reduces the total execution time of the program. That is why such a fast and small memory is needed. The cache memory is the fastest component in memory hierarchy and approaches the speed of CPU component. 

The performance of cache memory is frequently measured in terms of a quantity called hit ratio


HIT RATIO = HIT / (HIT+MISS)


There is also mapping process. Mapping consists of three types, associative mapping, direct mapping, set-associative mapping. 







The Replacement Algorithms
1) LRU (Least Recently Used) 
2) LFU (Least Frequently Used)
3) FIFO (First-In First-Out) 

Last but not least, the type of memory device is used is virtual memory. This term refers to something that appears to be real but it is not. If the technique is applied, it can allow users to use more memory of a program than the real memory of computers. Virtual memory is a temporary memory that is used along with the RAM of the system. 




Computer Organization
Introduction to Memory Organization
Chapter 12
Terms of Memory Unit



THAT'S ALL FROM ME. THANK YOU. ENJOY READING! 

CHAPTER 8: MEMORY ORGANIZATION (PART 1)

Undoubtedly, memory unit is really an essential component in computers nowadays as it is needed for storing programs and data. Information stored in memory devices can be divided into bits, bytes, words, blocks, segments, pages and other larger data structures, which have their own identifiers. There are various types of memory devices that are united under memory organization.

First of them is memory hierarchy
Memory hierarchy is to obtain the highest possible access speed while minimizing the total cost of the memory system. CPU logic is usually faster than main memory access time but the processing speed is limited. The cache memory is used for storing temporary data frequently need in present calculations. The typical access time between the cache memory and main memory is about 1 to 7. While auxiliary memory access time is 1000 times of main memory time.



Memory Hierarchy

Second of all is main memory
Main memory is a memory unit that communicates directly with the CPU which consists of two types of device which is RAM and ROM.
RAM stands for Random Access Memory and ROM stands for Read Only Memory. Both of them have same size, but it is possible to have more bits of ROM than RAM because the internal binary cells in ROM occupy less space than in RAM.



RAM and ROM


Next, let me introduce you to Auxiliary memory.
It is also called as Secondary memory which can store large chunks of data at a lesser cost per byte than a primary memory for backup. The most common form of auxiliary memory devices used is flash memory, magnetic disk, magnetic type and optical disk.





So now we're going to know about associative memory.
It is accessed by contents that is why we're known as associative or content addressable memory (CAM).

Tuesday, October 25

CHAPTER 9: INPUT AND OUTPUT DEVICES

As in computer terminology, I am also going to share you about input and output devices that are related to the computers. First of all, you need to know the concept of these two words, 'input' and 'output'. We need to use some input devices to produce output. If there is no input inserted, no output can be produced. Before computer process our data, we use few method to input data in our machine (computer). The device we use depends on what form of data it takes. After the computer has processed the data, the output could be a display on the computer screen, hard copy on printed pages, or even the audio playback of music we composed on the computer. Here are the lists of input and output devices of a computer :

INPUT DEVICES:
  • Graphics Tablets
  • Cameras
  • Video Capture Hardware
  • Trackballs
  • Barcode reader
  • Digital camera
  • Gamepad
  • Joystick
  • Keyboard
  • Microphone
  • MIDI keyboard (Musical Instrument Digital Interface)
  • Mouse (pointing device)
  • Scanner
  • Webcam
  • Touch pads
  • Pen Input
  • Microphone
  • Electronic Whiteboard
  • Punch card reader
  • Magnetic Tape Drive



OUTPUT  DEVICES:
  • Monitor (LED, LCD, CRT etc)
  • Printers (all types)
  • Plotters
  • Projector
  • LCD Projection Panels
  • Computer Output Microfilm (COM)
  • Speaker(s)
  • Head Phone
  • Visual Display Unit
  • Film Recorder
  • Microfiche

However, there are some devices that can work as both which is as an input device and also as an output device for computers. Some of them are :

INPUT-OUTPUT DEVICES :
  • Modems
  • Network cards
  • Touch Screen
  • Headsets (Headset consists of Speakers and Microphone. Speaker act Output Device and Microphone act as Input device)
  • Facsimile (FAX)(It has scanner to scan the document and also have printer to print the  document)
  • Audio Cards / Sound Card