コード例 #1
0
ファイル: test_eight.py プロジェクト: mossprescott/pynand
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,
   }
コード例 #2
0
ファイル: compare.py プロジェクト: mossprescott/pynand
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
コード例 #3
0
ファイル: test_eight.py プロジェクト: mossprescott/pynand
def test_gates_zero8():
    assert gate_count(Zero8)['nands'] == 22  # gate_count(Zero16)/2 - 1
コード例 #4
0
def test_xor():
    assert gate_count(Xor)['nands'] == 4
コード例 #5
0
def test_ram4k_legit():
    """The challenge is to implement RAM4K from Registers."""
    assert gate_count(RAM4K).keys() == set(['nands', 'dffs'])
コード例 #6
0
ファイル: test_eight.py プロジェクト: mossprescott/pynand
def test_gates_and8():
    assert gate_count(And8)['nands'] == 16
コード例 #7
0
def test_and16():
    assert gate_count(And16)['nands'] == 32
コード例 #8
0
ファイル: test_eight.py プロジェクト: mossprescott/pynand
def test_gates_pc8():
    assert gate_count(PC8) == {
        'nands': 266,  # Compare to 287. Not much savings here.
        'dffs': 24,    # This is actually 8 _more_.
    }
コード例 #9
0
def test_dmux8way():
    assert gate_count(DMux8Way)['nands'] == 31  # optimal?
コード例 #10
0
def test_not16():
    assert gate_count(Not16)['nands'] == 16
コード例 #11
0
def test_dmux4way():
    assert gate_count(DMux4Way)['nands'] == 14  # optimal?
コード例 #12
0
def test_dmux():
    assert gate_count(DMux)['nands'] == 5
コード例 #13
0
def test_mux():
    assert gate_count(Mux)['nands'] == 4
コード例 #14
0
ファイル: test_eight.py プロジェクト: mossprescott/pynand
def test_gates_alu():
    assert gate_count(EightALU)['nands'] == 284  # gate_count(ALU)/2 + 4
コード例 #15
0
def test_mux16():
    assert gate_count(Mux16)['nands'] == 49  # optimal?
コード例 #16
0
ファイル: test_eight.py プロジェクト: mossprescott/pynand
def test_gates_register8():
    assert gate_count(Register8) == {
        'nands': 32,  # ?
        'dffs': 8
    }
コード例 #17
0
def test_mux4Way16():
    assert gate_count(Mux4Way16)['nands'] == 146  # optimal?
コード例 #18
0
ファイル: test_eight.py プロジェクト: mossprescott/pynand
def test_gates_not8():
    assert gate_count(Not8)['nands'] == 8
コード例 #19
0
def test_mux8Way16():
    assert gate_count(Mux8Way16)['nands'] == 339  # optimal?
コード例 #20
0
ファイル: test_eight.py プロジェクト: mossprescott/pynand
def test_gates_mux8():
    assert gate_count(Mux8)['nands'] == 25  # optimal?
コード例 #21
0
def test_nand():
    assert gate_count(Nand)['nands'] == 1
コード例 #22
0
def test_register_legit():
    """The challenge is to implement Register from Nand and DFF."""
    assert gate_count(Register).keys() == set(['nands', 'dffs'])
コード例 #23
0
ファイル: test_eight.py プロジェクト: mossprescott/pynand
def test_gates_inc8():
    assert gate_count(Inc8)['nands'] == 40  # gate_count(Inc16)/2 + 2
コード例 #24
0
def test_my_dff_legit():
    """The challenge is to implement DFF with only Nand gates."""
    assert list(gate_count(MyDFF).keys()) == ['nands']
コード例 #25
0
ファイル: test_eight.py プロジェクト: mossprescott/pynand
def test_gates_add8():
    assert gate_count(Add8)['nands'] == 72  # gate_count(Add16)/2 + 2
コード例 #26
0
ファイル: compare.py プロジェクト: mossprescott/pynand
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))
コード例 #27
0
def test_and():
    assert gate_count(And)['nands'] == 2