<jupyter_start><jupyter_text>Single-stepping the `logictools` Pattern Generator * This notebook will show how to use single-stepping mode with the pattern generator* Note that all generators in the _logictools_ library may be **single-stepped**  Visually ... The _logictools_ library on the Zynq device on the PYNQ board ![](./images/single-stepping_pattern_generator.png)  Demonstrator notes* For this demo, the pattern generator implements a simple, 4-bit binary, up-counter* We will single-step the clock and verify the counter operation* The output is verified using the waveforms captured by the trace analyzer  Points to note* __Everything__ runs on the Zynq chip on the PYNQ board, even this slide show!    * We will specify and implement circuits __using only Python code__  * __No__ Xilinx CAD tools are used  * We can create live, real-time circuits __instantaneously__<jupyter_code># Specify a stimulus waveform and display it 
from pynq.overlays.logictools import LogicToolsOverlay
from pynq.lib.logictools import Waveform

logictools_olay = LogicToolsOverlay('logictools.bit')

up_counter_stimulus = {'signal': [
    {'name': 'bit0', 'pin': 'D0', 'wave': 'lh' * 8},
        {'name': 'bit1', 'pin': 'D1', 'wave': 'l.h.' * 4},
        {'name': 'bit2', 'pin': 'D2', 'wave': 'l...h...' * 2},
        {'name': 'bit3', 'pin': 'D3', 'wave': 'l.......h.......'}]}

# Check visually that the stimulus pattern is correct
waveform = Waveform(up_counter_stimulus)
waveform.display()
# Add the signals we want to analyze 
up_counter = {'signal': [
    ['stimulus',
        {'name': 'bit0', 'pin': 'D0', 'wave': 'lh' * 8},
        {'name': 'bit1', 'pin': 'D1', 'wave': 'l.h.' * 4},
        {'name': 'bit2', 'pin': 'D2', 'wave': 'l...h...' * 2},
        {'name': 'bit3', 'pin': 'D3', 'wave': 'l.......h.......'}],
    {},
    ['analysis',
        {'name': 'bit0_output', 'pin': 'D0'},
        {'name': 'bit1_output', 'pin': 'D1'},
        {'name': 'bit2_output', 'pin': 'D2'},
        {'name': 'bit3_output', 'pin': 'D3'}]]}

# Display the stimulus and analysis signal groups
waveform = Waveform(up_counter)
waveform.display()
# Configure the pattern generator and analyzer
pattern_generator = logictools_olay.pattern_generator
pattern_generator.trace(num_analyzer_samples=16)
pattern_generator.setup(up_counter,
                        stimulus_group_name='stimulus',
                        analysis_group_name='analysis')
# Press `cntrl-enter` to advance the pattern generator by one clock cycle
pattern_generator.step()
pattern_generator.show_waveform()
# Advance an arbitrary number of cycles
no_of_cycles = 7
for _ in range(no_of_cycles):
    pattern_generator.step()
pattern_generator.show_waveform()
# Finally, reset the pattern generator after use
pattern_generator.reset()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14733096085409253, 'fraction_numerical': 0.012099644128113879, 'mean_word_length': 4.028622540250447, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '2019', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 909, 'n_tokens_neox': 871, 'n_words': 285, 'path': 'Session_3/3_pattern_generator.ipynb', 'repo_name': 'xupsh/PYNQ_Workshop', 'size': '2810'}