예제 #1
0
def test_bnn_uart():
    generics = {
        "C_QUARTZ_FREQ": 115200 * 4
    }  # 4 cycles per bit for faster simulation
    run(
        vhdl_sources=get_files(
            pathlib.Path(__file__).parent.absolute() / ".." / "src", "*.vhd") +
        get_files(
            pathlib.Path(__file__).parent.absolute() / ".." / "src" /
            "interface",
            "*.vhd",
        ),
        toplevel="bnn_uart",
        module="test_bnn_uart",
        compile_args=["--work=bnn_lib", "--std=08"],
        parameters=generics,
    )
예제 #2
0
def test_bnn():
    generics = {}
    run(
        vhdl_sources=get_files(
            pathlib.Path(__file__).parent.absolute() / ".." / "src", "*.vhd"),
        toplevel="bnn",
        module="test_bnn",
        compile_args=["--work=bnn_lib", "--std=08"],
        parameters=generics,
    )
예제 #3
0
def test_maximum_pooling(kernel_size, channel):
    generics = {
        "C_KERNEL_SIZE": kernel_size,
        "C_CHANNEL": channel,
    }
    run(
        vhdl_sources=get_files(
            pathlib.Path(__file__).parent.absolute() / ".." / "src", "*.vhd"),
        toplevel="maximum_pooling",
        module="test_maximum_pooling",
        compile_args=["--work=bnn_lib", "--std=08"],
        parameters=generics,
    )
예제 #4
0
def analyze_uart_lib():
    """Analyze the UART library."""
    work = "uart_lib"
    source_path = ABSOLUTE_PATH / ".." / ".." / "submodules" / "icestick-uart" / "hdl"
    source_files = get_files(source_path, "*.vhd")

    if outdated(f"{WORK_DIR}/{work}-obj08.cf", source_files):
        os.makedirs(f"{WORK_DIR}", exist_ok=True)

        analyze_command = [
            "ghdl", "-i", STD, f"--work={work}", f"--workdir={WORK_DIR}"
        ]
        analyze_command.extend(source_files)
        subprocess.run(analyze_command, check=True)
예제 #5
0
def test_average_pooling():
    generics = {
        "C_BITWIDTH": 8,
        "C_CHANNEL": 6,
        "C_IMG_WIDTH": 6,
        "C_IMG_HEIGHT": 6,
    }
    run(
        vhdl_sources=get_files(
            pathlib.Path(__file__).parent.absolute() / ".." / "src", "*.vhd"
        ),
        toplevel="average_pooling",
        module="test_average_pooling",
        compile_args=["--work=bnn_lib", "--std=08"],
        parameters=generics,
    )
예제 #6
0
def analyze_window_ctrl_lib():
    """Analyze the window control library."""
    analyze_util()

    work = "window_ctrl_lib"
    source_path = ABSOLUTE_PATH / ".." / ".." / "src" / "window_ctrl"
    source_files = get_files(source_path, "*.vhd")

    if outdated(f"{WORK_DIR}/{work}-obj08.cf", source_files):
        os.makedirs(f"{WORK_DIR}", exist_ok=True)

        analyze_command = [
            "ghdl", "-i", STD, f"--work={work}", f"--workdir={WORK_DIR}"
        ]
        analyze_command.extend(source_files)
        subprocess.run(analyze_command, check=True)
def test_window_convolution_activation(kernel_size, stride, input_channel,
                                       output_channel,
                                       output_channel_bitwidth):
    # Input channel bitwidth > 1 is tested at convolution level.
    input_channel_bitwidth = 1
    generics = {
        "C_KERNEL_SIZE": kernel_size,
        "C_STRIDE": stride,
        "C_INPUT_CHANNEL": input_channel,
        "C_INPUT_CHANNEL_BITWIDTH": input_channel_bitwidth,
        "C_OUTPUT_CHANNEL": output_channel,
        "C_OUTPUT_CHANNEL_BITWIDTH": output_channel_bitwidth,
        "C_IMG_WIDTH": 8,
        "C_IMG_HEIGHT": 8,
    }
    run(
        vhdl_sources=get_files(
            pathlib.Path(__file__).parent.absolute() / ".." / "src", "*.vhd"),
        toplevel="window_convolution_activation",
        module="test_window_convolution_activation",
        compile_args=["--work=bnn_lib", "--std=08"],
        parameters=generics,
    )