|
27 | 27 | if not gowinhome:
|
28 | 28 | raise Exception("GOWINHOME not set")
|
29 | 29 |
|
| 30 | +# device = os.getenv("DEVICE") |
30 | 31 | device = sys.argv[1]
|
31 | 32 |
|
32 | 33 | params = {
|
@@ -80,41 +81,42 @@ def dff(locations):
|
80 | 81 | continue
|
81 | 82 |
|
82 | 83 | for cls in range(3): # for each cls
|
83 |
| - for typ, port in dffmap.items(): # for each bel type |
84 |
| - try: |
85 |
| - loc = next(locs) # get the next unused tile |
86 |
| - except StopIteration: |
87 |
| - yield ttyp, mod, cst, {} |
88 |
| - locs = iter(locations[ttyp]) |
89 |
| - loc = next(locs) |
90 |
| - mod = codegen.Module() |
91 |
| - cst = codegen.Constraints() |
92 |
| - |
93 |
| - lutname = make_name("DUMMY", "LUT4") |
94 |
| - lut = codegen.Primitive("LUT4", lutname) |
95 |
| - lut.params["INIT"] = "16'hffff" |
96 |
| - lut.portmap['F'] = lutname+"_F" |
97 |
| - lut.portmap['I0'] = lutname+"_I0" |
98 |
| - lut.portmap['I1'] = lutname+"_I1" |
99 |
| - lut.portmap['I2'] = lutname+"_I2" |
100 |
| - lut.portmap['I3'] = lutname+"_I3" |
101 |
| - |
102 |
| - mod.wires.update(lut.portmap.values()) |
103 |
| - mod.primitives[lutname] = lut |
104 |
| - name = make_name("DFF", typ) |
105 |
| - dff = codegen.Primitive(typ, name) |
106 |
| - dff.portmap['CLK'] = name+"_CLK" |
107 |
| - dff.portmap['D'] = lutname+"_F" |
108 |
| - dff.portmap['Q'] = name+"_Q" |
109 |
| - if port: |
110 |
| - dff.portmap[port] = name+"_"+port |
111 |
| - mod.wires.update(dff.portmap.values()) |
112 |
| - mod.primitives[name] = dff |
113 |
| - |
114 |
| - row = loc[0]+1 |
115 |
| - col = loc[1]+1 |
116 |
| - cst.cells[lutname] = f"R{row}C{col}[{cls}]" |
117 |
| - cst.cells[name] = f"R{row}C{col}[{cls}]" |
| 84 | + for side in ["A", "B"]: |
| 85 | + for typ, port in dffmap.items(): # for each bel type |
| 86 | + try: |
| 87 | + loc = next(locs) # get the next unused tile |
| 88 | + except StopIteration: |
| 89 | + yield ttyp, mod, cst, {} |
| 90 | + locs = iter(locations[ttyp]) |
| 91 | + loc = next(locs) |
| 92 | + mod = codegen.Module() |
| 93 | + cst = codegen.Constraints() |
| 94 | + |
| 95 | + lutname = make_name("DUMMY", "LUT4") |
| 96 | + lut = codegen.Primitive("LUT4", lutname) |
| 97 | + lut.params["INIT"] = "16'hffff" |
| 98 | + lut.portmap['F'] = lutname+"_F" |
| 99 | + lut.portmap['I0'] = lutname+"_I0" |
| 100 | + lut.portmap['I1'] = lutname+"_I1" |
| 101 | + lut.portmap['I2'] = lutname+"_I2" |
| 102 | + lut.portmap['I3'] = lutname+"_I3" |
| 103 | + |
| 104 | + mod.wires.update(lut.portmap.values()) |
| 105 | + mod.primitives[lutname] = lut |
| 106 | + name = make_name("DFF", typ) |
| 107 | + dff = codegen.Primitive(typ, name) |
| 108 | + dff.portmap['CLK'] = name+"_CLK" |
| 109 | + dff.portmap['D'] = lutname+"_F" |
| 110 | + dff.portmap['Q'] = name+"_Q" |
| 111 | + if port: |
| 112 | + dff.portmap[port] = name+"_"+port |
| 113 | + mod.wires.update(dff.portmap.values()) |
| 114 | + mod.primitives[name] = dff |
| 115 | + |
| 116 | + row = loc[0]+1 |
| 117 | + col = loc[1]+1 |
| 118 | + cst.cells[lutname] = f"R{row}C{col}[{cls}][{side}]" |
| 119 | + cst.cells[name] = f"R{row}C{col}[{cls}][{side}]" |
118 | 120 | yield ttyp, mod, cst, {}
|
119 | 121 |
|
120 | 122 | iobmap = {
|
@@ -185,8 +187,8 @@ def dualmode(ttyp):
|
185 | 187 | yield ttyp, mod, cst, cfg
|
186 | 188 |
|
187 | 189 | def read_posp(fname):
|
188 |
| - cst_parser = re.compile(r"(\w+) (?:PLACE|CST)_R(\d+)C(\d+)\[([0-3])\]\[([A-Z])\]") |
189 |
| - place_parser = re.compile(r"(\w+) (?:PLACE|CST)_IO([TBLR])(\d+)\[([A-Z])\]") |
| 190 | + cst_parser = re.compile(r"([^ ]+) (?:PLACE|CST)_R(\d+)C(\d+)\[([0-3])\]\[([A-Z])\]") |
| 191 | + place_parser = re.compile(r"([^ ]+) (?:PLACE|CST)_IO([TBLR])(\d+)\[([A-Z])\]") |
190 | 192 | with open(fname, 'r') as f:
|
191 | 193 | for line in f:
|
192 | 194 | cst = cst_parser.match(line)
|
@@ -373,16 +375,16 @@ def run_pnr(mod, constr, config):
|
373 | 375 | if bel_type == "DUMMY":
|
374 | 376 | continue
|
375 | 377 | elif bel_type == "DFF":
|
376 |
| - for i in range(2): # 2 DFF per CLS |
377 |
| - bel = db.grid[row][col].bels.setdefault(f"DFF{cls*2+i}", chipdb.Bel()) |
378 |
| - bel.modes[cell_type] = loc |
379 |
| - bel.portmap = { |
380 |
| - # D inputs hardwired to LUT F |
381 |
| - 'Q': f"Q{cls*2+i}", |
382 |
| - 'CLK': f"CLK{cls}", |
383 |
| - 'LSR': f"LSR{cls}", # set/reset |
384 |
| - 'CE': f"CE{cls}", # clock enable |
385 |
| - } |
| 378 | + i = ord(lut)-ord("A") |
| 379 | + bel = db.grid[row][col].bels.setdefault(f"DFF{cls*2+i}", chipdb.Bel()) |
| 380 | + bel.modes[cell_type] = loc |
| 381 | + bel.portmap = { |
| 382 | + # D inputs hardwired to LUT F |
| 383 | + 'Q': f"Q{cls*2+i}", |
| 384 | + 'CLK': f"CLK{cls}", |
| 385 | + 'LSR': f"LSR{cls}", # set/reset |
| 386 | + 'CE': f"CE{cls}", # clock enable |
| 387 | + } |
386 | 388 | elif bel_type == "IOB":
|
387 | 389 | bel = db.grid[row][col].bels.setdefault(f"IOB{pin}", chipdb.Bel())
|
388 | 390 | bel.modes[cell_type] = loc
|
|
0 commit comments