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

Moved the memories spi block back into the pinmux. #326

Merged
merged 4 commits into from
Nov 6, 2024
Merged

Conversation

HU90m
Copy link
Member

@HU90m HU90m commented Nov 6, 2024

This gives a little more flexibility in software compartmentalization and should also solve the problem found in #323

This will make it slightly easier to lock down a spi device in software.

This should also fix the problem found by adrian where:

> Combining CIPO lines directly without regard to Chip Selects
> is risky, and in particular the line `appspi_d1` from the
> flash is tri-stated without a pullup resistor on the FPGA
> board.

Also, added microSD card signals to pave the way for the microSD card
DPI model he has built.
@HU90m HU90m requested review from marnovandermaas, alees24 and GregAC and removed request for marnovandermaas and alees24 November 6, 2024 10:38
@HU90m HU90m force-pushed the pinmux branch 2 times, most recently from 812fd0b to a8849f9 Compare November 6, 2024 11:09
@HU90m
Copy link
Member Author

HU90m commented Nov 6, 2024

All tests passing apart from the SPI Flash Pinmux test

HU90m added 2 commits November 6, 2024 11:47
1. The address of the SPI connected to flash has changes.
2. There are now three SPI devices going through the pinmux, so the
   pinmux driver has changed.
1. Moved rs485 to be with the other UARTs in the register map.
2. Removed the SPI suffixes from the raspberry pi hat. They were
   inconsistent.
3. Changed the Pmod{0,1} pin numbering to match the Pmod standard
   physical pins as oppose to the sonata schematic.
@HU90m HU90m added bug Something isn't working 1.0 labels Nov 6, 2024
@@ -291,6 +291,7 @@ set_property -dict { PACKAGE_PIN C10 IOSTANDARD LVCMOS33 } [get_ports appspi_d1]
set_property -dict { PACKAGE_PIN A10 IOSTANDARD LVCMOS33 } [get_ports appspi_d2]
set_property -dict { PACKAGE_PIN A9 IOSTANDARD LVCMOS33 } [get_ports appspi_d3]
set_property -dict { PACKAGE_PIN D10 IOSTANDARD LVCMOS33 } [get_ports appspi_cs]
set_property PULLTYPE PULLUP [get_ports appspi_d1]
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we should add pull ups to all of the CIPO lines. If it makes sense here it makes sense everywhere.

Copy link
Member Author

@HU90m HU90m Nov 6, 2024

Choose a reason for hiding this comment

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

The microsd card lines appear to be pulled high on the board. Ethernet MAC chip (KSZ8851SNL/SNLI) is high impedance by default, so may make sense to pull high. I don't know what the behavior of the LCD is. And the LCD doesn't have a CIPO line.

What would you like me to do for this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

@alees24 🪣 (passing the buck on the ethmac CIPO)

rtl/system/sonata_system.sv Outdated Show resolved Hide resolved
name = "rs485_tx"
block_ios = [{ block = "uart", instance = 2, io = "tx" }]
no_default_out = true

Copy link
Contributor

Choose a reason for hiding this comment

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

I did put them at the end intentionally to avoid altering other mappings. In particular the UART 2 RX input selector. Previously RS485 sat at the end so anything else that wanted to mux a pin to the UART 2 RX input wouldn't now need to change which input it selected.

The real issue here was lack of constants for the actual selectors being generated by the pinmux generator, though maybe we do have that and I haven't noticed!

Certainly this change will need a fix in the rs485 check at least.

Copy link
Member Author

Choose a reason for hiding this comment

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

I appreciate wanting to avoid breaking other mappings, but I believe the RS485 check is the only software that is affected by this change. So I guess it's a question of what's preferred.

What register mapping do you prefer?

Copy link
Contributor

@GregAC GregAC left a comment

Choose a reason for hiding this comment

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

Thanks for this @HU90m no major objections on my side so approving to unblock but some things we can improve, potentially in follow up PRs.

// Tie flash wp_n and hold_n to 1 as they're active low and we don't need either signal
assign appspi_d2 = 1'b1;
assign appspi_d3 = 1'b1;
wire appspi_clk = out_to_pins[OUT_PIN_APPSPI_CLK];
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we not use the assign statement here?

Copy link
Member Author

Choose a reason for hiding this comment

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

My understanding is that

// when a is a net, it's a continuous assignment
wire a = b;
// equivalent to
wire a;
assign a = b;
// whereas when a is a variable, it's an initialisation assignment
var a = b;

I think it's generally less bug prone to useful to have the assignment with the definition in simple cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I guess I don't really understand why we're using wires here in the first place, but let's leave it for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

For reference I'm really not a fan of this style, exactly because you get different semantics when this changes between wire and logic. Far better to just have a consistent don't assign with declarations rules.

rtl/system/pinmux.sv Show resolved Hide resolved
Copy link
Contributor

@marnovandermaas marnovandermaas left a comment

Choose a reason for hiding this comment

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

Thanks for these changes!

@HU90m
Copy link
Member Author

HU90m commented Nov 6, 2024

Thank you both for the very prompt reviews

@HU90m HU90m merged commit 8a5c4ab into lowRISC:main Nov 6, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.0 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants