Beispiel #1
0
def test_program_counter_latches():
    pc = ProgramCounter()

    pc.clock()

    pc.clock(data=0x0D, con=['lp'])
    assert pc.data(['ep']) == 0x0D

    pc.clock(con=['cp'])
    assert pc.data(['ep']) == 0x0E
Beispiel #2
0
def test_program_counter_needs_ep():
    pc = ProgramCounter()

    pc.clock(con=['cp'])
    assert pc.data() == None

    pc.reset()
    assert pc.data() == None
Beispiel #3
0
def test_program_counter_resets():
    pc = ProgramCounter()

    pc.clock(con=['cp'])
    assert pc.data(['ep']) == 0x01

    pc.reset()
    assert pc.data(['ep']) == 0x00
Beispiel #4
0
def test_clock_fails_if_multi_data_accessed():
    # pull data from connected components from data bus
    clock = Clock()
    reg_a = RegisterA()
    pc = ProgramCounter()
    clock.add_component(reg_a)
    clock.add_component(pc)

    reg_a.clock(data=0xCD, con=['la'])
    pc.clock(data=0xAE, con=['ep'])

    control_word = ['ea', 'ep']

    with pytest.raises(RuntimeError):
        clock.data_bus(control_word)
Beispiel #5
0
def test_t0_increments_pc():
    clock = Clock()
    pc = ProgramCounter()

    clock.add_component(pc)

    # reset CPU
    clock.reset()

    # contrive for test
    pc.clock(data=0x0C, con=['lp'])
    clock.t_state = 0

    # apply single clock cycle
    clock.step()

    assert pc.value == 0x0D
Beispiel #6
0
def test_t0_transfers_pc_to_mar():
    clock = Clock()
    pc = ProgramCounter()
    mar = MemoryAddressRegister()

    clock.add_component(pc)
    clock.add_component(mar)

    # reset CPU
    clock.reset()

    # contrive for test
    pc.clock(data=0x0C, con=['lp'])
    clock.t_state = 0

    # apply single clock cycle
    clock.step()

    assert mar.value == 0x0C
Beispiel #7
0
def test_program_counter_increments():
    pc = ProgramCounter()

    pc.clock()
    assert pc.data(['ep']) == 0x00

    pc.clock(con=['cp'])
    assert pc.data(['ep']) == 0x01

    pc.clock(con=['cp'])
    assert pc.data(['ep']) == 0x02
Beispiel #8
0
def test_clock_add_component():
    clock = Clock()
    pc = ProgramCounter()
    clock.add_component(pc)