Skip to content

Instantly share code, notes, and snippets.

@lethalbit
Created April 1, 2021 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lethalbit/e65e296bc6a3810280d1b256c9df591b to your computer and use it in GitHub Desktop.
Save lethalbit/e65e296bc6a3810280d1b256c9df591b to your computer and use it in GitHub Desktop.
nmigen -> openlane example
from nmigen.build import *
from nmigen.vendor.open_lane import *
class sky130_fd_sc_hd(OpenLANEPlatform):
openlane_root = environ['OPENLANE_ROOT']
pdk = "sky130A"
cell_library = "sky130_fd_sc_hd"
settings = {
"PL_TARGET_DENSITY": 0.75,
"FP_HORIZONTAL_HALO": 6,
"FP_VERTICAL_HALO": 6,
"FP_CORE_UTIL": 5,
}
connectors = []
resources = []
class inv(Elaboratable):
def __init__(self, width=8):
self.i = Signal(width)
self.o = Signal(width)
def elaborate(self, platform):
m = Module()
m.d.comb += self.o.eq(~self.i)
return m
def get_ports(self):
return [self.i, self.o]
if __name__ == "__main__":
platform = sky130_fd_sc_hd()
inverter = inv()
platform.build(inverter, name="inverter", ports=inverter.get_ports())
@dvc94ch
Copy link

dvc94ch commented Jun 14, 2021

this isn't upstream. does this actually work?

@lethalbit
Copy link
Author

I don't even know how you found this gist, but yes, it works for the most part, mainly only for purely combinatorial logic at the moment:
see: https://twitter.com/lethalbit/status/1377123750680780806 | https://twitter.com/lethalbit/status/1377313053834948612 | https://twitter.com/lethalbit/status/1377315442813976581

It's not upstream do to some bugs and it needing a lot of work for synchronous logic

@dvc94ch
Copy link

dvc94ch commented Jun 14, 2021

why don't you think it's wanted as a PR? can you push the code somewhere? I'm interested in trying it out...

@lethalbit
Copy link
Author

You'll be happy to know that I now have a fork of nmigen with the openlane changes in it on my github, https://github.com/lethalbit/nmigen/tree/openlane and there is an example in tree over at https://github.com/lethalbit/nmigen/blob/openlane/examples/vendor/openlane_asic.py

The process of using it is 500% undocumented at the moment but that's on my todo list

@dvc94ch
Copy link

dvc94ch commented Jun 20, 2021

awesome! will give it a try soon. since it emits verilog, why doesn't synchronous logic work? looks like the create_missing_domain needs to be fleshed out with a proper por and oscillator?

@lethalbit
Copy link
Author

Like I said, it's a huge WIP, It needs a lot of work on some things and there is a lot of things that need to be considered, so it's not quite as simple as just throwing a POR and OSC in it.

Anyway, this discussion should be moved away from this gist and over to the fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment