-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (27 loc) · 986 Bytes
/
main.py
File metadata and controls
33 lines (27 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import sys
from cpu import CPU
from assembler import assemble
from cpu.pipeline import fetch_unit, decode_unit, execute_unit, writeback_unit
from Benchmarks.memory_initialisation import INITIALISATION
from cpu.Memory import MEMORY
if len(sys.argv) < 2:
sys.exit()
else:
debug = False
if len(sys.argv) > 2:
debug = sys.argv[2] == "debug"
instructions, labels = assemble(sys.argv[1])
eus = [execute_unit.execute_unit(), execute_unit.execute_unit(), execute_unit.execute_unit(), execute_unit.execute_unit()]
fu = fetch_unit.fetch_unit(len(eus))
du = decode_unit.decode_unit()
wu = writeback_unit.writeback_unit()
cpu = CPU.CPU(instructions, labels, fu, du, eus, wu)
if sys.argv[1][11:] in INITIALISATION:
MEMORY[:] = INITIALISATION[sys.argv[1][11:]]
i = 0
while not cpu.check_done():
cpu.iterate(debug)
# i += 1
# if i == 3000:
# debug = True
cpu.print_state(True)