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

Initial support for Tang nano 9k board #208

Closed
wants to merge 17 commits into from

Conversation

bl0x
Copy link
Contributor

@bl0x bl0x commented Dec 20, 2022

Pending PR amaranth-lang/amaranth#734 for platform support.

@josuah
Copy link

josuah commented Apr 17, 2023

The CI is stuck on "amaranth.vendor.gowin" missing.
I guess all it needs is to wait that amaranth-lang/amaranth#734 gets merged...

@bl0x
Copy link
Contributor Author

bl0x commented Apr 17, 2023

Yes, that's right @josuah, that's up to @whitequark. I've ironed out a few more things in the last weeks while actually working with the board.

part = "GW1NR-LV9QN88PC6/I5"
family = "GW1NR-9C"
default_clk = "clk27" # or "OSC" to use on-chip oscillator
osc_frequency = 2500000 # Hz
Copy link
Member

Choose a reason for hiding this comment

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

Our general policy here is that if default_clk points to a pin (like here), then osc_frequency is unspecified. However if the external clock is missing or unusable (like on the original Tang Nano), then default_clk would be OSC and the frequency would be specified by the designer, with some reasonable default (like 24 MHz).

from amaranth.vendor.gowin import *

try:
from .resources import *
Copy link
Member

Choose a reason for hiding this comment

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

This should only be from .resources import *; for testing you can install amaranth-boards in "editable mode".


if __name__ == "__main__":
try:
from .test.blinky import *
Copy link
Member

Choose a reason for hiding this comment

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

Likewise here.

" 54 55 56 57 68 69"
),
# TODO: Convert to Resource
Connector("rgb_lcd", 0,
Copy link
Member

Choose a reason for hiding this comment

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

You can take this for inspiration.

family = "GW1NR-9C"
default_clk = "clk27" # or "OSC" to use on-chip oscillator
osc_frequency = 2500000 # Hz
board = "tangnano9k"
Copy link
Member

Choose a reason for hiding this comment

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

Our convention is to inline the board field you have here into toolchain_program.

clk="36", cmd="37", dat0="39", dat3="38", wp_n="-",
attrs=Attrs(IO_TYPE="LVCMOS33")),

Resource("backlight_pwm", 0, Pins("86", dir="o"),
Copy link
Member

@whitequark whitequark Aug 8, 2023

Choose a reason for hiding this comment

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

Suggested change
Resource("backlight_pwm", 0, Pins("86", dir="o"),
Resource("lcd_backlight", 0, Pins("86", dir="o"),

UARTResource(0, rx="18", tx="17",
attrs=Attrs(PULL_MODE="UP", IO_TYPE="LVCMOS33")),

*SPIFlashResources(0,
Copy link
Member

Choose a reason for hiding this comment

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

Is this also a PSRAM on the 9k? If so, it should be:

Suggested change
*SPIFlashResources(0,
*SPIFlashResources("psram", 0,

# PIN76_MCLK SCL
# PIN48_CS CS

Resource("hdmi", 0, # FPGA_HDMI
Copy link
Member

Choose a reason for hiding this comment

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

Would you like to add HDMIResource?


]
connectors = [
Connector("gpio", 0,
Copy link
Member

Choose a reason for hiding this comment

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

The silk that is printed on the board refers to FPGA pin numbers, is that correct?

Copy link

Choose a reason for hiding this comment

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

This is what I remember from trying: they can be put in the .cst files as pin number.
This is also what the pinout diagram from Sipeed suggests:
img

Copy link
Member

Choose a reason for hiding this comment

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

By silk I mean the other side (not visible on the diagram).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, they just number their pins and also put these numbers on the silkscreen next to the GPIO headers.

Copy link
Member

Choose a reason for hiding this comment

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

Then we probably don't need this connector since it's much easier and less error prone to use actual pin numbers.

Copy link

Choose a reason for hiding this comment

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

mpv-shot0001
They match with the grey "IC Pin number" from the pinout diagram.

@whitequark
Copy link
Member

I now have a Tang Nano 9K and can test this PR.

@whitequark
Copy link
Member

See #233.

@whitequark
Copy link
Member

Obsoleted by #233. Thank you for this work!

@whitequark whitequark closed this Dec 8, 2023
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.

3 participants