AMF-Placer  2.0
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
getPinOffset.py
Go to the documentation of this file.
1 import matplotlib.cm as cm
2 import matplotlib as matplotlib
3 from matplotlib.colors import Normalize
4 import matplotlib.pyplot as plt
5 import matplotlib.patches as patches
6 from PIL import Image
7 import numpy as np
8 from matplotlib.patches import Patch
9 import re
10 import pathlib
11 import os
12 import sys
13 gw = 0.3
14 
15 assert(len(sys.argv) == 3)
16 
17 targetPath = sys.argv[1]
18 deviceName = sys.argv[2]
19 
20 deviceInfoFile = open(targetPath+"/"+deviceName +
21  "/"+deviceName+"_PCIEPin2Sw", "r")
22 refpinnamefile = open(
23  str(pathlib.Path(__file__).parent.absolute())+"/pcierefpinname", "r")
24 # pin=> XIL_UNCONN_OUT99 swtile=> INT_INTERFACE_PCIE_L_X77Y23
25 
26 lines = deviceInfoFile.readlines()
27 exportfile = open(targetPath+"/"+deviceName +
28  "/"+deviceName+"_PCIEPin2SwXY", "w")
29 
30 devicePinNames = set()
31 
32 for line in lines:
33  # puts $fo "bel=> $curBEL site=> $curSite tile=> $curTile type=> $siteType"
34  pin_SW = line.replace("\n", "").replace(
35  "pin=> ", "").replace(" swtile=> ", ";").split(";")
36 
37  pinName = pin_SW[0]
38 
39  if (re.search("[0-9]+", pinName)):
40  if (pinName.find("_") >= 0):
41  lastWord = pinName[pinName.rfind("_")+1:]
42  prevWord = pinName[:pinName.rfind("_")]
43  tmploc = re.search("[0-9]+", lastWord)
44  if (not tmploc is None):
45  tmploc = re.search("[0-9]+", lastWord).span()[0]
46  lastWord = lastWord[:tmploc]+"["+lastWord[tmploc:]+"]"
47  pinName = prevWord+lastWord
48  else:
49  tmploc = re.search("[0-9]+", pinName).span()[0]
50  pinName = pinName[:tmploc]+"["+pinName[tmploc:]+"]"
51 
52  pinName = pinName.replace("_", "")
53  pinName = pinName.split("/")[1]
54  SWName = pin_SW[1]
55  try:
56  X = 0
57  Y = int(SWName[SWName.rfind("Y")+1:])
58  devicePinNames.add(pinName)
59  # print("pin=> "+pinName+" swX=> "+str(X)+" swY=> "+str(Y))
60  print("pin=> "+pinName+" swX=> "+str(X) +
61  " swY=> "+str(Y), file=exportfile)
62  except:
63  pass
64 
65 lines = refpinnamefile.readlines()
66 
67 designRefPinNames = set(lines[0].replace("\n", "").split(" "))
68 
69 print("designRefPinNames-devicePinNames: ", designRefPinNames-devicePinNames)
70 
71 if (len(designRefPinNames-devicePinNames) > 0):
72  print("WARNING!!!!!!!!!!!!!!!!!")
73  print("The pins shown above fail to match with the design pins!")
74  print("They are required to find their loacations!! Find them in Vivado!!!!")
75  print("Add them in file: ( ", targetPath+"/"+deviceName +
76  "/"+deviceName+"_PCIEPin2SwXY", " )")
77 exportfile.close()