|
24 | 24 | class Openflow: |
25 | 25 | """Class which solves HDL-to-bitstream based on FOSS.""" |
26 | 26 |
|
27 | | - def __init__(self): |
| 27 | + def __init__(self, name='openflow', part='hx8k-ct256'): |
28 | 28 | """Class constructor.""" |
29 | | - print('Hello from Openflow') |
| 29 | + self.name = name |
| 30 | + self.part = get_part(part) |
| 31 | + |
| 32 | + # pylint: disable=too-many-arguments |
| 33 | + def synthesis( |
| 34 | + self, top, |
| 35 | + vhdl=None, verilog=None, system_verilog=None, |
| 36 | + arch=None, defines=None, params=None, paths=None): |
| 37 | + """Performs synthesis.""" |
| 38 | + print(self.name) |
| 39 | + print(self.part) |
| 40 | + print(top) |
| 41 | + print(vhdl) |
| 42 | + print(verilog) |
| 43 | + print(system_verilog) |
| 44 | + print(arch) |
| 45 | + print(defines) |
| 46 | + print(params) |
| 47 | + print(paths) |
| 48 | + |
| 49 | + def implementation(self, constraint=None): |
| 50 | + """Performs implementation.""" |
| 51 | + print(self.name) |
| 52 | + print(self.part) |
| 53 | + print(constraint) |
| 54 | + |
| 55 | + def bitstream(self): |
| 56 | + """Performs bitstream generation.""" |
| 57 | + print(self.name) |
| 58 | + print(self.part) |
| 59 | + |
| 60 | + |
| 61 | +def get_part(part): |
| 62 | + """Get info about the FPGA part. |
| 63 | +
|
| 64 | + :param part: the FPGA part as specified by the tool |
| 65 | + :returns: a dictionary with the keys name, family, device and package |
| 66 | + """ |
| 67 | + name = part.lower() |
| 68 | + # Looking for the family |
| 69 | + family = None |
| 70 | + families = [ |
| 71 | + # From <YOSYS>/techlibs/xilinx/synth_xilinx.cc |
| 72 | + 'xcup', 'xcu', 'xc7', 'xc6s', 'xc6v', 'xc5v', 'xc4v', 'xc3sda', |
| 73 | + 'xc3sa', 'xc3se', 'xc3s', 'xc2vp', 'xc2v', 'xcve', 'xcv' |
| 74 | + ] |
| 75 | + for item in families: |
| 76 | + if name.startswith(item): |
| 77 | + family = item |
| 78 | + families = [ |
| 79 | + # From <nextpnr>/ice40/main.cc |
| 80 | + 'lp384', 'lp1k', 'lp4k', 'lp8k', 'hx1k', 'hx4k', 'hx8k', |
| 81 | + 'up3k', 'up5k', 'u1k', 'u2k', 'u4k' |
| 82 | + ] |
| 83 | + if name.startswith(tuple(families)): |
| 84 | + family = 'ice40' |
| 85 | + families = [ |
| 86 | + # From <nextpnr>/ecp5/main.cc |
| 87 | + '12k', '25k', '45k', '85k', 'um-25k', 'um-45k', 'um-85k', |
| 88 | + 'um5g-25k', 'um5g-45k', 'um5g-85k' |
| 89 | + ] |
| 90 | + if name.startswith(tuple(families)): |
| 91 | + family = 'ecp5' |
| 92 | + # Looking for the device and package |
| 93 | + device = None |
| 94 | + package = None |
| 95 | + aux = name.split('-') |
| 96 | + if len(aux) == 2: |
| 97 | + device = aux[0] |
| 98 | + package = aux[1] |
| 99 | + elif len(aux) == 3: |
| 100 | + device = '{}-{}'.format(aux[0], aux[1]) |
| 101 | + package = aux[2] |
| 102 | + else: |
| 103 | + raise ValueError('Part must be DEVICE-PACKAGE') |
| 104 | + if family == 'ice40' and device.endswith('4k'): |
| 105 | + # See http://www.clifford.at/icestorm/ |
| 106 | + device = device.replace('4', '8') |
| 107 | + package += ":4k" |
| 108 | + # Finish |
| 109 | + return { |
| 110 | + 'name': name, 'family': family, 'device': device, 'package': package |
| 111 | + } |
0 commit comments