Bench: Ascon#
This module contains the documentation for the Top level Ascon model and testbench.
Ascon Model#
ascon_model.py#
Library for the AsconModel class.
This module contains the Python model used to verify the Ascon module.
Author: Timothée Charrier
- class ascon_model.AsconModel(dut: HierarchyObject, *, inputs: dict[str, int] | None = None, plaintext: list[int] | None = None)[source]#
Model for the Ascon module.
This class defines the model used to verify the Ascon module.
Methods
ascon128
(inputs)Compute the output state based on the current input state.
permutation
([i_round, is_first])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.
update_inputs
([inputs])Update the input state, data, key, and enable signals of the model.
xor_data_begin
(data)Perform XOR operation at the beginning with the data.
xor_key_begin
(key)Perform XOR operation at the beginning with the key.
Perform XOR operation at the end with the key.
Perform XOR operation at the end with the least significant bit.
- ascon128(inputs: dict[str, int]) dict[str, str] [source]#
Compute the output state based on the current input state.
- Parameters:
inputs (dict) – The input dictionary containing the data, key, and nonce.
- Returns:
The output state, tag, and cipher.
- Return type:
dict
- permutation(i_round: int = 0, *, is_first: bool = False) None [source]#
Compute the output state based on the current input state.
- Parameters:
i_round (int, optional) – The current round number. Default is 0.
is_first (bool, optional) – True if it is the first permutation, False otherwise. Default is False.
- 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
- update_inputs(inputs: dict[str, int] | None = None) None [source]#
Update the input state, data, key, and enable signals of the model.
- Parameters:
inputs (dict, optional) – The new input dictionary. Default is None.
- xor_data_begin(data: int) None [source]#
Perform XOR operation at the beginning with the data.
- Parameters:
data (int) – The data to XOR with the state.
Test Ascon#
test_ascon.py#
Testbench for the ascon module.
This module tests the ascon top level module by comparing the output of the Python implementation with the verilog implementation.
@author: Timothée Charrier
- async test_ascon.ascon_top_test(dut: HierarchyObject) None [source]#
Test the ascon top module.
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.