1 # ================================== Steps to add peripherals ============
2 # Step-1: create interface declaration for the peripheral to be added.
3 # Remember these are interfaces defined for the pinmux and hence
4 # will be opposite to those defined at the peripheral.
5 # For eg. the output TX from the UART will be input (method Action)
7 # These changes will have to be done in interface_decl.py
8 # Step-2 define the wires that will be required to transfer data from the
9 # peripheral interface to the IO cell and vice-versa. Create a
10 # mkDWire for each input/output between the peripheral and the
11 # pinmux. Also create an implicit wire of GenericIOType for each cell
12 # that can be connected to a each bit from the peripheral.
13 # These changes will have to be done in wire_def.py
14 # Step-3: create the definitions for each of the methods defined above.
15 # These changes will have to be done in interface_decl.py
16 # ========================================================================
18 # default module imports
22 from spec
import modules
, specgen
24 from bsv
.pinmux_generator
import pinmuxgen
as bsvgen
28 print ('''pinmux_generator.py [-o outputdir] [-v|--validate] [-h|--help]
29 [-t outputtype] [-s|--spec spec]
30 -s | spec : generate from spec (python module)
31 -t | outputtype : outputtype, defaults to bsv
32 -o outputdir : defaults to bsv_src. also location for reading pinmux.txt
33 interfaces.txt and *.txt
34 -v | --validate : runs some validation on the pinmux
35 -h | --help : this help message
39 if __name__
== '__main__':
41 options
, remainder
= getopt
.getopt(
51 except getopt
.GetoptError
as err
:
52 print ("ERROR: %s" % str(err
))
61 for opt
, arg
in options
:
62 if opt
in ('-o', '--output'):
64 elif opt
in ('-s', '--spec'):
66 elif opt
in ('-t', '--outputtype'):
68 elif opt
in ('-v', '--validate'):
70 elif opt
in ('-h', '--help'):
75 if pinspec
not in modules
:
76 print ("ERROR: spec type '%s' does not exist" % pinspec
)
79 module
= modules
[pinspec
]
80 pinout
, bankspec
, pinspec
, fixedpins
= module
.pinspec()
81 specgen(output_dir
, pinout
, bankspec
, pinspec
, fixedpins
)
83 gentypes
= {'bsv': bsvgen
}
84 if output_type
not in gentypes
:
85 print ("ERROR: output type '%s' does not exist" % output_type
)
88 gentypes
[output_type
](output_dir
, validate
)