본문 바로가기

ComputerScience/Computer Organization and Design

(9)
MIPS Processor : Simplified Version Process 의 내부 구조를 이해해보고자 한다. 이를 위해 MIPS의 Simplified Version과 Piplined Version을 살펴본다. Simplified Version a. 명령어 구성 MIPS 명령어의 Subset으로 구성된다 1. Memory 명령어 : load, store 2. Arithmetic & Logial 3. Control : branch, jump b. 명령어 실행 PC는 Instruction Memory 주소를 가지고 있는데, fetch instruction 을 활용해 명령어를 가져온다. c. Data Path 명령어들의 Flow - Instruction Fetch path instruction 명령어 fetch 이후에 ALU 에서 4만큼 더해져서 다음 명령어 주소를 가..
Floating Point 과학적 표기법 353.33 = 3.5333 * 10^2 컴퓨터에서 소수점을 사용하는 방법 Normalized significand : 1.xyz * 2^w 부동소수점 표현 1bit : sign 8bit: exponent (bias : 127) : 지수분 음수 표현을 위해? 23bit : fraction 부동소수점 장점 표현할 수 있는 숫자의 범위가 커짐 부동소수점 단점 10진수 유효숫자가 줄어든다 소수점을 갖는 연산은 항상 조심하도록 한다 예제1 print(1.0+2.0==3) #True print(1.0+2.0==3.0) #True print(0.1+0.2==0.3) #False print(0.1+0.2) print(0.3) 예제2 부동소수점으로는 0.1을 정확히 표현할 수 없다 0.25,0.5등은 정..
컴퓨터연산 덧셈 interger addition overflow result가 range를 벗어나는 경우 carry하고는 개념이 다르다 c언어에서는 overflow 무시 Saturating operations overflow발생하면 최대값 return video white+white⇒black return하는게 자연스러움 곱셈 Multiplcation multiplicant,multiplier,product으로 구성 32bit(multiplicand) * 32bit 계산(alu) ⇒ 64bit 결과 기존 하드웨어 : ALU 64bit,multiplicand: 64bit 필요 개선된 multiplication 32bit*32bit 계산 ⇒ 64bit 결과 alu : 32bit, multiplicand : 32bit ..
Sorting 예제 및 array와 pointer비교 Procedure Swap void swap(int v[],int k) { int temp; temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; } v in $a0,k in $a1,temp in $t0 1 swap: sll $t1 $a1,2 #t1 = k*4 : v에서 k번 째 주소를 찾기 위함 2 add $t1,$a0,$t1 #t1 = v+(k*4) : v의 주소 + 4* k byte 3 lw $t0 ,0($t1) # temp = v[k] 4 lw $t2 , 4($t1) # t2 - v[k+1] 5 sw $t2 0($t1) # v[k] = $t2 (v[k+1]) 6 sw $t0 4($t1) # v[k+1] = $t0 (temp) 7 jr $ra 1,2번 째 라인 : 우선 v의 ..
Compile Procedure C언어의 Compile 과정 Assembler Pseudo Instructions MIPS에는 없지만 Assemble에는 있는 명령어 move => add blt => slt, bne Object Module Assembler의 결과물 Machine Instruction(Binary code)로 구성 구성 Header Text Segment instructions Static data segment Relocation 정보 절대주소 Symbol Table 전역변수, external refs Debug info Static Linking Static Linking의 경우, 모듈 별로 코드를 모두 한번에 컴파일해서 하나의 실행파일을 만든다 단점 파일의 크기가 커질 수 있다 일부 모듈이 변경되면 새로 컴파일 ..
function procedure Terminology $ra Register Memory 중에 $ra라는 것이 있는데, 이는 return address의 약자로, 특정 함수가 끝나고 이동할 메모리 주소를 저장해 둔다. PC (Program Counter) 현재 실행하고 있는 명령어의 메모리 주소를 가지고 있는 메모리 주소를 의미한다. Leaf Procedure 함수 내에서다른 함수를 호출하지 않는 경우를Leaf Procedure라고 한다. 이제 함수의 실행 순서를 알아보자. 컴퓨터가 함수를 실행하는 과정은 아래와 같다. (엄청 길다 ㅠㅠ) Proceudre caller place argument in register where callee can access : $a0-$a3 Caller가 전달 인자를 Register에 넣는다 PC를 ..
Instructions 1. ISA ( Instruction Set Architecture) lowest sotfrware과 hardware의 interface 2. ABI ( Abstract Binary Interface) ABI는 OS와 ISA를 포함하는 개념이다. 3. MIPS ISA의 한 종류 byte addressable하며 word address는 4로 나누어질 수 있다. 4. Register와 Main memory Register 같은 경우 main memory보다 공간이 작기 때문에 빠르고 효율적으로 액세스 가능하다. MIPS architeuct의 경우, 32bit * 32bit Register를 사용한다. 또한 1word= 32bit= 4byte로 Register의 주소는 4로 나누어 떨어진다. 5. Data ..
CPU Time and CPI 1. CPU 성능 CPU 성능의 지표로서 cpu time을 사용한다. cpu time = clock cycles for a program * clock cycle time = clock cycles/clock cycle rate 2. CPI ( Clocks per Instruction) cpu clock cycle= clocks per instruction * instruction counts cpu time = cpu clock cycle * clock cycle time = cpi * instruction counts * clock cycle time clock cycles = sum(cpi * instruction) average cpi = clocks cycles /instruction count..