forked from tudortimi/rgen
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ipxact2uvm.py
executable file
·37 lines (27 loc) · 1.07 KB
/
ipxact2uvm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/env python2.7
import sys
sys.path.append('ipyxact')
import argparse
from ipyxact.ipyxact import Component
from mako.lookup import TemplateLookup
from mako.template import Template
from mako.runtime import Context
parser = argparse.ArgumentParser(description='Generate registers for UVM')
parser.add_argument('xml_path', metavar='<xml>', type=file, nargs=1,
help='path to IP-XACT XML file to be read')
args = parser.parse_args()
component = Component()
component.load(args.xml_path[0].name)
addressBlock = component.memoryMaps.memoryMap[0].addressBlock[0]
#busByteWidth = component.memoryMaps.memoryMap[0].addressBlock[0].width / 8
fileName = component.name.lower() + '_regs.svh'
lookup = TemplateLookup('templates')
buffer = open(fileName, 'w')
for reg in addressBlock.register:
template = lookup.get_template('uvm_reg.mako')
ctx = Context(buffer, reg=reg)
template.render_context(ctx)
buffer.write('\n\n\n\n')
template = lookup.get_template('uvm_reg_block.mako')
ctx = Context(buffer, addressBlock=addressBlock)
template.render_context(ctx)