Pattern Generator and Trace Analyzer

This notebook will show how to use the Pattern Generator to generate patterns on I/O pins. The pattern that will be generated is 3-bit up count performed 4 times.

Step 1: Download the logictools overlay


In [1]:
from pynq.overlays.logictools import LogicToolsOverlay

logictools_olay = LogicToolsOverlay('logictools.bit')

Step 2: Create WaveJSON waveform

The pattern to be generated is specified in the waveJSON format

The pattern is applied to the Arduino interface, pins D0, D1 and D2 are set to generate a 3-bit count. To check the generated pattern we loop them back to pins D19, D18 and D17 respectively and use the the trace analyzer to view the loopback signals

The Waveform class is used to display the specified waveform.


In [2]:
from pynq.lib.logictools import Waveform

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}], 
      
    ['analysis',
        {'name': 'bit2_loopback', 'pin': 'D17'},
        {'name': 'bit1_loopback', 'pin': 'D18'},
        {'name': 'bit0_loopback', 'pin': 'D19'}]], 

    'foot': {'tock': 1},
    'head': {'text': 'up_counter'}}

waveform = Waveform(up_counter)
waveform.display()


Note: Since there are no captured samples at this moment, the analysis group will be empty.

Step 3: Instantiate the pattern generator and trace analyzer objects

Users can choose whether to use the trace analyzer by calling the trace() method.
The analyzer can be set to trace a specific number of samples using, num_analyzer_samples argument.


In [3]:
pattern_generator = logictools_olay.pattern_generator
pattern_generator.trace(num_analyzer_samples=16)

Step 4: Setup the pattern generator

The pattern generator will work at the default frequency of 10MHz. This can be modified using a frequency argument in the setup() method.


In [4]:
pattern_generator.setup(up_counter,
                        stimulus_group_name='stimulus',
                        analysis_group_name='analysis')

Set the loopback connections using jumper wires on the Arduino Interface

  • Output pins D0, D1 and D2 are connected to pins D19, D18 and D17 respectively
  • Loopback/Input pins D19, D18 and D17 are observed using the trace analyzer as shown below
  • After setup, the pattern generator should be ready to run

Note: Make sure all other pins are disconnected.

Step 5: Run and display waveform

The run() method will execute all the samples, show_waveform() method is used to display the waveforms.
Alternatively, we can also use step() method to single step the pattern.


In [5]:
pattern_generator.run()
pattern_generator.show_waveform()


Step 6: Stop the pattern generator

Calling stop() will clear the logic values on output pins; however, the waveform will be recorded locally in the pattern generator instance.


In [6]:
pattern_generator.stop()