<jupyter_start><jupyter_text>Reading, math and writing demonstration  In this demo you will use the tProc to do some math and/or bitwise operations on two variables that you will pass in through the  config  dictionary and take out with  single_read .<jupyter_code># Import the QICK drivers and auxiliary libraries
from qick import *
import time
%pylab inline
# Load bitstream with custom overlay
soc = QickSoc()
soccfg = soc<jupyter_output><empty_output><jupyter_text>Hardware ConfigurationtProc channel 7   : DAC 229 CH3   Readout channel 0 : ADC 224 CH0<jupyter_code>class LoopbackProgram(AveragerProgram):
    def initialize(self):
        cfg=self.cfg   

        # Move value of A into tProc register
        self.regwi(0,1,self.cfg["A"])

        self.synci(200)  # give processor some time to configure pulses
    
    def body(self):
        # Do math: add value of B to the register value
        self.mathi(0, 1, 1, '+', self.cfg["B"])
        
        # Write the result to address 123
        self.memwi(0,1,123)<jupyter_output><empty_output><jupyter_text>Here we will add the value of   A  to the value of  B  using the tProc. We write the result to tProc memory address 123, and then read out that address value at the end of the program.<jupyter_code>config={"reps": 1, # fixed
        "A": 100,
        "B": -50
       }

prog =LoopbackProgram(soccfg, config)

soc.tproc.load_bin_program(prog.compile())
# Start tProc.
soc.tproc.start()
time.sleep(0.1)
result = soc.tproc.single_read(addr=123)
print("Result = ", result)<jupyter_output>Result =  50
{'fraction_non_alphanumeric': 0.08881789137380192, 'fraction_numerical': 0.0268370607028754, 'mean_word_length': 3.565597667638484, 'pattern_counts': {'":': 3, '<': 12, '<?xml version=': 0, '>': 12, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '316237', 'license': 'MIT', 'n_tokens_mistral': 536, 'n_tokens_neox': 492, 'n_words': 172, 'path': 'qick_demos/04_Reading_Math_Writing.ipynb', 'repo_name': 'meeg/qick', 'size': '1565'}