Add -b/--blackbox option, retain existing API

I wanted an option to write out blackbox versions of memories.

Please review this PR.  Recommend changes or alternate solution, if available.



A few test cases follow.

No arguments added. Position argument works as before.

~~~~
$ ./vlsi_mem_gen ../ExampleRocketSystem.conf
< no change in output >
~~~~

Positional argument for .conf file.
~~~~
$ ./vlsi_mem_gen 
usage: vlsi_mem_gen [-h] [--blackbox] .conf file
vlsi_mem_gen: error: too few arguments
~~~~

No arguments added.  Result: no change.

~~~~
$ ./vlsi_mem_gen ../ExampleRocketSystem.conf
< no change in output >
~~~~

Positional argument for .conf file and with -b option.  Result: empty module body.

~~~~
$ ./vlsi_mem_gen -b ../ExampleRocketSystem.conf

module data_arrays_0_ext(
  input RW0_clk,
  input [11:0] RW0_addr,
  input RW0_en,
  input RW0_wmode,
  input [3:0] RW0_wmask,
  input [31:0] RW0_wdata,
  output [31:0] RW0_rdata
);


endmodule
~~~~
This commit is contained in:
Edmond Cote 2018-04-10 16:59:23 -07:00 committed by GitHub
parent 7cd3352c3b
commit 34244efee7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 6 deletions

View File

@ -7,6 +7,7 @@ import sys
import math
use_latches = 0
blackbox = 0
def parse_line(line):
name = ''
@ -182,14 +183,20 @@ def gen_mem(name, width, depth, mask_gran, mask_seg, ports):
\n\
%s\
\n\
endmodule" % (name, ',\n '.join(port_spec), body)
endmodule" % (name, ',\n '.join(port_spec), body if blackbox == False else "")
return s
def main():
if len(sys.argv) < 2:
sys.exit('Please give a .conf file as input')
for line in open(sys.argv[1]):
def main(conf_file):
for line in open(conf_file):
print(gen_mem(*parse_line(line)))
if __name__ == '__main__':
main()
import argparse
parser = argparse.ArgumentParser(description='Memory generator for Rocket Chip')
parser.add_argument('conf', metavar='.conf file')
parser.add_argument('--blackbox', '-b', action='store_true')
args = parser.parse_args()
blackbox = args.blackbox # yes, global variable, not reinventing wheel, see use of use_latches
main(args.conf)