Bench: Sbox and Substitution Layer#
This module contains the documentation for the Substitution Layer, S-Box and the testbenches.
Sbox#
Model#
Library for the SboxModel class.
It contains the Python model used to verify the Sbox module.
@author: Timothée Charrier
- class sbox_model.SboxModel(*, s_table: list[int] | None = None)[source]
Bases:
object
Model for the SBOX module.
This class defines the model used to verify the SBOX module.
- compute(i_data: int) int [source]
Compute the output data based on the input data.
Methods
compute
(i_data)Compute the output data based on the input data.
- compute(i_data: int) int [source]
Compute the output data based on the input data.
- Parameters:
i_data (int) – The input data.
- Returns:
The computed output data.
- Return type:
int
Testbench#
Testbench for the sbox module.
This module tests the sbox module by comparing the output of the Python implementation with the VHDL implementation.
@author: Timothée Charrier
- async test_sbox.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.
Substitution Layer#
Model#
Library for the SubstitutionLayerModel class.
It contains the Python model used to verify the Substitution Layer module.
@author: Timothée Charrier
- class substitution_layer_model.SubstitutionLayerModel[source]
Bases:
object
Model for the Substitution Layer module.
This class defines the model used to verify the Substitution Layer module.
- o_state
The output state.
- Type:
list[int]
- _substitution_layer(state: list[int]) list[int] [source]
Apply the substitution layer (S-box).
- assert_output(dut: HierarchyObject, inputs: dict | None = None) None [source]
Assert the output of the DUT and log the input and output values.
Methods
assert_output
(dut[, inputs])Assert the output of the DUT and log the input and output values.
- _substitution_layer(state: list[int]) list[int] [source]
Apply the substitution layer (S-box).
- Parameters:
state (List[int]) – The current state.
- Returns:
The updated state after the substitution layer.
- Return type:
List[int]
- assert_output(dut: HierarchyObject, inputs: dict | 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).
inputs (dict, optional) – The input dictionary.
Testbench#
Testbench for the Substitution Layer module.
This module tests the Substitution Layer module by comparing the output of the Python implementation with the VHDL implementation.
@author: Timothée Charrier
- test_substitution_layer.get_generics(dut: HierarchyObject) dict [source]#
Retrieve the generic parameters from the DUT.
- Parameters:
dut (HierarchyObject) – The device under test (DUT).
- Returns:
A dictionary containing the generic parameters.
- Return type:
dict
- async test_substitution_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_substitution_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.
- async test_substitution_layer.substitution_layer_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.