wzab / agwb

Support for automatic address map generation and address decoding logic for Wishbone connected hierachical systems
12 stars 6 forks source link

C++ backend - how to enable run-time resolution of addresses #30

Open wzab opened 3 years ago

wzab commented 3 years ago

Theoretically the current header-based backend for C may be reused for C++. The only thing that should be improved is wrapping the inconvenient bitfield-access macros with elegant C++ methods.

However, when connecting the AGWB-described control-tree to a C++ software it is likely that the end user wants to avoid recompilation of the software whenever the hardware is modified. Therefore a representation capable of resolving the addresses at runtime is needed.

My first idea is to imitate the behaviour or the current Python backend. The AGWB output should provide the set of classes reflecting the addressable objects:

The convenient feature of the Python backend is that the hierarchy of the control-tree is fully reflected by the hierarchy of objects. Of course with run-time resolved description we can't dereference the objects like in Python, by including the names of objects in the code:

blockA.blocksB[nrb].blocksC[nrc].regsA[nrA].bitfieldA

In case if certain node in the control-tree hierarchy is supposed to be often used for looking up its children, we should be able to keep a reference to it. For run-time dereferencing we should pass the above path as the argument to the e.g. resolve function of the addressable object from which we start looking for a child. The resolve function takes two arguments: offset and path.

An important issue is how we can efficiently handle dynamic indexes when accessing an object. At the moment the only way to do that is to get the reference to the vector object (blockA.blocksB in the above example), then use its [] method to get the reference to the selected element, and repeat the above at each index.

Another possibility is to use the approach implemented in the Forth backend. We should:

Whenever "[ index ]" is found in the path, we consume one index and locate the appropriate element in the vector, and pass the rest of the list of indices to the resolve function of that element.

This is the first description of the problem and possible solution. Any comments and suggestions are appreciated.