Beispiel #1
0
	memory[10] = (Bus(0, list(map(int, HexToBin('0x17FFFFFD')))))
	memory[11] = (Bus(0, list(map(int, HexToBin('0xF80203ED')))))
	memory[12] = (Bus(0, list(map(int, HexToBin('0xF84203ED')))))

	output = Memory(True)
	output.mem = memory
	return output

def constructDMem():
	memory = [Bus(64) for i in range(5)]
	memory[0] = Bus(0, list(map(int, HexToBin('0x0000000000000001'))))
	memory[1] = Bus(0, list(map(int, HexToBin('0x000000000000000A'))))
	memory[2] = Bus(0, list(map(int, HexToBin('0x0000000000000005'))))
	memory[3] = Bus(0, list(map(int, HexToBin('0x123456789ABCEDFA'))))

	output = Memory(False)
	output.mem = memory
	return output

if __name__ == '__main__':
	p = Processor(Bus(64), constructIMem(), constructDMem())
	PC = Bus(64)
	while(locToIndex(PC) < 52):
		print("PC:", end='')
		PC.print('x')
		PC, output = p.runCycle()

	print('\n-----------------------------------------')
	print("Final Output: ")
	output.print()
	print('-----------------------------------------\n')
Beispiel #2
0
            newLines.append(line)

    #parse the lines and create the instuctions
    print('\n')
    print("Hex Instructions: ")
    for line in newLines:
        instruction = parseLine(line, iNum, symbolTable)
        if (instruction == None):
            continue
        iNum += 1
        instruction.print('x')
        instructions.append(instruction)

    #place the instructions into Instruction Memory
    IMem = Memory(True, iCount)
    for i in range(iCount):
        IMem.mem[i] = instructions[i]

    #execute the instructions
    proc = Processor(Bus(64), IMem)
    DMemOut = Bus(1)
    print('\n')
    print("Execution of program: ")
    while (locToIndex(proc.PC) < (iCount * 4)):
        print('PC: 0x', locToIndex(proc.PC), sep='')
        trash, DMemOut = proc.runCycle()

    print('\n-----------------------------------------')
    print("Final Output: ")
    DMemOut.print()
    print('-----------------------------------------\n')