Exemplo n.º 1
0
def test_computer_gates():
   assert gate_count(EightComputer) == {
       'nands': 1032,  # ??? compare to 1262
       'dffs': 67,  # 3*16 bits (as in the standard CPU), plus two more half-words to hold results between half-cycles, plus a handful more to track some odd bits
       'roms': 1,
       'rams': 2,
       'inputs': 1,
       'outputs': 1,
   }
Exemplo n.º 2
0
def main():
    std = measure(BUNDLED_PLATFORM)
    print_result("solutions", std)

    print_relative_result("project_0x.py", std, measure(USER_PLATFORM))
    print_relative_result("alt/lazy.py", std, measure(LAZY_PLATFORM))
    print_relative_result("alt/sp.py", std, measure(SP_PLATFORM))
    print_relative_result("alt/threaded.py", std, measure(THREADED_PLATFORM))
    print_relative_result("alt/shift.py", std, measure(SHIFT_PLATFORM))
    print_relative_result("alt/reg.py", std, measure(REG_PLATFORM))
    print_relative_result("alt/reduce.py", std, measure(REDUCE_PLATFORM))

    # print_relative_result("alt/eight.py", std, measure(EIGHT_PLATFORM, "vector"))
    print_relative_result("alt/eight.py", std,
                          (gate_count(EIGHT_PLATFORM.chip)['nands'], std[1],
                           std[2] * 2, std[3] * 2))  # Cheeky
Exemplo n.º 3
0
def test_gates_zero8():
    assert gate_count(Zero8)['nands'] == 22  # gate_count(Zero16)/2 - 1
Exemplo n.º 4
0
def test_xor():
    assert gate_count(Xor)['nands'] == 4
Exemplo n.º 5
0
def test_ram4k_legit():
    """The challenge is to implement RAM4K from Registers."""
    assert gate_count(RAM4K).keys() == set(['nands', 'dffs'])
Exemplo n.º 6
0
def test_gates_and8():
    assert gate_count(And8)['nands'] == 16
Exemplo n.º 7
0
def test_and16():
    assert gate_count(And16)['nands'] == 32
Exemplo n.º 8
0
def test_gates_pc8():
    assert gate_count(PC8) == {
        'nands': 266,  # Compare to 287. Not much savings here.
        'dffs': 24,    # This is actually 8 _more_.
    }
Exemplo n.º 9
0
def test_dmux8way():
    assert gate_count(DMux8Way)['nands'] == 31  # optimal?
Exemplo n.º 10
0
def test_not16():
    assert gate_count(Not16)['nands'] == 16
Exemplo n.º 11
0
def test_dmux4way():
    assert gate_count(DMux4Way)['nands'] == 14  # optimal?
Exemplo n.º 12
0
def test_dmux():
    assert gate_count(DMux)['nands'] == 5
Exemplo n.º 13
0
def test_mux():
    assert gate_count(Mux)['nands'] == 4
Exemplo n.º 14
0
def test_gates_alu():
    assert gate_count(EightALU)['nands'] == 284  # gate_count(ALU)/2 + 4
Exemplo n.º 15
0
def test_mux16():
    assert gate_count(Mux16)['nands'] == 49  # optimal?
Exemplo n.º 16
0
def test_gates_register8():
    assert gate_count(Register8) == {
        'nands': 32,  # ?
        'dffs': 8
    }
Exemplo n.º 17
0
def test_mux4Way16():
    assert gate_count(Mux4Way16)['nands'] == 146  # optimal?
Exemplo n.º 18
0
def test_gates_not8():
    assert gate_count(Not8)['nands'] == 8
Exemplo n.º 19
0
def test_mux8Way16():
    assert gate_count(Mux8Way16)['nands'] == 339  # optimal?
Exemplo n.º 20
0
def test_gates_mux8():
    assert gate_count(Mux8)['nands'] == 25  # optimal?
Exemplo n.º 21
0
def test_nand():
    assert gate_count(Nand)['nands'] == 1
Exemplo n.º 22
0
def test_register_legit():
    """The challenge is to implement Register from Nand and DFF."""
    assert gate_count(Register).keys() == set(['nands', 'dffs'])
Exemplo n.º 23
0
def test_gates_inc8():
    assert gate_count(Inc8)['nands'] == 40  # gate_count(Inc16)/2 + 2
Exemplo n.º 24
0
def test_my_dff_legit():
    """The challenge is to implement DFF with only Nand gates."""
    assert list(gate_count(MyDFF).keys()) == ['nands']
Exemplo n.º 25
0
def test_gates_add8():
    assert gate_count(Add8)['nands'] == 72  # gate_count(Add16)/2 + 2
Exemplo n.º 26
0
def measure(platform, simulator="codegen"):
    return (gate_count(platform.chip)['nands'],
            test_optimal_08.count_pong_instructions(platform),
            test_optimal_08.count_pong_cycles_first_iteration(
                platform, simulator),
            test_optimal_08.count_cycles_to_init(platform, simulator))
Exemplo n.º 27
0
def test_and():
    assert gate_count(And)['nands'] == 2