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

Fix VHDL and SystemVerilog gen for Xilinx oddr #2833

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DigitalBrains1
Copy link
Member

Verilog correctly picked one of the possible arguments to inspect for ResetKind, but the others picked the KnownNat constraint.

This lead to the following error message:

<no location info>: error:
    Clash error call:
    Don't know how to get a Domain out of HWType: Unsigned 64
    CallStack (from HasCallStack):
      error, called at src/Clash/Netlist/BlackBox/Util.hs:654:8 in clash-lib-1.9.0-inplace:Clash.Netlist.BlackBox.Util
      generalGetDomainConf, called at src/Clash/Netlist/BlackBox/Util.hs:639:17 in clash-lib-1.9.0-inplace:Clash.Netli
st.BlackBox.Util
      getDomainConf, called at src/Clash/Netlist/BlackBox/Util.hs:597:20 in clash-lib-1.9.0-inplace:Clash.Netlist.Blac
kBox.Util
      renderElem, called at src/Clash/Netlist/BlackBox/Util.hs:320:15 in clash-lib-1.9.0-inplace:Clash.Netlist.BlackBo
x.Util

Without Vivado, we can't actually test these primitives. However, here they already errored out during HDL generation. Perhaps we should add a "HDL generation only" test for all primitives that don't yet occur in any of the other tests in the test suite. This would have caught this particular bug.

The bug was introduced in 2019 in commit 0c38d65 part of PR #527.

Still TODO:

  • Write a changelog entry (see changelog/README.md)
  • Check copyright notices are up to date in edited files

@DigitalBrains1
Copy link
Member Author

DigitalBrains1 commented Oct 26, 2024

Without Vivado, we can't actually test these primitives.

Of course, while we didn't have Vivado back when the bug was introduced, we do now. Maybe it's even worth it to make a combined test with IDDR and ODDR prims, but just a "does this generate HDL" test is much more quickly written.

Anyway, the names in HDL are a bit weird:

        D1 => dataout_l(i),    -- 1-bit data input (positive edge)
        D2 => dataout_h(i),    -- 1-bit data input (negative edge)

Why is the data for the positive edge labeled L and the data for the negative edge labeled H? Note that Clash.Explicit.DDR.ddrOut labels them data_Pos and data_Neg respectively, which makes more sense.

@christiaanb
Copy link
Member

I think they're called like that due to copy/paste from the Intel primitives where the output ports of the Intel primivite are called dataout_l and dataout_h:

dataout_h => ~SYM[2],
dataout_l => ~SYM[1]

@DigitalBrains1
Copy link
Member Author

DigitalBrains1 commented Oct 28, 2024

Shall I name them more obviously in this PR as well? I'm thinking dataout_p and dataout_n data_pos and data_neg, after the edge that they are presented. It's similar to what Clash.Explicit.DDR.ddrOut does, but without capitalisation. I think we more regularly use underscores as word separators in variables in HDL, and to use both underscores as well as case to separate words feels redundant.

Copy link
Member

@christiaanb christiaanb left a comment

Choose a reason for hiding this comment

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

Yes, please clean up the names, and also it would be nice if we tested these primitives on Vivado at least in nightly builds. I mean... we already do that for the generic DDRout primitives:

, let _opts = def{ buildTargets = BuildSpecific [ "testBenchUA"
, "testBenchUS"
, "testBenchGA"
, "testBenchGS"
]
, hdlLoad = [Vivado]
, hdlSim = [Vivado]
, clashFlags=["-fclash-hdlsyn", "Vivado"]
}
in runTest "DDRout" _opts

`Clash.Explicit.DDR.ddrOut`: VHDL: Fix incorrect usage of `Enable` signal. With
asynchronous resets, the `Enable` was not connected to the registers.
Furthermore, the `Enable` was combinatorially(!) connected to the mux
that selects the output. The mux should not be affected by the `Enable`
at all (with the current Haskell simulation model).

`Clash.Xilinx.DDR`:
  - `oddr`: Verilog correctly picked one of the possible arguments to
    inspect for `ResetKind`, but the others picked the `KnownNat`
    constraint. This caused Clash to error out during HDL generation.
  - Both in and out prims: Renamed symbols that were incorrectly
    copy-pasted from the Intel prims.

`Clash.Intel.DDR`:
  - `altddioOut`: VHDL: Several numeric identifiers were incorrect,
    referring to wrong arguments or symbols. HDL generation completed
    without error, but the resulting VHDL was completely broken.
  - Both prims: evaluate the `SSymbol` in Haskell to fix HDL generation
    warning about using an argument that is unused in Haskell.

Note that the DDR input primitives were not checked to work correctly
(but the next commit adds a test bench for Xilinx iddr). This PR purely
fixes stuff related to the /output/ primitives, with really minor
adjustments to the input primitives.
The existing test benches for the generic primitives (in
`tests/shouldwork/DDR`) could be copied verbatim to test the Xilinx DDR
primitives.
@DigitalBrains1
Copy link
Member Author

DigitalBrains1 commented Nov 9, 2024

Note to self: to do: run the nightly tests on a temporary branch to be absolutely sure they did not break. The changed test benches were run succesfully under a single configuration on my laptop, but CI will test a whole bunch of configurations.

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.

2 participants