-
Notifications
You must be signed in to change notification settings - Fork 110
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
Add OLED connector to ulx3s.py #104
Conversation
This adds the OLED connector pins to the ULX3S platform. The constraints were taken from https://github.com/emard/ulx3s-misc/blob/master/constraints/ulx3s_v20.lpf
Please make this resource consistent with the version found in SPIResource(0, # OLED, SSD1306, 128 x 32
cs="dummy-cs0", clk="AF17", copi="Y15",
cipo="dummy-cipo0", reset="AB17",
attrs=Attrs(IOSTANDARD="LVCMOS18")),
Resource("oled", 0, # OLED, UG-2832HSWEG04
Subsignal("dc", Pins("AC17", dir="o")),
Subsignal("vdd_en", PinsN("AG17", dir="o")),
Subsignal("vbat_en", PinsN("AB22", dir="o"),
Attrs(IOSTANDARD="LVCMOS33")),
Attrs(IOSTANDARD="LVCMOS18")), Ideally we want the nmigen-boards platforms to be as consistent as possible about things like this. |
I've tried this, but I'm running into a problem. SPIResource expects a |
Hm. I think this is sufficiently weird to warrant further discussion - I'll bring it up with whitequark at Monday's meeting when she's back from vacation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried this, but I'm running into a problem. SPIResource expects a
cipo
pin, but the connector does not have one. If I set thecipo
parameter toNone
then I get an error that it cannot be empty, and any other string that I provide gives me an error that no pin with that name exists.
It is now possible to specify either cipo=None
or copi=None
when creating an SPIResource
. Please update the PR to use it.
I just update nmigen and nmigen-boards, and I still get the same error that the This is what I have right now: # OLED connector
SPIResource(0,
cs="N2", clk="P4", copi="P3", cipo=None, reset="P2",
attrs=Attrs(IO_TYPE="LVCMOS33", DRIVE="4", PULLMODE="UP")),
Resource("oled", 0,
Subsignal("dc", Pins("P1", dir="o"),
Attrs(IO_TYPE="LVCMOS33", DRIVE="4", PULLMODE="UP"))), For clarity, |
Sorry, I forgot to push. Try now. |
Also separate non-SPI signal `dc` into a separate Resource
I modified it, but the test code didn't work. Turns out I had to invert the In the old code I just directly assigned to the |
Nope; nMigen places inverters if you use |
That's strange then. I would expect these two to be equivalent: SPIResource(0,
cs="N2", clk="P4", copi="P3", cipo=None, reset="P2",
attrs=Attrs(IO_TYPE="LVCMOS33", DRIVE="4", PULLMODE="UP")),
spi = platform.request("spi")
oled_csn = spi.cs and oled_resource = [
Resource("oled_clk", 0, Pins("P4", dir="o"), Attrs(IO_TYPE="LVCMOS33", DRIVE="4", PULLMODE="UP")),
Resource("oled_mosi", 0, Pins("P3", dir="o"), Attrs(IO_TYPE="LVCMOS33", DRIVE="4", PULLMODE="UP")),
Resource("oled_resn", 0, Pins("P2", dir="o"), Attrs(IO_TYPE="LVCMOS33", DRIVE="4", PULLMODE="UP")),
Resource("oled_csn", 0, Pins("N2", dir="o"), Attrs(IO_TYPE="LVCMOS33", DRIVE="4", PULLMODE="UP")),
]
platform.add_resources(oled_resource)
oled_csn = platform.request("oled_csn") But in the former case I have to use |
No, you're actually right. We should develop a tool that prints an overview of the platform's connectivity: which resources were actually used, what polarities do the pins have, what kind of IO buffer are they configured with, and what connectors do they go through. We should also consider changing the naming convention so that pins with fixed inversion reflect that in the argument name. This really should've been |
I agree. Especially because I just assign to pins of the platform and I don't really think about any of the IO buffers the might get added by nMigen/synthesis tools. I happened to look at the generated code and saw that one version had an inverter and the other didn't. Another problem is that So yes, I think an overview with resources, polarities, IO buffer types, etc. would definitely help to clear thing up. |
The logic here is:
Although this might not be common in contemporary HDL, it is, in my view, self-consistent and clear. But, unfortunately, the way we defined resource factories does not follow that principle, as you have clearly demonstrated. |
Filed #129 to track the pin naming issue. |
Yes, and that's exactly how I expect it to work as well. I just looked at the Would it be a breaking change to either rename |
It would (specifically, it would break any external platforms that rely on resource definitions from this repo), but that's fine as this is a really severe issue. Changing
That would be most welcome! It's more than just |
In EDIT: I just realized that this has to be modified in nMigen too, or else |
Nope, the resources are all defined in nmigen-boards, specifically to handle this case. |
There are a lot more in |
Filed amaranth-lang/amaranth#551 to track report generation. |
Ah yes, I see it now. I'll go through the entire nmigen-boards repo then. |
Ok so now that the function names are properly changed, this PR should be able to get merged... except that I had to remove my fork of the repo for the previous PR. I don't really do much with PRs so I screwed this one up as well :S I'll create a new PR with the suggestions from this PR, and if/when it gets merged, we can close this one. |
This adds the OLED connector pins to the ULX3S platform. The constraints were taken from https://github.com/emard/ulx3s-misc/blob/master/constraints/ulx3s_v20.lpf