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

Add gmiiSgmiiBridge based on gig_ethernet_pcs_pma #2712

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

lmbollen
Copy link
Contributor

This pull requests adds a wrapper to generate the LogiCORE IP Ethernet 1000BASE-X PCS/PMA or SGMII as a GMII to SGMII bridge.

It generates a .tcl file to be used by the clashConnector based infra structure.
For now the configuration is minimal and static.

clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii/Types.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
Copy link
Member

@DigitalBrains1 DigitalBrains1 left a comment

Choose a reason for hiding this comment

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

Nice job figuring out the primitive!

But I do think there's room for improvement. CI has some errors for you as well.

clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii/Types.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii/Types.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
@lmbollen lmbollen force-pushed the add-gig-ethernet-pcs-pma branch 3 times, most recently from 93b8d16 to 10dc37e Compare April 25, 2024 10:21
Copy link
Member

@DigitalBrains1 DigitalBrains1 left a comment

Choose a reason for hiding this comment

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

First, it occurred to me you don't provide a VHDL primitive. If this isn't a simple oversight, it should be documented.

I was thinking about the module structure. Clash.Cores.Xilinx.Ethernet.Gmii is almost empty; it's just two definitions. If people want to do anything with the core other than just passing through inputs and outputs literally, they need to import Clash.Cores.Xilinx.Ethernet.Gmii.Types.

Maybe you are accomodating the module name for future additions of other cores that could be considered GMII?

I wonder if this even needs to be more than one module. We could have the Clash.Cores.Xilinx.Ethernet.Gmii module as follows:

  • gmiiSgmiiBridge
  • Gmii
  • DuplexMode
  • LinkSpeed
  • Pause
  • AutoNegConfig
  • Config
  • Status
  • BridgeOutput

And then a section Internal in the Haddock with the following:

  • gmiiSgmiiBridgePrim
  • AutoNegConfigVector
  • toAutoNegConfigVector (if pack is insufficient)
  • ConfigVector
  • toConfigVector (if pack is insufficient)
  • StatusVector
  • fromStatusVector (if unpack is insufficient)
  • tclTemplateFunction
  • tclTemplate

In this configuration, you'd just put the InlineYamlPrimitive implementation directly inside the annotation as the GHC staging restriction prevents you from using a function defined in the same module.

Also, this is just in the order that it is currently in the Haddock; I'm not proposing an ordering here. Do that as you think makes sense to the reader.

Alternatively, all the things that are marked Internal above could go into a separate module Clash.Cores.Xilinx.Ethernet.Gmii.Internal that is hidden from Haddock (but still exposed in the library! We like giving everybody all functions to do with as they please, as long as they understand it's all internal.)

I'm also wondering a bit about the very generic name of the module. What if some day we want to add another thing that is GMII, but has a different definition for Config, Status, LinkSpeed, ...? Maybe the module name should be GmiiSgmiiBridge. It's a bit long, but it does enable adding other cores later without getting them all mixed up. Ah, no, wait, this specific core can be configured as other things as well. Ugh. Naming things is hard.

clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii/Types.hs Outdated Show resolved Hide resolved
@lmbollen lmbollen force-pushed the add-gig-ethernet-pcs-pma branch 2 times, most recently from 7af30f7 to 5641e04 Compare May 10, 2024 09:24
@lmbollen lmbollen force-pushed the add-gig-ethernet-pcs-pma branch 3 times, most recently from 16327a6 to a8cdb95 Compare June 14, 2024 07:59
@lmbollen lmbollen force-pushed the add-gig-ethernet-pcs-pma branch 3 times, most recently from a107535 to f0b668f Compare July 5, 2024 11:24
@lmbollen lmbollen requested a review from christiaanb July 5, 2024 11:24
Copy link
Member

@DigitalBrains1 DigitalBrains1 left a comment

Choose a reason for hiding this comment

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

I think this concludes my review, but mostly I just want to go home now :-).

clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
Copy link
Member

@DigitalBrains1 DigitalBrains1 left a comment

Choose a reason for hiding this comment

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

Christiaans very first review comment was

The module documentation header should be at the very top, before the LANGUAGE and OPTIONS_GHC pragmas

but I suddenly realise that the fix for that evidently did not survive the reorganisation of the files...

@DigitalBrains1
Copy link
Member

Also, you forgot to hide the Internal module from Haddock.

Copy link
Member

@DigitalBrains1 DigitalBrains1 left a comment

Choose a reason for hiding this comment

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

You didn't apply all my suggestions. If you disagree with them, could you please discuss instead of simply presenting it again for review?

clash-cores/src/Clash/Cores/Xilinx/Ethernet/Gmii.hs Outdated Show resolved Hide resolved
Copy link
Member

@DigitalBrains1 DigitalBrains1 left a comment

Choose a reason for hiding this comment

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

LGTM!

@lmbollen lmbollen dismissed stale reviews from christiaanb and DigitalBrains1 August 7, 2024 09:50

Changes implemented

@lmbollen lmbollen enabled auto-merge (squash) August 7, 2024 09:51
@lmbollen lmbollen disabled auto-merge August 7, 2024 09:54
@lmbollen lmbollen enabled auto-merge August 7, 2024 09:54
lmbollen added a commit to bittide/bittide-hardware that referenced this pull request Aug 7, 2024
lmbollen added a commit to bittide/bittide-hardware that referenced this pull request Aug 7, 2024
@lmbollen lmbollen merged commit 96f741d into master Aug 7, 2024
13 checks passed
@lmbollen lmbollen deleted the add-gig-ethernet-pcs-pma branch August 7, 2024 11:33
@DigitalBrains1
Copy link
Member

@lmbollen Could you open a PR with this change over on clash-lang/clash-cores so we can merge it there? This PR hit in an unfortunate time of limbo where this code still exists in clash-compiler but we already split off to the new repo before this PR.

@lmbollen
Copy link
Contributor Author

@DigitalBrains1 clash-lang/clash-cores#11 :)
I simply added clash-compiler as remote locally and cherry-picked 20c1749

Which is the only commit that touches the code.

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

Successfully merging this pull request may close these issues.

5 participants