Presentation is loading. Please wait.

Presentation is loading. Please wait.

컴퓨터구조 – 중간시험 (답안지) 부분점수 (사소한 실수면 -1)

Similar presentations


Presentation on theme: "컴퓨터구조 – 중간시험 (답안지) 부분점수 (사소한 실수면 -1)"— Presentation transcript:

1 컴퓨터구조 – 중간시험 (답안지) 부분점수 (사소한 실수면 -1)
MIPS ISA는 필요한 소수의 instruction만을 제공하기 때문에 MIPS assembly language에서는 pseudoinstruction을 제공하여 보다 다양한 instruction을 가지고 프로그래밍을 하게 해준다. 다음에 주어지는 pseudoinstruction들을 MIPS ISA가 제공하는 instruction으로 바꾸어라. 단, 다음의 MIPS instruction과 register와 constant convention을 참조하시오. [총 20점] $zero : constant value 0 (hardwired) $at : assembler temporary register r1, r2, r3, $t0, $t1, $t2, $t3, $t4, $t5 : MIPS integer registers Imm16, small : 16-bit constant big : 32-bit constant (단, big_hi는 big[31:16]으로 16-bit constant, big_lo는 big[15:0]으로 16-bit constant를 의미한다고 가정하시오) Label, L : branch target add r1, r2, r // r1 = r2 + r3 addi r1, r2, Imm // r1 = r2 + Imm16 beq r1, r2, Label // if (r1 = r2) go to Label bne r1, r2, Label // if (r1 != r2) go to Label slt r1, r2, r // if (r2 < r3) r1 = 1 else r1 = 0 lui r1, Imm // r1[31:16] = Imm16; r1[15:0] = 0 ori r1, r2, Imm // r1 = r2 bit-wise-or Imm16 lw r1, Imm16(r2) // r1 = Memory[r2+Imm16] 부분점수 (사소한 실수면 -1) (a) clear $t // $t0 = 0 beq $t1, small, L // if ($t1 = small) go to L addi $t0, $t2, big // $t0 = $t2 + big bge $t5, $t3, L // if ($t5 >= $t3) go to L lw $t5, big($t2) // $t5 = Memory[$t2+big] => add $t0, $zero , $zero 혹은 addi $zero => addi $at, $zero , small beq $t1, $at , L => lui $at, big-hi ori $at, $at , big-lo add $t0, $t2, $at => slt $at, $t5 , $t3 beq $at, $zero , L => lui $at, big-hi ori $at, $at , big-lo lw $t5, 0($at) Pseudoinstruction meaning MIS ISA translation [각 4점]

2 음수 양수 +무한대 최소한 위의 그룹핑이 되면 2점 sign exponent significand
2. 다음의 IEEE 754 floating point standard에 따른 bit representaion을 참조하여 주어진 값을 작은 수 부터 큰 수 순으로 나열하시오. [10점] 부분점수 (0, 2, 10) normalized: exponent != 0 and exponet != 1인경우, 아래와 같은 값 (–1)sign x (1 + significand) x 2exponent – bias (single precision FP bias = 127) denormalized: exponent = 0인 경우, 아래와 같은 값 (–1)sign x (significand) x 21 – bias (single precision FP bias = 127) special: exponent = , significand = 0인 경우, sign에따라 infinity (a) (b) (c) (d) (e) (f) (g) a b c d e f g 음수 양수 +무한대 최소한 위의 그룹핑이 되면 2점 sign exponent significand

3 step name R-type memory reference branch (beq) jump instruction fetch
IR <= Memory[PC] PC <= PC + 4 instr decode/ register fetch A <= Reg[IR[25:21]], B <= Reg[IR[20:16]] ALUOut <= PC + (sign-extend(IR[15:0]) <<2) execution/addr calculation ALUOut <= A op B ALUOut <= A+ sign-extend(IR[15:0] If (A==B) PC <= ALUOut PC<={PC[31:28], (IR[25:0]),2’b00 memory access Reg[IR[15:11]] <= ALUOut Load: MDR<=Memory[ALUOut] Store: Memory[ALUOut]<=B X memory read completion Reg[IR[20:16]] <= MDR 3. 위 표는 MIPS 명령어의 Multicycle 실행을 위한 5-단계를 RTL 수준으로 설명하고 있다. 뒷 장 의 datapath 를 참조하여 다음 질문에 답하시오. [총 20점] (a) 위 표에 빠진 4 부분을 표에 채우시오. R type 명령어의 destination register 는 IR[15:11] 이며 load 명령어의 destination register 는 IR[20:16] 임. memory reference 명령어의 memory access step 은 load 와 store 로 나누어 설명. [10점] 부분점수 부여 (0, 2, 5, 7, 10) (b) 뒤에 나오는 datapath를 사용할 때, Step 2(decode) 단계의 ALUOut <= PC + (sign-extend(IR[15:0]) <<2) 작업을 Step 3으로 미루면 어떤 문제가 발생하는가? [5점] 부분점수 고려 (2, 5) R-type, memory-ref, branch (단, jump 제외) 명령어가 모두 ALU를 사용하는 operation을 3단계에서 하고 있으므로 multicycle 구조에서 2단계에서 수행하던 계산을 옮겨오면 ALU를 두번에 걸쳐 사용하므로 그 결과를 중간에 저장할 internal register가 없으며 3단계를 1 cycle만에 수행할 수 없다. (1 cycle이 길어진다는 취지로 쓴 경우 부분 점수 2점) 실제 2단계에서 하는 계산이 branch에만 필요하므로 branch의 3단계에서 수행하도록 하여도 마찬가지로 ALU의 A==B (subtract)의 계산과 중복되어 ALU를 사용하므로 앞의 이유와 마찬가지로 3단계를 1 cycle만에 수행할 수 없다. (c) Step 2의 주소계산, ALUOut <= PC + (sign-extend(IR[15:0]) <<2) 에서는 offset 부분을 shift(<<2)하여 4를 곱한 값으로 만드나 Step 3의 memory reference 에서는 주소값을 shift 없이 그대로 사용하는 이유는 무엇인가? [5점] 부분점수 고려 (2, 5) – (하나만 제대로 설명했을 경우 2점) Step 2의 주소 계산은 branch target 주소를 계산하는 것이므로 MIPS명령어가 모두 4 byte 크기를 가지고 명령어 4 byte 주소에 align되어 있으므로 branch target 주소는 항상 4의 배수인점을 고려하여 PC-relative addressing mode가 immediate을 2bit shift하여 사용하도록 되어 있다. Step3의 주소 계산은 memory reference (lw, sw)를 위한 데이터 주소 계산이며 데이터는 1 byte단위의 주소별로 접근이 가능한 점을 고려하여 base-addressing mode에서 shift없이 주소를 계산하도록 되어 있다.

4 (6) (5) (4) (3) (1) (2) R e a d r g i s t 1 2 W A L U Z o S n x 6 3 I
c [ ] 5 l M h f P C B O m y D 4 p 8 - J (5) (4) (3) (1) (2)

5 1 2 3 4 5 6 instruction fetch x decode/ r-fetch 17 18 exe/addr calc
4. 앞 장의 datapath 그림을 참조하여 다음 명령어가 실행될 때 그림에 표시된 datapath에 정의되는 값을 채우시오. 각 register는 자기 번호를 초기 값으로 갖고 있다고 가정, 즉 $17의 초기 값은 17임. (의미 없는 값은 X로 표시, 모르는 메모리 값은 M으로 표시) [총 20점] 예) add $8, $17, $18 (opcode=0, rs=17, rt=18, rd=8, shamt=0, funct=32) a) beq $7, $8, 503 (opcode=4, rs=7, rt=8, immediate=503) [10점] - 숫자로 써야 할곳만 제대로 썼는지 검사, X는 뭐라고 썼든지 내버려둘것 – 부분점수 (0, 2, 5, 7 10) b) lw $3, 13($2) (opcode=35, rs=2, rt=3, immediate=13) [10점] – 숫자로 써야 할곳만 제대로 썼는지 검사, X는 뭐라고 썼든지 내버려둘것 – 부분점수 (0, 2, 5, 7 10) 1 2 3 4 5 6 instruction fetch x decode/ r-fetch 17 18 exe/addr calc mem access 8 mem finish 1 2 3 4 5 6 instruction fetch x 100 104 decode/ r-fetch 7 8 2012 exe/addr calc 2012, 혹은 x mem access mem finish 1 2 3 4 5 6 instruction fetch x 10 14 decode/ r-fetch exe/addr calc 13 mem access mem finish

6 I n s t r u c t i o n f e t c h I n s t r u c t i o n d e c o d e / r
g i s t e r f e t c h M e m R e a d A L U S r c A = 1 I o r D = I R W r i t e A L U S r c A = 11 00 S t a r t A L U S r c B = 1 A L U S r c B = A L U O p = A L U O p = P C W r i t e P C S o u r c e = M e m o r y a d d r e s s B r a n c h J u m p c o m p u t a t i o n E x e c u t i o n c o m p l e t i o n c o m p l e t i o n 2 6 8 9 A L U S r c A = 1 A L U S r c A = 1 A L U S r c A = 1 P C W r i t e A L U S r c B = 10 A L U S r c B = A L U S r c B = 01 P C S o u r c e = 10 A L U O p = A L U O p = A L U O p = 10 P C W r i t e C o n d P C S o u r c e = M e m o r y M e m o r y a c c e s s a c c e s s R - t y p e c o m p l e t i o n 3 5 7 R e g D s t = 1 M e m R e a d M e m W r i t e I o r D = 1 I o r D = 1 R e g W r i t e M e m t o R e g = M e m o r y r e a d c o m p l e t o n s t e p 4 1 R e g D s t = R e g W r i t e M e m t o R e g = 5. 위 그림은 MIPS control logic 을 finite state machine으로 표시한 것이다. 앞의 datapath 그림을 참조하여 각 state에서 보내는 control signal 값 중 검은 박스( )로 표시된 부분의 값을 정하여 위 그림에 표시하시오. (총 10개) [30점] 하나당 3점부여 ALUOp 의 의미는 (00: add, 01: sub, 10: funct field decides) 으로 정한다.


Download ppt "컴퓨터구조 – 중간시험 (답안지) 부분점수 (사소한 실수면 -1)"

Similar presentations


Ads by Google