Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.
/ ITE2031 Public archive

Computer Architecture @ Hanyang Univ.

Notifications You must be signed in to change notification settings

frechele/ITE2031

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ITE2031 - Computer Architecture Project (LC-2K)

In this project, we implemented simple assembler and simulator for LC-2K Instruction-Set Architecture.

What is LC-2K?

The LC-2K is an 8-register, 32-bit computer. All addresses are word-addresses. The LC-2K has 65536 words of memory.

Supported instructions

This simulator supportes 3 type instructions followed.

  • R-type instructions (add, nor):
    • bits 24-22: opcode
    • bits 21-19: reg A
    • bits 18-16: reg B
    • bits 15-3: unused (should all be 0)
    • bits 2-0: desgReg
  • I-type instructions (lw, sw, beq):
    • bits 24-22: opcode
    • bits 21-19: reg A
    • bits 18-16: reg B
    • bits 15-0: offsetField (a 16-bit, 2's complement number with a range of -32768 to 32767)
  • J-type instructions (jalr):
    • bits 24-22: opcode
    • bits 21-19: reg A
    • bits 18-16: reg B
    • bits 15-0: unused (should all be 0)
  • O-type instructions (halt, noop):
    • bits 24-22: opcode
    • bits 21-0: unused (should all be 0)

How to build

First of all, you should clone this repository.

git clone https://github.com/JYPark09/ITE2031

And by using make, you can get assemble and simulate programs.

cd ITE2031
make

Test cases

samples/test.as

This test performs the same behavior as the C code below.

int i = 5;

do {
    i = i + (-1);
} while (i != 0);

samples/test1.as

This test is designed to check offsetField overflow condition. This code cannot generate machine language file.

samples/test2.as

This test is designed to check undefined label using. This code cannot generate machine language file.

samples/test3.as

This test is designed to check unrecognized opcode. This code cannot generate machine language file.

samples/test4.as

This test is designed to check duplicated label. This code cannot generate machine language file.

samples/test5.as

This test is designed to check invalid arguments. This code cannot generate machine language file.

samples/test6.as

This test performs the same behavior as the C code below.

int i;
int res = 0;

for (i = 1; i < 10; ++i)
    res += i;

samples/test7.as

This test is designed to ensure that the jalr instruction was implemented correctly.

samples/test8.as

This test is intended to ensure that the lw instruction was implemented correctly.

samples/test9.as

This test is designed to ensure that the nor instruction and lw/sw offset were implemented correctly. This test performs the same behavior as the C code followed.

int i, j;
int arr[10] = { 0 };

for (i = 0; i < 10; ++i) {
  for (j = 0; j < i; ++j) {
    arr[i] += i;
  }
}

samples/test10.as

This test is the stress test. The simulator will execute a lots of instructions for calculate many matrix additions.

About

Computer Architecture @ Hanyang Univ.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published