Bench: Permutation#

This module contains the documentation for the Permutation model and testbench.

Permutation Model#

permutation_model.py#

Library for the PermutationModel class.

It contains the Python model used to verify the Permutation module.

@author: Timothée Charrier

class permutation_model.PermutationModel[source]#

Model for the Permutation module.

This class defines the model used to verify the Permutation module.

Methods

assert_output(dut, inputs)

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

permutation(i_round, i_state)

Compute the output state based on the current input state.

rotate_right(value, num_bits)

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

assert_output(dut: HierarchyObject, inputs: dict[str, any]) None[source]#

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

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

  • inputs (dict, optional) – The input dictionary.

permutation(i_round: int, i_state: list[int]) list[int][source]#

Compute the output state based on the current input state.

Parameters:
  • i_round (int) – The number of the current round.

  • i_state (List[int]) – The current input state.

Return type:

Nothing, only updates the state array.

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 Permutation#

test_permutation.py#

Testbench for the permutation module.

This module tests the permutation module by comparing the output of the Python implementation with the verilog implementation.

@author: Timothée Charrier

async test_permutation.permutation_test(dut: HierarchyObject) None[source]#

Test the DUT’s behavior during normal computation.

Verifies that the output is correctly computed.

Parameters:

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

Raises:

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

async test_permutation.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_permutation.test_permutation() None[source]#

Function Invoked by the test runner to execute the tests.

Raises:

RuntimeError – If the test fails to build or run.