@cocotb.test()
async def test_peak_detect(dut):
    num_samples_per_epoch = (15 * 50)
    num_epochs = 10
    num_samples = (num_samples_per_epoch * num_epochs)
    data = np.loadtxt('46343_acceleration.txt', delimiter=' ')
    fs = 50
    time = np.arange(np.amin(data[:, 0]), np.amax(data[:, 0]), (1.0 / fs))
    z_accel = np.interp(time, data[:, 0], data[:, 3])
    start_offset_sec = 120
    offset = (fs * start_offset_sec)
    z_accel = z_accel[offset:(offset + num_samples)]
    print(f'Number of samples to input {z_accel.shape[0]}')
    clk = dut.clk
    (dut.i_z_accel <= 0)
    (dut.i_valid <= 0)
    cocotb.fork(Clock(clk, 25, units='ns').start())
    (await NextTimeStep())
    (dut.reset <= 1)
    (await ClockCycles(clk, 1))
    (await ReadWrite())
    (dut.reset <= 0)
    (await ClockCycles(clk, 1))
    (await ReadWrite())
    for (i, z) in enumerate(z_accel):
        (dut.i_z_accel <= BinaryValue(str(FixedPoint(float((z / 5)), 1, 7))))
        (dut.i_valid <= 1)
        (await ClockCycles(clk, 1))
        (dut.i_valid <= 0)
        (await ClockCycles(clk, 10))
    (dut.i_valid <= 0)
    (await ClockCycles(clk, 100))
@cocotb.test()
async def test_peak_detect(dut):
    num_samples_per_epoch = (15 * 50)
    num_epochs = 10
    num_samples = (num_samples_per_epoch * num_epochs)
    data = np.loadtxt('46343_acceleration.txt', delimiter=' ')
    fs = 50
    time = np.arange(np.amin(data[:, 0]), np.amax(data[:, 0]), (1.0 / fs))
    z_accel = np.interp(time, data[:, 0], data[:, 3])
    start_offset_sec = 120
    offset = (fs * start_offset_sec)
    z_accel = z_accel[offset:(offset + num_samples)]
    print(f'Number of samples to input {z_accel.shape[0]}')
    clk = dut.clk
    (dut.i_z_accel <= 0)
    (dut.i_valid <= 0)
    cocotb.fork(Clock(clk, 25, units='ns').start())
    (await NextTimeStep())
    (dut.reset <= 1)
    (await ClockCycles(clk, 1))
    (await ReadWrite())
    (dut.reset <= 0)
    (await ClockCycles(clk, 1))
    (await ReadWrite())
    for (i, z) in enumerate(z_accel):
        (dut.i_z_accel <= BinaryValue(str(FixedPoint(float((z / 5)), 1, 7))))
        (dut.i_valid <= 1)
        (await ClockCycles(clk, 1))
        (dut.i_valid <= 0)
        (await ClockCycles(clk, 10))
    (dut.i_valid <= 0)
    (await ClockCycles(clk, 100))