일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- MacOS
- XML
- Linux
- react
- control
- computer
- while
- system
- architecture
- Algorithm
- Class
- github
- data structure
- function
- python
- CSS
- javascript
- DS
- php
- web
- Java
- html
- for
- MIPS
- mysql
- Pipelining
- DATAPATH
- DB
- instruction
- DoM
- Today
- Total
목록Computer architectures (84)
YYYEJI

ALU(Arithmetic Logic Unit)과 같이 데이터 값을 연산하는 elements가 있습니다. ① Combinational circuit 결과(output)가 현재 입력된 input에만 관련되어 있습니다. output = f(input) ② Sequential circuit 결과(output)이 현재 입력된 값(input)과 현재 상태(current state)에 관련되어 있습니다. output = f(input, current state) • Asynchronous - unclocked Clock signal 없이 제어되기 때문에, 분석/디자인이 조금 더 어렵습니다. • Synchronous - clocked Clock signal에 의해 제어가 되기 때문에, clock을 보면 circuit..

IEEE (Institute of Electrical and Electronics Engineers) 에서는 F.P에 대한 표준 format을 가지고 있습니다. Machine code로 F.P를 표현하기 위해서 IEEE 754 format을 사용합니다. (2진수로 부동소수점으로 표현하라는 의미입니다.) 왜 필요할까요? ① Fraction 표현 Ex) 3.1416 . . . ② 매우 작은 숫자를 표현 Ex) .000000001 ③ 매우 큰 숫자를 표현 Ex) 3.12345 x 10^n 하기 위해서 입니다. Format을 알아봅시다. ① Scientific notation coefficient X (base number) ^ exponent Ex) 7.1234 X 10^4 , 0.1234 ^ 10^9 ② N..

MIPS version 나눗셈 연산을 알아보기 전에 나눗셈 format을 살펴보겠습니다. 0001001 # quotient ---------------- 1000 | 1001010 # Divisor and Dividend - 1000 ---------------- 10 # Partial remainder ........ ---------------- 10 # Remainder 본격적으로 MIPS 나눗셈 수행 방식을 알아보겠습니다. 알고리즘은 아래와 같습니다. partial에서 remainder가 divisor보다 크거나 작으면 quotient bit가 1이 됩니다. 반대로 작으면 quotient bit는 0이 됩니다. MIPS에서 나눗셈 수행 결과는 HI register와 LO register에 담기는데..

MIPS version 곱셈 연산을 알아보기 전에 곱셈 format을 살펴보겠습니다. 0010 # multiplicand X 1001 # multiplier ---------------------------------- 0010010 # product 본격적으로 MIPS 곱셈 수행 방식을 알아보겠습니다. MIPS는 곱셈을 하는데 있어서 하드웨어를 줄이는 방법으로 발전해 왔습니다. (In MIPS, Multiplier은 계속 오른쪽으로 shift 시키기 때문에 생략하겠습니다.) Version 1 Multiplicand를 왼쪽으로 움직이고, product는 움직이지 않습니다. (Using shift left logic) Version2 Multiplicand와 product를 상대적으로 생각해서 Multip..

** C code를 기준 ** 아래 코드를 MIPS assembly code로 변환해 보겠습니다. #include int main(void){ int i = 1; int sum = 0; int n = 15; while(in) goto exit div $t0, $t2 # hi = i/3 mfhi $t3 # t3 = hi bne $t3, $zero, loop # if (t3 != 0) goto loop add $t1, $t1, $t0 # sum += i j loop exit: li $v0, 4 la $a0, str1 syscall li $v0, 1 add $a0, $zero, $t1 syscall .end .text 코드를 하나하나 살펴보면 main: addi $t0, $zero, 0 # i = 0 addi..

** C code를 기준 ** 아래 코드를 MIPS assembly code로 변환해 보겠습니다. i = 0; while (a[i] == k) i++; C to MIPS assembly addi $s0, $zero, 0 # i = 0 loop: sll $t0, $s0, 2 # t0 = i*4 addi $t0, $t0, $s2 # t0 = t0 + &a[0] lw $t1, 0($t0) # t1 = a[t0] bne $t1, $s1 exit # if (t1 != s1) goto exit addi $s0, $s0, 1 # i = i + 1 j loop # goto loop exit: $s0 - i $s1 - k $s2 - a[0] 코드를 하나하나 살펴보면 addi $s0, $zero, 0 # i = 0 우선 ..

** C code를 기준 ** 아래 코드를 MIPS assembly code로 변환해 보겠습니다. switch (s) { case0: a = a case1: a = a + 1 case2: a + a + 2 default: a = a + 3 } C to MIPS assembly addi $t0, $zero, 1 # t0 = 1 addi $t1, $zero, 2 # t0 = 2 beq $s2, $zero, case0 # if (s == 0) goto case0 beq $s2, $t0, case1 # if (s == 1) goto case1 beq $s2, $t1, case2 # if (s == 2) goto case2 addi $s0, $zero, 3 # a = a + 3 j exit # goto exit ..

** C code를 기준 ** array에서 값을 가져오고 싶을 때 a = A[1]라고 작성을 하고, array에 저장하고 싶을 땐 A[1] = a라고 작성을 하게 됩니다. c 코드를 assembly code로 변환을 해보겠습니다. A[4] = A[8] + 4 lw $t0, 32($s0) # t0 = A[8] addi $t0, $t0, 4 # t0 = t0 + 4 = A[8] + 4 sw $t0, 16($s0) # A[4] = t0 $s0는 A[0]를 가르킵니다. 한 줄씩 살펴보면 lw $t0, 32($s0) # t0 = A[8] $t0에 A[8]의 값을 가져와서 저장하는데 32 값은 4*8입니다. (1 word가 4bytes이기 때문입니다.) addi $t0, $t0, 4 # t0 = t0 + 4 = ..