logictools
GeneratorsThis notebook will show how to use single stepping mode in logictools
generators. In this example the pattern generator is used to implement a simple 4-bit up-counter, we will be able to single step the clock and verify the counter operation. The output is verifired using the waveforms captured by the trace analyzer as well as the patterns on the on-board LEDs.
We use the boolean generator to transfer the pattern generator signals to the on-board LEDs. It implements 4 buffer functions that pass the input values received from the pattern generator to the on-board LEDs. we observe the patterns on the on-board LEDs by single stepping the clock at desired intervals.
Single stepping is supported in all the logictools
generators.
In [1]:
from pynq.overlays.logictools import LogicToolsOverlay
logictools_olay = LogicToolsOverlay('logictools.bit')
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},
{'name': 'bit3', 'pin': 'D3', 'wave': 'l.......h.......'}],
{},
['analysis',
{'name': 'bit0_loopback', 'pin': 'D0'},
{'name': 'bit1_loopback', 'pin': 'D1'},
{'name': 'bit2_loopback', 'pin': 'D2'},
{'name': 'bit3_loopback', 'pin': 'D3'}]],
'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.
In [3]:
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')
In [4]:
boolean_generator = logictools_olay.boolean_generator
functions = {'Buffer 1': 'LD3 = D16',
'Buffer 2': 'LD2 = D17',
'Buffer 3': 'LD1 = D18',
'Buffer 4': 'LD0 = D19'}
boolean_generator.setup(functions)
boolean_generator.expressions
Out[4]:
In [5]:
logictools_controller = logictools_olay.logictools_controller
Set the loopback connections using jumper wires on the Arduino Interface
Note: Make sure all other pins are disconnected.
Step 4 cycles using a 1 second delay loop. Observe the pattern on the on-board LEDs
In [6]:
from time import sleep
for _ in range(4):
logictools_controller.step([boolean_generator, pattern_generator])
sleep(1)
pattern_generator.show_waveform()
Step an additional 11 cycles using a 1 second delay loop. Observe the pattern on the on-board LEDs
In [7]:
from time import sleep
for _ in range(11):
logictools_controller.step([boolean_generator, pattern_generator])
sleep(1)
pattern_generator.show_waveform()
Step 1 additional cycle to reach the maximum count value. Observe the pattern on the on-board LEDs
In [8]:
logictools_controller.step([boolean_generator, pattern_generator])
pattern_generator.show_waveform()
In [9]:
pattern_generator.stop()
boolean_generator.stop()
In [10]:
pattern_generator.reset()
boolean_generator.reset()