Commit aa6fd4fd authored by Tristan Gingold's avatar Tristan Gingold

wrtd: WIP for builder script

parent 1d53a5a4
import yaml
import argparse
import sys
def error(msg):
sys.stderr.write(msg + '\n')
sys.exit(1)
def parse(filename):
d = yaml.load(open(filename))
if 'wrtd-board' not in d:
error('YAML file must have the wrtd-board key')
return d['wrtd-board']
def build_mt_config(desc):
appid = desc['appid']
cpus = desc['cpus']
ncpus = len([ x for x in cpus if isinstance(x, int) ])
res = """
constant c_mt_config : t_mt_config :=
(
app_id => x"{:08x}",
cpu_count => {},
cpu_config => (""".format(
appid, ncpus)
# Be sure that cpus are defined from 0 to N-1.
for i in range(ncpus):
cpu = desc['cpus'].get(i, None)
if cpu == None:
error('No definition for cpu {}'.format(i))
res += """
{} => (
memsize => {},
hmq_config => (""".format(
i, cpu['memsize'] * 1024 // 4)
hmq = cpu.get('hmq', None)
if hmq is not None:
res += """
slot_count => 1,
slot_config => (
0 => (
entries_bits => {},
width_bits => 7,
header_bits => 2,
endpoint_id => x"0000_0000",
enable_config_space => FALSE),""".format(
hmq['log_entries'])
res += """
others => c_DUMMY_MT_MQUEUE_SLOT)),
rmq_config => ("""
rmq = cpu.get('rmq', None)
if rmq is not None:
res += """
slot_count => 1,
slot_config => (
0 => (
entries_bits => {},
width_bits => 7,
header_bits => 4,
endpoint_id => x"0000_0000",
enable_config_space => TRUE),""".format(
rmq['log_entries'])
res += """
others => c_DUMMY_MT_MQUEUE_SLOT))),"""
res += """
others => (
0, c_MT_DEFAULT_MQUEUE_CONFIG, c_MT_DEFAULT_MQUEUE_CONFIG)),
shared_mem_size => {}
);""".format(cpus['shared_memsize'] * 1024 // 4)
return res
def main():
aparser = argparse.ArgumentParser(description='wrtd config generator')
aparser.add_argument('filename', help='YAML description file')
args = aparser.parse_args()
desc = parse(args.filename)
mt_config = build_mt_config(desc)
print(mt_config)
if __name__ == '__main__':
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment