본문 바로가기

Computer Architecture75

[컴퓨터구조] 3. Arithmetic for Computers (3) 1. Full adder 2. Ripple carry adder 예) 32-bit ripple carry adder Carry delay: 하나의 stage마다 2 gate delays Total delay: (2*32) gate delays = 64 gate delays 3. Carry lookahead adder 예) 32-bit carry lookahead adder 4-bit 단위로: 1 gate delay + 2 gate delays : 4-bit 단위로 gi, pi 계산 (1 gate delay) + C0가 도착한 후 gi, pi를 이용하여 C1~C4 동시에 계산 (2 gate delay) Total delay = 3*(32/4) gate delays = 24 gate delays 4. Rip.. 2023. 10. 22.
2. 컴퓨터 언어 2023. 10. 17.
[컴퓨터구조] 3. Arithmetic for Computers (2) Full Adder Ripple Carry Adder Carry Lookahead Adder Combine 4-bit Carry Lookahead Adders - Ripple/Lookahead - Group-Lookahead Binary Addition (Full Adder) ▶ Si = Ci XOR Ai XOR Bi (1-gate delay) ▶ C(i+1) = Ai*Bi + Ai*Ci + Bi*Ci (2 gate delay) Multi-Bit Adders (Ripple Carry Adder) : Full Adder를 여러 개 연결한 것 --> C-out으로 인한 delay ↑ Designing an Adder/Subtractor ▶ Addition: XOR gate에 0을 넣는다. --> ? XOR .. 2023. 10. 9.
[컴퓨터구조] 3. Arithmetic for Computers (1) Example 6 main: li $s0, 0x06 li $s1, 0x10 move $a0, $s0 // $s0에서 $a0로 move move $a1, $s1 jal sum nop move $s3, $v0 // Get the result move $a0, $s3 // Print the sum li $v0, 1 syscall li $v0, 1 // Exit syscall sum: add $t1m $a0, $a1 move $v0, $t1 jr $ra // Return to the main function nop Memory Layout Stack: automatic storage Dynamic data: heap Static data: global variable Text: program code Jump .. 2023. 10. 9.
[컴퓨터구조] 2. Instructions: Language of the Computer (6) The jr Instruction jr $ra // $ra(return address)에 저장된 주소로 jump Returns control to the caller. Copies the contents of $ra into the PC. Calling Convention jal ProcedureLabel // 서브루틴을 호출하고, 현재의 호출 주소를 $ra에 넣는다. jr $ra // The subroutine returns to its caller. Main Calling Mysub Example move $a0, $t1 // $t1 값을 $a0로 move li $a1, 4 // $a1에 4를 load_integer jal mysub // mysub 서브루틴을 호출하고, 현재의 주소를 $ra에 넣는다.. 2023. 10. 8.
[CA] Lecture #11 Chapter 3: Arithmetic for Computers Extra (From Digital Logic Class) Unsigned Integers Decimal & Binary Number Octal & Hexadecimal Number Binary to Octal and Hexadecimal Signed Number 1) Sign-and-Magnitude Representation 2) 1's Complement Representation : 뒤집기만! 3) 2's Complement Representation : 뒤집고, +1! Four-bit Signed Integers Addition 1) Sign and Magnitude 2) 1's Complement 3) 2's Complement .. 2023. 10. 7.
[CA] Lecture #10 Leaf Procedure Example // C code int leaf_example (int g, int h, int i, int j){ int f; f = (g+h) - (i+j); return f; } // g~j: x10~x13, f: x20 // temporaries x5, x6: g+h = x5, t+j = x6 Memory - stack 저장: x5, x6, x20 caller --> collee --> caller --> stack에 저장: collee에 의해 사용되어 값이 변하는 것만 저장한다. Local Data on the Stack // Assembly code leaf_example: addi sp, sp, -12 // stack에 12 byte 공간 확보 sw x5, 8(sp.. 2023. 9. 28.
[컴퓨터구조] 2. Instructions: Language of the Computer (5) Computing Integer Division // C code int a = 12; int b = 4; int result = 0; main(){ while (a >= b){ a = a - b; result++; } } // MIPS Assembly Language .data x: .word 12 y: .word 4 res: .word 0 .global main .text main: la $s0, x // load_address x in $s0 (memory --> register) lw $s1, 0($s0) // load_word $s0 in $s1 lw $s2, 4($s0) // load_word ($s0 + 4) in $s2 lw $s3, 8($s0) // load_word ($s0 + 8) i.. 2023. 9. 27.
[CA] Lecture #09 Logical Operations Instructions for bitwise manipulation. Shift Operations: immed: how many positions to shift AND Operations: & and x9, x10, x11 // x9 = x10 & x11 OR Operations: | or x9, x10, x11 // x9 = x10 | x11 XOR Operations: ^ (NOT Operation) XOR(exclusive OR) = NOT xor x9, x10, x11 // NOT Operation Conditional Operations beq: Branch if EQual bnq: Branch if Not eQual beq rs1, rs2, L1 // if.. 2023. 9. 27.