aboutsummaryrefslogtreecommitdiff
path: root/MicSim/micsim.py
blob: 23a91fe23eca66cbd9912706fa0ddca3e961bd11 (plain)
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
#!/usr/bin/python

from components.microprogram import Microprogram
from components.ram import Ram
from components.caretaker import Caretaker

def dump(ram,title): # Simple Helper function
	data=ram.getData()
	print("---------- "+title+" ----------")
	for addr,value in data.items():
		print("%-5s: 0x%-3x (%s)"%(addr,value,value))
	print("-"*(22+len(title)))		


c=Caretaker(5000) 					   # Init components ram size in byte
c["RAM"].loadRamFile("./ram.txt")	   # Load Ram from file

mic=Microprogram(c) 				   # Create micro program
dump(c["RAM"], "Ram Before Execution") # Dump ram before execution
mic.run(800, 1024) 					   # Run the micro program with run(constantPoolLocation,stackLocation)
dump(c["RAM"],"Ram After Execution")   # Dump ram after execution