OpenCores
URL https://opencores.org/ocsvn/ssbcc/ssbcc/trunk

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [ssbcc] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sinclairrf
#!/usr/bin/python2.7
2
 
3
################################################################################
4
#
5
# Copyright 2012, Sinclair R.F., Inc.
6
#
7
# Build an SSBCC system.
8
#
9
################################################################################
10
 
11
import math
12
import os
13
import re
14
import sys
15
import tempfile
16
 
17
from ssbccUtil import *;
18
from ssbccConfig import SSBCCconfig;
19
 
20
################################################################################
21
#
22
# Surround the program with a try ... except clause
23
#
24
################################################################################
25
 
26
try:
27
 
28
  ################################################################################
29
  #
30
  # Parse the command line arguments
31
  #
32
  ################################################################################
33
 
34
  #
35
  # Construct the command-line argument list parser
36
  #
37
 
38
  def validateFile(filename):
39
    if filename == '-':
40
      filename = '/dev/stdin';
41
    try:
42
      return file(filename,'r');
43
    except:
44
      raise SSBCCException('Error opening "%s"' % filename);
45
 
46
  import argparse
47
  argListParser = argparse.ArgumentParser(description='SSBCC system builder');
48
  argListParser.add_argument('-D', metavar='symbol', type=str, action='append', help='Define symbol');
49
  argListParser.add_argument('-G', metavar='parameter_name=value', type=str, action='append', help='Override parameter value');
50
  argListParser.add_argument('-I', metavar='include_dir', type=str, action='append', help='Add search directory for included files and peripherals');
51
  argListParser.add_argument('-P', metavar='peripheral_name[="parameters"]', type=str, action='append', help='Add peripheral');
52
  argListParser.add_argument('-o', metavar='outCoreName', type=str, help='output core name');
53
  argListParser.add_argument('-q', action='store_true', help='quiet');
54
  argListParser.add_argument('--define-clog2', action='store_true', help='define clog2 instead of using built-in $clog2');
55
  argListParser.add_argument('--display-opcode', action='store_true', help='add 3-letter decode of opcode (for trace viewer)');
56
  argListParser.add_argument('--verilator-tracing-on', action='store_true', help='show all signals in verilator waveform files');
57
  argListParser.add_argument('filename', metavar='filename', type=validateFile, help='SSBCC configuration file');
58
  argList = argListParser.parse_args();
59
 
60
  #
61
  # Set the command-line dependent configuration parameters.
62
  #
63
 
64
  config = SSBCCconfig();
65
 
66
  config.Set('define_clog2',argList.define_clog2);
67
  config.Set('verilator_tracing_on',argList.verilator_tracing_on);
68
 
69
  if argList.display_opcode:
70
    config.functions['display_opcode'] = True;
71
 
72
  if argList.D:
73
    for symbol in argList.D:
74
      config.AddSymbol(symbol);
75
 
76
  if argList.o:
77
    config.Set('outCoreName',argList.o);
78
  else:
79
    config.Set('outCoreName',os.path.splitext(os.path.basename(argList.filename.name))[0]);
80
 
81
  #
82
  # Read the configuration file into a line-by-line buffer.
83
  #
84
 
85
  filename = argList.filename.name;
86
  configList = LoadFile(argList.filename);
87
  ifstack = list();
88
 
89
  configListStack = list();
90
 
91
  #
92
  # Read the configuration file.
93
  #
94
 
95
  bufLine = "";
96
  compiler = [];
97
  user_header = list();
98
  while configList or configListStack:
99
    # If the current file has ended, then proceed to the next file.
100
    if not configList:
101
      if not len(bufLine) == 0:
102
        raise SSBCCException('Malformed configuration command at the end of %s' % filename);
103
      if ifstack:
104
        raise SSBCCException('%d unmatched conditional(s) at end of %s' % (len(ifstack),filename,));
105
      (filename,configList,ifstack) = configListStack.pop();
106
      continue;
107
    # Get the next line to process and its line number.
108
    (tmpLine,ixLine) = configList.pop(0);
109
    # Use the start line of a sequence of lines for error messages.
110
    if not bufLine:
111
      loc = '%s:%d' % (filename,ixLine,);
112
    # Merge continuation lines.
113
    bufLine += tmpLine;
114
    if bufLine and bufLine[-1] == '\\':
115
      bufLine = bufLine[:-1];
116
      continue;
117
    line = bufLine;
118
    bufLine = "";
119
    # Reject blank and comment lines
120
    if re.match(r'\s*(#.*)?$',line):
121
      pass;
122
    # .ELSE
123
    elif re.match(r'\s*\.ELSE\b',line):
124
      if not ifstack:
125
        raise SSBCCException('unmatched ".ELSE" at %s' % loc);
126
      ifstack[-1] = not ifstack[-1];
127
    # .ENDIF
128
    elif re.match(r'\s*\.ENDIF\b',line):
129
      if not ifstack:
130
        raise SSBCCException('unmatched ".ENDIF" at %s' % loc);
131
      ifstack.pop();
132
    # .IFDEF conditional
133
    elif re.match(r'\s*\.IFDEF\b',line):
134
      cmd = re.findall(r'\s*\.IFDEF\s+(\w+)\s*$',line);
135
      if not cmd:
136
        raise SSBCCException('Malformed ".IFDEF" configuration command on %s' % loc);
137
      cmd = cmd[0];
138
      ifstack.append(config.IsSymbol(cmd));
139
    # .IFNDEF conditional
140
    elif re.match(r'\s*\.IFNDEF\b',line):
141
      cmd = re.findall(r'\s*\.IFNDEF\s+(\w+)\s*$',line);
142
      if not cmd:
143
        raise SSBCCException('Malformed ".IFNDEF" configuration command on %s' % loc);
144
      cmd = cmd[0];
145
      ifstack.append(not config.IsSymbol(cmd));
146
    elif re.match(r'\s*.INCLUDE\b',line):
147
      cmd = re.findall(r'\s*\.INCLUDE\s+(\S+)\s*$',line);
148
      if not cmd:
149
        raise SSBCCException('Malformed ".INCLUDE" configuration command on %s' % loc);
150
      configListStack.append((filename,configList,ifstack,));
151
      filename = cmd[0];
152
      configList = LoadFile(filename);
153
      ifstack = list();
154
    # Consume configuration commands disabled by conditionals
155
    elif ifstack and not ifstack[-1]:
156
      pass;
157
    # ARCHITECTURE
158
    elif re.match(r'\s*ARCHITECTURE\b',line):
159
      if config.Exists('architecture'):
160
        raise SSBCCException('ARCHITECTURE already specified before %s' % loc);
161
      cmd = re.findall(r'\s*ARCHITECTURE\s+(\S+)\s+(\S+)$',line);
162
      if not cmd:
163
        raise SSBCCException('Malformed ARCHITECTURE configuration command at %s: "%s"' % (loc,line,));
164
      cmd = cmd[0];
165
      config.Set('architecture',cmd[0]);
166
      config.Set('hdl',cmd[1]);
167
      config.Set('corepath',os.path.join(sys.path[0],config.Get('architecture')));
168
      if not os.path.isdir(config.Get('corepath')):
169
        raise SSBCCException('Architecture "%s" does not exist at %s' % (cmd,loc,));
170
      config.InsertPeripheralPath(os.path.join(config.Get('corepath'),'peripherals'));
171
      # TODO -- move these assignments into an object
172
      config.Set('data_width',8);
173
    # ASSEMBLY language for processor code
174
    elif re.match(r'\s*ASSEMBLY\b',line):
175
      cmd = re.findall(r'\s*ASSEMBLY\s+(\S.*)',line);
176
      compiler = ('asm',cmd[0],);
177
    # COMBINE
178
    elif re.match(r'\s*COMBINE\b',line):
179
      config.ProcessCombine(loc,line);
180
    # CONSTANTS
181
    elif re.match(r'\s*CONSTANT\b',line):
182
      if not config.Exists('architecture'):
183
        raise SSBCCException('"CONSTANT"s cannot be defined before the "ARCHITECTURE" is defined at %s' % loc);
184
      cmd = re.findall(r'\s*CONSTANT\s+(C_\w+)\s+(\w+)\s*$',line);
185
      if not cmd:
186
        raise SSBCCException('Malformed "CONSTANT" configuration command on %s: "%s"' % (loc,line,));
187
      cmd = cmd[0];
188
      config.AddConstant(cmd[0],cmd[1],loc);
189
    # DATA_STACK
190
    elif re.match(r'\s*DATA_STACK\b',line):
191
      if config.Exists('data_stack'):
192
        raise SSBCCException('DATA_STACK already defined before %s' % loc);
193
      cmd = re.findall(r'\s*DATA_STACK\s+([1-9]\d*)',line);
194
      if not cmd:
195
        raise SSBCCException('Malformed "DATA_STACK" configuration command on %s: "%s"' % (loc,line,));
196
      x = int(cmd[0]);
197
      if math.modf(math.log(x,2))[0] != 0:
198
        raise SSBCCException('DATA_STACK must be set to a power of 2, not %d, at %s' % (x,loc,));
199
      if x < 8:
200
        raise SSBCCException('DATA_STACK must be at least 8, not %d, at %s' % (x,loc,));
201
      config.Set('data_stack',int(cmd[0]));
202
    # INPORT
203
    elif re.match(r'\s*INPORT\b',line):
204
      if not config.Exists('architecture'):
205
        raise SSBCCException('"INPORT"s cannot be defined before the "ARCHITECTURE" is defined at %s' % loc);
206
      config.ProcessInport(loc,line);
207
    # INSTRUCTION
208
    elif re.match(r'\s*INSTRUCTION\b',line):
209
      if config.Exists('nInstructions'):
210
        raise SSBCCException('INSTRUCTION already specified before %s' % loc);
211
      cmd = re.findall(r'\s*INSTRUCTION\s+([1-9]\d*\*?[1-9]?\d*)\s*$',line);
212
      if not cmd:
213
        raise SSBCCException('Malformed "INSTRUCTION" configuration command at %s: "%s"' % (loc,line,));
214
      config.SetMemoryBlock('nInstructions',cmd[0],(loc,line,));
215
    # INVERT_RESET
216
    elif re.match(r'\s*INVERT_RESET\s*$',line):
217
      if (config.Exists('invertReset')):
218
        raise SSBCCException('INVERT_RESET already specified before %s' % loc);
219
      config.Set('invertReset',True);
220
    # LOCALPARM
221
    elif re.match(r'\s*LOCALPARAM\b',line):
222
      cmd = re.findall(r'\s*LOCALPARAM\s+(L_\w+)\s+(\S+)$',line);
223
      if (not cmd) or (len(cmd[0]) != 2):
224
        raise SSBCCException('Malformed LOCALPARAM configuration command at %s: "%s"' % (loc,line,));
225
      cmd = cmd[0];
226
      config.AddParameter(cmd[0],cmd[1],loc);
227
    # MEMORY
228
    elif re.match(r'\s*MEMORY\b',line):
229
      if not config.Exists('architecture'):
230
        raise SSBCCException('"MEMORY"s cannot be defined before the "ARCHITECTURE" is defined at %s' % loc);
231
      # TODO -- make the maximum number of memories architecture dependent
232
      if config.NMemories() >= 4:
233
        raise SSBCCException('Program is limited to 4 memories');
234
      cmd = re.findall(r'\s*MEMORY\s+(RAM|ROM)\s+([A-Za-z]\w*)\s+(\d+)\s*$',line);
235
      if (not cmd) or (len(cmd[0]) != 3):
236
        raise SSBCCException('Malformed MEMORY configuration command at %s: "%s"' % (loc,line,));
237
      config.AddMemory(cmd[0],loc);
238
    # OUTPORT
239
    elif re.match(r'\s*OUTPORT\b',line):
240
      if not config.Exists('architecture'):
241
        raise SSBCCException('"OUTPORT"s cannot be defined before the "ARCHITECTURE" is defined at %s' % loc);
242
      config.ProcessOutport(line,loc);
243
    # PARAMETER
244
    elif re.match(r'\s*PARAMETER\b',line):
245
      cmd = re.findall(r'\s*PARAMETER\s+(G_\w+)\s+(\S+)$',line);
246
      if (not cmd) or (len(cmd[0]) != 2):
247
        raise SSBCCException('Malformed PARAMETER configuration command at %s: "%s"' % (loc,line,));
248
      cmd = cmd[0];
249
      config.AddParameter(cmd[0],cmd[1],loc);
250
    # PERIPHERAL
251
    elif re.match(r'\s*PERIPHERAL\b',line):
252
      if not config.Exists('architecture'):
253
        raise SSBCCException('"PERIPHERAL"s cannot be defined before the "ARCHITECTURE" is defined at %s' % loc);
254
      config.ProcessPeripheral(loc,line);
255
    # PORTCOMMENT
256
    elif re.match(r'\s*PORTCOMMENT\b',line):
257
      cmd = re.findall(r'\s*PORTCOMMENT\s+(.*)',line);
258
      config.AddIO(cmd[0],0,'comment',loc);
259
    # RETURN_STACK
260
    elif re.match(r'\s*RETURN_STACK\b',line):
261
      if config.Exists('return_stack'):
262
        raise SSBCCException('RETURN_STACK already specified before %s' % loc);
263
      cmd = re.findall(r'\s*RETURN_STACK\s+([1-9]\d*)',line);
264
      if not cmd:
265
        raise SSBCCException('Malformed "RETURN_STACK" configuration command at %s: "%s"' % (loc,line,));
266
      config.Set('return_stack',int(cmd[0]));
267
    # SRAM_WIDTH
268
    elif re.match(r'\s*SRAM_WIDTH\b',line):
269
      if config.Exists('sram_width'):
270
        raise SSBCCException('SRAM_WIDTH already specified before %s' % loc);
271
      cmd = re.findall(r'\s*SRAM_WIDTH\s+([1-9]\d*)',line);
272
      if not cmd:
273
        raise SSBCCException('Malformed "SRAM_WIDTH" configuration command %s: "%s"' % (loc,line,));
274
      config.Set('sram_width',int(cmd[0]));
275
    # USER_HEADER
276
    elif re.match(r'\s*USER_HEADER\b',line):
277
      user_header_done = False;
278
      while (line,ixLine) in configList:
279
        if re.match(r'\s*END_USER_HEADER\s',line):
280
          user_header_done = True;
281
          break;
282
        user_header.append(line);
283
      if not user_header_done:
284
        raise SSBCCException('No "END_USER_HEADER" found for "USER_HEADER" at %s' % loc);
285
    # error
286
    else:
287
      raise SSBCCException('Unrecognized configuration command at %s: "%s"' % (loc,line,));
288
  if bufLine:
289
    raise SSBCCException('Malformed last line(s): "%s"' % bufLine);
290
 
291
  if ifstack:
292
    raise SSBCCException('%d unmatched conditional(s) at end of %s' % (len(ifstack),filename,));
293
 
294
  #
295
  # Incorporate command-line specified parameter and localparam values.
296
  #
297
 
298
  if argList.G:
299
    for parameter in argList.G:
300
      if not re.match(r'[LG]_\w+=\S+$',parameter):
301
        raise SSBCCException('Malformed parameter specification: "%s"' % parameter);
302
      cmd = re.findall(r'([LG]_\w+)=(\S+)',parameter);
303
      cmd = cmd[0];
304
      config.OverrideParameter(cmd[0],cmd[1]);
305
 
306
  if argList.I:
307
    for pathString in argList.I:
308
      if not os.path.isdir(pathString):
309
        raise SSBCCException('Bad path string:  "%s"' % pathString);
310
      config.InsertPeripheralPath(pathString);
311
 
312
  #
313
  # Append peripherals from command-line.
314
  #
315
 
316
  if argList.P:
317
    for peripheral in argList.P:
318
      config.ProcessPeripheral(-1,'PERIPHERAL '+peripheral);
319
 
320
  #
321
  # Set unspecified default values
322
  #
323
 
324
  if not config.Exists('sram_width'):
325
    config.Set('sram_width',9);
326
  if not config.Exists('invertReset'):
327
    config.Set('invertReset',False);
328
 
329
  #
330
  # end-of-file processing
331
  #
332
 
333
  if not config.Exists('architecture'):
334
    raise SSBCCException('Required ARCHITECTURE configuration command missing');
335
  if not config.Exists('data_stack'):
336
    raise SSBCCException('Required DATA_STACK configuration command missing');
337
  if not config.Exists('nInstructions'):
338
    raise SSBCCException('Required INSTRUCTION configuration command missing');
339
  if not config.Exists('return_stack'):
340
    raise SSBCCException('Required RETURN_STACK configuration command missing');
341
 
342
  # Ensure reasonable values
343
  if config.Get('nInstructions')['length'] > 2**13:
344
    raise SSBCCException('Instruction space cannot exceed %d at %s: "%s"' % (2**13,loc,line,));
345
 
346
  # Add memories that are not combined into singleton entries in the "combined"
347
  # list and complete the address range assignments.
348
  config.CompleteCombines();
349
 
350
  ################################################################################
351
  #
352
  # Compile the processor code and read the tables it generated.
353
  #
354
  ################################################################################
355
 
356
  # Generate peripheral libraries (if any).
357
  for ix in range(len(config.peripheral)):
358
    config.peripheral[ix].GenAssembly(config);
359
 
360
  # Compute the file name to store the assembler output
361
  assemblerOutput = os.path.splitext(argList.filename.name)[0]+'.9x8-meta'
362
 
363
  # Compute the command to invoke the compiler.
364
  if not compiler:
365
    raise SSBCCException('ASSEMBLY configuration command is missing');
366
  cmd = os.path.join(config.Get('corepath'), compiler[0]);
367
  for name in config.constants:
368
    cmd += (' -C %s=%s' % (name,config.constants[name],));
369
  for ix in range(len(config.parameters)):
370
    cmd += (' -G %s' % config.parameters[ix][0]);
371
  for ix in range(config.NInports()):
372
    cmd += (' -I %s=%d' % (config.inports[ix][0],ix));
373
  for ix in range(config.NOutports()):
374
    if config.IsStrobeOnlyOutport(config.outports[ix]):
375
      cmd += (' -R %s=%d' % (config.outports[ix][0],ix));
376
    else:
377
      cmd += (' -O %s=%d' % (config.outports[ix][0],ix));
378
  for memNameLength in config.MemoryNameLengthList():
379
    cmd += (' -S %s=%d' % memNameLength);
380
  for signalNameLength in config.SignalLengthList():
381
    cmd += (' -S %s=%d' % signalNameLength);
382
  cmd += ' -o ' + assemblerOutput;
383
  for stack_name in ('data_stack','return_stack',):
384
    cmd += ' -s %s=%d' % (stack_name,config.config[stack_name],);
385
  cmd += ' -L %s/%s' % (sys.path[0], 'lib/9x8');
386
  if argList.I:
387
    for pathString in argList.I:
388
      cmd += ' -L %s' % pathString;
389
  cmd += ' ' + compiler[1];
390
 
391
  # Invoke the compiler and exit if it failed.
392
  if not argList.q:
393
    print 'Invoking the assember with the following command:  ' + cmd;
394
  cmdStatus = os.system(cmd);
395
  if cmdStatus != 0:
396
    raise SSBCCException('Running the assembler');
397
 
398
  # Read the assembler output tables.
399
  fpAssemberOutput = open(assemblerOutput,'r');
400
  ixLine = 0;
401
  programBody = list();
402
  programBodyLength = 0;
403
  for line in fpAssemberOutput:
404
    ixLine = ixLine + 1;
405
    # blank line
406
    if re.match('^\s*$',line):
407
      continue;
408
    # memory type, name, index, and length
409
    elif re.match(':memory',line):
410
      cmd = re.findall(':memory (\S+) (\S+) (\S+) (\S+)',line);
411
      cmd = cmd[0];
412
      memName = cmd[1];
413
      if not config.IsMemory(memName):
414
        raise SSBCCException('%s "%s" not declared in %s' % (cmd[0],memName,argList.filename,));
415
      memParam = config.GetMemoryParameters(memName);
416
      if cmd[0] != memParam['type']:
417
        raise SSBCCException('Type of memory "%s" is inconsistent' % memName);
418
      if int(cmd[3]) > memParam['maxLength']:
419
        raise SSBCCException('Length of memory "%s" is %s which exceeds limit of %d' % (memName,cmd[3],memParam['maxLength'],));
420
      memoryBody = list();
421
      for line in fpAssemberOutput:
422
        ixLine = ixLine + 1;
423
        if len(line) > 1:
424
          memoryBody.append(line)
425
        else:
426
          break;
427
      config.SetMemoryParameters(memParam,dict(bank=int(cmd[2]),length=int(cmd[3]),body=memoryBody));
428
    # program .main, optional .interrupt, and length
429
    elif re.match(':program',line):
430
      cmd = re.findall(':program (\d+) (\S+) (\d+)',line);
431
      mainStart = int(cmd[0][0]);
432
      if cmd[0][1] == '[]':
433
        interruptStart = -1;
434
      else:
435
        interruptStart = int(cmd[0][1]);
436
      mainLength = int(cmd[0][2]);
437
      for line in fpAssemberOutput:
438
        ixLine = ixLine + 1;
439
        while line and line[-1] in ('\n','\r',):
440
          line = line[:-1];
441
        if not line:
442
          break;
443
        programBody.append(line);
444
        if line[0] != '-':
445
          programBodyLength = programBodyLength + 1;
446
      if programBodyLength != mainLength:
447
        raise SSBCCException('Program Bug:  program length doesn\'t match declared length');
448
      maxProgramBodyLength = config.Get('nInstructions')['length'];
449
      if programBodyLength > maxProgramBodyLength:
450
        raise SSBCCException('Program body length = %d is longer than the allocated instruction table = %d' % (programBodyLength,maxProgramBodyLength,));
451
    else:
452
      raise Exception('Program Bug:  Unrecognized line at %s:%d :  "%s"' % (fpAssemberOutput.filename,ixLine,line,));
453
 
454
  ################################################################################
455
  #
456
  # Ensure the processor has been consistently defined.
457
  #
458
  ################################################################################
459
 
460
  # Ensure all memories are used.
461
  for ixMem in range(config.NMemories()):
462
    memParam = config.GetMemoryParameters(ixMem);
463
    if 'length' not in memParam:
464
      raise SSBCCException('Memory "%s" not used in program' % memParam['name']);
465
 
466
  ################################################################################
467
  #
468
  # Generate the processor core.
469
  #
470
  ################################################################################
471
 
472
  #
473
  # Access the language-specific core generator and core.
474
  #
475
 
476
  if config.Get('hdl') == 'Verilog':
477
    ssbccGenFile = 'ssbccGenVerilog.py';
478
  elif config.Get('hdl') == 'VHDL':
479
    ssbccGenFile = 'ssbccGenVHDL.py';
480
  else:
481
    raise SSBCCException('Unrecognized hdl = "%s"' % config.Get('hdl'));
482
 
483
  ssbccGenFile = os.path.join(config.Get('corepath'),ssbccGenFile);
484
  if not os.path.isfile(ssbccGenFile):
485
    raise SSBCCException('Core generator "%s" missing for hdl = "%s"' % (ssbccGenFile,config.Get('hdl'),));
486
  execfile(ssbccGenFile);
487
 
488
  rawCoreName = os.path.join(config.Get('corepath'),genCoreName());
489
  if not os.path.isfile(rawCoreName):
490
    raise SSBCCException('Core "%s% missing for hdl = "%s"' % (rawCoreName,config.Get('hdl'),));
491
  fpRawCore = open(rawCoreName,'r');
492
 
493
  outName = genOutName(config.Get('outCoreName'));
494
  fpOutCore = open(outName,'wt');
495
 
496
  memFileName = re.sub(r'\.v.*','.mem',outName);
497
  fpMemFile = open(memFileName,'wt');
498
 
499
  #
500
  # Loop through the core, copying or filling in the file as required.
501
  #
502
 
503
  for line in fpRawCore:
504
    if not re.match(r'..@SSBCC@',line):
505
      if re.match(r'\s*(reg|wire)\s',line):
506
        cmd = re.findall(r'\s*(reg|wire)\s+([[][^]]+]\s+)?(\w+)\b',line);
507
        if config.IsSymbol(cmd[0][-1]):
508
          raise SSBCCException('Symbol "%s" is used by the core and cannot be used by peripherals, etc.' % cmd[0][-1]);
509
      fpOutCore.write(line);
510
      continue;
511
    fillCommand = re.findall(r'..@SSBCC@\s+(\S+)',line)[0];
512
    # functions and tasks
513
    if fillCommand == "functions":
514
      genFunctions(fpOutCore,config);
515
    # inports
516
    elif fillCommand == 'inports':
517
      genInports(fpOutCore,config);
518
    # localparam
519
    elif fillCommand == 'localparam':
520
      genLocalParam(fpOutCore,config);
521
    # memories
522
    elif fillCommand == 'memories':
523
      genMemories(fpOutCore,fpMemFile,config,programBody);
524
    # module
525
    elif fillCommand == 'module':
526
      genModule(fpOutCore,config);
527
    # outports
528
    elif fillCommand == 'outports':
529
      genOutports(fpOutCore,config);
530
    # peripherals
531
    elif fillCommand == 'peripherals':
532
      if not config.peripheral:
533
        fpOutCore.write('//\n// No peripherals\n//\n');
534
      for ix in range(len(config.peripheral)):
535
        if ix != 0:
536
          fpOutCore.write('\n');
537
        config.peripheral[ix].GenHDL(fpOutCore,config);
538
    # "s_memory" declaration
539
    elif fillCommand == 's_memory':
540
      if config.NMemories() == 0:
541
        fpOutCore.write('wire [7:0] s_memory = 8\'h00;\n');
542
      else:
543
        fpOutCore.write('wire [7:0] s_memory;\n');
544
    # additional signals
545
    elif fillCommand == 'signals':
546
      genSignals(fpOutCore,config);
547
    # user_header
548
    elif fillCommand == 'user_header':
549
      genUserHeader(fpOutCore,user_header);
550
    # Verilator tracing on/off
551
    elif fillCommand == "verilator_tracing":
552
      if config.Get('verilator_tracing_on'):
553
        fpOutCore.write('/* verilator tracing_on */\n');
554
      else:
555
        fpOutCore.write('/* verilator tracing_off */\n');
556
    # error
557
    else:
558
      print 'WARNING:  Unimplemented command ' + fillCommand;
559
 
560
  #
561
  # Write package file (for use in VHDL or mixed-language projects)
562
  #
563
 
564
  import ssbccGenVhdlPkg
565
  ssbccGenVhdlPkg.genVhdlPkg(config);
566
 
567
################################################################################
568
#
569
# Terminating except clause
570
#
571
################################################################################
572
 
573
except SSBCCException, msg:
574
  print >> sys.stderr, 'FATAL ERROR:  ' + str(msg);
575
  exit(1);

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.