Bench: Diffusion Layer#

This module contains the documentation for the diffusion layer model and testbench.

Diffusion Layer Model#

diffusion_layer_model.py#

Library for the DiffusionLayerModel class.

It contains the Python model used to verify the Diffusion Layer module.

@author: Timothée Charrier

class diffusion_layer_model.DiffusionLayerModel[source]#

Model for the Diffusion Layer module.

This class defines the model used to verify the Diffusion Layer module.

Methods

assert_output(dut[, state])

Assert the output of the DUT and log the input and output values.

rotate_right(value, num_bits)

Rotate the bits of a 64-bit integer to the right.

assert_output(dut: HierarchyObject, state: list[int] | None = None) None[source]#

Assert the output of the DUT and log the input and output values.

Parameters:
  • dut (HierarchyObject) – The device under test (DUT).

  • state (List[int], optional) – The input state, by default None.

static rotate_right(value: int, num_bits: int) int[source]#

Rotate the bits of a 64-bit integer to the right.

Parameters:
  • value (int) – The input value.

  • num_bits (int) – The number of bits to rotate.

Returns:

The rotated value.

Return type:

int

Test Diffusion Layer#

test_diffusion_layer.py#

Testbench for the Diffusion Layer module.

This module tests the Diffusion Layer module by comparing the output of the Python implementation with the VHDL implementation.

@author: Timothée Charrier

async test_diffusion_layer.diffusion_layer_test(dut: HierarchyObject) None[source]#

Test the Diffusion Layer module.

Parameters:

dut (HierarchyObject) – The device under test (DUT).

Raises:

RuntimeError – If the DUT fails to compute the correct output.

async test_diffusion_layer.initialize_dut(dut: HierarchyObject, inputs: dict) None[source]#

Initialize the DUT with the given inputs.

Parameters:
  • dut (HierarchyObject) – The device under test (DUT).

  • inputs (dict) – The input dictionary.

async test_diffusion_layer.reset_dut_test(dut: HierarchyObject) None[source]#

Test the DUT’s behavior during reset.

Verifies that the output is correctly reset and remains stable.

Parameters:

dut (HierarchyObject) – The device under test (DUT).

Raises:

RuntimeError – If the DUT fails to reset.

test_diffusion_layer.test_diffusion_layer() None[source]#

Function Invoked by the test runner to execute the tests.

Raises:

RuntimeError – If the test fails to build or run.