Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flow: convert DONT_USE to text files if GZ, ensure files are read as … #373

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions flow/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ WRAPPED_LIBS = $(foreach lib,$(notdir $(WRAP_LIBS)),$(OBJECTS_DIR)/$(lib:.lib=_m
export ADDITIONAL_LEFS += $(WRAPPED_LEFS) $(WRAP_LEFS)
export LIB_FILES += $(WRAP_LIBS) $(WRAPPED_LIBS)

export DONT_USE_LIBS = $(addprefix $(OBJECTS_DIR)/lib/, $(notdir $(LIB_FILES)))
export DONT_USE_SC_LIB ?= $(OBJECTS_DIR)/lib/$(notdir $(firstword $(LIB_FILES)))
export DONT_USE_LIBS = $(patsubst %.gz %.GZ,, $(addprefix $(OBJECTS_DIR)/lib/, $(notdir $(LIB_FILES))))
export DONT_USE_SC_LIB ?= $(firstword $(DONT_USE_LIBS))

# Stream system used for final result (GDS is default): GDS, GSDII, GDS2, OASIS, or OAS
STREAM_SYSTEM ?= GDS
Expand Down Expand Up @@ -304,7 +304,7 @@ versions.txt:
# Create temporary Liberty files which have the proper dont_use properties set
# For use with Yosys and ABC
.SECONDEXPANSION:
$(DONT_USE_LIBS): $$(filter %$$(@F),$(LIB_FILES))
$(DONT_USE_LIBS): $$(filter %$$(@F) %$$(@F).gz %$$(@F).GZ,$(LIB_FILES))
@mkdir -p $(OBJECTS_DIR)/lib
$(UTILS_DIR)/markDontUse.py -p "$(DONT_USE_CELLS)" -i $^ -o $@

Expand Down
12 changes: 9 additions & 3 deletions flow/util/markDontUse.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

# Read input file
print("Opening file for replace:",args.inputFile)
if args.inputFile.endswith(".gz"):
f = gzip.open(args.inputFile, 'rt')
if args.inputFile.endswith(".gz") or args.inputFile.endswith(".GZ"):
f = gzip.open(args.inputFile, 'rt', encoding="ascii")
else:
f = open(args.inputFile)
f = open(args.inputFile, encoding="ascii")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on your comments today, do you need to use utf8?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I read it as acsii, the characters are ignored, so it has the same effect as reading it as uft-8 and then converting (except being a little simpler)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wrong, I had the wrong version of the file copied in

content = f.read()
f.close()

Expand All @@ -45,6 +45,12 @@
content, count = re.subn(pattern, replace, content)
print("Commented", count, "lines containing \"original_pin\"")

# Yosys, does not like properties that start with : !, without quotes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I'm necroposting, but I'm revisiting the necessity for this script from the yosys side. Is this a workaround for YosysHQ/yosys#3498 which has been fixed?

cc @povik

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Highly likely, you can try removing those lines (file is currently called preprocessLib.py) and see if it still works as intended. I think I recall that it used to emit a warning that it was ignoring the cell, not error out.

pattern = r":\s+(!.*)\s+;"
replace = r': "\1" ;'
content, count = re.subn(pattern, replace, content)
print("Replaced malformed functions", count)

# Write output file
print("Writing replaced file:",args.outputFile)
f = open(args.outputFile, "w")
Expand Down