Showing posts with label TAN KAI LUN. Show all posts
Showing posts with label TAN KAI LUN. Show all posts

Thursday, 20 December 2012

MIPS SIMULATOR: FUNDAMENTALS OF EMULATION & QTSPIM

FUNDAMENTALS OF EMULATION

  • untuk mempelajari seni bina MIPS, kita menggunakan emulator untuk memahami processor.
  • emulator sering digunakan untuk debugging.
  • untuk program pemasangan, kita boleh debug dan melihat bagaimana processor melaksanakan operasi pada cip melalui emulator.


QtSPIM

  • menjalankan program MIP32 dengan mengemulasi MIPS processor.
  • MIPS processor mumpunyai 32 registers, masing-masing memegang 32 bits.
  • freeware dan boleh didapatkan dengan senang melalui WWW
  • website: http://spimsimulator.sourceforge.net/


  1. Register display: memaparkan kesemua 32 registers dan kandungannya, sama ada dalan hex, binary atau decimal mengikut tetapan pengguna. Semua kandungan dalam registers adalah 0 pada mula-mulanya.
  2. Data display: mengandungi User Data Segment, User Stack dan Kernel Data Segment.
  3. Text display: lajur pertama merupakan alamat memori. Lokasi arahan mesin ditunjukkan pada lajur kedua dalam hexadecimal. lajur ketiga pula menunjukkan kod assembly.
  4. SPIM Messages: menunjukkan mesej simulator sama ada terdapat kesilapan kod atau tidak.

Wednesday, 19 December 2012

MEMORY: RAM

RAM (Random-Access Memory)

  • ingatan meruap, memerlukan bekalan elektrik untuk mengekalkan maklumat
  • dibahagikan kepada 2 jenis RAM utama, SRAM & DRAM

SRAM (Static RAM)

  • RAM statik
  • transistor digunakan dalam sel memori
  • tidak mempunyai kapasitor dalam sel
  • lebih mahal, tetapi lebih cepat dan memerlukan kuasa yang kurang daripada DRAM
  • sering digunakan sebagai cache memory untuk CPU

DRAM (Dynamic RAM)

  • RAM dinamik
  • menyimpan setiap bit data dalam kapasitor berasingan dalam litar bersepadu
  • kapasitor berkeadaan sama ada caj atau dicaj yang mewakili 1 atau 0 masing-masing
  • disebabkan keadaan kebocoran caj kapasitor, maklumat akan mengalami kepudaran, dan mesti dibarui dari semasa ke semasa

FPM DRAM (Fast Page Mode DRAM)

  • bentuk asal DRAM
  • menunggu proses mencari data mengikut lajur dan baris, kemudian membaca sebelum bermulanya bit seterusnya

EDO DRAM (Extended Data Out DRAM)

  • tidak menunggu proses mencari data
  • ini membolehkan pertindihan dalam operasi (pipelining)

SDRAM (Synchronous DRAM)

  • menggunakan kelebihan konsep burst mode untuk meningkatkan prestasi, dengan konsep pipelining
  • bermakna bahawa cip boleh menerima arahan baru sebelum proses sebelumnya diselasaikan
  • arahan menulis boleh diikuti dengan arahan lain, tanpa perlu menunggu data dituliskan

DDR SDRAM (Double Data Rate SDRAM)

  • generasi lanjutan SDRAM
  • dua kali ganda jalur lebar SDRAM yang mempunyai kekerapan jam yang sama, dengan menggunakan konsep double pumping

RDRAM (Rambus DRAM)

  • menggunakan bas data kelajuan tinggi khas yang dipanggil Rambus channel
  • menjana haba yang lebih

PCMCIA Card

  • PCMCIA - Personal Computer Memory Card International Association
  • juga dekenali sebagai PC Card
  • direka untuk komputer riba, digantikan oleh CardBus pada tahun 1995 dan seterusnya ExpressCard pada tahun 2003

CMOS RAM

  • juga dikenali sebagai Nonvolatile BIOS memory
  • digunakan untuk mengingati perkara-perkara seperti tetapan cakera keras
  • menggunakan bateri kecil untuk menyediakan ia kuasa yang diperlukan untuk mengekalkan memori

VRAM (Video RAM)

  • digunakan khas untuk 3-D accelerators
  • faktor penentu dalam resolusi dan warna paparan
  • digunakan untuk memegang maklumat grafik

MEMORY MODULE

SIMM (Single In-line Memory Module)

  • menggunakan penyambung 30, 64, atau 72-pin
  • bersaiz kira-kira 3.5 x 0,75 inci (kira-kira 9 x 2 cm)
30-pin (atas) and 72-pin (bawah) SIMMs


DIMM (Dual In-line Memory Module)

  • menggunakan penyambung 72, 100, 144, 168, 172, 184, 200, 204, 214, 240, atau 244-pin
  • bersaiz kira-kira 5.4 x 1 inci (kira-kira 14 x 2.5 cm)
  • pelbagai kapasiti dari 8 MB ​​hingga 1 GB setiap modul
168-pin SDRAM module (atas) and a 184-pin DDR SDRAM module (bawah)

SDRAM DIMM slots

SO-DIMM (Small Outline DIMM)

  • bersaiz kira-kira 2 x 1 inci (kira-kira 5 x 2.5 cm)
  • mempunyai 100, 144, 200, atau 204 pin
  • pelbagai kapasiti dari 512 MB hingga 1 GB setiap modul
DDR2 SO-DIMM (200-pin)

DDR3 SO-DIMM (204-pin)

SO-DIMM slot

LANGUAGE OF THE COMPUTER: R & I FORMAT

R-FORMAT


op
rs
rt
rd
shamt
funct
6 bits
5 bits
5 bits
5 bits
5 bits
6 bits

  • op: kod operasi
  • rs: sumber register pertama
  • rt: sumber register kedua
  • rd: destinasi register
  • shamt: digunakan dengan arahan peralihan dan putaran
  • funct: mengandungi kod kawalan yang diperlukan untuk membezakan arahan yang berbeza bagi arahan yang megunnakan kod operasi yang sama
  • R-format digunakan apabila semua data nilai-nilai yang digunakan terletak di register

Jadual MIPS register

Contoh:
add $t0, $s0, $s1
Special
$s0
$s1
$t0
0
Add
0
16
17
8
0
32
000000
10000
10001
01000
00000
100000

  • boleh dituliskan dalam bentuk hexadecimal
  • contoh: 1111 1100 1010 1000 0110 0100 0010 0000 = FCA8 6420

Pertukaran antara nombor hexadecimal & binary

I-FORMAT

op
rs
rt
Constant or address
6 bits
5 bits
5 bits
16 bits

  • op: kod operasi
  • rs, rt: sumber & destinasi register
  • constant: nilai 16 bit (–2^15 to +2^15 – 1)

Contoh kod operasi:

Mnemonic
Type
Opcode
Funct
add
R
0x00
0x20
addi
I
0x08
NA
addiu
I
0x09
NA
addu
R
0x00
0x21
and
R
0x00
0x24
andi
I
0x0C
NA
beq
I
0x04
NA
bne
I
0x05
NA
div
R
0x00
0x1A
divu
R
0x00
0x1B
j
J
0x02
NA
jal
J
0x03
NA
jr
R
0x00
0x08
lbu
I
0x24
NA
lhu
I
0x25
NA
lui
I
0x0F
NA
lw
I
0x23
NA
mfhi
R
0x00
0x10
mflo
R
0x00
0x12
mfc0
R
0x10
NA
mult
R
0x00
0x18
multu
R
0x00
0x19
nor
R
0x00
0x27
xor
R
0x00
0x26
or
R
0x00
0x25
ori
I
0x0D
NA
sb
I
0x28
NA
sh
I
0x29
NA
slt
R
0x00
0x2A
slti
I
0x0A
NA
sltiu
I
0x0B
NA
sltu
R
0x00
0x2B
sll
R
0x00
0x00
srl
R
0x00
0x02
sub
R
0x00
0x22
subu
R
0x00
0x23
sw
I
0x2B
NA

Sunday, 28 October 2012

DIGITAL LOGIC: BOOLEAN ALGEBRA



  • Boolean algebra makes use of logical variables and operations.
  • A variable may take 1 (TRUE) or 0 (FALSE).
  • The basic logical operations are AND, OR, and NOT, which are symbolically represented by dot, plus sign, and overbar.




  • The operation AND yields true (binary value 1) if and only if both of its operands are true.
  • The operation OR yields true if either or both of its operands are true.
  • The unary operation NOT inverts the value of its operand.


Boolean Operators of 2 Input Variables

Boolean Operators Extended to More than 2 Inputs

Basic Identities of Boolean Algebra

COMPUTER ARITHMETIC: INTEGER ARITHMETIC

NEGATION

The negation of an integer can be formed with the following rules:
  1. Set each 1 to 0 and each 0 to 1.
  2. Add 1.


Special case:
  1. Negation of 0 is 0.
  2. Negation of an n-bit word of 2^n, will get back the same number.


ADDITION AND SUBTRACTION



To Subtract a number (subtrahend) from another (minuend), take the negation of the subtrahend and add it to the minuend.

Block Diagram of Hardware for Addition and Subtraction


MULTIPLICATION


UNSIGNED INTEGER


Multiplication of Unsigned Binary Integers

Hardware Implementation of Unsigned Binary Multiplication

  1. Multiplier and multiplicand are loaded into tow registers (Q and M).
  2. A third register, A register is initially set to 0.
  3. A 1-bit C register is also initialized to 0.
  4. Control logic reads the bits of the multiplier (Q) one at a time.
    • If it is 1, M is added to the A register and the result is stored. Then all the bits of the C, A, Q registers are shifted to right one bit.
    • If it is 0, no addition is performed, just the shift.
  5. This process repeated for each bit of the original multiplier.
  6. The product is contained in the A and Q registers.

Flowchart for Unsigned Binary Multiplication


TWO'S COMPLEMENT MULTIPLICATION


Booth's Algorithm for Two's Complement Multiplication

Booth's Algorithm (7 x 3)

  1. The multiplier and multiplicand are placed in the Q and M registers respectively.
  2. A 1-bit register is placed to the right of the LSB of the Q register.
  3. A register is initialized to 0.
  4. Control logic scans the bits of Q one at a time. The bit to its right is also examined.
    • If the 2 bits are same (1-1 or 0-0), then shift all the registers (except M) to the right 1 bit.
    • If the 2 bits differ, then M is added to (0-1) or subtracted from (1-0) the A register, follow by the right shift. 
    • In either case, the right shift is such that the leftmost bit of A, not only is shifted, but also remains.
  5. This process repeated for each bit of the original multiplier.


DIVISION

Flowchart for Unsigned Binary Division


Two's Complement Division (7/3)

  1. Load the divisor into the M register. Load the dividend into the A, Q registers. (The dividend is expressed as a 2n-bit positive number.)
  2. Shift A, Q left 1 bit position.
  3. Subtract M from A.
    • If the result is positive, then add 1 to Q.
    • If the result is negative, restore the previous value of A.
  4. This process repeated for each bit of the original dividend.
  5. The remainder is in A and the quotient is in Q.

To do two's complement division, convert the operands into unsigned values and account for the signs by complementation where needed.