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 Xilinx dual clock FIFO primitive #2182

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .ci/bindist/linux/debian/focal/buildinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,26 @@
"name": "generic-lens-core",
"src": {"type": "hackage", "version": "2.0.0.0"}
},
{
"name": "hedgehog",
"src": {"type": "hackage", "version": "1.0.5"}
},
{
"name": "tasty-hedgehog",
"src": {"type": "hackage", "version": "1.2.0.0"}
},
{
"name": "generic-lens",
"src": {"type": "hackage", "version": "2.0.0.0"}
},
{
"name": "regex-base",
"src": {"type": "hackage", "version": "0.94.0.2"}
},
{
"name": "regex-tdfa",
"src": {"type": "hackage", "version": "1.3.1.2"}
},
{
"name": "concurrent-extra",
"src": {"type": "hackage", "version": "0.7.0.12"},
Expand Down Expand Up @@ -77,6 +93,11 @@
],
"src": {"type": "local", "dir": "../../../../../clash-ghc"}
},
{
"name": "clash-cores",
"cabal_debian_options": ["--disable-haddock", "--disable-tests"],
"src": {"type": "local", "dir": "../../../../../clash-cores"}
},
{
"name": "clash-testsuite",
"src": {"type": "local", "dir": "../../../../../tests"},
Expand All @@ -86,7 +107,7 @@
"--depends", "haskell-clash-testsuite-utils:ghdl-llvm"
],
"after_install": {
"cmd": ["clash-testsuite", "-p", "Calculator.Verilog"],
"cmd": ["clash-testsuite", "-p", "Calculator.Verilog", "--no-vivado"],
"env": {"USE_GLOBAL_CLASH": "1"},
"cwd": "../../../../..",
"comment": "Sanity check"
Expand Down
5 changes: 3 additions & 2 deletions .ci/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,12 @@ FROM ubuntu:$UBUNTU_VERSION AS run
LABEL vendor="QBayLogic B.V." maintainer="[email protected]"
ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 LC_ALL=C.UTF-8 PATH="$PATH:/opt/bin:/root/.ghcup/bin"

ARG DEPS_RUNTIME="ca-certificates ccache curl g++ gcc git jq libc6-dev libgmp10-dev libgnat-9 libllvm11 libreadline8 libtinfo-dev libtcl8.6 make perl python3 ssh zlib1g-dev zlibc zstd"
ARG DEPS_RUNTIME="ca-certificates ccache curl g++ gcc git jq libc6-dev libgmp10-dev libgnat-9 libllvm11 libreadline8 libtinfo-dev libtcl8.6 make perl python3 ssh zlib1g-dev zlibc zstd locales libtinfo5 libx11-6"
RUN apt-get update \
&& apt-get install -y --no-install-recommends $DEPS_RUNTIME \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/* \
&& locale-gen en_US.UTF-8

COPY --from=build-ghdl /opt /opt
COPY --from=build-iverilog /opt /opt
Expand Down
2 changes: 1 addition & 1 deletion .ci/gitlab/benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.benchmark:
image: ghcr.io/clash-lang/clash-ci-$GHC_VERSION:2022-05-10
image: ghcr.io/clash-lang/clash-ci-$GHC_VERSION:2022-06-23
stage: test
timeout: 2 hours
variables:
Expand Down
2 changes: 1 addition & 1 deletion .ci/gitlab/common.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.common:
image: ghcr.io/clash-lang/clash-ci-$GHC_VERSION:2022-05-10
image: ghcr.io/clash-lang/clash-ci-$GHC_VERSION:2022-06-23
timeout: 2 hours
stage: build
variables:
Expand Down
2 changes: 1 addition & 1 deletion .ci/gitlab/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ debian-bindist-test:
- apt-get update
- cd .ci/bindist/linux/debian/focal/build && apt-get -y install ./*/*.deb && cd -
- apt-get -y install iverilog
- clash-testsuite -p '$(NF-3) == "Vector" && $(NF-1) == "Verilog"' --no-verilator
- clash-testsuite -p '$(NF-3) == "Vector" && $(NF-1) == "Verilog"' --no-verilator --no-vivado
tags:
- local

Expand Down
46 changes: 43 additions & 3 deletions .ci/gitlab/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,57 @@ prelude:doctests:
- cabal v2-run -- clash-prelude:doctests -j${THREADS}

# Tests run on local fast machines:

suite:vhdl:
extends: .test-common-local
script:
- cabal v2-run -- clash-testsuite -j$THREADS -p .VHDL --hide-successes
- cabal v2-run -- clash-testsuite -j$THREADS -p .VHDL --hide-successes --no-vivado

suite:verilog:
extends: .test-common-local
script:
- cabal v2-run -- clash-testsuite -j$THREADS -p .Verilog --hide-successes
- cabal v2-run -- clash-testsuite -j$THREADS -p .Verilog --hide-successes --no-vivado

suite:systemverilog:
extends: .test-common-local
script:
- cabal v2-run -- clash-testsuite -j$THREADS -p .SystemVerilog --hide-successes --no-modelsim
- cabal v2-run -- clash-testsuite -j$THREADS -p .SystemVerilog --hide-successes --no-modelsim --no-vivado

# Vivado is quite slow, so we only run a subset of the tests on development branches
# with it. The full testsuite gets run with Vivado every night on 'master'.
suite:cores:
extends: .test-common-local
script:
- source /opt/tools/Xilinx/Vivado/2022.1/settings64.sh
- cabal v2-run -- clash-testsuite -j$THREADS -p Cores --hide-successes --no-modelsim --no-ghdl --no-iverilog --no-verilator --no-symbiyosys
tags:
- local
- vivado-2022.1-standard


# Tests run on local fast machines with Vivado installed. We only run these at night
# to save resources - as Vivado is quite slow to execute.
.test-common-local-nightly:
extends: .test-common-local
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" # When schedueled (at night)
- if: $CI_PIPELINE_SOURCE == "trigger" # When triggered (manual triggers)
- if: '$CI_COMMIT_TAG != null' # When tags are set (releases)

suite:vivado:vhdl:
extends: .test-common-local-nightly
script:
- source /opt/tools/Xilinx/Vivado/2022.1/settings64.sh
- cabal v2-run -- clash-testsuite -j$THREADS -p .VHDL --hide-successes --no-modelsim --no-ghdl --no-iverilog --no-verilator --no-symbiyosys
tags:
- local
- vivado-2022.1-standard

suite:vivado:verilog:
extends: .test-common-local-nightly
script:
- source /opt/tools/Xilinx/Vivado/2022.1/settings64.sh
- cabal v2-run -- clash-testsuite -j$THREADS -p .Verilog --hide-successes --no-modelsim --no-ghdl --no-iverilog --no-verilator --no-symbiyosys
tags:
- local
- vivado-2022.1-standard
2 changes: 2 additions & 0 deletions .ci/stack-8.6.5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ extra-deps:
- fakedata-parser-0.1.0.0@sha256:6de870a2c21624aa4516f7ee28fc0076b3b19f3c32d23c969f8f0d7de47c606a,1362
- string-random-0.1.4.2@sha256:d34c614b63dbf928af428c1f2be033463c9bddfb286f3002657ef13336a2de32,2172
- lazysmallcheck-0.6@sha256:dac7a1e4877681f1260309e863e896674dd6efc1159897b7945893e693f2a6bc,1696
- regex-tdfa-1.3.1.2@sha256:9bafdeace4742f553d22a3da008081ac09009b3b52d38a53ad76795dfd3f180a,6572
- regex-base-0.94.0.2@sha256:4ff4425c710cddf440dfbac6cd52310bb6b23e17902390ff71c9fc7eaafc4fcc,2643
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
run: stack build

- name: Run Vector testsuite
run: stack run -- clash-testsuite --hide-successes -p .Vector. --no-ghdl --no-verilator --no-modelsim
run: stack run -- clash-testsuite --hide-successes -p .Vector. --no-ghdl --no-verilator --no-modelsim --no-vivado

build_and_test:
# Only run for external PRs
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:

# Run steps inside the clash CI docker image
container:
image: ghcr.io/clash-lang/clash-ci-${{ matrix.ghc }}:2022-05-10
image: ghcr.io/clash-lang/clash-ci-${{ matrix.ghc }}:2022-06-23

env:
THREADS: 2
Expand Down Expand Up @@ -139,10 +139,10 @@ jobs:
cabal v2-test clash-cosim

- name: Testsuite (VHDL)
run: cabal v2-run clash-testsuite -- -j$THREADS --hide-successes -p .VHDL
run: cabal v2-run clash-testsuite -- -j$THREADS --hide-successes -p .VHDL --no-vivado

- name: Testsuite (Verilog)
run: cabal v2-run clash-testsuite -- -j$THREADS --hide-successes -p .Verilog
run: cabal v2-run clash-testsuite -- -j$THREADS --hide-successes -p .Verilog --no-vivado

- name: Testsuite (SystemVerilog)
run: cabal v2-run clash-testsuite -- -j$THREADS --hide-successes -p .SystemVerilog --no-modelsim
run: cabal v2-run clash-testsuite -- -j$THREADS --hide-successes -p .SystemVerilog --no-modelsim --no-vivado
16 changes: 13 additions & 3 deletions clash-cores/clash-cores.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,19 @@ common basic-config
ghc-typelits-knownnat >= 0.6,
interpolate >= 0.2,
QuickCheck,
template-haskell
template-haskell,
containers >=0.5 && <0.7

library
import: basic-config
hs-source-dirs: src

exposed-modules:
Clash.Cores.Xilinx.Common
Clash.Cores.Xilinx.DcFifo
Clash.Cores.Xilinx.DcFifo.BlackBoxes
Clash.Cores.Xilinx.DcFifo.Explicit
Clash.Cores.Xilinx.DcFifo.Instances
Clash.Cores.Xilinx.Floating
Clash.Cores.Xilinx.Floating.Annotations
Clash.Cores.Xilinx.Floating.BlackBoxes
Expand Down Expand Up @@ -112,9 +118,13 @@ test-suite unittests
Test.Cores.SPI
Test.Cores.UART
Test.Cores.SPI.MultiSlave
Test.Cores.Xilinx.DcFifo

build-depends:
clash-cores,
tasty >= 1.2 && < 1.3,
clash-lib,
tasty >= 1.2 && < 1.5,
tasty-hunit,
tasty-quickcheck
tasty-quickcheck,
hedgehog,
tasty-hedgehog >= 1.2.0
91 changes: 91 additions & 0 deletions clash-cores/src/Clash/Cores/Xilinx/Common.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{-|
Copyright : (C) 2022 Google Inc
License : BSD2 (see the file LICENSE)
Maintainer : QBayLogic B.V. <[email protected]>

Common utilities for defining Xilinx IP primitives.
-}

{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE QuasiQuotes #-}

module Clash.Cores.Xilinx.Common where

import Prelude

import Clash.Netlist.Id (Identifier)
import Data.String (fromString)
import Data.String.Interpolate (i)
import Data.Text.Prettyprint.Doc.Extra (Doc)

import qualified Clash.Netlist.Id as Id
import qualified Data.Text as Text
import Data.List (intercalate)

type PropName = String
type PropValue = String
type Property = (PropName, PropValue)

data IpConfig = IpConfig
{ name :: String
, vendor :: String
, library :: String
, version :: String
, moduleName :: Identifier
, properties :: [Property]
}

defIpConfig ::
-- | Name of IP core. For example: \"fifo_generator\".
String ->
-- | Version of IP core. For example: \"13.2\".
String ->
-- | Name of module the IP core should be generated as. For example: \"dcfifo\". This
-- name should be unique. See "Clash.Netlist.Id" for more information on how to
-- generate unique identifiers.
Identifier ->
-- | Configuration with sensible defaults.
IpConfig
defIpConfig name_ version_ moduleName_ = IpConfig
{ name = name_
, version = version_
, moduleName = moduleName_
, vendor = "xilinx.com"
, library = "ip"
, properties = []
}

renderTcl :: IpConfig -> Doc
renderTcl IpConfig{..} =
fromString [i|
proc createNamespace ns {
namespace eval $ns {
variable api {1}
variable ipName {#{moduleNameString}}
variable scriptPurpose {createIp}
proc createIp {ipName0 args} {
create_ip \\
-name #{name} \\
-vendor #{vendor} \\
-library #{library} \\
-version #{version} \\
-module_name $ipName0 \\
{*}$args

set_property -dict [list \\
#{renderedProperties}
] \\
[get_ips {#{moduleNameString}}]
}
}
}|]

where
moduleNameString = Text.unpack (Id.toText moduleName)
renderedProperties = intercalate "\n" (map prop properties)
prop (name_, value) = [i|#{indent}CONFIG.#{name_} {#{value}} \\|]
indent = replicate 25 ' '

toTclBool :: Bool -> String
toTclBool True = "true"
toTclBool False = "false"
8 changes: 8 additions & 0 deletions clash-cores/src/Clash/Cores/Xilinx/DcFifo.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Clash.Cores.Xilinx.DcFifo
( module Clash.Cores.Xilinx.DcFifo.BlackBoxes
, module Clash.Cores.Xilinx.DcFifo.Explicit
) where

import Clash.Cores.Xilinx.DcFifo.BlackBoxes
import Clash.Cores.Xilinx.DcFifo.Instances ()
import Clash.Cores.Xilinx.DcFifo.Explicit
Loading