build.xilinx: Convert attributes to something Yosys understands.
authorTim 'mithro' Ansell <me@mith.ro>
Fri, 5 Oct 2018 19:48:30 +0000 (12:48 -0700)
committerTim 'mithro' Ansell <me@mith.ro>
Fri, 5 Oct 2018 19:48:30 +0000 (12:48 -0700)
Convert keep, dont_touch and async_reg to something Yosys understands.

Write out an EDIF file with the attributes so that Vivado can use them.
(Requires Yosys with commit
https://github.com/YosysHQ/yosys/commit/115ca576475a2e8d30e63b339ae6a1b5db6906a6)

litex/build/xilinx/common.py

index 1006ab4098605ce92570b0910dc77fe6bd2ed0b0..ad0ff0ce04fda48863fa2e8113b62eff634557d9 100644 (file)
@@ -235,9 +235,37 @@ def _run_yosys(device, sources, vincpaths, build_name):
         ys_contents += "read_{}{} {}\n".format(language, incflags, filename)
 
     ys_contents += """\
-# hierarchy -top top
+hierarchy -top top
+
+# FIXME: Are these needed?
 # proc; memory; opt; fsm; opt
-synth_xilinx -top top -edif {build_name}.edif""".format(build_name=build_name)
+
+# Map keep to keep=1 for yosys
+log
+log XX. Converting (* keep = "xxxx" *) attribute for Yosys
+log
+attrmap -tocase keep -imap keep="true" keep=1 -imap keep="false" keep=0 -remove keep=0
+select -list a:keep=1
+
+# Add keep=1 for yosys to objects which have dont_touch="true" attribute.
+log
+log XX. Converting (* dont_touch = "true" *) attribute for Yosys
+log
+select -list a:dont_touch=true
+setattr -set keep 1 a:dont_touch=true
+
+# Convert (* async_reg = "true" *) to async registers for Yosys.
+# (* async_reg = "true", dont_touch = "true" *) reg xilinxmultiregimpl0_regs1 = 1'd0;
+log
+log XX. Converting (* async_reg = "true" *) attribute to async registers for Yosys
+log
+select -list a:async_reg=true
+setattr -set keep 1 a:async_reg=true
+
+synth_xilinx -top top
+
+write_edif -attrprop {build_name}.edif
+""".format(build_name=build_name)
 
     ys_name = build_name + ".ys"
     tools.write_to_file(ys_name, ys_contents)