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

make Gowin boards work with Apicula #603

Merged
merged 1 commit into from
Sep 4, 2024

Conversation

pepijndevos
Copy link
Contributor

@pepijndevos pepijndevos commented Aug 16, 2024

Thanks to enjoy-digital/litex#2036 by @Mai-Lapyst LiteX supports Apicula with the Himaechel target now, but it appears that the boards do not yet work correctly.

This is a WIP PR to try and fix those. I figured I'd put it out there to avoid duplicating work with Mai.

So far I've been mostly threading toolchain through to the platform. Currently it fails to connect the RAM chips with their SERDES and SiP IO stuff. Some of that may be a more long-term project.

Depends on enjoy-digital/litex#2042

@trabucayre
Copy link
Contributor

LGTM. But for 20k, 25k BaseSoC call must be update with the toolchain param.

@pepijndevos
Copy link
Contributor Author

Yes several Gowin boards remain to be tested, currently only 4K actually works completely, some of the others might be fine if I take a target that doesn't use advanced IO things for memory.

@pepijndevos
Copy link
Contributor Author

pepijndevos commented Aug 19, 2024

  • make 4k run with nolutram
  • add magic sdram pins to nextpnr
  • add family aliases to nextpnr
  • fix toolchain in remaining gowin boards

@pepijndevos
Copy link
Contributor Author

pepijndevos commented Aug 22, 2024

Alright so the current status is:

  • Tang Nano: I think hits some regression ERROR: No bel named X0Y5/IOBF which I don't think is a LiteX problem
  • Tang Nano 4K: works perfectly
  • Tang Nano 9K: works without SDRAM
  • Tang Nano 20K: builds a bitstream but don't have the board
  • Tang Primer 20K: works without CLKDIV until Add DHCEN primitive. YosysHQ/apicula#261
  • Tang Primer 25K: GW5A is not yet supported in Apicula so is purely forward compatibility

@pepijndevos pepijndevos changed the title WIP: make Gowin boards work with Apicula make Gowin boards work with Apicula Aug 23, 2024
@pepijndevos
Copy link
Contributor Author

I didn't break CI right?

Any commit guidelines I should follow?

I think this is pretty much done on the LiteX side, and I'll be working on the Apicula/Nextpnr side to improve things there so we can hopefully use SDRAM.

Comment on lines 95 to 102
if toolchain=="gowin":
# this is just a software check that doesn't translate to hardware
# apicula does not implement this check, so beware of bricking your board
self.toolchain.options["use_mode_as_gpio"] = 1
else:
# yosys doesn't know that 4K doesn't have lutram so we tell it
self.toolchain._synth_opts += " -nolutram"

Copy link
Contributor

Choose a reason for hiding this comment

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

A last question here: maybe is it possible to move this part to apicula toolchain? This avoid to have to copy/paste these lines for all boards with this trick.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It'd have to be spread across several tools I guess.

Yosys is currently oblivious to the specific device it's synthesizing for, so you could add a -family flag there or something but that doesn't really have any advantage over -nolutram until there are more significant differences.

We could add a --mode-as-gpio flag to the packer that implements the check, but like the comment said it doesn't translate to anything in hardware. It's more of a "are you sure you want to do this" thing. Given that you wrote the constraints file, I would assume the answer is "yes". All of the other as-gpio flags actually change bits to switch the functionality.

Comment on lines 63 to 76
self.specials += [
Instance("DHCEN",
i_CLKIN = self.cd_sys2x_i.clk,
i_CE = self.stop,
o_CLKOUT = self.cd_sys2x.clk),
Instance("CLKDIV",
p_DIV_MODE = "2",
i_CALIB = 0,
i_HCLKIN = self.cd_sys2x.clk,
i_RESETN = ~self.reset,
o_CLKOUT = self.cd_sys.clk),
AsyncResetSynchronizer(self.cd_sys, ~pll.locked | self.rst | self.reset),
]
Copy link
Contributor

Choose a reason for hiding this comment

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

This piece of code is required to use external DDR. Is the build end successfully?
Also when with_clk reset signal isn't driven by self.rst nor by self.reset

Copy link
Contributor Author

@pepijndevos pepijndevos Aug 23, 2024

Choose a reason for hiding this comment

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

Ah, maybe it should be gated on integrated_main_ram_size then? I've only tested it without sdram because Apicula doesn't support the magic constraints yet.

In the clkdivless case it's exactly the same as Tang Nano 20k.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How does this sys2x domain actually get used? It doesn't seem to be passed to the sdram directly

Copy link
Contributor

Choose a reason for hiding this comment

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

This clock source is used by the litedram phy

@trabucayre
Copy link
Contributor

No this PR doesn't break anything. CI fails due to a recent litedram update.

@pepijndevos
Copy link
Contributor Author

I see ci is fixed. All good now?

@trabucayre trabucayre merged commit 185f8d5 into litex-hub:master Sep 4, 2024
1 check passed
@trabucayre
Copy link
Contributor

Applied with some modifications. Thanks @pepijndevos


if dock == "lite":
with_led_chaser = False # No leds on core board nor on dock lite.

# CRG --------------------------------------------------------------------------------------
self.crg = _CRG(platform, sys_clk_freq, with_video_pll=with_video_terminal)
with_dram = (kwargs.get("integrated_main_ram_size", 0) == 0)
assert not (toolchain == "apicula" and with_dram)
Copy link
Contributor Author

@pepijndevos pepijndevos Sep 4, 2024

Choose a reason for hiding this comment

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

So we need to remove this assertion once Apicula supports sdram right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants