Displaying a Variable's Value
To output a variable's value, use the print statement. This code:
# Declare a variable
design_name = "pt_demo"
# Inspecting a single variable
print("Design: " + design_name)
# Another way of inspecting a single variable
print("Design: {}".format(design_name))
# Yet another way of inspecting a single variable
print(f"Design: {design_name}")
Prints this output to the Python console:
Design: pt_demo
Design: pt_demo
Design: pt_demo
If you want to print a map, the built-in Python function, pprint(),
nicely prints out the content. This code:
# Declare a dict of pin name and its information
pin_data = {
"resetn":"Global control reset pin",
"Oclk":"Output clock pin name"
}
# Inspecting a dict
import pprint # This can be done at the top as well
pprint.pprint(pin_data)
Prints this result to the Python
console:
{'Oclk': 'Output clock pin name', 'resetn': 'Global control reset pin'}