pynq.lib.pynqmicroblaze.pynqmicroblaze Module

class pynq.lib.pynqmicroblaze.pynqmicroblaze.MBInterruptEvent(intr_pin, intr_ack_gpio)[source]

Bases: object

The class provides and asyncio Event-like interface to the interrupt subsystem for a Microblaze. The event is set by raising an interrupt and cleared using the clear function.

Typical use is to call clear prior to sending a request to the Microblaze and waiting in a loop until the response is received. This order of operations will avoid race conditions between the Microblaze and the host code.

clear()[source]

Clear the interrupt and reset the event. Resetting the event should be done before sending a request that will be acknowledged interrupts.

wait()[source]

Coroutine to wait until the event is set by an interrupt.

class pynq.lib.pynqmicroblaze.pynqmicroblaze.MicroblazeHierarchy(description, mbtype='Unknown')[source]

Bases: pynq.overlay.DefaultHierarchy

Hierarchy driver for the microblaze subsystem.

Enables the user to load programs on to the microblaze. All function calls and member accesses are delegated to the loaded program.

static checkhierarchy(description)[source]

Function to check if the driver matches a particular hierarchy

This function should be redefined in derived classes to return True if the description matches what is expected by the driver. The default implementation always returns False so that drivers that forget don’t get loaded for hierarchies they don’t expect.

mbtype

The defined type of the microblaze subsystem. Used by driver programs to limit what microblaze subsystems the program is run on.

class pynq.lib.pynqmicroblaze.pynqmicroblaze.PynqMicroblaze(mb_info, mb_program, force=False)[source]

Bases: object

This class controls the active Microblaze instances in the system.

ip_name

The name of the IP corresponding to the Microblaze.

Type:str
rst_name

The name of the reset pin for the Microblaze.

Type:str
mb_program

The absolute path of the Microblaze program.

Type:str
state

The status (IDLE, RUNNING, or STOPPED) of the Microblaze.

Type:str
reset_pin

The reset pin associated with the Microblaze.

Type:GPIO
mmio

The MMIO instance associated with the Microblaze.

Type:MMIO
interrupt

An asyncio.Event-like class for waiting on and clearing interrupts.

Type:Event
program()[source]

This method programs the Microblaze.

This method is called in __init__(); it can also be called after that. It uses the attribute self.mb_program to program the Microblaze.

Returns:
Return type:None
read(offset, length=1)[source]

This method reads data from the shared memory of Microblaze.

Parameters:
  • offset (int) – The beginning offset where data are read from.
  • length (int) – The number of data (32-bit int) to be read.
Returns:

An int of a list of data read from the shared memory.

Return type:

int/list

reset()[source]

Reset the Microblaze to stop it from running.

This method will update the status of the Microblaze.

Returns:
Return type:None
run()[source]

Start the Microblaze to run program loaded.

This method will update the status of the Microblaze.

Returns:
Return type:None
write(offset, data)[source]

This method write data into the shared memory of the Microblaze.

Parameters:
  • offset (int) – The beginning offset where data are written into.
  • data (int/list) – A list of 32b words to be written.
Returns:

Return type:

None

pynq.lib.pynqmicroblaze.compile Module

class pynq.lib.pynqmicroblaze.compile.MicroblazeProgram(mb_info, program_text, bsp=None)[source]

Bases: pynq.lib.pynqmicroblaze.pynqmicroblaze.PynqMicroblaze

pynq.lib.pynqmicroblaze.compile.checkmodule(name, mb_info)[source]
pynq.lib.pynqmicroblaze.compile.dependencies(source, bsp)[source]
pynq.lib.pynqmicroblaze.compile.preprocess(source, bsp=None, mb_info=None)[source]
pynq.lib.pynqmicroblaze.compile.recursive_dependencies(source, bsp, current_set=None)[source]

pynq.lib.pynqmicroblaze.rpc Module

class pynq.lib.pynqmicroblaze.rpc.ConstCharPointerWrapper(type_)[source]

Bases: pynq.lib.pynqmicroblaze.rpc.ConstPointerWrapper

Wrapper for const char*s which accepts Python strings and makes sure they are NULL-terminated

param_encode(old_val)[source]
class pynq.lib.pynqmicroblaze.rpc.ConstPointerWrapper(type_, struct_string)[source]

Bases: object

Wrapper for const T pointers, transfers data in only one direction.

param_decode(old_val, stream)[source]
param_encode(old_val)[source]
post_argument(name)[source]
pre_argument(name)[source]
return_decode(stream)[source]
class pynq.lib.pynqmicroblaze.rpc.FuncAdapter(decl, typedefs)[source]

Bases: object

Provides the C and Python interfaces for a function declaration

return_interface

The type wrapper for the return type

Type:TypeWrapper
arg_interfaces

An array of type wrappers for the arguments

Type:[TypeWrapper]
call_ast

Syntax tree for the wrapped function call

Type:pycparser.c_ast
pack_args(*args)[source]

Create a bytes of the provided arguments

receive_response(stream, *args)[source]

Reads the response stream, updates arguments and returns the value of the function call if applicable

class pynq.lib.pynqmicroblaze.rpc.FuncDefVisitor[source]

Bases: pycparser.c_ast.NodeVisitor

Primary visitor that parses out function definitions, typedes and enumerations from a syntax tree

visit_Enum(node)[source]
visit_FuncDecl(node)[source]
visit_FuncDef(node)[source]
visit_Typedef(node)[source]
exception pynq.lib.pynqmicroblaze.rpc.MicroblazeError[source]

Bases: Exception

class pynq.lib.pynqmicroblaze.rpc.MicroblazeFunction(stream, index, function, return_type)[source]

Bases: object

Calls a specific function

call(*args)[source]
call_async(*args)[source]
class pynq.lib.pynqmicroblaze.rpc.MicroblazeLibrary(iop, libraries)[source]

Bases: pynq.lib.pynqmicroblaze.rpc.MicroblazeRPC

Provides simple Python-only access to a set of Microblaze libraries.

The members of this class are determined by the libraries chosen and can determined either by using dir on the instance or the ? operator inside of IPython

class pynq.lib.pynqmicroblaze.rpc.MicroblazeRPC(iop, program_text)[source]

Bases: object

Provides a python interface to the Microblaze based on an RPC mechanism.

The attributes of the class are generated dynamically from the typedefs, enumerations and functions given in the provided source.

Functions are added as methods, the values in enumerations are added as constants to the class and types are added as classes.

release()[source]

Alias for reset()

reset()[source]

Reset and free the microblaze for use by other programs

class pynq.lib.pynqmicroblaze.rpc.ParsedEnum[source]

Bases: object

Holds the values of an enum from the C source

class pynq.lib.pynqmicroblaze.rpc.PointerWrapper(type_, struct_string)[source]

Bases: object

Wrapper for non-const T pointers that retrieves any data modified by the called function.

param_decode(old_val, stream)[source]
param_encode(old_val)[source]
post_argument(name)[source]
pre_argument(name)[source]
return_decode(stream)[source]
class pynq.lib.pynqmicroblaze.rpc.PrimitiveWrapper(struct_string, type_)[source]

Bases: object

Wrapper for C primitives that can be represented by a single Struct string.

param_decode(old_val, stream)[source]
param_encode(old_val)[source]
post_argument(name)[source]
pre_argument(name)[source]
return_decode(stream)[source]
class pynq.lib.pynqmicroblaze.rpc.PyBoolWrapper(type_)[source]

Bases: pynq.lib.pynqmicroblaze.rpc.PrimitiveWrapper

return_decode(stream)[source]
class pynq.lib.pynqmicroblaze.rpc.PyFloatWrapper(type_)[source]

Bases: pynq.lib.pynqmicroblaze.rpc.PrimitiveWrapper

return_decode(stream)[source]
class pynq.lib.pynqmicroblaze.rpc.PyIntWrapper(type_)[source]

Bases: pynq.lib.pynqmicroblaze.rpc.PrimitiveWrapper

return_decode(stream)[source]
class pynq.lib.pynqmicroblaze.rpc.PyVoidWrapper(type_)[source]

Bases: pynq.lib.pynqmicroblaze.rpc.PrimitiveWrapper

return_decode(stream)[source]
class pynq.lib.pynqmicroblaze.rpc.VoidPointerWrapper(type_)[source]

Bases: object

Wrapper for a void* pointer that will refer to a physically contiguous chunk of memory.

param_decode(old_val, stream)[source]
param_encode(old_val)[source]
post_argument(name)[source]
pre_argument(name)[source]
return_decode(stream)[source]
class pynq.lib.pynqmicroblaze.rpc.VoidWrapper[source]

Bases: object

Wraps void - only valid for return types

param_decode(old_val, stream)[source]
param_encode(old_val)[source]
post_argument(name)[source]
pre_argument(name)[source]
return_decode(stream)[source]

pynq.lib.pynqmicroblaze.magic Module

class pynq.lib.pynqmicroblaze.magic.MicroblazeMagics(shell=None, **kwargs)[source]

Bases: IPython.core.magic.Magics

magics = {'cell': {'microblaze': 'microblaze'}, 'line': {}}
microblaze(line, cell)[source]
name2obj(name)[source]
registered = True

pynq.lib.pynqmicroblaze.streams Module

class pynq.lib.pynqmicroblaze.streams.InterruptMBStream(iop, read_offset=62464, write_offset=61440)[source]

Bases: pynq.lib.pynqmicroblaze.streams.SimpleMBStream

read_async()[source]
wait_for_data_async()[source]
class pynq.lib.pynqmicroblaze.streams.SimpleMBChannel(buffer, offset=0, length=0)[source]

Bases: object

buffer_space()[source]
bytes_available()[source]
read(n=-1)[source]
read_upto(n=-1)[source]
write(b)[source]
class pynq.lib.pynqmicroblaze.streams.SimpleMBStream(iop, read_offset=62464, write_offset=61440)[source]

Bases: object

buffer_space()[source]
bytes_available()[source]
read(n=-1)[source]
read_byte()[source]
read_float()[source]
read_int16()[source]
read_int32()[source]
read_string()[source]
read_uint16()[source]
read_uint32()[source]
write(b)[source]
write_address(p, adjust=True)[source]
write_byte(b)[source]
write_float(f)[source]
write_int16(i)[source]
write_int32(i)[source]
write_string(s)[source]
write_uint16(u)[source]
write_uint32(u)[source]

pynq.lib.pynqmicroblaze.bsp Module

class pynq.lib.pynqmicroblaze.bsp.BSPInstance(root)[source]

Bases: object

class pynq.lib.pynqmicroblaze.bsp.Module(root)[source]

Bases: object

pynq.lib.pynqmicroblaze.bsp.add_bsp(directory)[source]
pynq.lib.pynqmicroblaze.bsp.add_module_path(directory)[source]