def __init__(self, data): self.data = bytearray(data) self.dma = dma() self.gpu = gpu() self.debug = False self.cpu = cpu(self, self.data) self.ramrange = (0x00000000, 2 * 1024 * 1024) self.expansion1 = (0x1F000000, 512 * 1024) self.biosrange = (0x1FC00000, 512 * 1024) self.memcontrol = (0x1F801000, 36) self.ramsize = (0x1F801060, 4) self.irqcontrol = (0x1F801070, 8) self.spurange = (0x1F801C00, 640) self.expansion2 = (0x1F802000, 66) self.cachecontrol = (0xFFFE0130, 4) self.timerrange = (0x1F801100, 0x30) self.dmarange = (0x1F801080, 0x80) self.gpurange = (0x1F801810, 8) self.timerrange = (0x1F801100, 0x30) self.regionmask = [ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x7FFFFFFF, 0x1FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF ] self.bios = bios(self.data) self.ram = ram() self.renderer = renderer() self.gpu.link_bus_renderer(self, self.renderer) self.renderer.link_bus(self)
def __init__(self): romPath = sys.argv[1] self.cartridge = romLoader(romPath) self.cartridge.load() CPU = cpu(self.cartridge) CPU.run()
def setupEmulation(self, romPath): self.nes = hardware.NES() self.r = romloader.romLoader(self.nes) self.r.loadRom(romPath) self.c = cpu.cpu(self.nes) self.c.memoryInit() self.c.cpuInit()
def __init__(self, rom0mif, uart0_map): self.cpu0 = cpu(self.readFunction, self.writeFunction, self.retiFunction, self.interrupt, "cpu0") self.rom0 = rom(0x000000, 8, rom0mif, "rom0") self.ram0 = ram(0x000400, 10, "ram0") self.ram1 = ram(0x100000, 13, "ram1") self.systim0 = systim(0x000104, self.interrupt, "systim0") self.intControler0 = intControler(0x00010F, self.cpu0, "intControler0") self.uart0 = uart(0x000130, self.interrupt, uart0_map, "uart0") self.lfsr0 = lfsr(0x00010E, "lfsr0")
def __init__(self, rom0mif, uart0_map): self.cpu0 = cpu(self.readFunction, self.writeFunction, self.retiFunction, self.interrupt, "cpu0") self.rom0 = rom(0x000000, 8, rom0mif, "rom0") self.ram0 = ram(0x000400, 10, "ram0") self.ram1 = ram(0x100000, 13, "ram1") self.systim0 = systim(0x000104, self.interrupt, "systim0") self.intControler0 = intControler(0x00010F, self.cpu0, "intControler0") self.uart0 = uart(0x000130, self.interrupt, uart0_map, "uart0")
def gameCheckFuncs(screen): if (data.startScreen): g.setScreen(screen) s.getKings() data.playerOne.setPlayer = data.player1turn # Increment player turns data.playerTwo.setPlayer = data.player2turn s.incTimers() if data.player1turn and data.cpu: g.drawPieces(screen) # Move the CPU pieces if AI is playing cpu.cpu(data.board) #print("change turnMain") data.player2turn = True data.player1turn = False if gameLogic.checkKing( data.board): # Check is any of the two kings are in check data.check = True if data.check: g.check(screen, "CHECK", 175, 650) # Display the check message event.mouseMotion() gameLogic.checkGameOver()
def __init__(self): romPath = sys.argv[1] self.cartridge = romLoader(romPath) try: self.cartridge.load() except: print("Couldn't load NES cartridge") CPU = cpu(self.cartridge) CPU.run()
def exec_command(self): # import pdb # pdb.set_trace() if functions.curr_time() - self.curr_time >= 1: data = { 'network': network(self.network), 'cpu': cpu(self.cpu), 'storage': storage(self.storage), 'memory': memory(self.memory), 'timestamp': functions.curr_time(), 'id': self.system_data['id'] } # pdb.set_trace() print data['timestamp'] self.send_data(data, 'live') self.curr_time = functions.curr_time()
def __init__(self, ruta_procesos): """ Inicializa un nuevo planificador""" print "Inicializando scheduler" self.cpu = cpu() self.tasks = [] print "Añadiendo proceso(s): ", ruta_procesos self.add_tasks(ruta_procesos) print "Número de tareas en el sistema: ",len(self.tasks) self.cpu.start() self.current = self.cpu.idle_task self.NEED_RESCHED = False self.did_sched = False # Para el GUI self.stats = {"PRIO": sched_stats(), "TSLICE": sched_stats(), "PERCENT": sched_stats(), "SWITCHES": sched_stats() } # Para las estadísticaas
def _fmt_load_avg(self): '''Format get_load_avg() into string with percentages''' loads = self.get_load_avg() cpus = cpu(self.target, self.options).get_cpu_info()['processors'] percs = [] for item in loads: index = loads.index(item) loadperc = (float(item) / cpus) * 100 if loadperc < 75: pc = self.color['DBLUE'] elif loadperc > 74 and loadperc < 100: pc = self.color['WARN'] else: pc = self.color['BRED'] loads[index] = (loads[index] + pc + '(%.2f)' + self.color['ENDC']) % loadperc ldavg = '[%s CPUs] %s' % (cpus, str(loads[0] + loads[1] + loads[2])) return ldavg
def __init__(self, debugmode): self.cpu = cpu(self) self.ppu = ppu(self) self.debugmode = debugmode self.controller_state = [0, 0] self.systemClockCounter = 0 self.dma_page = 0 self.dma_addr = 0 self.dma_data = 0 self.dma_transfer = False self.dma_dummy = True self.cpucycles = 0 self.ppucycles = 0 self.cpuavg = 0 self.cputotal = 0 self.ppuavg = 0 self.pputotal = 0 self.cpustarttime = 0 self.ppustarttime = 0
def get_processor_info(self): cinfo = cpu(self.target, self.options).get_cpu_info() cinfo['extra'] = '{} sockets - {} cores - {} threads per core'.format( cinfo['sockets'], cinfo['cores'], cinfo['threadspercore']) return cinfo
def __init__(self, channel_num): self.channel_num = channel_num self.channels = self.build_channels() self.cpu = cpu() self.executing_channels = [] self.empty_channels = self.channels
str(params.index(param) + 1) + "]") elif param[0] == 'i-cache': try: cycle = int(param[1][0]) icache = func_unit.icache(cycle, mem) except: lib.error( "Error: Invalid config file: invalid cycle number [Line " + str(params.index(param) + 1) + "]") elif param[0] == 'd-cache': try: cycle = int(param[1][0]) dcache = func_unit.dcache(cycle, mem) except: lib.error( "Error: Invalid config file: invalid cycle number [Line " + str(params.index(param) + 1) + "]") else: lib.error( "Error: Invalid config file: unknown configuration [Line " + str(params.index(param) + 1) + "]") pass 'check the function units' if fp_adder is None or fp_multiplier is None or fp_divider is None or mem is None or icache is None or dcache is None: lib.error("Error: Invalid config file: missing configuration") orderlist = sort(orderlist) cpu = cpu.cpu(fp_adder, fp_multiplier, fp_divider, icache, dcache, mem.getLookupTable(), orderlist, reg, mem) cpu.run()
def setUp(self): self.testCPU = cpu.cpu()
print(env.board.reshape(3, 3)) print(info) if is_fin: sg.popup(show_result(), custom_text=('もう一回'), title='対戦結果') env = tictactoe_env.TictactoeEnv() [ window[utils.conv1dto2d(i, env.BOARD_SIZE)].update( '', image_filename=img_e, image_size=(1, 1), image_subsample=4) for i in range(env.BOARD_SIZE * env.BOARD_SIZE) ] continue # CPUのターン index, is_fin, info, valid = env.put(cpu.cpu(env, model)) window[utils.conv1dto2d(index, env.BOARD_SIZE)].update('', image_filename=img_o, image_size=(1, 1), image_subsample=4) print(env.board.reshape(3, 3)) print(info) if is_fin: sg.popup(show_result(), custom_text=('もう一回'), title='対戦結果') env = tictactoe_env.TictactoeEnv() [ window[utils.conv1dto2d(i, env.BOARD_SIZE)].update( '', image_filename=img_e, image_size=(1, 1), image_subsample=4)
import board as board import player as player import cpu as cpu board = board.board() player = player.player() cpu = cpu.cpu() gameRunning = 0 currentPlayer = 0 while (gameRunning == 0): board.print_it() if (currentPlayer == 0): player.make_turn(board) currentPlayer = 1 else: cpu.make_turn(board) currentPlayer = 0 gameRunning = board.is_finished() board.print_it()
import tkinter as tk from tkinter import ttk from tkinter import messagebox from PIL import Image, ImageTk from util import * from message import message import cpu WIDTH = 1200 HEIGHT = 400 BG_IMG_PATH = "bg.png" # set up CPU proc = cpu.cpu() # set up GUI root = tk.Tk() root.title("Alpha") root.geometry("{}x{}".format(WIDTH, HEIGHT)) canvas = tk.Canvas(root, width=WIDTH, height=HEIGHT) canvas.pack() bg_img = ImageTk.PhotoImage( Image.open(BG_IMG_PATH).resize((WIDTH, HEIGHT), Image.ANTIALIAS)) canvas.background = bg_img bg = canvas.create_image(0, 0, anchor=tk.NW, image=bg_img)