Line 46... |
Line 46... |
import argparse
|
import argparse
|
argListParser = argparse.ArgumentParser(description='SSBCC system builder');
|
argListParser = argparse.ArgumentParser(description='SSBCC system builder');
|
argListParser.add_argument('-D', metavar='symbol', type=str, action='append', help='Define symbol');
|
argListParser.add_argument('-D', metavar='symbol', type=str, action='append', help='Define symbol');
|
argListParser.add_argument('-G', metavar='parameter_name=value', type=str, action='append', help='Override parameter value');
|
argListParser.add_argument('-G', metavar='parameter_name=value', type=str, action='append', help='Override parameter value');
|
argListParser.add_argument('-I', metavar='include_dir', type=str, action='append', help='Add search directory for included files and peripherals');
|
argListParser.add_argument('-I', metavar='include_dir', type=str, action='append', help='Add search directory for included files and peripherals');
|
|
argListParser.add_argument('-M', metavar='macropath', action='append', help='Macro search path');
|
argListParser.add_argument('-P', metavar='peripheral_name[="parameters"]', type=str, action='append', help='Add peripheral');
|
argListParser.add_argument('-P', metavar='peripheral_name[="parameters"]', type=str, action='append', help='Add peripheral');
|
argListParser.add_argument('-o', metavar='outCoreName', type=str, help='output core name');
|
argListParser.add_argument('-o', metavar='outCoreName', type=str, help='output core name');
|
argListParser.add_argument('-q', action='store_true', help='quiet');
|
argListParser.add_argument('-q', action='store_true', help='quiet');
|
argListParser.add_argument('--define-clog2', action='store_true', help='define clog2 instead of using built-in $clog2');
|
argListParser.add_argument('--define-clog2', action='store_true', help='define clog2 instead of using built-in $clog2');
|
argListParser.add_argument('--display-opcode', action='store_true', help='add 3-letter decode of opcode (for trace viewer)');
|
argListParser.add_argument('--display-opcode', action='store_true', help='add 3-letter decode of opcode (for trace viewer)');
|
|
argListParser.add_argument('--rand-instr-mem', action='store_true', help='fill unused instruction memory with random values');
|
|
argListParser.add_argument('--synth-instr-mem', type=str, help='synthesis constraint for instruction memory');
|
argListParser.add_argument('--verilator-tracing-on', action='store_true', help='show all signals in verilator waveform files');
|
argListParser.add_argument('--verilator-tracing-on', action='store_true', help='show all signals in verilator waveform files');
|
argListParser.add_argument('filename', metavar='filename', type=validateFile, help='SSBCC configuration file');
|
argListParser.add_argument('filename', metavar='filename', type=validateFile, help='SSBCC configuration file');
|
argList = argListParser.parse_args();
|
argList = argListParser.parse_args();
|
|
|
#
|
#
|
Line 62... |
Line 65... |
#
|
#
|
|
|
config = SSBCCconfig();
|
config = SSBCCconfig();
|
|
|
config.Set('define_clog2',argList.define_clog2);
|
config.Set('define_clog2',argList.define_clog2);
|
|
config.Set('rand_instr_mem',argList.rand_instr_mem);
|
config.Set('verilator_tracing_on',argList.verilator_tracing_on);
|
config.Set('verilator_tracing_on',argList.verilator_tracing_on);
|
|
|
if argList.display_opcode:
|
if argList.display_opcode:
|
config.functions['display_opcode'] = True;
|
config.functions['display_opcode'] = True;
|
|
|
if argList.D:
|
if argList.D:
|
for symbol in argList.D:
|
for symbol in argList.D:
|
config.AddSymbol(symbol);
|
config.AddSymbol(symbol);
|
|
|
|
if argList.I:
|
|
for pathString in argList.I:
|
|
if not os.path.isdir(pathString):
|
|
raise SSBCCException('Bad path string: "%s"' % pathString);
|
|
config.AppendIncludePath(pathString);
|
|
config.InsertPeripheralPath(pathString);
|
|
|
if argList.o:
|
if argList.o:
|
config.Set('outCoreName',argList.o);
|
config.Set('outCoreName',argList.o);
|
else:
|
else:
|
config.Set('outCoreName',os.path.splitext(os.path.basename(argList.filename.name))[0]);
|
config.Set('outCoreName',os.path.splitext(os.path.basename(argList.filename.name))[0]);
|
|
|
|
if argList.synth_instr_mem:
|
|
config.Set('synth_instr_mem',argList.synth_instr_mem);
|
|
else:
|
|
config.Set('synth_instr_mem',None);
|
|
|
#
|
#
|
# Read the configuration file into a line-by-line buffer.
|
# Read the configuration file into a line-by-line buffer.
|
|
# Note: argList.filename is a file handle, so no paths will be searched by
|
|
# LoadFile. This is ensured by setting config to None.
|
#
|
#
|
|
|
filename = argList.filename.name;
|
filename = argList.filename.name;
|
configList = LoadFile(argList.filename);
|
configList = LoadFile(argList.filename,None);
|
ifstack = list();
|
ifstack = list();
|
|
|
configListStack = list();
|
configListStack = list();
|
|
|
#
|
#
|
Line 147... |
Line 165... |
cmd = re.findall(r'\s*\.INCLUDE\s+(\S+)\s*$',line);
|
cmd = re.findall(r'\s*\.INCLUDE\s+(\S+)\s*$',line);
|
if not cmd:
|
if not cmd:
|
raise SSBCCException('Malformed ".INCLUDE" configuration command on %s' % loc);
|
raise SSBCCException('Malformed ".INCLUDE" configuration command on %s' % loc);
|
configListStack.append((filename,configList,ifstack,));
|
configListStack.append((filename,configList,ifstack,));
|
filename = cmd[0];
|
filename = cmd[0];
|
configList = LoadFile(filename);
|
configList = LoadFile(filename,config);
|
ifstack = list();
|
ifstack = list();
|
# Consume configuration commands disabled by conditionals
|
# Consume configuration commands disabled by conditionals
|
elif ifstack and not ifstack[-1]:
|
elif ifstack and not ifstack[-1]:
|
pass;
|
pass;
|
# ARCHITECTURE
|
# ARCHITECTURE
|
Line 273... |
Line 291... |
raise SSBCCException('Malformed "SRAM_WIDTH" configuration command %s: "%s"' % (loc,line,));
|
raise SSBCCException('Malformed "SRAM_WIDTH" configuration command %s: "%s"' % (loc,line,));
|
config.Set('sram_width',int(cmd[0]));
|
config.Set('sram_width',int(cmd[0]));
|
# USER_HEADER
|
# USER_HEADER
|
elif re.match(r'\s*USER_HEADER\b',line):
|
elif re.match(r'\s*USER_HEADER\b',line):
|
user_header_done = False;
|
user_header_done = False;
|
while (line,ixLine) in configList:
|
while configList:
|
if re.match(r'\s*END_USER_HEADER\s',line):
|
(line,ixLine) = configList.pop(0);
|
|
if re.match(r'\s*END_USER_HEADER\b',line):
|
user_header_done = True;
|
user_header_done = True;
|
break;
|
break;
|
user_header.append(line);
|
user_header.append(line);
|
if not user_header_done:
|
if not user_header_done:
|
raise SSBCCException('No "END_USER_HEADER" found for "USER_HEADER" at %s' % loc);
|
raise SSBCCException('No "END_USER_HEADER" found for "USER_HEADER" at %s' % loc);
|
Line 301... |
Line 320... |
raise SSBCCException('Malformed parameter specification: "%s"' % parameter);
|
raise SSBCCException('Malformed parameter specification: "%s"' % parameter);
|
cmd = re.findall(r'([LG]_\w+)=(\S+)',parameter);
|
cmd = re.findall(r'([LG]_\w+)=(\S+)',parameter);
|
cmd = cmd[0];
|
cmd = cmd[0];
|
config.OverrideParameter(cmd[0],cmd[1]);
|
config.OverrideParameter(cmd[0],cmd[1]);
|
|
|
if argList.I:
|
|
for pathString in argList.I:
|
|
if not os.path.isdir(pathString):
|
|
raise SSBCCException('Bad path string: "%s"' % pathString);
|
|
config.InsertPeripheralPath(pathString);
|
|
|
|
#
|
#
|
# Append peripherals from command-line.
|
# Append peripherals from command-line.
|
#
|
#
|
|
|
if argList.P:
|
if argList.P:
|
Line 380... |
Line 393... |
for signalNameLength in config.SignalLengthList():
|
for signalNameLength in config.SignalLengthList():
|
cmd += (' -S %s=%d' % signalNameLength);
|
cmd += (' -S %s=%d' % signalNameLength);
|
cmd += ' -o ' + assemblerOutput;
|
cmd += ' -o ' + assemblerOutput;
|
for stack_name in ('data_stack','return_stack',):
|
for stack_name in ('data_stack','return_stack',):
|
cmd += ' -s %s=%d' % (stack_name,config.config[stack_name],);
|
cmd += ' -s %s=%d' % (stack_name,config.config[stack_name],);
|
cmd += ' -L %s/%s' % (sys.path[0], 'lib/9x8');
|
cmd += ' -L %s' % os.path.join(sys.path[0],'lib','9x8');
|
|
if argList.M:
|
|
for path in argList.M:
|
|
cmd += ' -M %s' % path;
|
|
cmd += ' -M %s' % os.path.join(sys.path[0],'macros','9x8');
|
if argList.I:
|
if argList.I:
|
for pathString in argList.I:
|
for pathString in argList.I:
|
cmd += ' -L %s' % pathString;
|
cmd += ' -L %s' % pathString;
|
cmd += ' ' + compiler[1];
|
cmd += ' ' + compiler[1];
|
|
|