[컴퓨터구조] RISC-V Instruction Formats(1)

2023. 4. 14. 17:43· SKKU SW/Computer Architecture

Instructions and data are represented in binary.

(machine code)

 

Instructions and data are stored in memory (set of bytes)

 

Operating system will load the program binary from the disk and put it to the memory

-> CPU ready to execute the program

 

RISC-V의 모든 instruction은 32-bit, 즉 1 word의 길이로 나타내며,

little endian으로 나타낸다. 한 마디로, 우리는 뒤에서부터 읽어 해석해야 한다.

 

<RISC-V R-format Instructions>

- Instruction fields

opcode: operation code

(0~6비트까지 총 7bits. representing type of instruction. shift인지 arithmetic인지 이런거 구분해주는 역할을 한다.)

rd: destination register number

연산 결과가 저장될 레지스터의 번호

funct3: 3-bit function code (additional opcode)

rs1: the first source register number

rs2: the second source register number

funct7: 7-bit function code (additional opcode)

funct3와 funct7를 합친 10-bit가 operation의 세부적인 기능을 결정한다.

 

RISC-V assembly instruction will be represented in 32 bits in binary value in memory

-> CPU will read this 32 bits and execute

 

오른쪽에서부터 쭉 읽어서 이를 4비트씩 끊고, 이렇게 표현된 binary를

hexadecimal format으로 읽을 수도 있다!

 

<RISC-V I-format Instructions>

Immediate arithmetic and load instructions

rs1: source or base address register number

R-format의 opcode~rs1까지는 동일한 형식이지만, I-format은 rs2가 불필요하므로 rs2 + funct7 영역을 합친

12bit로 상수를 표현한다.(immediate)

immediate: constant operand, or offset added to base address

using 2's complement

-> will be sign extended to 32-bit

 

<Sign extension>

representing a number using more bits

preserve the numeric value

 

sign bit를 왼쪽으로 쭉 replicate한다.

ex)

0000 0010 -> 0000 0000 0000 0010

1111 1110 -> 1111 1111 1111 1110

 

lb: sign-extend loaded byte

1bu: zero-extend loaded byte

 

<Shift Operations>

slli, srli, srai

but not using I-format

shamt (0~31): shift amount in number of bit positions

 

sll, srl, sra

rd <- value in rs1 shifted by shift amount in rs2

 

'SKKU SW > Computer Architecture' 카테고리의 다른 글

[컴퓨터구조] Procedure Calling  (0) 2023.04.17
[컴퓨터구조] RISC-V Instruction Formats(2)  (0) 2023.04.15
[컴퓨터구조] Logical operations  (0) 2023.04.14
[컴퓨터구조] Immediate Operands, Load Immediate Value  (0) 2023.04.14
[컴퓨터구조] 명령어(instruction) / 명령어집합(instruction set) 그리고 간단한 arithmetic operation  (0) 2023.04.14
'SKKU SW/Computer Architecture' 카테고리의 다른 글
  • [컴퓨터구조] Procedure Calling
  • [컴퓨터구조] RISC-V Instruction Formats(2)
  • [컴퓨터구조] Logical operations
  • [컴퓨터구조] Immediate Operands, Load Immediate Value
효딩
효딩
개ㄱ발은 기세다. 줄여서 객기.
효딩
hyoding
효딩
전체
오늘
어제
  • 분류 전체보기 (245)
    • SKKU SW (30)
      • Computer Architecture (14)
      • Database (4)
      • Computer Network (3)
      • Operating System (7)
      • Mobile App Programming (2)
    • SuperCoding (68)
    • CS (8)
    • Web Programming (19)
    • Cloud (13)
    • Languages (45)
      • Python (8)
      • Java (37)
    • Supporters (8)
      • MoteMote (6)
      • NHN Cloud (2)
    • Certification (27)
      • Network Advisor (14)
      • ADsP (10)
      • Engineer Information Proces.. (3)
    • Finance (9)
      • 경제금융용어 (3)
    • Woori FISA (14)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • 앱개발
  • nhn cloud
  • 클라우드 서비스
  • 우리에프아이에스
  • 코틀린
  • 인프라개발
  • 서버배포
  • 글로벌소프트웨어캠퍼스
  • 인프라
  • 네트워크관리사 후기
  • 클라우드
  • K-디지털트레이닝
  • 네트워크관리사2급
  • 네트워크관리사2급 필기
  • 네트워크관리사2급 공부방법
  • apppaas
  • 네트워크관리사 합격
  • 서버개발
  • AWS
  • 네트워크관리사 커트라인
  • rds local 접속
  • 네트워크관리사
  • Kotlin
  • 네트워크관리사 준비물
  • 서버생성
  • 봐
  • 클라우드서비스개발
  • 우리FISA
  • 코틀린문법
  • 우리fis아카데미

최근 댓글

최근 글

hELLO · Designed By 정상우.v4.2.2
효딩
[컴퓨터구조] RISC-V Instruction Formats(1)
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.