Data Types

The API uses simple variables and sequence-based and map-based data structures.

Simple Variables

Simple variables are strings or numbers like integers and floating-point.

Sequences

Sequence-based structures are a collection of a variable's instances/objects. You access the members of the structure by indexing, and you can iterate (loop through) the structure. Python starts its index at zero. The API mostly uses an array-like type, which is called a list in Python.

This code:

# Declare a list of pin names
pin_names = ["resetn", "Oclk"]

# Get a single pin
clkpin_name = pin_names[1]
print("Clk pin: " + clkpin_name)

# Iterate through all
for pin in pin_names:
    print("Pin name: " + pin)
Prints this result in the Python console:
Clk pin: Oclk
Pin name: resetn
Pin name: Oclk

Maps

A map is a collection of key-value pairs. The API typically uses the dictionary type, which is called a dict in Python.

This code:

# Declare a dict of pin name and its information
pin_data = {
    "resetn":"Global control reset pin",
    "Oclk":"Output clock pin name"
}

# Get a single pin info
clk_pin_info = pin_data.get("Oclk", None)
print("Clk pin info: " + clk_pin_info)

# Iterate through all
for name, info in pin_data.items():
    print("Pin name: " + name)
    print("Pin info: " + info)
Prints this result to the Python console:
Clk pin info: Output clock pin name
Pin name: resetn
Pin info: Global control reset pin
Pin name: Oclk
Pin info: Output clock pin name