Skip to content

Commit

Permalink
add height and width to toplevel test
Browse files Browse the repository at this point in the history
  • Loading branch information
marph91 committed Mar 25, 2021
1 parent b35167c commit 84e5e38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions playground/04_custom_toplevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ def __init__(
self.entity = f"""
entity bnn is
generic (
-- TODO: Height and width are only used for the testsuite.
C_INPUT_HEIGHT : integer := {self.previous_layer_info["height"]};
C_INPUT_WIDTH : integer := {self.previous_layer_info["width"]};
C_INPUT_CHANNEL : integer := {self.previous_layer_info["channel"]};
C_INPUT_CHANNEL_BITWIDTH : integer := {self.previous_layer_info["bitwidth"]}
);
Expand Down Expand Up @@ -381,8 +384,8 @@ def to_vhdl(self):
output_channel = 8
output_channel_bitwidth = 8
b = Bnn(
8,
8,
22,
22,
input_channel,
input_channel_bitwidth,
output_channel,
Expand Down
7 changes: 5 additions & 2 deletions sim/test_bnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,25 @@

@cocotb.test()
async def run_test(dut):
height = dut.C_INPUT_HEIGHT.value.integer
width = dut.C_INPUT_WIDTH.value.integer

# initialize the test
clock_period = 10 # ns
tick = Tick(clock_period=clock_period)
cocotb.fork(Clock(dut.isl_clk, clock_period, units="ns").start())
dut.isl_valid <= 0
await tick.wait()

for _ in range(8 * 8):
for _ in range(height * width):
dut.isl_valid <= 1
dut.islv_data <= randint(0, 255)
await tick.wait()
dut.isl_valid <= 0
await tick.wait()
await tick.wait()

await tick.wait_multiple(100)
await tick.wait_multiple(height * width)
# assert (
# dut.oslv_data.value.integer == case.output_data
# ), f"{dut.oslv_data.value.integer} /= {case.output_data}"
Expand Down

0 comments on commit 84e5e38

Please sign in to comment.