Exemple #1
0
def main():
    ram = [1] * 16
    cu = CU("intel", "2019-08-16", "manage everything", ram, 2.4, True)

    code = open(".code", "r")
    codelines = code.readlines()

    cu.startInstructions(codelines)
Exemple #2
0
def main():
    global bus, ram, ppi, alu, cu
    bus = Bus()
    ram = RAM(0x0, 64)
    ppi = PPI(0x40)
    bus.AddMemoryPeripheral(ram, 0x0, 0x0+64*1024-1)
    bus.AddIOPeripheral(ppi, 0x40, 0x40+3)
    
    
    alu = ALU()
    cu = CU(alu, bus)
    
    ppi.SetInterruptCallPA(partial(cu.RST, 5.5, ppi))
    ppi.SetInterruptCallPB(partial(cu.RST, 6.5, ppi))
    
    openFile()
    i = 0
    for wd in words:
        ram.Write(0x8000+i, wd)
        i += 1
    
    
    #ram.Write(0x002C, 0x6F)
    #ram.Write(0x002D, 0xC9)
    ram.Write(0x002c, 0xdb)
    ram.Write(0x002d, 0x40)
    ram.Write(0x002e, 0xc9)
    cu.Reset()
    cu.SetPC(0x8000)
    
    thread = Thread(target=execute)
    thread.start()
    
    ppi.a = 0xbb
    while cu.running:
        pass
#        cmd = input("Enter a command: ")
#        if cmd == "quit":
#            cu.running = False
#        elif cmd == "stba":
#            ppi.StrobeA()
#        elif cmd == "stbb":
#            ppi.StrobeB()
#        elif cmd == "show":
#            print("")
#            alu.Show()
#            #print("\n")
#            #ram.Show()
#            print("\n")
#            ppi.Show()

    ram.ShowRange(parser.labels["TABLE"], parser.labels["TABLE"]+0x63)
    alu.Show()
def main():
    tabla = RAM()
    visual = Rom()
    registros = Rom()
    reloj = Rom()
    operacion = Rom()
    r1= Register()
    delay1=delay()
    delay1.Htz()
    registros.vis()
    visual.vis()
    reloj.vis()
    operacion.vis()




    print ("\n                  Proyecto 1 CPU Simulator                           ")
    print ("*--------------------------------------------------------------------*")
    print ("""      Integrantes:
            - Juan Luis Fernandez
            - Rodrigo Reyes
            - Esteban Samayoa\n
                """)
    delay1.tiempo()
    if visual.v == True:
        print ("*--------------------------------*")
        print ("              RAM                    ")
        tabla.valoress()
    delay1.tiempo()
    if registros.b == True:
        print (f"""
*---------------------------------*
            REGISTROS:
        Primer registro : {r1.R0}
        Segundo registro : {r1.R1}
        Tercer registro : {r1.R2}

    """)
    delay1.tiempo()
    if reloj.c == True:
        print ("*--------------------------------*")
        print (f"""
        Tiempo : {hrtzz.htz}
        """)
    delay1.tiempo()
    if operacion.a == True:
        cu1=CU()
        cu1.operate()
Exemple #4
0
 def __init__(self):
     self.alu = Alu()
     self.clock = CPUclock()
     self.memory = Memory()
     self.ram = Ram()
     self.rom = Rom()
     self.registers = Registers()
     self.cu = CU()
Exemple #5
0
    def __init__(self):
        self.weight_mat = []
        for i in range(NN_layer):
            self.weight_mat.append(
                Weight_matrix(NN_layer, filter_bit, filter_h, filter_w))

        self.CU_array = []
        for i in range(CU_num):
            self.CU_array.append(
                CU(IO_n, self.weight_mat, macro, xbar_h, xbar_w, OU_h, OU_w,
                   pooling_h, pooling_w))
from CU import CU
Cu_ = CU("AMD", "26/09/2020", "CU Simulator")
Cu_.runmain()
Exemple #7
0
def main():
    responses = Response()
    bios = Bios()
    yml = open("../bios.yml", "r")
    ymlines = yml.readlines()
    bios.setValues(ymlines)
    print(bios.clock)
    print(bios.visualization)
    print(bios.ram)
    #ram = [1] * 16
    cu = CU("intel", "2019-08-16", "manage everything", bios.ram, bios.clock,
            True)

    code = open("../Programs/Program4.code", "r")
    codelines = code.readlines()
    print(codelines)
    cu.run(codelines)

    response = {
        "registers": {
            "A": cu.a.getData(),
            "B": cu.b.getData(),
            "C": cu.c.getData(),
            "D": cu.d.getData()
        },
        "RAM": cu.ram.getRAM(),
        "CLOCK": cu.clock.freq,
        "ALU": cu.alu.getFlags()
    }

    y = json.dumps(response)
    responses.setResponse(y)

    @app.route('/')
    def hello():
        return responses.getResponse()

    @app.route('/post', methods=['POST'])
    def hello1():
        if 'file' not in request.files:
            print("no file")

        file = request.files['file']
        print(file)
        codelines = []
        filestream = file.stream.readlines()
        print(filestream)
        for i in filestream:
            string = str(i).replace("b'", "", 1)
            string = string.replace("\\n'", "\n", 1)
            string = string.replace("'", "", 1)
            #string = string.strip("\\n")
            codelines.append(str(string))
            #i.strip("\n'")
        print(codelines)
        cu.run(codelines)

        response = {
            "registers": {
                "A": cu.a.getData(),
                "B": cu.b.getData(),
                "C": cu.c.getData(),
                "D": cu.d.getData()
            },
            "RAM": cu.ram.getRAM(),
            "CLOCK": cu.clock.freq,
            "ALU": cu.alu.getFlags()
        }

        y = json.dumps(response)
        responses.setResponse(y)
        return y
Exemple #8
0
from Assembler import Assembler
from PPIWindow import PPIWindow

from threading import Thread
from functools import partial
import re
import time
from enum import Enum
import sys, os

bus = Bus()
ram = RAM(0x0, 64)
bus.AddMemoryPeripheral(ram, 0x0, 0x0 + 64 * 1024 - 1)

alu = ALU()
cu = CU(alu, bus)


def AddPPI(addr):
    ppi = PPI(addr)
    bus.AddIOPeripheral(ppi, addr, addr + 3)
    ppi.SetInterruptCallPA(partial(cu.RST, 5.5, ppi))
    ppi.SetInterruptCallPB(partial(cu.RST, 6.5, ppi))
    return ppi


class State(Enum):
    none = 0
    exam_mem = 1
    exam_reg = 2
    go = 3