Computer Science/Computer Architecture and Organization
-
Instructions for Making DecisionsComputer Science/Computer Architecture and Organization 2021. 4. 26. 22:40
If-then-else 컴퓨터와 단순 계산기와 다른점은 바로 판단할 수 있는 기능이다. input과 계산된 결과값에 따라서 컴퓨터는 다른 instruction을 수행할 수 있다. 주로 Java나 C와 같은 high-level programming language에서는 if statement를 이용한다. (때로는 go to도 사용한다). RISC-V assembly language는 go to 가 있는 if statement와 비슷한 두개의 decision-making instructions, 즉 판단 명령어가 있다. 첫번째로는 다음과 같다. beq rs1, rs2, L1 rs1의 값이 rs2의 값과 같으면, L1에 해당하는 문장으로 가라는 뜻이다. beq는 branch if equal 을 의미한다. 다..
-
Logical OperationsComputer Science/Computer Architecture and Organization 2021. 4. 25. 18:39
Operations 워드 전체에 대한 처리뿐만 아니라, 일부 비트들 또는 워드내에 8bit로 저장된 문자를 검사하는등의 작업또한 필요했다. 여러개 비트들을 워드로 packing하는 작업과 워드를 비트 단위로 나누는 unpacking작업을 간단하게 하는 연산들이 추가되었는데, 이러한 instructions(명령어)를 logical operations, 논리연산 명령어라고 부른다. 다음은 C언어와 자바의 RISC-V의 logical operations를 보여준다. 예를 들어서, Java 에서 다음과같이 왼쪽으로 4번 자리이동을 시키는 명령어를 실행시키면? int x=9; int y = x
-
RISC-V FieldsComputer Science/Computer Architecture and Organization 2021. 4. 25. 13:26
Field RISC-V Instruction Fields들에는 다음과 같은 이름이 붙어있다. opcode (0 - 6, 7bits): basic operation of the instruction rd (7 - 11, 5 bits): register destination operand. Gets result of the operation. funct3 (12 - 14, 3 bits): Additional opcode field rs1 (15 - 19, 5 bits): first register source operand rs2 (20 - 24, 5 bits): second register source operand funct7 (25 - 31, 7 bits): Additional opcode field ..
-
Representing Instructions in the ComputerComputer Science/Computer Architecture and Organization 2021. 4. 25. 12:30
Instruction Format 그렇다면 사람이 컴퓨터에 명령을 내리는것과 컴퓨터가 그 명령어를 해석하는것은 어떻게 다를까? RISC-V의 32개 레지스터들은 0부터 31개의 숫자로 표시된다. 아래 예시를 보면서 기계언어로 변환하는 과정을 알아보자. Translating a RISC-V Assembly Instruction into a Machine Instruction Let’s do the next step in the refinement of the RISC-V language as an example. We’ll show the real RISC-V language version of the instruction represented symbolically as add x9, x20, x21 f..
-
Signed and Unsigned Numbers | Two's ComplementComputer Science/Computer Architecture and Organization 2021. 4. 24. 11:32
Base 컴퓨터가 숫자를 어떻게 나타낼까? 사람은 보통 숫자를 셀 때 10진법(Base 10)을 사용한다. 아래 예시를 보자 123 = 1111011 놀랍게도 이 둘은 같은 숫자이다. 물론, 123은 base 10, 즉 10진법을 이용해 나타내었고, 1111011은 base 2, 즉 2진법을 이용해 나타내었다. 앞에서 말했듯, 컴퓨터의 트랜지스터는 0과 1만 표현할 수 있다. 그렇기때문에 모든 정보는 binary digit, 즉 bit로 구성된다. 어떤 기수의 숫자이든, 이 숫자를 구하려면 아래와 같이 계산할 수 있다. $$ d * Base^i $$ 여기서 i 는 0부터 시작해서 왼쪽으로 갈수록 1씩 증가한다. 예를들어 아래 binary bit를 base10 으로 계산해보자 $ 1011_{two} \\ ..
-
Operands of the Computer Hardware | RISC-VComputer Science/Computer Architecture and Organization 2021. 4. 22. 23:39
high-level 프로그램 언어와는 다르게, 하드웨어쪽에서 실행되는 operands는 다르게 처리가 되는데, 이것은 하드웨어에서 registers 라고 불리는 장소에서 이뤄져야한다. RISC-C의 아키텍쳐는 64bits를 보통 사용한다. 이는 doubleword라고도 부른다. (32bits도 많이 쓰이는데, 이는 word라고 한다). 프로그래밍 언어와 registers의 차이는, 제한적이라는것인데, 보통 32개의 register를 쓴다. 그렇기때문에, RISC-V 연산이 될 때, 32개의 64-bit 크기의 레지스터들중 하나에서 처리되어야 한다. 아래 문제를 보자. Compiling a C Assignment Using Registers Example It is the compiler’s job to ..
-
RISC-V assembly languageComputer Science/Computer Architecture and Organization 2021. 4. 21. 23:21
컴퓨터와 대화를 하기 위해서는 그(?)가 사용하는 언어를 해야하는데 그것을 instructions 라고 부르고, 그 어휘를 instruction set 이라고 부른다. 그중에 하나가 전에 소개한 MIPS 이고, 오늘 소개할것은 RISC-V 인데, UC Berkely 에서 2010년에 개발되었다. MIPS는 1980년부터 개발이 시작되었고, RISC-V는 MIPS와 매우 흡사한 디자인이다. 또다른 언어로 Intel x86이 있는데, 1970년대 시작했고, 현재까지도 강력하게 쓰이고 있다. 그렇다면 MIPS와 마찬가지로 아래 주어진 코드를 RISC-V로 옮겨보자. Compiling Two C Assignment Statements into RISC-V This segment of a C program con..
-
MIPS, Memory Operands and Constant(Immediate) OperandsComputer Science/Computer Architecture and Organization 2021. 4. 4. 16:25
Memory Operands 위의 예시에서는 간단한 더하기 빼기였지만, 실제 프로그래밍에서는 훨씬더 복잡한 컨셉이 등장한다. 예를들어 Array, Tree, Linked List 또는 Map과 같은 것들이다. 어떻게 컴퓨터는 이런 큰 Data Structure를 접근하고 나타낼 수 있을까? 프로세서는 아주 작은 양의 데이터를 registers에 보관할 수 있는데, 컴퓨터의 메모리는 수십GB부터 수TB까지, 더 큰 컴퓨터는 그 이상의 방대한 양의 정보가 저장되어있고 처리를 기다리고 있다. 위에서 말했든, Arithmetic Operations(사칙연산)들은 MIPS instructions에서는 오직 프로세서의 registers에서만 처리될 수 있고, 그렇기때문에 MIPS는 registers와 memory간..