Created
August 8, 2023 00:08
-
-
Save bl0x/bae35c42a02eadd49c980f2e831e1872 to your computer and use it in GitHub Desktop.
match all parts and families of Gowin FPGAs with regexes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from parts import parts | |
some_parts = [ | |
"GW1NR-UV9QN88C6/I5", | |
"GW1N-LV1QN48C6/I5", | |
"GW1NZ-LV1QN48C6/I5", | |
"GW1NSR-LV4CQN48PC7/I6", | |
"GW1NR-LV9QN88PC6/I5", | |
"GW1N-UV4LQ144C6/I5", | |
"GW1NS-UX2CQN48C5/I4", | |
] | |
packages = [ | |
"QN32U", | |
"QN32", | |
"QN48E", | |
"QN48F", | |
"QN48G", | |
"QN48H", | |
"QN48P", | |
"QN48", | |
"QN88PF", | |
"QN88P", | |
"QN88", | |
"CS16", | |
"CS30", | |
"CS36U", | |
"CS36", | |
"CS42", | |
"CS49", | |
"CS72", | |
"CS81M", | |
"FN32G", | |
"FN32F", | |
"FN32", | |
"M64", | |
"MG49PG", | |
"MG49P", | |
"MG49G", | |
"MG64P", | |
"MG64", | |
"MG81P", | |
"MG100PA", | |
"MG100PD", | |
"MG100PF", | |
"MG100PS", | |
"MG100PT", | |
"MG100P", | |
"MG100T", | |
"MG100", | |
"MG121X", | |
"MG121", | |
"MG132H", | |
"MG132X", | |
"MG132", | |
"MG160", | |
"MG196", | |
"PG256S", | |
"LQ100X", | |
"LQ100", | |
"LQ144P", | |
"LQ144X", | |
"LQ144", | |
"LQ176", | |
"EQ144PF", | |
"EQ144P", | |
"EQ144", | |
"EQ176", | |
"UG169", | |
"UG256", | |
"UG324D", | |
"UG324", | |
"UG332", | |
"UG400", | |
"UG484", | |
"UG676", | |
"PG256CF", | |
"PG256C", | |
"PG256E", | |
"PG256M", | |
"PG256", | |
"PG484", | |
"PG1156", | |
] | |
reg_series = "(GW[12]{1}[AN]{1}[EFNRSZ]{0,3})-" | |
reg_voltage = "(ZV|EV|LV|LX|UV|UX)" | |
reg_size = "(1|2|4|9|18|55)" | |
reg_subseries = "(?:(B|C|S|X|P5)?)" | |
reg_package = "((?:PG|UG|EQ|LQ|MG|M|QN|CS|FN)(?:\d+)(?:P?)(?:A|E|M|CF|C|D|G|H|F|S|T|U|X)?)" | |
reg_speed = "((?:C\d{1}/I\d{1})|ES|A\d{1}|I\d{1})" | |
matches = [(x, re.search(reg_package, x)) for x in packages] | |
for p,m in matches: | |
if m is not None: | |
if 0: | |
print(m.groups()) | |
else: | |
print(f"ERROR: No match for package: {p}") | |
matches = [(x[0], re.search(reg_series+reg_voltage+reg_size+reg_subseries+reg_package+reg_speed, x[0])) for x in parts] | |
n = len(parts) | |
n_matched = 0 | |
for part,m in matches: | |
if m is not None: | |
n_matched += 1 | |
assert len(m.groups()) == 6 | |
series = m.group(1) | |
voltage = m.group(2) | |
size = m.group(3) | |
subseries = m.group(4) | |
package = m.group(5) | |
speed = m.group(6) | |
if 0: | |
print(f"part: {part}") | |
print(f" series = {series}") | |
print(f" voltage = {voltage}") | |
print(f" size = {size}") | |
print(f" subseries = {subseries}") | |
print(f" package = {package}") | |
print(f" speed = {speed}") | |
else: | |
print(f"ERROR: No match for part: {part}") | |
print(f"matched {n_matched} out of {n} parts") | |
matches = [(x[1], re.search(reg_series+reg_size+reg_subseries, x[1])) for x in parts] | |
n = len(parts) | |
n_matched = 0 | |
for part,m in matches: | |
if m is not None: | |
n_matched += 1 | |
assert len(m.groups()) == 3 | |
series = m.group(1) | |
size = m.group(2) | |
subseries = m.group(3) | |
if 0: | |
print(f"family: {part}") | |
print(f" series = {series}") | |
print(f" size = {size}") | |
print(f" subseries = {subseries}") | |
else: | |
print(f"ERROR: No match for family: {part}") | |
print(f"matched {n_matched} out of {n} families") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment