<commit_before>""" A class for building a PyRTL AES circuit.

Currently this class only supports 128 bit AES encryption/decryption

Example::

    aes = AES()
    plaintext = pyrtl.Input(bitwidth=128, name='aes_plaintext')
    key = pyrtl.Input(bitwidth=128, name='aes_key')
    aes_ciphertext = pyrtl.Output(bitwidth=128, name='aes_ciphertext')
    reset = pyrtl.Input(1)
    ready = pyrtl.Output(1, name='ready')
    ready_out, aes_cipher = aes.encryption_statem(plaintext, key, reset)
    ready <<= ready_out
    aes_ciphertext <<= aes_cipher
    sim_trace = pyrtl.SimulationTrace()
    sim = pyrtl.Simulation(tracer=sim_trace)
    sim.step ({
        aes_plaintext: 0x00112233445566778899aabbccddeeff,
        aes_key: <KEY>,
        reset: 1
    })
    for cycle in range(1,10):
        sim.step ({
            aes_plaintext: 0x00112233445566778899aabbccddeeff,
            aes_key: 0x000102030405060708090a0b0c0d0e0f,
            reset: 0<commit_msg>Update AES example<commit_after>""" A class for building a PyRTL AES circuit.

Currently this class only supports 128 bit AES encryption/decryption

Example::

    import pyrtl
    from pyrtl.rtllib.aes import AES

    aes = AES()
    plaintext = pyrtl.Input(bitwidth=128, name='aes_plaintext')
    key = pyrtl.Input(bitwidth=128, name='aes_key')
    aes_ciphertext = pyrtl.Output(bitwidth=128, name='aes_ciphertext')
    reset = pyrtl.Input(1, name='reset')
    ready = pyrtl.Output(1, name='ready')
    ready_out, aes_cipher = aes.encrypt_state_m(plaintext, key, reset)
    ready <<= ready_out
    aes_ciphertext <<= aes_cipher
    sim_trace = pyrtl.SimulationTrace()
    sim = pyrtl.Simulation(tracer=sim_trace)
    sim.step ({
        'aes_plaintext': 0x00112233445566778899aabbccddeeff,
        'aes_key': <KEY>,
        'reset': 1
    })
    for cycle in range(1,10):
        sim.step ({
            'aes_plaintext': 0x00112233445566778899aabbccddeeff,
            'aes_key': <KEY>,
            'reset': 0
{'fraction_non_alphanumeric': 0.10981189628876462, 'fraction_numerical': 0.07574987290289781, 'mean_word_length': 3.3063457330415753, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4641633', 'n_tokens_mistral': 831, 'n_tokens_neox': 685, 'n_words': 140}