Exemplo n.º 1
0
                    if signal in IN_OUT_LINES:
                        byte = byte & IN_OUT_LINES[signal]

            ROM.write(address, byte)


ROM.init()

if CLEAR:
    # Clear the ROM (Fill it with HLTs)
    if ROM_NUM == 0:

        byte = CTRL_LINES["HLT"]
        # Invert active low signals (ALU_OUT, HLT, NXT)
        byte = byte ^ 0b11100000
        ROM.fill(byte)

    else:
        # All 1s is no IN and not OUT
        ROM.fill(0xff)
if WRITE_FETCH_CYCLES:
    write_fetch_cycles()

file = open("intsructions-micro-steps.txt", "r")

instruction_line = clean_line(file.readline(), file)
micro_step_line = clean_line(file.readline(), file)

# If both lines are not empty
while instruction_line and micro_step_line:
    # print_latex(instruction_line, micro_step_line)
Exemplo n.º 2
0
    "PUSH a": 0xa2,
    "PUSH w": 0xa6,
    "PUSH PC+3": 0xa7,
    "POP A": 0xa8,
    "POP PC": 0xae,
}

assert len(
    sys.argv
) > 1, "You have to specify a file to write to memory as an argument"

file = open(sys.argv[1], "r")

ROM.init()
if CLEAR:
    ROM.fill(0xff)

address = 0

key_points = {}
placeholders = {}

for line in file:
    line = line.strip()
    # Skip empty line and lines with only whitespaces
    if not line:
        continue

    if line.endswith(":"):
        line = line[:-1]
        key_points[line] = address