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

Change signal names to match polarity #131

Closed
wants to merge 1 commit into from
Closed

Change signal names to match polarity #131

wants to merge 1 commit into from

Conversation

GuzTech
Copy link
Contributor

@GuzTech GuzTech commented Nov 25, 2020

This commit adds the _n suffix to signal names and function parameters that use PinsN. It also changes the default reset signal name where necessary to reflect the _n suffix.

Signed-off-by: Oguz Meteer <info@guztech.nl>
@whitequark
Copy link
Member

Sadly, you did the exact opposite of what I'd like you to do... the names that you have changed correspond to active high signals.

Here's what I had in mind:

diff --git a/nmigen_boards/resources/interface.py b/nmigen_boards/resources/interface.py
index 8d5bd7e..0e0118a 100644
--- a/nmigen_boards/resources/interface.py
+++ b/nmigen_boards/resources/interface.py
@@ -56,21 +56,21 @@ def IrDAResource(number, *, rx, tx, en=None, sd=None,
     return Resource("irda", number, *io)
 
 
-def SPIResource(*args, cs, clk, copi, cipo, int=None, reset=None,
+def SPIResource(*args, cs_n, clk, copi, cipo, int=None, reset=None,
                 conn=None, attrs=None, role="controller"):
     assert role in ("controller", "peripheral")
     assert copi is not None or cipo is not None # support unidirectional SPI
 
     io = []
     if role == "controller":
-        io.append(Subsignal("cs", PinsN(cs, dir="o", conn=conn)))
+        io.append(Subsignal("cs", PinsN(cs_n, dir="o", conn=conn)))
         io.append(Subsignal("clk", Pins(clk, dir="o", conn=conn, assert_width=1)))
         if copi is not None:
             io.append(Subsignal("copi", Pins(copi, dir="o", conn=conn, assert_width=1)))
         if cipo is not None:
             io.append(Subsignal("cipo", Pins(cipo, dir="i", conn=conn, assert_width=1)))
     else:  # peripheral
-        io.append(Subsignal("cs", PinsN(cs, dir="i", conn=conn, assert_width=1)))
+        io.append(Subsignal("cs", PinsN(cs_n, dir="i", conn=conn, assert_width=1)))
         io.append(Subsignal("clk", Pins(clk, dir="i", conn=conn, assert_width=1)))
         if copi is not None:
             io.append(Subsignal("copi", Pins(copi, dir="i", conn=conn, assert_width=1)))

@GuzTech
Copy link
Contributor Author

GuzTech commented Nov 25, 2020

Ah, you want to keep the signal names the same, but only change the user-facing function parameter names?

@whitequark
Copy link
Member

Correct. As I mentioned before, the choice of signal names as they are exposed to the design is very much deliberate. But I think the parameter names simply slipped by without anyone noticing this flaw until now.

@GuzTech
Copy link
Contributor Author

GuzTech commented Nov 25, 2020

Ok, then the change should be smaller than what I've done here. The function parameters should reflect the polarity, and any board file that uses these functions should have their parameter names updated, but the rest of the signal names should be untouched.

Let me start over with the commit and PR in order not to pollute the log history with reverts and such.

@whitequark
Copy link
Member

Let me start over with the commit and PR in order not to pollute the log history with reverts and such.

FYI, if you force-push to a PR branch, you can replace the entire history. But there's no real harm in closing and reopening it either.

@GuzTech GuzTech closed this Nov 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants