""" Simple Example using coreali to access a register model. Needs no h^ardware"""

# Import dependencies and compile register model with systemrdl-compiler
from systemrdl import RDLCompiler
import coreali 
import numpy as np
import os
from coreali import RegisterModel

rdlc = RDLCompiler()
rdlc.compile_file(os.path.dirname(__file__)+"/../systemrdl/logger.rdl")
root = rdlc.elaborate()

# Generate hierarchical register model 
rio = coreali.registerio.RegIoNoHW(np.zeros([256], np.uint8()))
logger = RegisterModel(root, rio)

# Use the generated register model
logger.Ctrl.read()
logger.LogMem.write(0,[1,2,3])
logger.LogMem.read()
logger.LogMem[1].write(0,[11,12,13])
print(logger)

[((10, 7, 10, 20), 'systemrdl.RDLCompiler', 'RDLCompiler', ({}, {}), '()', False, 'from systemrdl import RDLCompiler\n'), ((16, 9, 16, 33), 'coreali.RegisterModel', 'RegisterModel', ({(16, 23, 16, 27): 'root', (16, 29, 16, 32): 'rio'}, {}), '(root, rio)', False, 'from coreali import RegisterModel\n'), ((11, 18, 11, 43), 'os.path.dirname', 'os.path.dirname', ({(11, 34, 11, 42): '__file__'}, {}), '(__file__)', False, 'import os\n'), ((15, 51, 15, 61), 'numpy.uint8', 'np.uint8', ({}, {}), '()', True, 'import numpy as np\n')]