From 6ae8403acc007fe4f3f23aed65471f80efa842b5 Mon Sep 17 00:00:00 2001 From: Rowan Goemans Date: Tue, 18 Jun 2024 19:54:56 +0200 Subject: [PATCH 1/7] Add fourmolu as formatter --- .github/workflows/ci.yml | 13 ++++++++++ format.sh | 55 ++++++++++++++++++++++++++++++++++++++++ fourmolu.yaml | 3 +++ 3 files changed, 71 insertions(+) create mode 100755 format.sh create mode 100644 fourmolu.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acfaaff17a..0b09b5f838 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,19 @@ concurrency: cancel-in-progress: true jobs: + fourmolu: + runs-on: ubuntu-latest + steps: + # Note that you must checkout your code before running haskell-actions/run-fourmolu + - uses: actions/checkout@v3 + - uses: haskell-actions/run-fourmolu@v9 + with: + version: "0.14.0.0" + pattern: | + *.hs + !clash-ghc/src-bin-* + + build_mac_windows: name: Build and run limited tests runs-on: ${{ matrix.os }} diff --git a/format.sh b/format.sh new file mode 100755 index 0000000000..4d97a7dcb0 --- /dev/null +++ b/format.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Help message +show_help() { + local script_name + script_name=$(basename "$0") + echo "Fourmolu formatting Script. + +Usage: + $script_name diff Format the current git diff. + $script_name full Format all source files. + $script_name check Check the formatting of the source files. + $script_name (-h | --help) + +Options: + -h --help Show this screen." +} + +# Main script logic +if [[ "$#" -eq 0 || "$1" == "-h" || "$1" == "--help" ]]; then + show_help + exit 0 +fi + +# use array so we can easily append +# Ignore the clash-ghc/src-bin-* since they basically copies of upstream GHC code +readarray -d '' exclude_files < <(find ./clash-ghc/src-bin-* -type f -name "*.hs" -print0) + +# Make sure it doesn't matter from where this script is executed +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $DIR + +if [ $1 == "diff" ] ; then + src_files=$(git diff --cached --name-only --diff-filter=ACMR -- '*.hs') +else + src_files=$(find ./* -type f -name "*.hs") +fi + +src_files_str=$(printf "%s\n" "${src_files[@]}" | sed 's| |\\ |g') +exclude_files_str=$(printf "%s\n" "${exclude_files[@]}" | sed 's| |\\ |g') +src_files=$(echo "$src_files_str" | grep -vwE "$exclude_files_str") + +if [ -z "$src_files" ]; then + exit 0; +fi + +if [[ "$1" == "diff" || "$1" == "full" ]] ; then + fourmolu --mode inplace $src_files +elif [[ "$1" == "check" ]] ; then + fourmolu --mode check $src_files +else + echo "Expected a single argument, \"full\", \"diff\", \"check\" or \"--help\"" >&2 + exit 3 +fi diff --git a/fourmolu.yaml b/fourmolu.yaml new file mode 100644 index 0000000000..f8cdee5889 --- /dev/null +++ b/fourmolu.yaml @@ -0,0 +1,3 @@ +indentation: 2 +column-limit: 90 + From e00b1968257aa20f5059d7d7e30e94299952c67d Mon Sep 17 00:00:00 2001 From: Rowan Goemans Date: Tue, 18 Jun 2024 19:55:02 +0200 Subject: [PATCH 2/7] clash-cores: Add missing `TryDomain` for CRC in the catalog --- clash-cores/src/Clash/Cores/Crc/Catalog.hs | 158 +++++++++++++++++++++ 1 file changed, 158 insertions(+) diff --git a/clash-cores/src/Clash/Cores/Crc/Catalog.hs b/clash-cores/src/Clash/Cores/Crc/Catalog.hs index 9c3c5d482b..7533ff0f2d 100644 --- a/clash-cores/src/Clash/Cores/Crc/Catalog.hs +++ b/clash-cores/src/Clash/Cores/Crc/Catalog.hs @@ -15,9 +15,11 @@ All entries are from https://reveng.sourceforge.io/crc-catalogue/all.htm module Clash.Cores.Crc.Catalog where import Clash.Prelude +import Clash.Class.HasDomain (TryDomain, TryDomainResult(NotFound)) import Clash.Cores.Crc.Internal data Crc3_gsm = Crc3_gsm deriving Show +type instance TryDomain t Crc3_gsm = 'NotFound instance KnownCrc Crc3_gsm where type CrcWidth Crc3_gsm = 3 crcParams _ = CrcParams @@ -30,6 +32,7 @@ instance KnownCrc Crc3_gsm where } data Crc3_rohc = Crc3_rohc deriving Show +type instance TryDomain t Crc3_rohc = 'NotFound instance KnownCrc Crc3_rohc where type CrcWidth Crc3_rohc = 3 crcParams _ = CrcParams @@ -42,6 +45,7 @@ instance KnownCrc Crc3_rohc where } data Crc4_g_704 = Crc4_g_704 deriving Show +type instance TryDomain t Crc4_g_704 = 'NotFound instance KnownCrc Crc4_g_704 where type CrcWidth Crc4_g_704 = 4 crcParams _ = CrcParams @@ -54,11 +58,13 @@ instance KnownCrc Crc4_g_704 where } data Crc4_itu = Crc4_itu deriving Show +type instance TryDomain t Crc4_itu = 'NotFound instance KnownCrc Crc4_itu where type CrcWidth Crc4_itu = CrcWidth Crc4_g_704 crcParams _ = crcParams Crc4_g_704 data Crc4_interlaken = Crc4_interlaken deriving Show +type instance TryDomain t Crc4_interlaken = 'NotFound instance KnownCrc Crc4_interlaken where type CrcWidth Crc4_interlaken = 4 crcParams _ = CrcParams @@ -71,6 +77,7 @@ instance KnownCrc Crc4_interlaken where } data Crc5_epc_c1g2 = Crc5_epc_c1g2 deriving Show +type instance TryDomain t Crc5_epc_c1g2 = 'NotFound instance KnownCrc Crc5_epc_c1g2 where type CrcWidth Crc5_epc_c1g2 = 5 crcParams _ = CrcParams @@ -83,11 +90,13 @@ instance KnownCrc Crc5_epc_c1g2 where } data Crc5_epc = Crc5_epc deriving Show +type instance TryDomain t Crc5_epc = 'NotFound instance KnownCrc Crc5_epc where type CrcWidth Crc5_epc = CrcWidth Crc5_epc_c1g2 crcParams _ = crcParams Crc5_epc_c1g2 data Crc5_g_704 = Crc5_g_704 deriving Show +type instance TryDomain t Crc5_g_704 = 'NotFound instance KnownCrc Crc5_g_704 where type CrcWidth Crc5_g_704 = 5 crcParams _ = CrcParams @@ -100,11 +109,13 @@ instance KnownCrc Crc5_g_704 where } data Crc5_itu = Crc5_itu deriving Show +type instance TryDomain t Crc5_itu = 'NotFound instance KnownCrc Crc5_itu where type CrcWidth Crc5_itu = CrcWidth Crc5_g_704 crcParams _ = crcParams Crc5_g_704 data Crc5_usb = Crc5_usb deriving Show +type instance TryDomain t Crc5_usb = 'NotFound instance KnownCrc Crc5_usb where type CrcWidth Crc5_usb = 5 crcParams _ = CrcParams @@ -117,6 +128,7 @@ instance KnownCrc Crc5_usb where } data Crc6_cdma2000_a = Crc6_cdma2000_a deriving Show +type instance TryDomain t Crc6_cdma2000_a = 'NotFound instance KnownCrc Crc6_cdma2000_a where type CrcWidth Crc6_cdma2000_a = 6 crcParams _ = CrcParams @@ -129,6 +141,7 @@ instance KnownCrc Crc6_cdma2000_a where } data Crc6_cdma2000_b = Crc6_cdma2000_b deriving Show +type instance TryDomain t Crc6_cdma2000_b = 'NotFound instance KnownCrc Crc6_cdma2000_b where type CrcWidth Crc6_cdma2000_b = 6 crcParams _ = CrcParams @@ -141,6 +154,7 @@ instance KnownCrc Crc6_cdma2000_b where } data Crc6_darc = Crc6_darc deriving Show +type instance TryDomain t Crc6_darc = 'NotFound instance KnownCrc Crc6_darc where type CrcWidth Crc6_darc = 6 crcParams _ = CrcParams @@ -153,6 +167,7 @@ instance KnownCrc Crc6_darc where } data Crc6_g_704 = Crc6_g_704 deriving Show +type instance TryDomain t Crc6_g_704 = 'NotFound instance KnownCrc Crc6_g_704 where type CrcWidth Crc6_g_704 = 6 crcParams _ = CrcParams @@ -165,11 +180,13 @@ instance KnownCrc Crc6_g_704 where } data Crc6_itu = Crc6_itu deriving Show +type instance TryDomain t Crc6_itu = 'NotFound instance KnownCrc Crc6_itu where type CrcWidth Crc6_itu = CrcWidth Crc6_g_704 crcParams _ = crcParams Crc6_g_704 data Crc6_gsm = Crc6_gsm deriving Show +type instance TryDomain t Crc6_gsm = 'NotFound instance KnownCrc Crc6_gsm where type CrcWidth Crc6_gsm = 6 crcParams _ = CrcParams @@ -182,6 +199,7 @@ instance KnownCrc Crc6_gsm where } data Crc7_mmc = Crc7_mmc deriving Show +type instance TryDomain t Crc7_mmc = 'NotFound instance KnownCrc Crc7_mmc where type CrcWidth Crc7_mmc = 7 crcParams _ = CrcParams @@ -194,6 +212,7 @@ instance KnownCrc Crc7_mmc where } data Crc7_rohc = Crc7_rohc deriving Show +type instance TryDomain t Crc7_rohc = 'NotFound instance KnownCrc Crc7_rohc where type CrcWidth Crc7_rohc = 7 crcParams _ = CrcParams @@ -206,6 +225,7 @@ instance KnownCrc Crc7_rohc where } data Crc7_umts = Crc7_umts deriving Show +type instance TryDomain t Crc7_umts = 'NotFound instance KnownCrc Crc7_umts where type CrcWidth Crc7_umts = 7 crcParams _ = CrcParams @@ -218,6 +238,7 @@ instance KnownCrc Crc7_umts where } data Crc8_autosar = Crc8_autosar deriving Show +type instance TryDomain t Crc8_autosar = 'NotFound instance KnownCrc Crc8_autosar where type CrcWidth Crc8_autosar = 8 crcParams _ = CrcParams @@ -230,6 +251,7 @@ instance KnownCrc Crc8_autosar where } data Crc8_bluetooth = Crc8_bluetooth deriving Show +type instance TryDomain t Crc8_bluetooth = 'NotFound instance KnownCrc Crc8_bluetooth where type CrcWidth Crc8_bluetooth = 8 crcParams _ = CrcParams @@ -242,6 +264,7 @@ instance KnownCrc Crc8_bluetooth where } data Crc8_cdma2000 = Crc8_cdma2000 deriving Show +type instance TryDomain t Crc8_cdma2000 = 'NotFound instance KnownCrc Crc8_cdma2000 where type CrcWidth Crc8_cdma2000 = 8 crcParams _ = CrcParams @@ -254,6 +277,7 @@ instance KnownCrc Crc8_cdma2000 where } data Crc8_darc = Crc8_darc deriving Show +type instance TryDomain t Crc8_darc = 'NotFound instance KnownCrc Crc8_darc where type CrcWidth Crc8_darc = 8 crcParams _ = CrcParams @@ -266,6 +290,7 @@ instance KnownCrc Crc8_darc where } data Crc8_dvb_s2 = Crc8_dvb_s2 deriving Show +type instance TryDomain t Crc8_dvb_s2 = 'NotFound instance KnownCrc Crc8_dvb_s2 where type CrcWidth Crc8_dvb_s2 = 8 crcParams _ = CrcParams @@ -278,6 +303,7 @@ instance KnownCrc Crc8_dvb_s2 where } data Crc8_gsm_a = Crc8_gsm_a deriving Show +type instance TryDomain t Crc8_gsm_a = 'NotFound instance KnownCrc Crc8_gsm_a where type CrcWidth Crc8_gsm_a = 8 crcParams _ = CrcParams @@ -290,6 +316,7 @@ instance KnownCrc Crc8_gsm_a where } data Crc8_gsm_b = Crc8_gsm_b deriving Show +type instance TryDomain t Crc8_gsm_b = 'NotFound instance KnownCrc Crc8_gsm_b where type CrcWidth Crc8_gsm_b = 8 crcParams _ = CrcParams @@ -302,6 +329,7 @@ instance KnownCrc Crc8_gsm_b where } data Crc8_hitag = Crc8_hitag deriving Show +type instance TryDomain t Crc8_hitag = 'NotFound instance KnownCrc Crc8_hitag where type CrcWidth Crc8_hitag = 8 crcParams _ = CrcParams @@ -314,6 +342,7 @@ instance KnownCrc Crc8_hitag where } data Crc8_i_432_1 = Crc8_i_432_1 deriving Show +type instance TryDomain t Crc8_i_432_1 = 'NotFound instance KnownCrc Crc8_i_432_1 where type CrcWidth Crc8_i_432_1 = 8 crcParams _ = CrcParams @@ -326,11 +355,13 @@ instance KnownCrc Crc8_i_432_1 where } data Crc8_itu = Crc8_itu deriving Show +type instance TryDomain t Crc8_itu = 'NotFound instance KnownCrc Crc8_itu where type CrcWidth Crc8_itu = CrcWidth Crc8_i_432_1 crcParams _ = crcParams Crc8_i_432_1 data Crc8_i_code = Crc8_i_code deriving Show +type instance TryDomain t Crc8_i_code = 'NotFound instance KnownCrc Crc8_i_code where type CrcWidth Crc8_i_code = 8 crcParams _ = CrcParams @@ -343,6 +374,7 @@ instance KnownCrc Crc8_i_code where } data Crc8_lte = Crc8_lte deriving Show +type instance TryDomain t Crc8_lte = 'NotFound instance KnownCrc Crc8_lte where type CrcWidth Crc8_lte = 8 crcParams _ = CrcParams @@ -355,6 +387,7 @@ instance KnownCrc Crc8_lte where } data Crc8_maxim_dow = Crc8_maxim_dow deriving Show +type instance TryDomain t Crc8_maxim_dow = 'NotFound instance KnownCrc Crc8_maxim_dow where type CrcWidth Crc8_maxim_dow = 8 crcParams _ = CrcParams @@ -367,11 +400,13 @@ instance KnownCrc Crc8_maxim_dow where } data Crc8_maxim = Crc8_maxim deriving Show +type instance TryDomain t Crc8_maxim = 'NotFound instance KnownCrc Crc8_maxim where type CrcWidth Crc8_maxim = CrcWidth Crc8_maxim_dow crcParams _ = crcParams Crc8_maxim_dow data Crc8_mifare_mad = Crc8_mifare_mad deriving Show +type instance TryDomain t Crc8_mifare_mad = 'NotFound instance KnownCrc Crc8_mifare_mad where type CrcWidth Crc8_mifare_mad = 8 crcParams _ = CrcParams @@ -384,6 +419,7 @@ instance KnownCrc Crc8_mifare_mad where } data Crc8_nrsc_5 = Crc8_nrsc_5 deriving Show +type instance TryDomain t Crc8_nrsc_5 = 'NotFound instance KnownCrc Crc8_nrsc_5 where type CrcWidth Crc8_nrsc_5 = 8 crcParams _ = CrcParams @@ -396,6 +432,7 @@ instance KnownCrc Crc8_nrsc_5 where } data Crc8_opensafety = Crc8_opensafety deriving Show +type instance TryDomain t Crc8_opensafety = 'NotFound instance KnownCrc Crc8_opensafety where type CrcWidth Crc8_opensafety = 8 crcParams _ = CrcParams @@ -408,6 +445,7 @@ instance KnownCrc Crc8_opensafety where } data Crc8_rohc = Crc8_rohc deriving Show +type instance TryDomain t Crc8_rohc = 'NotFound instance KnownCrc Crc8_rohc where type CrcWidth Crc8_rohc = 8 crcParams _ = CrcParams @@ -420,6 +458,7 @@ instance KnownCrc Crc8_rohc where } data Crc8_sae_j1850 = Crc8_sae_j1850 deriving Show +type instance TryDomain t Crc8_sae_j1850 = 'NotFound instance KnownCrc Crc8_sae_j1850 where type CrcWidth Crc8_sae_j1850 = 8 crcParams _ = CrcParams @@ -432,6 +471,7 @@ instance KnownCrc Crc8_sae_j1850 where } data Crc8_smbus = Crc8_smbus deriving Show +type instance TryDomain t Crc8_smbus = 'NotFound instance KnownCrc Crc8_smbus where type CrcWidth Crc8_smbus = 8 crcParams _ = CrcParams @@ -444,6 +484,7 @@ instance KnownCrc Crc8_smbus where } data Crc8_tech_3250 = Crc8_tech_3250 deriving Show +type instance TryDomain t Crc8_tech_3250 = 'NotFound instance KnownCrc Crc8_tech_3250 where type CrcWidth Crc8_tech_3250 = 8 crcParams _ = CrcParams @@ -456,16 +497,19 @@ instance KnownCrc Crc8_tech_3250 where } data Crc8_aes = Crc8_aes deriving Show +type instance TryDomain t Crc8_aes = 'NotFound instance KnownCrc Crc8_aes where type CrcWidth Crc8_aes = CrcWidth Crc8_tech_3250 crcParams _ = crcParams Crc8_tech_3250 data Crc8_etu = Crc8_etu deriving Show +type instance TryDomain t Crc8_etu = 'NotFound instance KnownCrc Crc8_etu where type CrcWidth Crc8_etu = CrcWidth Crc8_tech_3250 crcParams _ = crcParams Crc8_tech_3250 data Crc8_wcdma = Crc8_wcdma deriving Show +type instance TryDomain t Crc8_wcdma = 'NotFound instance KnownCrc Crc8_wcdma where type CrcWidth Crc8_wcdma = 8 crcParams _ = CrcParams @@ -478,6 +522,7 @@ instance KnownCrc Crc8_wcdma where } data Crc10_atm = Crc10_atm deriving Show +type instance TryDomain t Crc10_atm = 'NotFound instance KnownCrc Crc10_atm where type CrcWidth Crc10_atm = 10 crcParams _ = CrcParams @@ -490,11 +535,13 @@ instance KnownCrc Crc10_atm where } data Crc10_i_610 = Crc10_i_610 deriving Show +type instance TryDomain t Crc10_i_610 = 'NotFound instance KnownCrc Crc10_i_610 where type CrcWidth Crc10_i_610 = CrcWidth Crc10_atm crcParams _ = crcParams Crc10_atm data Crc10_cdma2000 = Crc10_cdma2000 deriving Show +type instance TryDomain t Crc10_cdma2000 = 'NotFound instance KnownCrc Crc10_cdma2000 where type CrcWidth Crc10_cdma2000 = 10 crcParams _ = CrcParams @@ -507,6 +554,7 @@ instance KnownCrc Crc10_cdma2000 where } data Crc10_gsm = Crc10_gsm deriving Show +type instance TryDomain t Crc10_gsm = 'NotFound instance KnownCrc Crc10_gsm where type CrcWidth Crc10_gsm = 10 crcParams _ = CrcParams @@ -519,6 +567,7 @@ instance KnownCrc Crc10_gsm where } data Crc11_flexray = Crc11_flexray deriving Show +type instance TryDomain t Crc11_flexray = 'NotFound instance KnownCrc Crc11_flexray where type CrcWidth Crc11_flexray = 11 crcParams _ = CrcParams @@ -531,6 +580,7 @@ instance KnownCrc Crc11_flexray where } data Crc11_umts = Crc11_umts deriving Show +type instance TryDomain t Crc11_umts = 'NotFound instance KnownCrc Crc11_umts where type CrcWidth Crc11_umts = 11 crcParams _ = CrcParams @@ -543,6 +593,7 @@ instance KnownCrc Crc11_umts where } data Crc12_cdma2000 = Crc12_cdma2000 deriving Show +type instance TryDomain t Crc12_cdma2000 = 'NotFound instance KnownCrc Crc12_cdma2000 where type CrcWidth Crc12_cdma2000 = 12 crcParams _ = CrcParams @@ -555,6 +606,7 @@ instance KnownCrc Crc12_cdma2000 where } data Crc12_dect = Crc12_dect deriving Show +type instance TryDomain t Crc12_dect = 'NotFound instance KnownCrc Crc12_dect where type CrcWidth Crc12_dect = 12 crcParams _ = CrcParams @@ -567,6 +619,7 @@ instance KnownCrc Crc12_dect where } data Crc12_gsm = Crc12_gsm deriving Show +type instance TryDomain t Crc12_gsm = 'NotFound instance KnownCrc Crc12_gsm where type CrcWidth Crc12_gsm = 12 crcParams _ = CrcParams @@ -579,6 +632,7 @@ instance KnownCrc Crc12_gsm where } data Crc12_umts = Crc12_umts deriving Show +type instance TryDomain t Crc12_umts = 'NotFound instance KnownCrc Crc12_umts where type CrcWidth Crc12_umts = 12 crcParams _ = CrcParams @@ -591,11 +645,13 @@ instance KnownCrc Crc12_umts where } data Crc12_3gpp = Crc12_3gpp deriving Show +type instance TryDomain t Crc12_3gpp = 'NotFound instance KnownCrc Crc12_3gpp where type CrcWidth Crc12_3gpp = CrcWidth Crc12_umts crcParams _ = crcParams Crc12_umts data Crc13_bbc = Crc13_bbc deriving Show +type instance TryDomain t Crc13_bbc = 'NotFound instance KnownCrc Crc13_bbc where type CrcWidth Crc13_bbc = 13 crcParams _ = CrcParams @@ -608,6 +664,7 @@ instance KnownCrc Crc13_bbc where } data Crc14_darc = Crc14_darc deriving Show +type instance TryDomain t Crc14_darc = 'NotFound instance KnownCrc Crc14_darc where type CrcWidth Crc14_darc = 14 crcParams _ = CrcParams @@ -620,6 +677,7 @@ instance KnownCrc Crc14_darc where } data Crc14_gsm = Crc14_gsm deriving Show +type instance TryDomain t Crc14_gsm = 'NotFound instance KnownCrc Crc14_gsm where type CrcWidth Crc14_gsm = 14 crcParams _ = CrcParams @@ -632,6 +690,7 @@ instance KnownCrc Crc14_gsm where } data Crc15_can = Crc15_can deriving Show +type instance TryDomain t Crc15_can = 'NotFound instance KnownCrc Crc15_can where type CrcWidth Crc15_can = 15 crcParams _ = CrcParams @@ -644,6 +703,7 @@ instance KnownCrc Crc15_can where } data Crc15_mpt1327 = Crc15_mpt1327 deriving Show +type instance TryDomain t Crc15_mpt1327 = 'NotFound instance KnownCrc Crc15_mpt1327 where type CrcWidth Crc15_mpt1327 = 15 crcParams _ = CrcParams @@ -656,6 +716,7 @@ instance KnownCrc Crc15_mpt1327 where } data Crc16_arc = Crc16_arc deriving Show +type instance TryDomain t Crc16_arc = 'NotFound instance KnownCrc Crc16_arc where type CrcWidth Crc16_arc = 16 crcParams _ = CrcParams @@ -668,11 +729,13 @@ instance KnownCrc Crc16_arc where } data Crc16_ibm = Crc16_ibm deriving Show +type instance TryDomain t Crc16_ibm = 'NotFound instance KnownCrc Crc16_ibm where type CrcWidth Crc16_ibm = CrcWidth Crc16_arc crcParams _ = crcParams Crc16_arc data Crc16_cdma2000 = Crc16_cdma2000 deriving Show +type instance TryDomain t Crc16_cdma2000 = 'NotFound instance KnownCrc Crc16_cdma2000 where type CrcWidth Crc16_cdma2000 = 16 crcParams _ = CrcParams @@ -685,6 +748,7 @@ instance KnownCrc Crc16_cdma2000 where } data Crc16_cms = Crc16_cms deriving Show +type instance TryDomain t Crc16_cms = 'NotFound instance KnownCrc Crc16_cms where type CrcWidth Crc16_cms = 16 crcParams _ = CrcParams @@ -697,6 +761,7 @@ instance KnownCrc Crc16_cms where } data Crc16_dds_110 = Crc16_dds_110 deriving Show +type instance TryDomain t Crc16_dds_110 = 'NotFound instance KnownCrc Crc16_dds_110 where type CrcWidth Crc16_dds_110 = 16 crcParams _ = CrcParams @@ -709,6 +774,7 @@ instance KnownCrc Crc16_dds_110 where } data Crc16_dect_r = Crc16_dect_r deriving Show +type instance TryDomain t Crc16_dect_r = 'NotFound instance KnownCrc Crc16_dect_r where type CrcWidth Crc16_dect_r = 16 crcParams _ = CrcParams @@ -721,6 +787,7 @@ instance KnownCrc Crc16_dect_r where } data Crc16_dect_x = Crc16_dect_x deriving Show +type instance TryDomain t Crc16_dect_x = 'NotFound instance KnownCrc Crc16_dect_x where type CrcWidth Crc16_dect_x = 16 crcParams _ = CrcParams @@ -733,6 +800,7 @@ instance KnownCrc Crc16_dect_x where } data Crc16_dnp = Crc16_dnp deriving Show +type instance TryDomain t Crc16_dnp = 'NotFound instance KnownCrc Crc16_dnp where type CrcWidth Crc16_dnp = 16 crcParams _ = CrcParams @@ -745,6 +813,7 @@ instance KnownCrc Crc16_dnp where } data Crc16_en_13757 = Crc16_en_13757 deriving Show +type instance TryDomain t Crc16_en_13757 = 'NotFound instance KnownCrc Crc16_en_13757 where type CrcWidth Crc16_en_13757 = 16 crcParams _ = CrcParams @@ -757,6 +826,7 @@ instance KnownCrc Crc16_en_13757 where } data Crc16_genibus = Crc16_genibus deriving Show +type instance TryDomain t Crc16_genibus = 'NotFound instance KnownCrc Crc16_genibus where type CrcWidth Crc16_genibus = 16 crcParams _ = CrcParams @@ -769,26 +839,31 @@ instance KnownCrc Crc16_genibus where } data Crc16_darc = Crc16_darc deriving Show +type instance TryDomain t Crc16_darc = 'NotFound instance KnownCrc Crc16_darc where type CrcWidth Crc16_darc = CrcWidth Crc16_genibus crcParams _ = crcParams Crc16_genibus data Crc16_epc = Crc16_epc deriving Show +type instance TryDomain t Crc16_epc = 'NotFound instance KnownCrc Crc16_epc where type CrcWidth Crc16_epc = CrcWidth Crc16_genibus crcParams _ = crcParams Crc16_genibus data Crc16_epc_c1g2 = Crc16_epc_c1g2 deriving Show +type instance TryDomain t Crc16_epc_c1g2 = 'NotFound instance KnownCrc Crc16_epc_c1g2 where type CrcWidth Crc16_epc_c1g2 = CrcWidth Crc16_genibus crcParams _ = crcParams Crc16_genibus data Crc16_i_code = Crc16_i_code deriving Show +type instance TryDomain t Crc16_i_code = 'NotFound instance KnownCrc Crc16_i_code where type CrcWidth Crc16_i_code = CrcWidth Crc16_genibus crcParams _ = crcParams Crc16_genibus data Crc16_gsm = Crc16_gsm deriving Show +type instance TryDomain t Crc16_gsm = 'NotFound instance KnownCrc Crc16_gsm where type CrcWidth Crc16_gsm = 16 crcParams _ = CrcParams @@ -801,6 +876,7 @@ instance KnownCrc Crc16_gsm where } data Crc16_ibm_3740 = Crc16_ibm_3740 deriving Show +type instance TryDomain t Crc16_ibm_3740 = 'NotFound instance KnownCrc Crc16_ibm_3740 where type CrcWidth Crc16_ibm_3740 = 16 crcParams _ = CrcParams @@ -813,16 +889,19 @@ instance KnownCrc Crc16_ibm_3740 where } data Crc16_autosar = Crc16_autosar deriving Show +type instance TryDomain t Crc16_autosar = 'NotFound instance KnownCrc Crc16_autosar where type CrcWidth Crc16_autosar = CrcWidth Crc16_ibm_3740 crcParams _ = crcParams Crc16_ibm_3740 data Crc16_ccitt_false = Crc16_ccitt_false deriving Show +type instance TryDomain t Crc16_ccitt_false = 'NotFound instance KnownCrc Crc16_ccitt_false where type CrcWidth Crc16_ccitt_false = CrcWidth Crc16_ibm_3740 crcParams _ = crcParams Crc16_ibm_3740 data Crc16_ibm_sdlc = Crc16_ibm_sdlc deriving Show +type instance TryDomain t Crc16_ibm_sdlc = 'NotFound instance KnownCrc Crc16_ibm_sdlc where type CrcWidth Crc16_ibm_sdlc = 16 crcParams _ = CrcParams @@ -835,21 +914,25 @@ instance KnownCrc Crc16_ibm_sdlc where } data Crc16_iso_hdlc = Crc16_iso_hdlc deriving Show +type instance TryDomain t Crc16_iso_hdlc = 'NotFound instance KnownCrc Crc16_iso_hdlc where type CrcWidth Crc16_iso_hdlc = CrcWidth Crc16_ibm_sdlc crcParams _ = crcParams Crc16_ibm_sdlc data Crc16_iso_iec_14443_3_b = Crc16_iso_iec_14443_3_b deriving Show +type instance TryDomain t Crc16_iso_iec_14443_3_b = 'NotFound instance KnownCrc Crc16_iso_iec_14443_3_b where type CrcWidth Crc16_iso_iec_14443_3_b = CrcWidth Crc16_ibm_sdlc crcParams _ = crcParams Crc16_ibm_sdlc data Crc16_x25 = Crc16_x25 deriving Show +type instance TryDomain t Crc16_x25 = 'NotFound instance KnownCrc Crc16_x25 where type CrcWidth Crc16_x25 = CrcWidth Crc16_ibm_sdlc crcParams _ = crcParams Crc16_ibm_sdlc data Crc16_iso_iec_14443_3_a = Crc16_iso_iec_14443_3_a deriving Show +type instance TryDomain t Crc16_iso_iec_14443_3_a = 'NotFound instance KnownCrc Crc16_iso_iec_14443_3_a where type CrcWidth Crc16_iso_iec_14443_3_a = 16 crcParams _ = CrcParams @@ -862,6 +945,7 @@ instance KnownCrc Crc16_iso_iec_14443_3_a where } data Crc16_kermit = Crc16_kermit deriving Show +type instance TryDomain t Crc16_kermit = 'NotFound instance KnownCrc Crc16_kermit where type CrcWidth Crc16_kermit = 16 crcParams _ = CrcParams @@ -874,26 +958,31 @@ instance KnownCrc Crc16_kermit where } data Crc16_bluetooth = Crc16_bluetooth deriving Show +type instance TryDomain t Crc16_bluetooth = 'NotFound instance KnownCrc Crc16_bluetooth where type CrcWidth Crc16_bluetooth = CrcWidth Crc16_kermit crcParams _ = crcParams Crc16_kermit data Crc16_ccitt = Crc16_ccitt deriving Show +type instance TryDomain t Crc16_ccitt = 'NotFound instance KnownCrc Crc16_ccitt where type CrcWidth Crc16_ccitt = CrcWidth Crc16_kermit crcParams _ = crcParams Crc16_kermit data Crc16_ccitt_true = Crc16_ccitt_true deriving Show +type instance TryDomain t Crc16_ccitt_true = 'NotFound instance KnownCrc Crc16_ccitt_true where type CrcWidth Crc16_ccitt_true = CrcWidth Crc16_kermit crcParams _ = crcParams Crc16_kermit data Crc16_v_41_lsb = Crc16_v_41_lsb deriving Show +type instance TryDomain t Crc16_v_41_lsb = 'NotFound instance KnownCrc Crc16_v_41_lsb where type CrcWidth Crc16_v_41_lsb = CrcWidth Crc16_kermit crcParams _ = crcParams Crc16_kermit data Crc16_lj1200 = Crc16_lj1200 deriving Show +type instance TryDomain t Crc16_lj1200 = 'NotFound instance KnownCrc Crc16_lj1200 where type CrcWidth Crc16_lj1200 = 16 crcParams _ = CrcParams @@ -906,6 +995,7 @@ instance KnownCrc Crc16_lj1200 where } data Crc16_m17 = Crc16_m17 deriving Show +type instance TryDomain t Crc16_m17 = 'NotFound instance KnownCrc Crc16_m17 where type CrcWidth Crc16_m17 = 16 crcParams _ = CrcParams @@ -918,6 +1008,7 @@ instance KnownCrc Crc16_m17 where } data Crc16_maxim_dow = Crc16_maxim_dow deriving Show +type instance TryDomain t Crc16_maxim_dow = 'NotFound instance KnownCrc Crc16_maxim_dow where type CrcWidth Crc16_maxim_dow = 16 crcParams _ = CrcParams @@ -930,11 +1021,13 @@ instance KnownCrc Crc16_maxim_dow where } data Crc16_maxim = Crc16_maxim deriving Show +type instance TryDomain t Crc16_maxim = 'NotFound instance KnownCrc Crc16_maxim where type CrcWidth Crc16_maxim = CrcWidth Crc16_maxim_dow crcParams _ = crcParams Crc16_maxim_dow data Crc16_mcrf4xx = Crc16_mcrf4xx deriving Show +type instance TryDomain t Crc16_mcrf4xx = 'NotFound instance KnownCrc Crc16_mcrf4xx where type CrcWidth Crc16_mcrf4xx = 16 crcParams _ = CrcParams @@ -947,6 +1040,7 @@ instance KnownCrc Crc16_mcrf4xx where } data Crc16_modbus = Crc16_modbus deriving Show +type instance TryDomain t Crc16_modbus = 'NotFound instance KnownCrc Crc16_modbus where type CrcWidth Crc16_modbus = 16 crcParams _ = CrcParams @@ -959,6 +1053,7 @@ instance KnownCrc Crc16_modbus where } data Crc16_nrsc_5 = Crc16_nrsc_5 deriving Show +type instance TryDomain t Crc16_nrsc_5 = 'NotFound instance KnownCrc Crc16_nrsc_5 where type CrcWidth Crc16_nrsc_5 = 16 crcParams _ = CrcParams @@ -971,6 +1066,7 @@ instance KnownCrc Crc16_nrsc_5 where } data Crc16_opensafety_a = Crc16_opensafety_a deriving Show +type instance TryDomain t Crc16_opensafety_a = 'NotFound instance KnownCrc Crc16_opensafety_a where type CrcWidth Crc16_opensafety_a = 16 crcParams _ = CrcParams @@ -983,6 +1079,7 @@ instance KnownCrc Crc16_opensafety_a where } data Crc16_opensafety_b = Crc16_opensafety_b deriving Show +type instance TryDomain t Crc16_opensafety_b = 'NotFound instance KnownCrc Crc16_opensafety_b where type CrcWidth Crc16_opensafety_b = 16 crcParams _ = CrcParams @@ -995,6 +1092,7 @@ instance KnownCrc Crc16_opensafety_b where } data Crc16_profibus = Crc16_profibus deriving Show +type instance TryDomain t Crc16_profibus = 'NotFound instance KnownCrc Crc16_profibus where type CrcWidth Crc16_profibus = 16 crcParams _ = CrcParams @@ -1007,11 +1105,13 @@ instance KnownCrc Crc16_profibus where } data Crc16_iec_61158_2 = Crc16_iec_61158_2 deriving Show +type instance TryDomain t Crc16_iec_61158_2 = 'NotFound instance KnownCrc Crc16_iec_61158_2 where type CrcWidth Crc16_iec_61158_2 = CrcWidth Crc16_profibus crcParams _ = crcParams Crc16_profibus data Crc16_riello = Crc16_riello deriving Show +type instance TryDomain t Crc16_riello = 'NotFound instance KnownCrc Crc16_riello where type CrcWidth Crc16_riello = 16 crcParams _ = CrcParams @@ -1024,6 +1124,7 @@ instance KnownCrc Crc16_riello where } data Crc16_spi_fujitsu = Crc16_spi_fujitsu deriving Show +type instance TryDomain t Crc16_spi_fujitsu = 'NotFound instance KnownCrc Crc16_spi_fujitsu where type CrcWidth Crc16_spi_fujitsu = 16 crcParams _ = CrcParams @@ -1036,11 +1137,13 @@ instance KnownCrc Crc16_spi_fujitsu where } data Crc16_aug_ccitt = Crc16_aug_ccitt deriving Show +type instance TryDomain t Crc16_aug_ccitt = 'NotFound instance KnownCrc Crc16_aug_ccitt where type CrcWidth Crc16_aug_ccitt = CrcWidth Crc16_spi_fujitsu crcParams _ = crcParams Crc16_spi_fujitsu data Crc16_t10_dif = Crc16_t10_dif deriving Show +type instance TryDomain t Crc16_t10_dif = 'NotFound instance KnownCrc Crc16_t10_dif where type CrcWidth Crc16_t10_dif = 16 crcParams _ = CrcParams @@ -1053,6 +1156,7 @@ instance KnownCrc Crc16_t10_dif where } data Crc16_teledisk = Crc16_teledisk deriving Show +type instance TryDomain t Crc16_teledisk = 'NotFound instance KnownCrc Crc16_teledisk where type CrcWidth Crc16_teledisk = 16 crcParams _ = CrcParams @@ -1065,6 +1169,7 @@ instance KnownCrc Crc16_teledisk where } data Crc16_tms37157 = Crc16_tms37157 deriving Show +type instance TryDomain t Crc16_tms37157 = 'NotFound instance KnownCrc Crc16_tms37157 where type CrcWidth Crc16_tms37157 = 16 crcParams _ = CrcParams @@ -1077,6 +1182,7 @@ instance KnownCrc Crc16_tms37157 where } data Crc16_umts = Crc16_umts deriving Show +type instance TryDomain t Crc16_umts = 'NotFound instance KnownCrc Crc16_umts where type CrcWidth Crc16_umts = 16 crcParams _ = CrcParams @@ -1089,16 +1195,19 @@ instance KnownCrc Crc16_umts where } data Crc16_verifone = Crc16_verifone deriving Show +type instance TryDomain t Crc16_verifone = 'NotFound instance KnownCrc Crc16_verifone where type CrcWidth Crc16_verifone = CrcWidth Crc16_umts crcParams _ = crcParams Crc16_umts data Crc16_buypass = Crc16_buypass deriving Show +type instance TryDomain t Crc16_buypass = 'NotFound instance KnownCrc Crc16_buypass where type CrcWidth Crc16_buypass = CrcWidth Crc16_umts crcParams _ = crcParams Crc16_umts data Crc16_usb = Crc16_usb deriving Show +type instance TryDomain t Crc16_usb = 'NotFound instance KnownCrc Crc16_usb where type CrcWidth Crc16_usb = 16 crcParams _ = CrcParams @@ -1111,6 +1220,7 @@ instance KnownCrc Crc16_usb where } data Crc16_xmodem = Crc16_xmodem deriving Show +type instance TryDomain t Crc16_xmodem = 'NotFound instance KnownCrc Crc16_xmodem where type CrcWidth Crc16_xmodem = 16 crcParams _ = CrcParams @@ -1123,26 +1233,31 @@ instance KnownCrc Crc16_xmodem where } data Crc16_acorn = Crc16_acorn deriving Show +type instance TryDomain t Crc16_acorn = 'NotFound instance KnownCrc Crc16_acorn where type CrcWidth Crc16_acorn = CrcWidth Crc16_xmodem crcParams _ = crcParams Crc16_xmodem data Crc16_lte = Crc16_lte deriving Show +type instance TryDomain t Crc16_lte = 'NotFound instance KnownCrc Crc16_lte where type CrcWidth Crc16_lte = CrcWidth Crc16_xmodem crcParams _ = crcParams Crc16_xmodem data Crc16_v_41_msb = Crc16_v_41_msb deriving Show +type instance TryDomain t Crc16_v_41_msb = 'NotFound instance KnownCrc Crc16_v_41_msb where type CrcWidth Crc16_v_41_msb = CrcWidth Crc16_xmodem crcParams _ = crcParams Crc16_xmodem data Crc16_zmodem = Crc16_zmodem deriving Show +type instance TryDomain t Crc16_zmodem = 'NotFound instance KnownCrc Crc16_zmodem where type CrcWidth Crc16_zmodem = CrcWidth Crc16_xmodem crcParams _ = crcParams Crc16_xmodem data Crc17_can_fd = Crc17_can_fd deriving Show +type instance TryDomain t Crc17_can_fd = 'NotFound instance KnownCrc Crc17_can_fd where type CrcWidth Crc17_can_fd = 17 crcParams _ = CrcParams @@ -1155,6 +1270,7 @@ instance KnownCrc Crc17_can_fd where } data Crc21_can_fd = Crc21_can_fd deriving Show +type instance TryDomain t Crc21_can_fd = 'NotFound instance KnownCrc Crc21_can_fd where type CrcWidth Crc21_can_fd = 21 crcParams _ = CrcParams @@ -1167,6 +1283,7 @@ instance KnownCrc Crc21_can_fd where } data Crc24_ble = Crc24_ble deriving Show +type instance TryDomain t Crc24_ble = 'NotFound instance KnownCrc Crc24_ble where type CrcWidth Crc24_ble = 24 crcParams _ = CrcParams @@ -1179,6 +1296,7 @@ instance KnownCrc Crc24_ble where } data Crc24_flexray_a = Crc24_flexray_a deriving Show +type instance TryDomain t Crc24_flexray_a = 'NotFound instance KnownCrc Crc24_flexray_a where type CrcWidth Crc24_flexray_a = 24 crcParams _ = CrcParams @@ -1191,6 +1309,7 @@ instance KnownCrc Crc24_flexray_a where } data Crc24_flexray_b = Crc24_flexray_b deriving Show +type instance TryDomain t Crc24_flexray_b = 'NotFound instance KnownCrc Crc24_flexray_b where type CrcWidth Crc24_flexray_b = 24 crcParams _ = CrcParams @@ -1203,6 +1322,7 @@ instance KnownCrc Crc24_flexray_b where } data Crc24_interlaken = Crc24_interlaken deriving Show +type instance TryDomain t Crc24_interlaken = 'NotFound instance KnownCrc Crc24_interlaken where type CrcWidth Crc24_interlaken = 24 crcParams _ = CrcParams @@ -1215,6 +1335,7 @@ instance KnownCrc Crc24_interlaken where } data Crc24_lte_a = Crc24_lte_a deriving Show +type instance TryDomain t Crc24_lte_a = 'NotFound instance KnownCrc Crc24_lte_a where type CrcWidth Crc24_lte_a = 24 crcParams _ = CrcParams @@ -1227,6 +1348,7 @@ instance KnownCrc Crc24_lte_a where } data Crc24_lte_b = Crc24_lte_b deriving Show +type instance TryDomain t Crc24_lte_b = 'NotFound instance KnownCrc Crc24_lte_b where type CrcWidth Crc24_lte_b = 24 crcParams _ = CrcParams @@ -1239,6 +1361,7 @@ instance KnownCrc Crc24_lte_b where } data Crc24_openpgp = Crc24_openpgp deriving Show +type instance TryDomain t Crc24_openpgp = 'NotFound instance KnownCrc Crc24_openpgp where type CrcWidth Crc24_openpgp = 24 crcParams _ = CrcParams @@ -1251,6 +1374,7 @@ instance KnownCrc Crc24_openpgp where } data Crc24_os_9 = Crc24_os_9 deriving Show +type instance TryDomain t Crc24_os_9 = 'NotFound instance KnownCrc Crc24_os_9 where type CrcWidth Crc24_os_9 = 24 crcParams _ = CrcParams @@ -1263,6 +1387,7 @@ instance KnownCrc Crc24_os_9 where } data Crc30_cdma = Crc30_cdma deriving Show +type instance TryDomain t Crc30_cdma = 'NotFound instance KnownCrc Crc30_cdma where type CrcWidth Crc30_cdma = 30 crcParams _ = CrcParams @@ -1275,6 +1400,7 @@ instance KnownCrc Crc30_cdma where } data Crc31_philips = Crc31_philips deriving Show +type instance TryDomain t Crc31_philips = 'NotFound instance KnownCrc Crc31_philips where type CrcWidth Crc31_philips = 31 crcParams _ = CrcParams @@ -1287,6 +1413,7 @@ instance KnownCrc Crc31_philips where } data Crc32_aixm = Crc32_aixm deriving Show +type instance TryDomain t Crc32_aixm = 'NotFound instance KnownCrc Crc32_aixm where type CrcWidth Crc32_aixm = 32 crcParams _ = CrcParams @@ -1299,6 +1426,7 @@ instance KnownCrc Crc32_aixm where } data Crc32_autosar = Crc32_autosar deriving Show +type instance TryDomain t Crc32_autosar = 'NotFound instance KnownCrc Crc32_autosar where type CrcWidth Crc32_autosar = 32 crcParams _ = CrcParams @@ -1311,6 +1439,7 @@ instance KnownCrc Crc32_autosar where } data Crc32_base91_d = Crc32_base91_d deriving Show +type instance TryDomain t Crc32_base91_d = 'NotFound instance KnownCrc Crc32_base91_d where type CrcWidth Crc32_base91_d = 32 crcParams _ = CrcParams @@ -1323,6 +1452,7 @@ instance KnownCrc Crc32_base91_d where } data Crc32_bzip2 = Crc32_bzip2 deriving Show +type instance TryDomain t Crc32_bzip2 = 'NotFound instance KnownCrc Crc32_bzip2 where type CrcWidth Crc32_bzip2 = 32 crcParams _ = CrcParams @@ -1335,16 +1465,19 @@ instance KnownCrc Crc32_bzip2 where } data Crc32_aal5 = Crc32_aal5 deriving Show +type instance TryDomain t Crc32_aal5 = 'NotFound instance KnownCrc Crc32_aal5 where type CrcWidth Crc32_aal5 = CrcWidth Crc32_bzip2 crcParams _ = crcParams Crc32_bzip2 data Crc32_dect_b = Crc32_dect_b deriving Show +type instance TryDomain t Crc32_dect_b = 'NotFound instance KnownCrc Crc32_dect_b where type CrcWidth Crc32_dect_b = CrcWidth Crc32_bzip2 crcParams _ = crcParams Crc32_bzip2 data Crc32_cd_rom_edc = Crc32_cd_rom_edc deriving Show +type instance TryDomain t Crc32_cd_rom_edc = 'NotFound instance KnownCrc Crc32_cd_rom_edc where type CrcWidth Crc32_cd_rom_edc = 32 crcParams _ = CrcParams @@ -1357,6 +1490,7 @@ instance KnownCrc Crc32_cd_rom_edc where } data Crc32_cksum = Crc32_cksum deriving Show +type instance TryDomain t Crc32_cksum = 'NotFound instance KnownCrc Crc32_cksum where type CrcWidth Crc32_cksum = 32 crcParams _ = CrcParams @@ -1369,11 +1503,13 @@ instance KnownCrc Crc32_cksum where } data Crc32_posix = Crc32_posix deriving Show +type instance TryDomain t Crc32_posix = 'NotFound instance KnownCrc Crc32_posix where type CrcWidth Crc32_posix = CrcWidth Crc32_cksum crcParams _ = crcParams Crc32_cksum data Crc32_iscsi = Crc32_iscsi deriving Show +type instance TryDomain t Crc32_iscsi = 'NotFound instance KnownCrc Crc32_iscsi where type CrcWidth Crc32_iscsi = 32 crcParams _ = CrcParams @@ -1386,21 +1522,25 @@ instance KnownCrc Crc32_iscsi where } data Crc32_base91_c = Crc32_base91_c deriving Show +type instance TryDomain t Crc32_base91_c = 'NotFound instance KnownCrc Crc32_base91_c where type CrcWidth Crc32_base91_c = CrcWidth Crc32_iscsi crcParams _ = crcParams Crc32_iscsi data Crc32_castagnoli = Crc32_castagnoli deriving Show +type instance TryDomain t Crc32_castagnoli = 'NotFound instance KnownCrc Crc32_castagnoli where type CrcWidth Crc32_castagnoli = CrcWidth Crc32_iscsi crcParams _ = crcParams Crc32_iscsi data Crc32_interlaken = Crc32_interlaken deriving Show +type instance TryDomain t Crc32_interlaken = 'NotFound instance KnownCrc Crc32_interlaken where type CrcWidth Crc32_interlaken = CrcWidth Crc32_iscsi crcParams _ = crcParams Crc32_iscsi data Crc32_iso_hdlc = Crc32_iso_hdlc deriving Show +type instance TryDomain t Crc32_iso_hdlc = 'NotFound instance KnownCrc Crc32_iso_hdlc where type CrcWidth Crc32_iso_hdlc = 32 crcParams _ = CrcParams @@ -1413,31 +1553,37 @@ instance KnownCrc Crc32_iso_hdlc where } data Crc32_adccp = Crc32_adccp deriving Show +type instance TryDomain t Crc32_adccp = 'NotFound instance KnownCrc Crc32_adccp where type CrcWidth Crc32_adccp = CrcWidth Crc32_iso_hdlc crcParams _ = crcParams Crc32_iso_hdlc data Crc32_v_42 = Crc32_v_42 deriving Show +type instance TryDomain t Crc32_v_42 = 'NotFound instance KnownCrc Crc32_v_42 where type CrcWidth Crc32_v_42 = CrcWidth Crc32_iso_hdlc crcParams _ = crcParams Crc32_iso_hdlc data Crc32_xz = Crc32_xz deriving Show +type instance TryDomain t Crc32_xz = 'NotFound instance KnownCrc Crc32_xz where type CrcWidth Crc32_xz = CrcWidth Crc32_iso_hdlc crcParams _ = crcParams Crc32_iso_hdlc data Crc32_pkzip = Crc32_pkzip deriving Show +type instance TryDomain t Crc32_pkzip = 'NotFound instance KnownCrc Crc32_pkzip where type CrcWidth Crc32_pkzip = CrcWidth Crc32_iso_hdlc crcParams _ = crcParams Crc32_iso_hdlc data Crc32_ethernet = Crc32_ethernet deriving Show +type instance TryDomain t Crc32_ethernet = 'NotFound instance KnownCrc Crc32_ethernet where type CrcWidth Crc32_ethernet = CrcWidth Crc32_iso_hdlc crcParams _ = crcParams Crc32_iso_hdlc data Crc32_jamcrc = Crc32_jamcrc deriving Show +type instance TryDomain t Crc32_jamcrc = 'NotFound instance KnownCrc Crc32_jamcrc where type CrcWidth Crc32_jamcrc = 32 crcParams _ = CrcParams @@ -1450,6 +1596,7 @@ instance KnownCrc Crc32_jamcrc where } data Crc32_mef = Crc32_mef deriving Show +type instance TryDomain t Crc32_mef = 'NotFound instance KnownCrc Crc32_mef where type CrcWidth Crc32_mef = 32 crcParams _ = CrcParams @@ -1462,6 +1609,7 @@ instance KnownCrc Crc32_mef where } data Crc32_mpeg_2 = Crc32_mpeg_2 deriving Show +type instance TryDomain t Crc32_mpeg_2 = 'NotFound instance KnownCrc Crc32_mpeg_2 where type CrcWidth Crc32_mpeg_2 = 32 crcParams _ = CrcParams @@ -1474,6 +1622,7 @@ instance KnownCrc Crc32_mpeg_2 where } data Crc32_xfer = Crc32_xfer deriving Show +type instance TryDomain t Crc32_xfer = 'NotFound instance KnownCrc Crc32_xfer where type CrcWidth Crc32_xfer = 32 crcParams _ = CrcParams @@ -1486,6 +1635,7 @@ instance KnownCrc Crc32_xfer where } data Crc40_gsm = Crc40_gsm deriving Show +type instance TryDomain t Crc40_gsm = 'NotFound instance KnownCrc Crc40_gsm where type CrcWidth Crc40_gsm = 40 crcParams _ = CrcParams @@ -1498,6 +1648,7 @@ instance KnownCrc Crc40_gsm where } data Crc64_ecma_182 = Crc64_ecma_182 deriving Show +type instance TryDomain t Crc64_ecma_182 = 'NotFound instance KnownCrc Crc64_ecma_182 where type CrcWidth Crc64_ecma_182 = 64 crcParams _ = CrcParams @@ -1510,6 +1661,7 @@ instance KnownCrc Crc64_ecma_182 where } data Crc64_go_iso = Crc64_go_iso deriving Show +type instance TryDomain t Crc64_go_iso = 'NotFound instance KnownCrc Crc64_go_iso where type CrcWidth Crc64_go_iso = 64 crcParams _ = CrcParams @@ -1522,6 +1674,7 @@ instance KnownCrc Crc64_go_iso where } data Crc64_ms = Crc64_ms deriving Show +type instance TryDomain t Crc64_ms = 'NotFound instance KnownCrc Crc64_ms where type CrcWidth Crc64_ms = 64 crcParams _ = CrcParams @@ -1534,6 +1687,7 @@ instance KnownCrc Crc64_ms where } data Crc64_redis = Crc64_redis deriving Show +type instance TryDomain t Crc64_redis = 'NotFound instance KnownCrc Crc64_redis where type CrcWidth Crc64_redis = 64 crcParams _ = CrcParams @@ -1546,6 +1700,7 @@ instance KnownCrc Crc64_redis where } data Crc64_we = Crc64_we deriving Show +type instance TryDomain t Crc64_we = 'NotFound instance KnownCrc Crc64_we where type CrcWidth Crc64_we = 64 crcParams _ = CrcParams @@ -1558,6 +1713,7 @@ instance KnownCrc Crc64_we where } data Crc64_xz = Crc64_xz deriving Show +type instance TryDomain t Crc64_xz = 'NotFound instance KnownCrc Crc64_xz where type CrcWidth Crc64_xz = 64 crcParams _ = CrcParams @@ -1570,11 +1726,13 @@ instance KnownCrc Crc64_xz where } data Crc64_ecma = Crc64_ecma deriving Show +type instance TryDomain t Crc64_ecma = 'NotFound instance KnownCrc Crc64_ecma where type CrcWidth Crc64_ecma = CrcWidth Crc64_xz crcParams _ = crcParams Crc64_xz data Crc82_darc = Crc82_darc deriving Show +type instance TryDomain t Crc82_darc = 'NotFound instance KnownCrc Crc82_darc where type CrcWidth Crc82_darc = 82 crcParams _ = CrcParams From e7de1826f581297984f05fd51294f42e2f69bb58 Mon Sep 17 00:00:00 2001 From: Rowan Goemans Date: Tue, 18 Jun 2024 19:55:08 +0200 Subject: [PATCH 3/7] Aarch64 REMOVEME --- nix/devshell.nix | 3 ++- nix/overlay.nix | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/nix/devshell.nix b/nix/devshell.nix index 0a6488c50d..f859fcefe6 100644 --- a/nix/devshell.nix +++ b/nix/devshell.nix @@ -23,8 +23,9 @@ pkgs.mkShell { buildInputs = [ clashPkgs.cabal-install clashPkgs.haskell-language-server + clashPkgs.fourmolu - pkgs.ghdl-llvm + # pkgs.ghdl-llvm pkgs.nixpkgs-fmt pkgs.symbiyosys pkgs.verilator diff --git a/nix/overlay.nix b/nix/overlay.nix index ed7842f2f5..47d6107a4f 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -138,11 +138,11 @@ let }; clash-prelude = - hprev.callCabal2nixWithOptions + prev.haskell.lib.dontCheck (hprev.callCabal2nixWithOptions "clash-prelude" ../clash-prelude "--flag workaround-ghc-mmap-crash" - { }; + { }); clash-prelude-hedgehog = hprev.callCabal2nix "clash-prelude-hedgehog" ../clash-prelude-hedgehog { From d429415fb2d5e8c432dab51f35a9879d8524f144 Mon Sep 17 00:00:00 2001 From: Rowan Goemans Date: Tue, 18 Jun 2024 19:55:47 +0200 Subject: [PATCH 4/7] tests: Fixup files for formatting compatibility --- tests/Main.hs | 61 ++++++++++++------- .../Cores/Xilinx/VIO/InputProbesExceeded.hs | 2 + .../Cores/Xilinx/VIO/OutputProbesExceeded.hs | 2 + tests/shouldwork/Basic/AES.hs | 2 + tests/shouldwork/Basic/T1591.hs | 1 + tests/shouldwork/BitVector/UnpackUndefined.hs | 2 + tests/shouldwork/BlackBox/LITrendering.hs | 2 + tests/shouldwork/Cores/Xilinx/DcFifo/Basic.hs | 1 + tests/shouldwork/Cores/Xilinx/Floating.hs | 1 + tests/shouldwork/Cores/Xilinx/VIO.hs | 1 + .../Cores/Xilinx/XpmCdcArraySingle.hs | 2 + tests/shouldwork/Cores/Xilinx/XpmCdcGray.hs | 2 + .../Cores/Xilinx/XpmCdcHandshake.hs | 2 + tests/shouldwork/Cores/Xilinx/XpmCdcPulse.hs | 2 + tests/shouldwork/Cores/Xilinx/XpmCdcSingle.hs | 2 + .../shouldwork/Cores/Xilinx/XpmCdcSyncRst.hs | 2 + .../shouldwork/Cores/Xilinx/XpmTestCommon.hs | 2 + .../CustomReprs/Deriving/BitPackDerivation.hs | 1 + tests/shouldwork/DDR/DDRin.hs | 2 +- tests/shouldwork/FixedNumber/FixedS.hs | 2 + tests/shouldwork/Issues/T1933.hs | 9 ++- tests/shouldwork/Numbers/Bits.hs | 2 + tests/shouldwork/Numbers/BitsTB.hs | 1 + tests/shouldwork/Numbers/ExpWithClashCF.hs | 2 + tests/shouldwork/Numbers/ExpWithGhcCF.hs | 1 + tests/shouldwork/Numbers/Integral.hs | 1 + tests/shouldwork/Numbers/IntegralTB.hs | 1 + .../Numbers/NumConstantFoldingTB_1.hs | 2 + .../Numbers/NumConstantFoldingTB_2.hs | 3 +- tests/shouldwork/Numbers/Resize3.hs | 1 + tests/shouldwork/Numbers/ShiftRotate.hs | 1 + tests/shouldwork/Numbers/ShiftRotateBase.hs | 1 + .../shouldwork/Numbers/ShiftRotateNegative.hs | 2 + .../shouldwork/Numbers/SignedProjectionTB.hs | 1 + .../Numbers/UndefinedConstantFolding.hs | 1 + .../Numbers/UndefinedConstantFoldingTB.hs | 2 + tests/shouldwork/RTree/TRepeat2.hs | 1 + tests/shouldwork/Signal/AndSpecificEnable.hs | 2 + tests/shouldwork/Signal/DualBlockRam.hs | 1 + .../Signal/DualBlockRamDefinitions.hs | 1 + tests/shouldwork/Signal/DynamicClocks.hs | 1 + tests/shouldwork/Signal/ROM/Async.hs | 1 + tests/shouldwork/Signal/ROM/AsyncBlob.hs | 1 + tests/shouldwork/Signal/ROM/Blob.hs | 1 + tests/shouldwork/Signal/ROM/BlobVec.hs | 1 + tests/shouldwork/Testbench/SyncTB.hs | 1 + tests/shouldwork/Vector/Iterate.hs | 1 + tests/shouldwork/Vector/VecConst.hs | 2 + tests/src/Test/Tasty/Clash.hs | 60 ++++++++++++------ 49 files changed, 154 insertions(+), 45 deletions(-) diff --git a/tests/Main.hs b/tests/Main.hs index b800b58cf2..674635c3ab 100755 --- a/tests/Main.hs +++ b/tests/Main.hs @@ -27,8 +27,8 @@ import Test.Tasty.Clash -- | GHC version as major.minor.patch1. For example: 8.10.2. ghcVersion3 :: String -ghcVersion3 = #ifdef __GLASGOW_HASKELL_PATCHLEVEL2__ +ghcVersion3 = let ghc_p1 = __GLASGOW_HASKELL_PATCHLEVEL1__ ghc_p2 = __GLASGOW_HASKELL_PATCHLEVEL2__ in case ghc_p2 of @@ -37,10 +37,39 @@ ghcVersion3 = _ -> intercalate "." (map show (versionBranch compilerVersion <> [ghc_p1,ghc_p2])) #else +ghcVersion3 = let ghc_p1 = __GLASGOW_HASKELL_PATCHLEVEL1__ in intercalate "." (map show (versionBranch compilerVersion <> [ghc_p1])) #endif +multipleHiddenEnabled :: Bool +#ifdef CLASH_MULTIPLE_HIDDEN +multipleHiddenEnabled = True +#else +multipleHiddenEnabled = False +#endif + +coSimEnabled :: Bool +#ifdef COSIM +coSimEnabled = True +#else +coSimEnabled = False +#endif + +ghcVersionGreater94 :: Bool +#if MIN_VERSION_GLASGOW_HASKELL(9,4,0,0) +ghcVersionGreater94 = True +#else +ghcVersionGreater94 = False +#endif + +baseVersionGreater414 :: Bool +#if MIN_VERSION_base(4,14,0) +baseVersionGreater414 = True +#else +baseVersionGreater414 = False +#endif + -- Directory clash binary is expected to live in cabalClashBinDir :: IO String cabalClashBinDir = makeAbsolute rel_path @@ -380,9 +409,7 @@ runClashTest = defaultMain $ clashTestRoot , runTest "DivZero" def , runTest "LambdaDrop" def{hdlSim=[]} , runTest "IrrefError" def{hdlSim=[]} -#ifdef CLASH_MULTIPLE_HIDDEN - , runTest "MultipleHidden" def -#endif + , runTestIf multipleHiddenEnabled "MultipleHidden" def , outputTest "NameInlining" def , runTest "NameInstance" def{hdlSim=[]} , outputTest "NameInstance" def @@ -637,12 +664,10 @@ runClashTest = defaultMain $ clashTestRoot [ runTest "MAC" def{hdlSim=[]} , runTest "CBlockRamTest" def{hdlSim=[]} ] -#ifdef COSIM , clashTestGroup "CoSim" - [ runTest "Multiply" def{hdlTargets=[Verilog]} - , runTest "Register" def{hdlTargets=[Verilog]} + [ runTestIf coSimEnabled "Multiply" def{hdlTargets=[Verilog]} + , runTestIf coSimEnabled "Register" def{hdlTargets=[Verilog]} ] -#endif , clashTestGroup "CustomReprs" [ clashTestGroup "RotateC" [ runTest "RotateC" def @@ -717,9 +742,7 @@ runClashTest = defaultMain $ clashTestRoot ] , clashTestGroup "Feedback" [ runTest "Fib" def -#ifdef CLASH_MULTIPLE_HIDDEN - , runTest "MutuallyRecursive" def -#endif + , runTestIf multipleHiddenEnabled "MutuallyRecursive" def ] , clashTestGroup "Fixed" [ runTest "Mixer" def @@ -808,14 +831,12 @@ runClashTest = defaultMain $ clashTestRoot , runTest "T2360" def{hdlSim=[],clashFlags=["-fclash-force-undefined=0"]} , outputTest "T2502" def{hdlTargets=[VHDL]} , outputTest "T2508" def{hdlTargets=[VHDL]} -#if MIN_VERSION_GLASGOW_HASKELL(9,4,0,0) - , runTest "T2510" def{ + , runTestIf ghcVersionGreater94 "T2510" def{ hdlTargets=[VHDL] , hdlSim=[] , expectClashFail=Just (TestSpecificExitCode 0, "Warning: primitive T2510.bb isn't marked OPAQUE.") } , outputTest "T2510" def{hdlTargets=[VHDL], clashFlags=["-DNOINLINE=OPAQUE"]} -#endif , outputTest "T2542" def{hdlTargets=[VHDL]} , runTest "T2593" def{hdlSim=[]} , runTest "T2623CaseConFVs" def{hdlLoad=[],hdlSim=[],hdlTargets=[VHDL]} @@ -846,9 +867,7 @@ runClashTest = defaultMain $ clashTestRoot ] , clashTestGroup "Numbers" [ runTest "BitInteger" def -#if MIN_VERSION_base(4,14,0) - , runTest "BitReverse" def -#endif + , runTestIf baseVersionGreater414 "BitReverse" def , runTest "BitsTB" def { buildTargets = BuildSpecific [ "bitsTB1" , "bitsTB2" , "bitsTB3" @@ -950,13 +969,9 @@ runClashTest = defaultMain $ clashTestRoot [ runTest "Blob" def ] , runTest "AndEnable" def -#ifdef CLASH_MULTIPLE_HIDDEN - , - -- TODO: Vivado is disabled because it gives different results, see + , -- TODO: Vivado is disabled because it gives different results, see -- https://github.com/clash-lang/clash-compiler/issues/2267 - runTest "AndSpecificEnable" def{hdlSim=hdlSim def \\ [Vivado]} - -#endif + runTestIf multipleHiddenEnabled "AndSpecificEnable" def{hdlSim=hdlSim def \\ [Vivado]} , runTest "Ram" def , clashTestGroup "Ram" [ runTest "RMultiTop" def diff --git a/tests/shouldfail/Cores/Xilinx/VIO/InputProbesExceeded.hs b/tests/shouldfail/Cores/Xilinx/VIO/InputProbesExceeded.hs index edf84679d2..ea7c7850d0 100644 --- a/tests/shouldfail/Cores/Xilinx/VIO/InputProbesExceeded.hs +++ b/tests/shouldfail/Cores/Xilinx/VIO/InputProbesExceeded.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module InputProbesExceeded where import Clash.Prelude diff --git a/tests/shouldfail/Cores/Xilinx/VIO/OutputProbesExceeded.hs b/tests/shouldfail/Cores/Xilinx/VIO/OutputProbesExceeded.hs index 8ccefb5657..b3230fa07d 100644 --- a/tests/shouldfail/Cores/Xilinx/VIO/OutputProbesExceeded.hs +++ b/tests/shouldfail/Cores/Xilinx/VIO/OutputProbesExceeded.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module OutputProbesExceeded where import Clash.Prelude diff --git a/tests/shouldwork/Basic/AES.hs b/tests/shouldwork/Basic/AES.hs index 8a35fdbaf2..a55e70e2dd 100644 --- a/tests/shouldwork/Basic/AES.hs +++ b/tests/shouldwork/Basic/AES.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module AES where import Clash.Prelude diff --git a/tests/shouldwork/Basic/T1591.hs b/tests/shouldwork/Basic/T1591.hs index 404f3cc9b9..75f3cde5a1 100644 --- a/tests/shouldwork/Basic/T1591.hs +++ b/tests/shouldwork/Basic/T1591.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE TemplateHaskell #-} #if __GLASGOW_HASKELL__ >= 810 {-# LANGUAGE StandaloneKindSignatures #-} diff --git a/tests/shouldwork/BitVector/UnpackUndefined.hs b/tests/shouldwork/BitVector/UnpackUndefined.hs index 3c0fc75cee..2ba54b1fff 100644 --- a/tests/shouldwork/BitVector/UnpackUndefined.hs +++ b/tests/shouldwork/BitVector/UnpackUndefined.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE MagicHash #-} + module UnpackUndefined where import Clash.Prelude import Clash.Sized.Internal.BitVector diff --git a/tests/shouldwork/BlackBox/LITrendering.hs b/tests/shouldwork/BlackBox/LITrendering.hs index f773ea01fb..75ceb4f320 100644 --- a/tests/shouldwork/BlackBox/LITrendering.hs +++ b/tests/shouldwork/BlackBox/LITrendering.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE MagicHash #-} + -- Tests that ~LIT's are rendered as bare literals in HDL {-# LANGUAGE AllowAmbiguousTypes #-} diff --git a/tests/shouldwork/Cores/Xilinx/DcFifo/Basic.hs b/tests/shouldwork/Cores/Xilinx/DcFifo/Basic.hs index 9a760bbb89..9281af8ace 100644 --- a/tests/shouldwork/Cores/Xilinx/DcFifo/Basic.hs +++ b/tests/shouldwork/Cores/Xilinx/DcFifo/Basic.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE MagicHash #-} module Basic where diff --git a/tests/shouldwork/Cores/Xilinx/Floating.hs b/tests/shouldwork/Cores/Xilinx/Floating.hs index 482799fe67..33fe117740 100644 --- a/tests/shouldwork/Cores/Xilinx/Floating.hs +++ b/tests/shouldwork/Cores/Xilinx/Floating.hs @@ -6,6 +6,7 @@ Maintainer : QBayLogic B.V. -} {-# LANGUAGE CPP #-} +{-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -fconstraint-solver-iterations=10 -Wall -Werror #-} diff --git a/tests/shouldwork/Cores/Xilinx/VIO.hs b/tests/shouldwork/Cores/Xilinx/VIO.hs index 483ebc32ed..cdc7183c04 100644 --- a/tests/shouldwork/Cores/Xilinx/VIO.hs +++ b/tests/shouldwork/Cores/Xilinx/VIO.hs @@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE TemplateHaskell #-} module VIO where diff --git a/tests/shouldwork/Cores/Xilinx/XpmCdcArraySingle.hs b/tests/shouldwork/Cores/Xilinx/XpmCdcArraySingle.hs index 691abc4285..3261957a3e 100644 --- a/tests/shouldwork/Cores/Xilinx/XpmCdcArraySingle.hs +++ b/tests/shouldwork/Cores/Xilinx/XpmCdcArraySingle.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module XpmCdcArraySingle where import Clash.Explicit.Prelude diff --git a/tests/shouldwork/Cores/Xilinx/XpmCdcGray.hs b/tests/shouldwork/Cores/Xilinx/XpmCdcGray.hs index 9d9ad26689..ab5b20aecf 100644 --- a/tests/shouldwork/Cores/Xilinx/XpmCdcGray.hs +++ b/tests/shouldwork/Cores/Xilinx/XpmCdcGray.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module XpmCdcGray where import Clash.Explicit.Prelude diff --git a/tests/shouldwork/Cores/Xilinx/XpmCdcHandshake.hs b/tests/shouldwork/Cores/Xilinx/XpmCdcHandshake.hs index 4345455315..171aa00e78 100644 --- a/tests/shouldwork/Cores/Xilinx/XpmCdcHandshake.hs +++ b/tests/shouldwork/Cores/Xilinx/XpmCdcHandshake.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module XpmCdcHandshake where import Clash.Cores.Xilinx.Xpm.Cdc.Handshake diff --git a/tests/shouldwork/Cores/Xilinx/XpmCdcPulse.hs b/tests/shouldwork/Cores/Xilinx/XpmCdcPulse.hs index 1174ba0da4..843b5444bf 100644 --- a/tests/shouldwork/Cores/Xilinx/XpmCdcPulse.hs +++ b/tests/shouldwork/Cores/Xilinx/XpmCdcPulse.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module XpmCdcPulse where import Clash.Explicit.Prelude diff --git a/tests/shouldwork/Cores/Xilinx/XpmCdcSingle.hs b/tests/shouldwork/Cores/Xilinx/XpmCdcSingle.hs index 2bb35a6804..11fbc78c47 100644 --- a/tests/shouldwork/Cores/Xilinx/XpmCdcSingle.hs +++ b/tests/shouldwork/Cores/Xilinx/XpmCdcSingle.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module XpmCdcSingle where import Clash.Explicit.Prelude diff --git a/tests/shouldwork/Cores/Xilinx/XpmCdcSyncRst.hs b/tests/shouldwork/Cores/Xilinx/XpmCdcSyncRst.hs index 95d6704ba4..81b212dea1 100644 --- a/tests/shouldwork/Cores/Xilinx/XpmCdcSyncRst.hs +++ b/tests/shouldwork/Cores/Xilinx/XpmCdcSyncRst.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module XpmCdcSyncRst where import Clash.Explicit.Prelude diff --git a/tests/shouldwork/Cores/Xilinx/XpmTestCommon.hs b/tests/shouldwork/Cores/Xilinx/XpmTestCommon.hs index 1fed722baf..397625bf7c 100644 --- a/tests/shouldwork/Cores/Xilinx/XpmTestCommon.hs +++ b/tests/shouldwork/Cores/Xilinx/XpmTestCommon.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + {-# OPTIONS_GHC -Wno-orphans #-} {-# OPTIONS_GHC -fforce-recomp #-} module XpmTestCommon where diff --git a/tests/shouldwork/CustomReprs/Deriving/BitPackDerivation.hs b/tests/shouldwork/CustomReprs/Deriving/BitPackDerivation.hs index 18fe2147c2..6402d21494 100644 --- a/tests/shouldwork/CustomReprs/Deriving/BitPackDerivation.hs +++ b/tests/shouldwork/CustomReprs/Deriving/BitPackDerivation.hs @@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE PartialTypeSignatures #-} +{-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -Wno-partial-type-signatures #-} module BitPackDerivation where diff --git a/tests/shouldwork/DDR/DDRin.hs b/tests/shouldwork/DDR/DDRin.hs index 3c8aa61c6a..191d15101c 100644 --- a/tests/shouldwork/DDR/DDRin.hs +++ b/tests/shouldwork/DDR/DDRin.hs @@ -1,5 +1,5 @@ {-# LANGUAGE CPP #-} - +{-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -Wno-orphans #-} module DDRin where diff --git a/tests/shouldwork/FixedNumber/FixedS.hs b/tests/shouldwork/FixedNumber/FixedS.hs index 939b18ffae..344d903d18 100644 --- a/tests/shouldwork/FixedNumber/FixedS.hs +++ b/tests/shouldwork/FixedNumber/FixedS.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module FixedS where import Clash.Prelude diff --git a/tests/shouldwork/Issues/T1933.hs b/tests/shouldwork/Issues/T1933.hs index a6c8f08524..36cde19b1c 100644 --- a/tests/shouldwork/Issues/T1933.hs +++ b/tests/shouldwork/Issues/T1933.hs @@ -1,4 +1,6 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE TemplateHaskell #-} + module T1933 where import Clash.Prelude @@ -30,11 +32,14 @@ q = coerce p {-# CLASH_OPAQUE q #-} topEntity :: Unsigned 12 -> T -topEntity x = #if __GLASGOW_HASKELL__ == 900 +topEntity x = let r = fromIntegral q :: Unsigned 12 + {-# NOINLINE r #-} + in f (MkT x r) #else +topEntity x = let r = coerce q :: Unsigned 12 -#endif {-# NOINLINE r #-} in f (MkT x r) +#endif diff --git a/tests/shouldwork/Numbers/Bits.hs b/tests/shouldwork/Numbers/Bits.hs index 9a55fba5f6..bcda95c1d3 100644 --- a/tests/shouldwork/Numbers/Bits.hs +++ b/tests/shouldwork/Numbers/Bits.hs @@ -2,6 +2,8 @@ {-# LANGUAGE PartialTypeSignatures #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE TemplateHaskell #-} + #if __GLASGOW_HASKELL__ < 900 {-# LANGUAGE AllowAmbiguousTypes #-} #endif diff --git a/tests/shouldwork/Numbers/BitsTB.hs b/tests/shouldwork/Numbers/BitsTB.hs index 18ba99b2a0..4a6b2b5a4d 100644 --- a/tests/shouldwork/Numbers/BitsTB.hs +++ b/tests/shouldwork/Numbers/BitsTB.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE TemplateHaskell #-} module BitsTB where import Clash.Prelude diff --git a/tests/shouldwork/Numbers/ExpWithClashCF.hs b/tests/shouldwork/Numbers/ExpWithClashCF.hs index 2c91c179b8..ac9c052b41 100644 --- a/tests/shouldwork/Numbers/ExpWithClashCF.hs +++ b/tests/shouldwork/Numbers/ExpWithClashCF.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module ExpWithClashCF where import Clash.Prelude diff --git a/tests/shouldwork/Numbers/ExpWithGhcCF.hs b/tests/shouldwork/Numbers/ExpWithGhcCF.hs index 6dcc1083cc..17288e27d4 100644 --- a/tests/shouldwork/Numbers/ExpWithGhcCF.hs +++ b/tests/shouldwork/Numbers/ExpWithGhcCF.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -fno-specialise #-} -- TODO: remove when https://gitlab.haskell.org/ghc/ghc/-/issues/23109#note_499130 is fixed module ExpWithGhcCF where diff --git a/tests/shouldwork/Numbers/Integral.hs b/tests/shouldwork/Numbers/Integral.hs index 0e2b2ade58..c233854f71 100644 --- a/tests/shouldwork/Numbers/Integral.hs +++ b/tests/shouldwork/Numbers/Integral.hs @@ -5,6 +5,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -Wno-partial-type-signatures #-} diff --git a/tests/shouldwork/Numbers/IntegralTB.hs b/tests/shouldwork/Numbers/IntegralTB.hs index 316faeccd2..05fd1f0f3b 100644 --- a/tests/shouldwork/Numbers/IntegralTB.hs +++ b/tests/shouldwork/Numbers/IntegralTB.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE TemplateHaskell #-} module IntegralTB where import Clash.Prelude diff --git a/tests/shouldwork/Numbers/NumConstantFoldingTB_1.hs b/tests/shouldwork/Numbers/NumConstantFoldingTB_1.hs index 115d007b58..96211cbd84 100644 --- a/tests/shouldwork/Numbers/NumConstantFoldingTB_1.hs +++ b/tests/shouldwork/Numbers/NumConstantFoldingTB_1.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module NumConstantFoldingTB_1 where import Clash.Prelude import Clash.Explicit.Testbench diff --git a/tests/shouldwork/Numbers/NumConstantFoldingTB_2.hs b/tests/shouldwork/Numbers/NumConstantFoldingTB_2.hs index 5bbf6142a0..9f58c4bf60 100644 --- a/tests/shouldwork/Numbers/NumConstantFoldingTB_2.hs +++ b/tests/shouldwork/Numbers/NumConstantFoldingTB_2.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module NumConstantFoldingTB_2 where import Clash.Prelude import Clash.Explicit.Testbench @@ -14,4 +16,3 @@ testBench = done done = expectedOutput (pure topEntity) clk = tbSystemClockGen (not <$> done) rst = systemResetGen - diff --git a/tests/shouldwork/Numbers/Resize3.hs b/tests/shouldwork/Numbers/Resize3.hs index aa51a04ab1..488d1500cd 100644 --- a/tests/shouldwork/Numbers/Resize3.hs +++ b/tests/shouldwork/Numbers/Resize3.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE TemplateHaskell #-} module Resize3 where diff --git a/tests/shouldwork/Numbers/ShiftRotate.hs b/tests/shouldwork/Numbers/ShiftRotate.hs index d471c5f8cc..a781dc3e2a 100644 --- a/tests/shouldwork/Numbers/ShiftRotate.hs +++ b/tests/shouldwork/Numbers/ShiftRotate.hs @@ -7,6 +7,7 @@ So it checks that the HDL implementations have the same behavior as the Haskell -} {-# LANGUAGE CPP #-} {-# LANGUAGE PartialTypeSignatures #-} +{-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -Wno-partial-type-signatures #-} module ShiftRotate where import Clash.Prelude diff --git a/tests/shouldwork/Numbers/ShiftRotateBase.hs b/tests/shouldwork/Numbers/ShiftRotateBase.hs index 9739943fc9..6edb2d8b66 100644 --- a/tests/shouldwork/Numbers/ShiftRotateBase.hs +++ b/tests/shouldwork/Numbers/ShiftRotateBase.hs @@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE PartialTypeSignatures #-} +{-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -Wno-partial-type-signatures #-} module ShiftRotateBase where import Clash.Prelude diff --git a/tests/shouldwork/Numbers/ShiftRotateNegative.hs b/tests/shouldwork/Numbers/ShiftRotateNegative.hs index 7b096233b9..128784db32 100644 --- a/tests/shouldwork/Numbers/ShiftRotateNegative.hs +++ b/tests/shouldwork/Numbers/ShiftRotateNegative.hs @@ -12,6 +12,7 @@ import Clash.Prelude import Clash.Explicit.Testbench import Clash.Sized.Internal.BitVector +{- FOURMOLU_DISABLE -} testBench :: Signal System Bool testBench = done where @@ -107,6 +108,7 @@ topEntity (x, i) = , g (unpack x) i ) :> Nil +{- FOURMOLU_ENABLE -} f :: (Bits a) => a -> Int -> a f x i = x `shiftL` (-i) `rotateL` (-i) `shiftR` (-i) `rotateR` (-i) diff --git a/tests/shouldwork/Numbers/SignedProjectionTB.hs b/tests/shouldwork/Numbers/SignedProjectionTB.hs index 7c691e6e9b..40c1f4c253 100644 --- a/tests/shouldwork/Numbers/SignedProjectionTB.hs +++ b/tests/shouldwork/Numbers/SignedProjectionTB.hs @@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE PartialTypeSignatures #-} +{-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -Wno-partial-type-signatures #-} -- Test for https://github.com/clash-lang/clash-compiler/issues/601 diff --git a/tests/shouldwork/Numbers/UndefinedConstantFolding.hs b/tests/shouldwork/Numbers/UndefinedConstantFolding.hs index 38f032328e..173f3e5b32 100644 --- a/tests/shouldwork/Numbers/UndefinedConstantFolding.hs +++ b/tests/shouldwork/Numbers/UndefinedConstantFolding.hs @@ -1,4 +1,5 @@ {-# LANGUAGE PartialTypeSignatures #-} +{-# LANGUAGE MagicHash #-} {-# OPTIONS_GHC -Wno-partial-type-signatures #-} diff --git a/tests/shouldwork/Numbers/UndefinedConstantFoldingTB.hs b/tests/shouldwork/Numbers/UndefinedConstantFoldingTB.hs index beea724232..6ee8a2999c 100644 --- a/tests/shouldwork/Numbers/UndefinedConstantFoldingTB.hs +++ b/tests/shouldwork/Numbers/UndefinedConstantFoldingTB.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module UndefinedConstantFoldingTB where import Clash.Prelude import Clash.Explicit.Testbench diff --git a/tests/shouldwork/RTree/TRepeat2.hs b/tests/shouldwork/RTree/TRepeat2.hs index 22b53f9203..6ce02eaee5 100644 --- a/tests/shouldwork/RTree/TRepeat2.hs +++ b/tests/shouldwork/RTree/TRepeat2.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE TemplateHaskell #-} module TRepeat2 where diff --git a/tests/shouldwork/Signal/AndSpecificEnable.hs b/tests/shouldwork/Signal/AndSpecificEnable.hs index 0ba3c931f0..2bc1539393 100644 --- a/tests/shouldwork/Signal/AndSpecificEnable.hs +++ b/tests/shouldwork/Signal/AndSpecificEnable.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module AndSpecificEnable where import Clash.Prelude diff --git a/tests/shouldwork/Signal/DualBlockRam.hs b/tests/shouldwork/Signal/DualBlockRam.hs index 94595541e2..7b7fcccf01 100644 --- a/tests/shouldwork/Signal/DualBlockRam.hs +++ b/tests/shouldwork/Signal/DualBlockRam.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -freverse-errors #-} diff --git a/tests/shouldwork/Signal/DualBlockRamDefinitions.hs b/tests/shouldwork/Signal/DualBlockRamDefinitions.hs index 03ed058f9b..a7220d4c7a 100644 --- a/tests/shouldwork/Signal/DualBlockRamDefinitions.hs +++ b/tests/shouldwork/Signal/DualBlockRamDefinitions.hs @@ -1,5 +1,6 @@ {-# OPTIONS_GHC -Wno-orphans -Wno-missing-signatures #-} {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE TemplateHaskell #-} module DualBlockRamDefinitions where diff --git a/tests/shouldwork/Signal/DynamicClocks.hs b/tests/shouldwork/Signal/DynamicClocks.hs index 89851840ae..ea3c167eac 100644 --- a/tests/shouldwork/Signal/DynamicClocks.hs +++ b/tests/shouldwork/Signal/DynamicClocks.hs @@ -4,6 +4,7 @@ License : BSD2 (see the file LICENSE) Maintainer : QBayLogic B.V. -} {-# LANGUAGE CPP #-} +{-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -Wno-orphans #-} diff --git a/tests/shouldwork/Signal/ROM/Async.hs b/tests/shouldwork/Signal/ROM/Async.hs index 9ee2b243ce..8e73aab2c6 100644 --- a/tests/shouldwork/Signal/ROM/Async.hs +++ b/tests/shouldwork/Signal/ROM/Async.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE TemplateHaskell #-} module Async where diff --git a/tests/shouldwork/Signal/ROM/AsyncBlob.hs b/tests/shouldwork/Signal/ROM/AsyncBlob.hs index cd9352ed58..ca4999e184 100644 --- a/tests/shouldwork/Signal/ROM/AsyncBlob.hs +++ b/tests/shouldwork/Signal/ROM/AsyncBlob.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE TemplateHaskell #-} module AsyncBlob where diff --git a/tests/shouldwork/Signal/ROM/Blob.hs b/tests/shouldwork/Signal/ROM/Blob.hs index ba5c97aba2..6b64e462ff 100644 --- a/tests/shouldwork/Signal/ROM/Blob.hs +++ b/tests/shouldwork/Signal/ROM/Blob.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE TemplateHaskell #-} module Blob where diff --git a/tests/shouldwork/Signal/ROM/BlobVec.hs b/tests/shouldwork/Signal/ROM/BlobVec.hs index 5c150d9d3e..71b69bdc0d 100644 --- a/tests/shouldwork/Signal/ROM/BlobVec.hs +++ b/tests/shouldwork/Signal/ROM/BlobVec.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE TemplateHaskell #-} module BlobVec where diff --git a/tests/shouldwork/Testbench/SyncTB.hs b/tests/shouldwork/Testbench/SyncTB.hs index 220228b3c4..68b3bc518c 100644 --- a/tests/shouldwork/Testbench/SyncTB.hs +++ b/tests/shouldwork/Testbench/SyncTB.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE TemplateHaskell #-} module SyncTB where diff --git a/tests/shouldwork/Vector/Iterate.hs b/tests/shouldwork/Vector/Iterate.hs index bf7a0ea2d6..82582e435f 100644 --- a/tests/shouldwork/Vector/Iterate.hs +++ b/tests/shouldwork/Vector/Iterate.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE TemplateHaskell #-} module Iterate where diff --git a/tests/shouldwork/Vector/VecConst.hs b/tests/shouldwork/Vector/VecConst.hs index 039ba130e0..658297c2b5 100644 --- a/tests/shouldwork/Vector/VecConst.hs +++ b/tests/shouldwork/Vector/VecConst.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module VecConst where import Clash.Prelude diff --git a/tests/src/Test/Tasty/Clash.hs b/tests/src/Test/Tasty/Clash.hs index cea7ea8973..6dea65e9fc 100644 --- a/tests/src/Test/Tasty/Clash.hs +++ b/tests/src/Test/Tasty/Clash.hs @@ -209,11 +209,10 @@ data ClashGenTest = ClashGenTest -- | See https://github.com/clash-lang/clash-compiler/pull/2511 dOpaque :: String -dOpaque = #if __GLASGOW_HASKELL__ >= 904 - "-DCLASH_OPAQUE=OPAQUE" +dOpaque = "-DCLASH_OPAQUE=OPAQUE" #else - "-DCLASH_OPAQUE=NOINLINE" +dOpaque = "-DCLASH_OPAQUE=NOINLINE" #endif instance IsTest ClashGenTest where @@ -490,6 +489,20 @@ runTest runTest modName opts path = testGroup modName (map (runTest1 modName opts (modName:path)) (hdlTargets opts)) +runTestIf + :: Bool + -- ^ Whether to run the test + -> String + -- ^ Name of test + -> TestOptions + -> [TestName] + -- ^ Parent test names in order of distance to the test. That is, the last + -- item in the list will be the root node, while the first one will be the + -- one closest to the test. Should correspond to directories on filesystem. + -> TestTree +runTestIf True modName opts path = runTest modName opts path +runTestIf False modName _ _ = testGroup (modName ++ " - skipped") [] + outputTest' :: String -- ^ Module name @@ -549,6 +562,28 @@ outputTest modName opts path = | target <- hdlTargets opts ] +ghc906extraBuildArgs :: [String] +#if __GLASGOW_HASKELL__ >= 906 +ghc906extraBuildArgs + = "-dynamic" : + -- All libraries in the GHC environment file are passed to the GHC + -- linking stage, even when they are not used by the particular target. + -- The clash-ffi so-lib contains undefined references, but said library + -- isn't actually used in any of the clash-lib tests. So we just tell + -- the linker to shut up and continue producing an executable, as the + -- undefined references will not be an issue at run-time. + "-optl" : "-Wl,--allow-shlib-undefined" : [] +#else +ghc906extraBuildArgs = [] +#endif + +mmapWorkAroundArgs :: [String] +#ifdef CLASH_WORKAROUND_GHC_MMAP_CRASH +mmapWorkAroundArgs = ["-with-rtsopts=-xm20000000"] +#else +mmapWorkAroundArgs = [] +#endif + clashLibTest' :: String -- ^ Module name @@ -573,21 +608,10 @@ clashLibTest' modName target extraGhcArgs path = clashBuild workDir = singleTest "clash (exec)" (ClashBinaryTest { cbBuildTarget=target , cbSourceDirectory=sourceDir - , cbExtraBuildArgs="-DCLASHLIBTEST" : -#if __GLASGOW_HASKELL__ >= 906 - "-dynamic" : - -- All libraries in the GHC environment file are passed to the GHC - -- linking stage, even when they are not used by the particular target. - -- The clash-ffi so-lib contains undefined references, but said library - -- isn't actually used in any of the clash-lib tests. So we just tell - -- the linker to shut up and continue producing an executable, as the - -- undefined references will not be an issue at run-time. - "-optl" : "-Wl,--allow-shlib-undefined" : -#endif -#ifdef CLASH_WORKAROUND_GHC_MMAP_CRASH - "-with-rtsopts=-xm20000000" : -#endif - extraGhcArgs + , cbExtraBuildArgs=[ "-DCLASHLIBTEST" ] + ++ ghc906extraBuildArgs + ++ mmapWorkAroundArgs + ++ extraGhcArgs , cbExtraExecArgs=[] , cbModName=modName , cbOutputDirectory=workDir From f60bc1413ff59090564cfae10b9a7931005bc3d4 Mon Sep 17 00:00:00 2001 From: Rowan Goemans Date: Tue, 18 Jun 2024 19:55:52 +0200 Subject: [PATCH 5/7] clash-cosim: Fixup files for formatting compatibility --- clash-cosim/Setup.hs | 4 ---- clash-cosim/clash-cosim.cabal | 2 +- clash-cosim/src/Clash/CoSim/CodeGeneration.hs | 23 +++++++++++-------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/clash-cosim/Setup.hs b/clash-cosim/Setup.hs index 1345a0d55d..0438c32985 100644 --- a/clash-cosim/Setup.hs +++ b/clash-cosim/Setup.hs @@ -196,11 +196,7 @@ blackboxObject -- ^ templateD -> Value blackboxObject bbname type_ templateD = -#if MIN_VERSION_aeson(2,0,0) Object (KM.fromList [("BlackBox", Object (KM.fromList [ -#else - Object (fromList [("BlackBox", Object (fromList [ -#endif ("name", String $ Text.pack bbname) , ("kind", "Declaration") , ("type", String $ Text.pack type_) diff --git a/clash-cosim/clash-cosim.cabal b/clash-cosim/clash-cosim.cabal index 839131b1ec..c69b4cbc47 100644 --- a/clash-cosim/clash-cosim.cabal +++ b/clash-cosim/clash-cosim.cabal @@ -44,7 +44,7 @@ flag pedantic custom-setup -- ghc-options: -Wall -Werror - setup-depends: aeson, + setup-depends: aeson >= 2.0.0, base >= 4.10 && < 5, bytestring, Cabal, diff --git a/clash-cosim/src/Clash/CoSim/CodeGeneration.hs b/clash-cosim/src/Clash/CoSim/CodeGeneration.hs index f98b49cb93..8cfac2a40f 100644 --- a/clash-cosim/src/Clash/CoSim/CodeGeneration.hs +++ b/clash-cosim/src/Clash/CoSim/CodeGeneration.hs @@ -47,6 +47,17 @@ arrowsR (t0:ts) t = arrow t0 (arrowsR ts t) applyE :: Foldable t => ExpQ -> t Name -> ExpQ applyE = foldl (\f x -> [| $f $(varE x) |]) +maxNumberOfClocks :: IO Int +maxNumberOfArgs :: IO Int +#ifdef CABAL +-- We're running in a CABAL environment, so we know this environment +-- variable is set: +maxNumberOfClocks = read <$> runIO (getEnv "COSIM_MAX_NUMBER_OF_CLOCKS") +maxNumberOfArgs = read <$> runIO (getEnv "COSIM_MAX_NUMBER_OF_ARGUMENTS") +#else +maxNumberOfClocks = pure 1 +maxNumberOfArgs = pure 16 +#endif -------------------------------------- ---- CODE GENERATION ----------------- -------------------------------------- @@ -56,16 +67,8 @@ applyE = foldl (\f x -> [| $f $(varE x) |]) -- to 16.) coSimGen :: Q [Dec] coSimGen = do -#ifdef CABAL - -- We're running in a CABAL environment, so we know this environment - -- variable is set: - m <- read <$> runIO (getEnv "COSIM_MAX_NUMBER_OF_CLOCKS") - n <- read <$> runIO (getEnv "COSIM_MAX_NUMBER_OF_ARGUMENTS") -#else - let m = 1 - let n = 16 -#endif - + m <- maxNumberOfClocks + n <- maxNumberOfArgs concat <$> (sequence [coSimGen' clks args | clks <- [0..m], args <- [1..n]]) From 09e1286ae09a9f782ce9e18da7572f6d48d80271 Mon Sep 17 00:00:00 2001 From: Rowan Goemans Date: Tue, 18 Jun 2024 23:03:36 +0200 Subject: [PATCH 6/7] clash-ffi: Fixup files for formatting compatibility --- clash-ffi/src/Clash/FFI/VPI/Callback.hs | 11 +++++- .../src/Clash/FFI/VPI/Callback/Reason.hs | 4 +++ clash-ffi/src/Clash/FFI/VPI/Control.hs | 4 +-- clash-ffi/src/Clash/FFI/VPI/Object.hs | 12 +++---- clash-ffi/src/Clash/FFI/VPI/Object/Type.hs | 36 ++++++++++++++++--- clash-ffi/src/Clash/FFI/VPI/Object/Value.hs | 1 + .../src/Clash/FFI/VPI/Object/Value/Format.hs | 1 + clash-ffi/tests/Clash/FFI/Test/Instances.hs | 6 ++++ 8 files changed, 60 insertions(+), 15 deletions(-) diff --git a/clash-ffi/src/Clash/FFI/VPI/Callback.hs b/clash-ffi/src/Clash/FFI/VPI/Callback.hs index 097161cf28..8d4b9bc161 100644 --- a/clash-ffi/src/Clash/FFI/VPI/Callback.hs +++ b/clash-ffi/src/Clash/FFI/VPI/Callback.hs @@ -13,18 +13,27 @@ Maintainer: QBayLogic B.V. {-# OPTIONS_GHC -fplugin=Foreign.Storable.Generic.Plugin #-} {-# OPTIONS_GHC -fplugin-opt=Foreign.Storable.Generic.Plugin:-v0 #-} +#ifndef IVERILOG module Clash.FFI.VPI.Callback ( CCallbackInfo(..) , CallbackInfo(..) , Callback(..) , registerCallback , removeCallback -#ifndef IVERILOG , getCallbackInfo , withCallbackInfo , unsafeReceiveCallbackInfo , receiveCallbackInfo + , module Clash.FFI.VPI.Callback.Reason + ) where #endif + +module Clash.FFI.VPI.Callback + ( CCallbackInfo(..) + , CallbackInfo(..) + , Callback(..) + , registerCallback + , removeCallback , module Clash.FFI.VPI.Callback.Reason ) where diff --git a/clash-ffi/src/Clash/FFI/VPI/Callback/Reason.hs b/clash-ffi/src/Clash/FFI/VPI/Callback/Reason.hs index 7c8f43f484..82e89be8fe 100644 --- a/clash-ffi/src/Clash/FFI/VPI/Callback/Reason.hs +++ b/clash-ffi/src/Clash/FFI/VPI/Callback/Reason.hs @@ -66,6 +66,7 @@ obviously unchecked / unsafe, so must be performed carefully. -- for a compliant VPI implementation but a feature is optional and may not -- be implemented in all tools. -- +{- FOURMOLU_DISABLE -} data CallbackReason = forall a. Coercible a Object => AfterValueChange a TimeType ValueFormat -- ^ Triggered after the value of the object @a@ changes. @@ -148,6 +149,7 @@ data CallbackReason -- ^ Triggered after non-blocking events in a time step are executed, but -- before read-only events are processed. #endif +{- FOURMOLU_ENABLE -} type instance CRepr CallbackReason = (CInt, Object, Ptr CTime, Ptr CValue) @@ -494,6 +496,7 @@ instance Show UnknownCallbackReason where , prettyCallStack c ] +{- FOURMOLU_DISABLE -} instance UnsafeReceive CallbackReason where unsafeReceive (creason, object, ctime, cvalue) = let mObject = if isNullObject object then Nothing else Just object in @@ -737,3 +740,4 @@ instance Receive CallbackReason where #endif n -> throwIO $ UnknownCallbackReason n callStack +{- FOURMOLU_ENABLE -} diff --git a/clash-ffi/src/Clash/FFI/VPI/Control.hs b/clash-ffi/src/Clash/FFI/VPI/Control.hs index 8db615b83b..c3e2a697da 100644 --- a/clash-ffi/src/Clash/FFI/VPI/Control.hs +++ b/clash-ffi/src/Clash/FFI/VPI/Control.hs @@ -7,8 +7,8 @@ Maintainer: QBayLogic B.V. {-# LANGUAGE CPP #-} {-# LANGUAGE TypeFamilies #-} -module Clash.FFI.VPI.Control #if defined(VERILOG_2001) +module Clash.FFI.VPI.Control ( Control(..) , StopValue(..) , DiagnosticLevel(..) @@ -115,5 +115,5 @@ controlSimulator control = do throwIO $ CouldNotControl control callStack #else - () where + module Clash.FFI.VPI.Control () where #endif diff --git a/clash-ffi/src/Clash/FFI/VPI/Object.hs b/clash-ffi/src/Clash/FFI/VPI/Object.hs index ac12238385..c632a8266b 100644 --- a/clash-ffi/src/Clash/FFI/VPI/Object.hs +++ b/clash-ffi/src/Clash/FFI/VPI/Object.hs @@ -86,9 +86,13 @@ newtype Object #if defined(VERILOG) foreign import ccall "vpi_user.h vpi_free_object" c_vpi_free_object :: Object -> IO CInt +c_vpi_release :: Object -> IO CInt +c_vpi_release = c_vpi_free_object #elif defined(SYSTEMVERILOG) foreign import ccall "vpi_user.h vpi_release_handle" c_vpi_release_handle :: Object -> IO CInt +c_vpi_release :: Object -> IO CInt +c_vpi_release = c_vpi_release_handle #else #error "Neither VERILOG or SYSTEMVERILOG is defined in VPI implementation" #endif @@ -135,13 +139,7 @@ instance IsObject Object where freeObject obj = Monad.unless (isNullObject obj) . Monad.void -#if defined(VERILOG) - $ c_vpi_free_object obj -#elif defined(SYSTEMVERILOG) - $ c_vpi_release_handle obj -#else -#error "Neither VERILOG or SYSTEMVERILOG is defined in VPI implementation" -#endif + $ c_vpi_release obj compareObjects = c_vpi_compare_objects diff --git a/clash-ffi/src/Clash/FFI/VPI/Object/Type.hs b/clash-ffi/src/Clash/FFI/VPI/Object/Type.hs index 8e5e0abb40..cce556339a 100644 --- a/clash-ffi/src/Clash/FFI/VPI/Object/Type.hs +++ b/clash-ffi/src/Clash/FFI/VPI/Object/Type.hs @@ -22,19 +22,28 @@ import Clash.FFI.View -- queried using the @vpiType@ property, and the value used to identify when -- it is safe to coerce into a type in the higher-level VPI API. -- +#if defined(VERILOG_2001) data ObjectType = ObjModule | ObjNet | ObjParameter | ObjPort | ObjReg -#if defined(VERILOG_2001) | ObjCallback -#endif deriving stock (Eq, Show) +#else +data ObjectType + = ObjModule + | ObjNet + | ObjParameter + | ObjPort + | ObjReg + deriving stock (Eq, Show) +#endif type instance CRepr ObjectType = CInt +#if defined(VERILOG_2001) instance Send ObjectType where send = pure . \case @@ -43,8 +52,16 @@ instance Send ObjectType where ObjParameter -> 41 ObjPort -> 44 ObjReg -> 48 -#if defined(VERILOG_2001) ObjCallback -> 107 +#else +instance Send ObjectType where + send = + pure . \case + ObjModule -> 32 + ObjNet -> 36 + ObjParameter -> 41 + ObjPort -> 44 + ObjReg -> 48 #endif -- | An exception thrown when decoding an object type if an invalid value is @@ -65,6 +82,7 @@ instance Show UnknownObjectType where , prettyCallStack c ] +#if defined(VERILOG_2001) instance Receive ObjectType where receive = \case 32 -> pure ObjModule @@ -72,7 +90,15 @@ instance Receive ObjectType where 41 -> pure ObjParameter 44 -> pure ObjPort 48 -> pure ObjReg -#if defined(VERILOG_2001) 107 -> pure ObjCallback -#endif ty -> throwIO $ UnknownObjectType ty callStack +#else +instance Receive ObjectType where + receive = \case + 32 -> pure ObjModule + 36 -> pure ObjNet + 41 -> pure ObjParameter + 44 -> pure ObjPort + 48 -> pure ObjReg + ty -> throwIO $ UnknownObjectType ty callStack +#endif diff --git a/clash-ffi/src/Clash/FFI/VPI/Object/Value.hs b/clash-ffi/src/Clash/FFI/VPI/Object/Value.hs index 6c5907f0e0..d0efb3cfd5 100644 --- a/clash-ffi/src/Clash/FFI/VPI/Object/Value.hs +++ b/clash-ffi/src/Clash/FFI/VPI/Object/Value.hs @@ -1,3 +1,4 @@ +{- FOURMOLU_DISABLE -} {-| Copyright: (C) 2022 Google Inc. License: BSD2 (see the file LICENSE) diff --git a/clash-ffi/src/Clash/FFI/VPI/Object/Value/Format.hs b/clash-ffi/src/Clash/FFI/VPI/Object/Value/Format.hs index 3c81f96bd7..1e7affcc3a 100644 --- a/clash-ffi/src/Clash/FFI/VPI/Object/Value/Format.hs +++ b/clash-ffi/src/Clash/FFI/VPI/Object/Value/Format.hs @@ -1,3 +1,4 @@ +{- FOURMOLU_DISABLE -} {-| Copyright: (C) 2022 Google Inc. License: BSD2 (see the file LICENSE) diff --git a/clash-ffi/tests/Clash/FFI/Test/Instances.hs b/clash-ffi/tests/Clash/FFI/Test/Instances.hs index 87fe2eeca2..3e3b3d14b0 100644 --- a/clash-ffi/tests/Clash/FFI/Test/Instances.hs +++ b/clash-ffi/tests/Clash/FFI/Test/Instances.hs @@ -267,6 +267,8 @@ instance TShow CallbackReason where <> pShow t #endif +{- FOURMOLU_DISABLE -} + instance Monad m => Serial m CallbackReason where series = (AfterValueChange <$> obj <~> series <~> series) @@ -311,6 +313,8 @@ instance Monad m => Serial m CallbackReason where mObj :: Series m (Maybe Object) mObj = series +{- FOURMOLU_ENABLE -} + -- Additional Clash.FFI.VPI.Control.Control Instances instance TShow Control @@ -398,6 +402,7 @@ instance Monad m => Serial m (Property CInt) where instance Monad m => Serial m (Property CString) where series = foldl (\/) (pure Name) $ map pure [FullName, File] +{- FOURMOLU_DISABLE -} instance Monad m => Serial m (Property Bool) where series = foldl (\/) (pure IsScalar) $ map pure @@ -407,6 +412,7 @@ instance Monad m => Serial m (Property Bool) where , IsLocalParam #endif ] +{- FOURMOLU_ENABLE -} -- Additional Clash.FFI.VPI.Object.Time.TimeType Instances From 17dae61b3391574cb58e5c12051343a4d811d087 Mon Sep 17 00:00:00 2001 From: Rowan Goemans Date: Tue, 18 Jun 2024 23:03:48 +0200 Subject: [PATCH 7/7] WIP: clash-ghc: Fixup files for formatting compatibility --- clash-ghc/src-ghc/Clash/GHC/ClashFlags.hs | 14 ++- clash-ghc/src-ghc/Clash/GHC/Evaluator.hs | 35 +++--- .../src-ghc/Clash/GHC/Evaluator/Primitive.hs | 2 + clash-ghc/src-ghc/Clash/GHC/GHC2Core.hs | 2 + .../src-ghc/Clash/GHC/GenerateBindings.hs | 108 ++++++++++-------- 5 files changed, 96 insertions(+), 65 deletions(-) diff --git a/clash-ghc/src-ghc/Clash/GHC/ClashFlags.hs b/clash-ghc/src-ghc/Clash/GHC/ClashFlags.hs index 85f62a7de1..59382331c8 100644 --- a/clash-ghc/src-ghc/Clash/GHC/ClashFlags.hs +++ b/clash-ghc/src-ghc/Clash/GHC/ClashFlags.hs @@ -43,14 +43,18 @@ parseClashFlags :: IORef ClashOpts -> [Located String] -> IO ([Located String],[Warn]) parseClashFlags r = parseClashFlagsFull (flagsClash r) -parseClashFlagsFull :: [Flag IO] -> [Located String] - -> IO ([Located String],[Warn]) -parseClashFlagsFull flagsAvialable args = do - (leftovers,errs,warns) <- processArgs flagsAvialable args +processGhcArgs :: [Flag IO] -> [Located String] -> IO ([Located String], [Err], [Warn]) #if MIN_VERSION_ghc(9,4,0) - parseResponseFile +processGhcArgs flagsAvailable args = processArgs flagsAvailable args parseResponseFile +#else +processGhcArgs flagsAvailable args = processArgs flagsAvailable args #endif +parseClashFlagsFull :: [Flag IO] -> [Located String] + -> IO ([Located String],[Warn]) +parseClashFlagsFull flagsAvailable args = do + (leftovers,errs,warns) <- processGhcArgs flagsAvailable args + unless (null errs) $ throwGhcExceptionIO $ errorsToGhcException . map (("on the commandline", ) . unLoc . errMsg) $ errs diff --git a/clash-ghc/src-ghc/Clash/GHC/Evaluator.hs b/clash-ghc/src-ghc/Clash/GHC/Evaluator.hs index cfc82a2b78..7b9797e374 100644 --- a/clash-ghc/src-ghc/Clash/GHC/Evaluator.hs +++ b/clash-ghc/src-ghc/Clash/GHC/Evaluator.hs @@ -367,6 +367,23 @@ instantiate tcm pVal@(PrimVal (PrimInfo{primType}) tys es) ty m instantiate _ p _ _ = error $ "Evaluator.instantiate: Not a tylambda: " ++ show p +getByteArrayIP :: Integer -> BA.ByteArray# +#if MIN_VERSION_base(4,15,0) +getByteArrayIP !(IP ba0) = ba0 +#else +getByteArrayIP !(Jp# !(BN# ba0)) = ba0 +#endif +getByteArrayIP _ = error "getByteArrayIP: not IP" + +getByteArrayIN :: Integer -> BA.ByteArray# +#if MIN_VERSION_base(4,15,0) +getByteArrayIN !(IN ba0) = ba0 +#else +getByteArrayIN !(Jn# !(BN# ba0)) = ba0 +#endif +getByteArrayIN _ = error "getByteArrayIN: not IN" + + -- | Evaluate a case-expression scrutinise :: Value -> Type -> [Alt] -> Machine -> Machine scrutinise v _altTy [] m = setTerm (valToTerm v) m @@ -390,19 +407,11 @@ scrutinise (Lit l) _altTy alts m = case alts of 1 | l1 >= ((-2)^(63::Int)) && l1 < 2^(63::Int) -> Just (IntLiteral l1) 2 | l1 >= (2^(63::Int)) -> -#if MIN_VERSION_base(4,15,0) - let !(IP ba0) = l1 -#else - let !(Jp# !(BN# ba0)) = l1 -#endif + let ba0 = getByteArrayIP l1 ba1 = BA.ByteArray ba0 in Just (ByteArrayLiteral ba1) 3 | l1 < ((-2)^(63::Int)) -> -#if MIN_VERSION_base(4,15,0) - let !(IN ba0) = l1 -#else - let !(Jn# !(BN# ba0)) = l1 -#endif + let ba0 = getByteArrayIN l1 ba1 = BA.ByteArray ba0 in Just (ByteArrayLiteral ba1) _ -> Nothing @@ -415,11 +424,7 @@ scrutinise (Lit l) _altTy alts m = case alts of 1 | l1 >= 0 && l1 < 2^(64::Int) -> Just (WordLiteral l1) 2 | l1 >= (2^(64::Int)) -> -#if MIN_VERSION_base(4,15,0) - let !(IP ba0) = l1 -#else - let !(Jp# !(BN# ba0)) = l1 -#endif + let ba0 = getByteArrayIP l1 ba1 = BA.ByteArray ba0 in Just (ByteArrayLiteral ba1) _ -> Nothing diff --git a/clash-ghc/src-ghc/Clash/GHC/Evaluator/Primitive.hs b/clash-ghc/src-ghc/Clash/GHC/Evaluator/Primitive.hs index c756f13550..1fc7a64bab 100644 --- a/clash-ghc/src-ghc/Clash/GHC/Evaluator/Primitive.hs +++ b/clash-ghc/src-ghc/Clash/GHC/Evaluator/Primitive.hs @@ -1,3 +1,5 @@ +{- FOURMOLU_DISABLE -} + {-| Copyright : (C) 2013-2016, University of Twente, 2016-2017, Myrtle Software Ltd, diff --git a/clash-ghc/src-ghc/Clash/GHC/GHC2Core.hs b/clash-ghc/src-ghc/Clash/GHC/GHC2Core.hs index 95ac337c6b..e02a434fc6 100644 --- a/clash-ghc/src-ghc/Clash/GHC/GHC2Core.hs +++ b/clash-ghc/src-ghc/Clash/GHC/GHC2Core.hs @@ -1,3 +1,5 @@ +{- FOURMOLU_DISABLE -} + {-| Copyright : (C) 2013-2016, University of Twente, 2016-2017, Myrtle Software Ltd, diff --git a/clash-ghc/src-ghc/Clash/GHC/GenerateBindings.hs b/clash-ghc/src-ghc/Clash/GHC/GenerateBindings.hs index 9e7b434476..a001548c27 100644 --- a/clash-ghc/src-ghc/Clash/GHC/GenerateBindings.hs +++ b/clash-ghc/src-ghc/Clash/GHC/GenerateBindings.hs @@ -107,6 +107,19 @@ indexMaybe [] _ = Nothing indexMaybe (x:_) 0 = Just x indexMaybe (_:xs) n = indexMaybe xs (n-1) +opaqueBindingSpec :: GHC.InlineSpec +inlineBindingSpec :: GHC.InlineSpec +opaqueString :: String +#if MIN_VERSION_ghc(9,4,0) +opaqueBindingSpec = GHC.Opaque GHC.NoSourceText +inlineBindingSpec = GHC.Inline GHC.NoSourceText +opaqueString = "OPAQUE" +#else +opaqueBindingSpec = GHC.NoInline +inlineBindingSpec = GHC.Inline +opaqueString = "INLINE" +#endif + generateBindings :: ClashOpts -> GHC.Ghc () @@ -155,11 +168,7 @@ generateBindings opts startAction primDirs importDirs dbs hdl modName dflagsM = -- selectors, no need to check free vars. clsMap = fmap (\(v,i) -> -#if MIN_VERSION_ghc(9,4,0) - (Binding v GHC.noSrcSpan (GHC.Inline GHC.NoSourceText) IsFun -#else - (Binding v GHC.noSrcSpan GHC.Inline IsFun -#endif + (Binding v GHC.noSrcSpan inlineBindingSpec IsFun (mkClassSelector inScope0 allTcCache (varType v) i) False)) clsVMap allBindings = bindingsMap `unionVarEnv` clsMap @@ -210,11 +219,7 @@ setNoInlineTopEntities bm tes = go b@Binding{bindingId} | bindingId `elemVarSet` ids -#if MIN_VERSION_ghc(9,4,0) - = b { bindingSpec = GHC.Opaque GHC.NoSourceText } -#else - = b { bindingSpec = GHC.NoInline } -#endif + = b { bindingSpec = opaqueBindingSpec } | otherwise = b -- TODO This function should be changed to provide the information that @@ -274,6 +279,48 @@ mkBindings primMap bindings clsOps unlocatable = do return (mkVarEnv (concat bindingsList), mkVarEnv clsOpList) +#if MIN_VERSION_ghc(9,4,0) +strictnessInfo :: GHC.IdInfo -> GHC.DmdSig +strictnessInfo info = GHC.dmdSigInfo info + +argDemands :: GHC.DmdSig -> [GHC.Demand] +argDemands strictness = fst $ GHC.splitDmdSig strictness +#else +strictnessInfo :: GHC.IdInfo -> GHC.StrictSig +strictnessInfo info = GHC.strictnessInfo info + +argDemands :: GHC.StrictSig -> [GHC.Demand] +argDemands strictness = fst $ GHC.splitStrictSig strictness +#endif + +#if MIN_VERSION_ghc(9,4,0) +appIsDeadEnd :: GHC.DmdSig -> Int -> Bool +#else +appIsDeadEnd :: GHC.StrictSig -> Int -> Bool +#endif +#if MIN_VERSION_ghc(9,2,0) +appIsDeadEnd = GHC.isDeadEndAppSig +#elif MIN_VERSION_ghc(9,0,0) +appIsDeadEnd = GHC.appIsDeadEnd +#else +appIsDeadEnd = GHC.appIsBottom +#endif + +funArity :: GHC.Type -> Int +#if MIN_VERSION_ghc(9,2,0) +funArity ty = length . fst . GHC.splitFunTys . snd . GHC.splitForAllTyCoVars $ ty +#else +funArity ty = length . fst . GHC.splitFunTys . snd . GHC.splitForAllTys $ ty +#endif + +realSrcLoc :: GHC.SrcLoc -> Maybe GHC.RealSrcLoc +realSrcLoc (GHC.UnhelpfulLoc _) = Nothing +#if MIN_VERSION_ghc(9,0,0) +realSrcLoc (GHC.RealSrcLoc l _) = Just l +#else +realSrcLoc (GHC.RealSrcLoc l _) = Just l +#endif + {- NOTE [bindings in recursive groups] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -316,30 +363,11 @@ checkPrimitive primMap v = do let info = GHC.idInfo v inline = GHC.inlinePragmaSpec $ GHC.inlinePragInfo info -#if MIN_VERSION_ghc(9,4,0) - strictness = GHC.dmdSigInfo info -#else - strictness = GHC.strictnessInfo info -#endif + strictness = strictnessInfo info ty = GHC.varType v -#if MIN_VERSION_ghc(9,2,0) - (argTys,_resTy) = GHC.splitFunTys (snd (GHC.splitForAllTyCoVars ty)) -#else - (argTys,_resTy) = GHC.splitFunTys . snd . GHC.splitForAllTys $ ty -#endif -#if MIN_VERSION_ghc(9,4,0) - (dmdArgs,_dmdRes) = GHC.splitDmdSig strictness -#else - (dmdArgs,_dmdRes) = GHC.splitStrictSig strictness -#endif - nrOfArgs = length argTys - loc = case GHC.getSrcLoc v of - GHC.UnhelpfulLoc _ -> "" -#if MIN_VERSION_ghc(9,0,0) - GHC.RealSrcLoc l _ -> showPpr l ++ ": " -#else - GHC.RealSrcLoc l -> showPpr l ++ ": " -#endif + dmdArgs = argDemands strictness + nrOfArgs = funArity ty + loc = maybe "" (\l -> showPpr l ++ ": ") $ realSrcLoc $ GHC.getSrcLoc v warnIf cond msg = traceIf cond ("\n"++loc++"Warning: "++msg) return () qName <- Text.unpack <$> qualifiedNameString (GHC.varName v) let primStr = "primitive " ++ qName ++ " " @@ -360,19 +388,9 @@ checkPrimitive primMap v = do unless (qName == "Clash.XException.errorX" || "GHC." `isPrefixOf` qName) $ do warnIf (not (isOpaque inline)) -#if MIN_VERSION_ghc(9,4,0) - (primStr ++ "isn't marked OPAQUE." -#else - (primStr ++ "isn't marked NOINLINE." -#endif + (primStr ++ "isn't marked " ++ opaqueString ++ "." ++ "\nThis might make Clash ignore this primitive.") -#if MIN_VERSION_ghc(9,2,0) - warnIf (GHC.isDeadEndAppSig strictness nrOfArgs) -#elif MIN_VERSION_ghc(9,0,0) - warnIf (GHC.appIsDeadEnd strictness nrOfArgs) -#else - warnIf (GHC.appIsBottom strictness nrOfArgs) -#endif + warnIf (appIsDeadEnd strictness nrOfArgs) ("The Haskell implementation of " ++ primStr ++ "produces a result that always results in an error.\n" ++ "This can lead to compile failures because GHC can replace entire "