Add clash

This commit is contained in:
harris-chris 2022-03-18 11:21:33 +09:00
parent 3fecc12003
commit 35b90044df
43 changed files with 915 additions and 1 deletions

1
gitignore Normal file
View file

@ -0,0 +1 @@
**/__pycache__

@ -1 +0,0 @@
Subproject commit 1e7263237368e6322727792530b34dedfc871756

BIN
haskell-clash/MAC.hi Normal file

Binary file not shown.

18
haskell-clash/MAC.hs Normal file
View file

@ -0,0 +1,18 @@
module MAC where
import Clash.Prelude
import Clash.Explicit.Testbench
mac :: (Num a) => a -> (a, a) -> (a, a)
mac acc (x, y) = (acc + x * y, acc)
macS :: (HiddenClockResetEnable dom, Num a, NFDataX a) => Signal dom (a, a) -> Signal dom a
macS = mealy mac 0
topEntity
:: Clock System
-> Reset System
-> Enable System
-> Signal System (Int, Int)
-> Signal System Int
topEntity = exposeClockResetEnable macS

BIN
haskell-clash/MAC.o Normal file

Binary file not shown.

7
haskell-clash/Main.hs Normal file
View file

@ -0,0 +1,7 @@
module Main where
import HaskellSay (haskellSay)
main :: IO ()
main =
haskellSay "Hello, Haskell! You're using a function from another package!"

View file

@ -0,0 +1,5 @@
packages:
./
package clash-test
tests: True

View file

@ -0,0 +1,16 @@
{ pkgs ? import <nixos> {} }:
let
unstable = import (fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz) {};
in pkgs.mkShell {
name = "clash-compiler-shell";
buildInputs = with unstable.haskellPackages; [
(ghcWithPackages (p: with p; [
clash-ghc
ghc-typelits-extra
ghc-typelits-knownnat
ghc-typelits-natnormalise
])
)
];
}

View file

@ -0,0 +1,71 @@
cabal-version: 2.4
name: clash-test
version: 0
license: BSD-3-Clause
build-type: Simple
license-file: LICENSE
author: harris-chris
maintainer: harris-chris <chrisharriscjh@gmail.com>
copyright: 2021 harris-chris
tested-with: GHC ==8.6.3 || ==8.8.3 || ==8.10.5
extra-doc-files:
CHANGELOG.md
README.md
-- category:
-- description: description
-- synopsis: one-line synopsis
-- homepage: https://github.com/FIXME/haskell-nix-test#readme
-- source-repository head
-- type: git
-- location: git://github.com/FIXME/haskell-nix-test.git
common common-options
build-depends:
base >=4.9 && <5
--clash-ghc >= 1.4.3
default-language: Haskell2010
ghc-options:
-Wall -Wcompat -Widentities -Wincomplete-uni-patterns
-Wincomplete-record-updates -Wredundant-constraints
-fhide-source-paths -Wpartial-fields
--library
--import: common-options
--hs-source-dirs: src
--exposed-modules: Lib
--build-depends:
--, containers
--, mtl
executable haskell-nix-test-exe
import: common-options
hs-source-dirs: ., app
main-is: Main.hs
build-depends:
haskell-say ^>=1.0.0.0
ghc-options: -threaded -rtsopts -with-rtsopts=-N
--test-suite haskell-nix-test-test
--import: common-options
--type: exitcode-stdio-1.0
--hs-source-dirs: test
--main-is: Spec.hs
--build-depends:
--, hspec
--, HUnit
--, haskell-nix-test
--, QuickCheck
--ghc-options: -threaded -rtsopts -with-rtsopts=-N
--benchmark haskell-nix-test-bench
--import: common-options
--type: exitcode-stdio-1.0
--hs-source-dirs: bench
--main-is: Main.hs
--build-depends:
--, criterion
--, haskell-nix-test
--ghc-options: -threaded -rtsopts -with-rtsopts=-N

30
haskell-clash/default.nix Normal file
View file

@ -0,0 +1,30 @@
let
# Read in the Niv sources
sources = import ./nix/sources.nix {};
# If ./nix/sources.nix file is not found run:
# niv init
# niv add input-output-hk/haskell.nix -n haskellNix
# Fetch the haskell.nix commit we have pinned with Niv
haskellNix = import sources.haskellNix {};
# If haskellNix is not found run:
# niv add input-output-hk/haskell.nix -n haskellNix
# Import nixpkgs and pass the haskell.nix provided nixpkgsArgs
pkgs = import
# haskell.nix provides access to the nixpkgs pins which are used by our CI,
# hence you will be more likely to get cache hits when using these.
# But you can also just use your own, e.g. '<nixpkgs>'.
haskellNix.sources.nixpkgs-2009
# These arguments passed to nixpkgs, include some patches and also
# the haskell.nix functionality itself as an overlay.
haskellNix.nixpkgsArgs;
in pkgs.haskell-nix.project {
# 'cleanGit' cleans a source directory based on the files known by git
src = pkgs.haskell-nix.haskellLib.cleanGit {
name = "haskell-nix-test";
src = ./.;
};
# Specify the GHC version to use.
compiler-nix-name = "ghc8102"; # Not required for `stack.yaml` based projects.
}

View file

@ -0,0 +1,50 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NoRebindableSyntax #-}
{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}
module Paths_haskell_nix_test (
version,
getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,
getDataFileName, getSysconfDir
) where
import qualified Control.Exception as Exception
import Data.Version (Version(..))
import System.Environment (getEnv)
import Prelude
#if defined(VERSION_base)
#if MIN_VERSION_base(4,0,0)
catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
#else
catchIO :: IO a -> (Exception.Exception -> IO a) -> IO a
#endif
#else
catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
#endif
catchIO = Exception.catch
version :: Version
version = Version [0] []
bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath
bindir = "/home/chris/.cabal/bin"
libdir = "/home/chris/.cabal/lib/x86_64-linux-ghc-8.10.2/haskell-nix-test-0-inplace"
dynlibdir = "/home/chris/.cabal/lib/x86_64-linux-ghc-8.10.2"
datadir = "/home/chris/.cabal/share/x86_64-linux-ghc-8.10.2/haskell-nix-test-0"
libexecdir = "/home/chris/.cabal/libexec/x86_64-linux-ghc-8.10.2/haskell-nix-test-0"
sysconfdir = "/home/chris/.cabal/etc"
getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath
getBinDir = catchIO (getEnv "haskell_nix_test_bindir") (\_ -> return bindir)
getLibDir = catchIO (getEnv "haskell_nix_test_libdir") (\_ -> return libdir)
getDynLibDir = catchIO (getEnv "haskell_nix_test_dynlibdir") (\_ -> return dynlibdir)
getDataDir = catchIO (getEnv "haskell_nix_test_datadir") (\_ -> return datadir)
getLibexecDir = catchIO (getEnv "haskell_nix_test_libexecdir") (\_ -> return libexecdir)
getSysconfDir = catchIO (getEnv "haskell_nix_test_sysconfdir") (\_ -> return sysconfdir)
getDataFileName :: FilePath -> IO FilePath
getDataFileName name = do
dir <- getDataDir
return (dir ++ "/" ++ name)

View file

@ -0,0 +1,143 @@
/* DO NOT EDIT: This file is automatically generated by Cabal */
/* package haskell-nix-test-0 */
#ifndef VERSION_haskell_nix_test
#define VERSION_haskell_nix_test "0"
#endif /* VERSION_haskell_nix_test */
#ifndef MIN_VERSION_haskell_nix_test
#define MIN_VERSION_haskell_nix_test(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 0 || \
(major1) == 0 && (major2) == 0 && (minor) <= 0)
#endif /* MIN_VERSION_haskell_nix_test */
/* package base-4.14.1.0 */
#ifndef VERSION_base
#define VERSION_base "4.14.1.0"
#endif /* VERSION_base */
#ifndef MIN_VERSION_base
#define MIN_VERSION_base(major1,major2,minor) (\
(major1) < 4 || \
(major1) == 4 && (major2) < 14 || \
(major1) == 4 && (major2) == 14 && (minor) <= 1)
#endif /* MIN_VERSION_base */
/* package containers-0.6.2.1 */
#ifndef VERSION_containers
#define VERSION_containers "0.6.2.1"
#endif /* VERSION_containers */
#ifndef MIN_VERSION_containers
#define MIN_VERSION_containers(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 6 || \
(major1) == 0 && (major2) == 6 && (minor) <= 2)
#endif /* MIN_VERSION_containers */
/* package mtl-2.2.2 */
#ifndef VERSION_mtl
#define VERSION_mtl "2.2.2"
#endif /* VERSION_mtl */
#ifndef MIN_VERSION_mtl
#define MIN_VERSION_mtl(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 2 || \
(major1) == 2 && (major2) == 2 && (minor) <= 2)
#endif /* MIN_VERSION_mtl */
/* tool gcc-9.3.0 */
#ifndef TOOL_VERSION_gcc
#define TOOL_VERSION_gcc "9.3.0"
#endif /* TOOL_VERSION_gcc */
#ifndef MIN_TOOL_VERSION_gcc
#define MIN_TOOL_VERSION_gcc(major1,major2,minor) (\
(major1) < 9 || \
(major1) == 9 && (major2) < 3 || \
(major1) == 9 && (major2) == 3 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_gcc */
/* tool ghc-8.10.2 */
#ifndef TOOL_VERSION_ghc
#define TOOL_VERSION_ghc "8.10.2"
#endif /* TOOL_VERSION_ghc */
#ifndef MIN_TOOL_VERSION_ghc
#define MIN_TOOL_VERSION_ghc(major1,major2,minor) (\
(major1) < 8 || \
(major1) == 8 && (major2) < 10 || \
(major1) == 8 && (major2) == 10 && (minor) <= 2)
#endif /* MIN_TOOL_VERSION_ghc */
/* tool ghc-pkg-8.10.2 */
#ifndef TOOL_VERSION_ghc_pkg
#define TOOL_VERSION_ghc_pkg "8.10.2"
#endif /* TOOL_VERSION_ghc_pkg */
#ifndef MIN_TOOL_VERSION_ghc_pkg
#define MIN_TOOL_VERSION_ghc_pkg(major1,major2,minor) (\
(major1) < 8 || \
(major1) == 8 && (major2) < 10 || \
(major1) == 8 && (major2) == 10 && (minor) <= 2)
#endif /* MIN_TOOL_VERSION_ghc_pkg */
/* tool haddock-2.24.0 */
#ifndef TOOL_VERSION_haddock
#define TOOL_VERSION_haddock "2.24.0"
#endif /* TOOL_VERSION_haddock */
#ifndef MIN_TOOL_VERSION_haddock
#define MIN_TOOL_VERSION_haddock(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 24 || \
(major1) == 2 && (major2) == 24 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_haddock */
/* tool hpc-0.68 */
#ifndef TOOL_VERSION_hpc
#define TOOL_VERSION_hpc "0.68"
#endif /* TOOL_VERSION_hpc */
#ifndef MIN_TOOL_VERSION_hpc
#define MIN_TOOL_VERSION_hpc(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 68 || \
(major1) == 0 && (major2) == 68 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_hpc */
/* tool hsc2hs-0.68.7 */
#ifndef TOOL_VERSION_hsc2hs
#define TOOL_VERSION_hsc2hs "0.68.7"
#endif /* TOOL_VERSION_hsc2hs */
#ifndef MIN_TOOL_VERSION_hsc2hs
#define MIN_TOOL_VERSION_hsc2hs(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 68 || \
(major1) == 0 && (major2) == 68 && (minor) <= 7)
#endif /* MIN_TOOL_VERSION_hsc2hs */
/* tool runghc-8.10.2 */
#ifndef TOOL_VERSION_runghc
#define TOOL_VERSION_runghc "8.10.2"
#endif /* TOOL_VERSION_runghc */
#ifndef MIN_TOOL_VERSION_runghc
#define MIN_TOOL_VERSION_runghc(major1,major2,minor) (\
(major1) < 8 || \
(major1) == 8 && (major2) < 10 || \
(major1) == 8 && (major2) == 10 && (minor) <= 2)
#endif /* MIN_TOOL_VERSION_runghc */
/* tool strip-2.31 */
#ifndef TOOL_VERSION_strip
#define TOOL_VERSION_strip "2.31"
#endif /* TOOL_VERSION_strip */
#ifndef MIN_TOOL_VERSION_strip
#define MIN_TOOL_VERSION_strip(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 31 || \
(major1) == 2 && (major2) == 31 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_strip */
#ifndef CURRENT_PACKAGE_KEY
#define CURRENT_PACKAGE_KEY "haskell-nix-test-0-inplace"
#endif /* CURRENT_PACKAGE_KEY */
#ifndef CURRENT_COMPONENT_ID
#define CURRENT_COMPONENT_ID "haskell-nix-test-0-inplace"
#endif /* CURRENT_COMPONENT_ID */
#ifndef CURRENT_PACKAGE_VERSION
#define CURRENT_PACKAGE_VERSION "0"
#endif /* CURRENT_PACKAGE_VERSION */

View file

@ -0,0 +1,50 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NoRebindableSyntax #-}
{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}
module Paths_haskell_nix_test (
version,
getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,
getDataFileName, getSysconfDir
) where
import qualified Control.Exception as Exception
import Data.Version (Version(..))
import System.Environment (getEnv)
import Prelude
#if defined(VERSION_base)
#if MIN_VERSION_base(4,0,0)
catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
#else
catchIO :: IO a -> (Exception.Exception -> IO a) -> IO a
#endif
#else
catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
#endif
catchIO = Exception.catch
version :: Version
version = Version [0] []
bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath
bindir = "/home/chris/.cabal/bin"
libdir = "/home/chris/.cabal/lib/x86_64-linux-ghc-8.10.2/haskell-nix-test-0-inplace-haskell-nix-test-exe"
dynlibdir = "/home/chris/.cabal/lib/x86_64-linux-ghc-8.10.2"
datadir = "/home/chris/.cabal/share/x86_64-linux-ghc-8.10.2/haskell-nix-test-0"
libexecdir = "/home/chris/.cabal/libexec/x86_64-linux-ghc-8.10.2/haskell-nix-test-0"
sysconfdir = "/home/chris/.cabal/etc"
getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath
getBinDir = catchIO (getEnv "haskell_nix_test_bindir") (\_ -> return bindir)
getLibDir = catchIO (getEnv "haskell_nix_test_libdir") (\_ -> return libdir)
getDynLibDir = catchIO (getEnv "haskell_nix_test_dynlibdir") (\_ -> return dynlibdir)
getDataDir = catchIO (getEnv "haskell_nix_test_datadir") (\_ -> return datadir)
getLibexecDir = catchIO (getEnv "haskell_nix_test_libexecdir") (\_ -> return libexecdir)
getSysconfDir = catchIO (getEnv "haskell_nix_test_sysconfdir") (\_ -> return sysconfdir)
getDataFileName :: FilePath -> IO FilePath
getDataFileName name = do
dir <- getDataDir
return (dir ++ "/" ++ name)

View file

@ -0,0 +1,129 @@
/* DO NOT EDIT: This file is automatically generated by Cabal */
/* package haskell-nix-test-0 */
#ifndef VERSION_haskell_nix_test
#define VERSION_haskell_nix_test "0"
#endif /* VERSION_haskell_nix_test */
#ifndef MIN_VERSION_haskell_nix_test
#define MIN_VERSION_haskell_nix_test(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 0 || \
(major1) == 0 && (major2) == 0 && (minor) <= 0)
#endif /* MIN_VERSION_haskell_nix_test */
/* package base-4.14.1.0 */
#ifndef VERSION_base
#define VERSION_base "4.14.1.0"
#endif /* VERSION_base */
#ifndef MIN_VERSION_base
#define MIN_VERSION_base(major1,major2,minor) (\
(major1) < 4 || \
(major1) == 4 && (major2) < 14 || \
(major1) == 4 && (major2) == 14 && (minor) <= 1)
#endif /* MIN_VERSION_base */
/* package haskell-say-1.0.0.0 */
#ifndef VERSION_haskell_say
#define VERSION_haskell_say "1.0.0.0"
#endif /* VERSION_haskell_say */
#ifndef MIN_VERSION_haskell_say
#define MIN_VERSION_haskell_say(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 0 || \
(major1) == 1 && (major2) == 0 && (minor) <= 0)
#endif /* MIN_VERSION_haskell_say */
/* tool gcc-9.3.0 */
#ifndef TOOL_VERSION_gcc
#define TOOL_VERSION_gcc "9.3.0"
#endif /* TOOL_VERSION_gcc */
#ifndef MIN_TOOL_VERSION_gcc
#define MIN_TOOL_VERSION_gcc(major1,major2,minor) (\
(major1) < 9 || \
(major1) == 9 && (major2) < 3 || \
(major1) == 9 && (major2) == 3 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_gcc */
/* tool ghc-8.10.2 */
#ifndef TOOL_VERSION_ghc
#define TOOL_VERSION_ghc "8.10.2"
#endif /* TOOL_VERSION_ghc */
#ifndef MIN_TOOL_VERSION_ghc
#define MIN_TOOL_VERSION_ghc(major1,major2,minor) (\
(major1) < 8 || \
(major1) == 8 && (major2) < 10 || \
(major1) == 8 && (major2) == 10 && (minor) <= 2)
#endif /* MIN_TOOL_VERSION_ghc */
/* tool ghc-pkg-8.10.2 */
#ifndef TOOL_VERSION_ghc_pkg
#define TOOL_VERSION_ghc_pkg "8.10.2"
#endif /* TOOL_VERSION_ghc_pkg */
#ifndef MIN_TOOL_VERSION_ghc_pkg
#define MIN_TOOL_VERSION_ghc_pkg(major1,major2,minor) (\
(major1) < 8 || \
(major1) == 8 && (major2) < 10 || \
(major1) == 8 && (major2) == 10 && (minor) <= 2)
#endif /* MIN_TOOL_VERSION_ghc_pkg */
/* tool haddock-2.24.0 */
#ifndef TOOL_VERSION_haddock
#define TOOL_VERSION_haddock "2.24.0"
#endif /* TOOL_VERSION_haddock */
#ifndef MIN_TOOL_VERSION_haddock
#define MIN_TOOL_VERSION_haddock(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 24 || \
(major1) == 2 && (major2) == 24 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_haddock */
/* tool hpc-0.68 */
#ifndef TOOL_VERSION_hpc
#define TOOL_VERSION_hpc "0.68"
#endif /* TOOL_VERSION_hpc */
#ifndef MIN_TOOL_VERSION_hpc
#define MIN_TOOL_VERSION_hpc(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 68 || \
(major1) == 0 && (major2) == 68 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_hpc */
/* tool hsc2hs-0.68.7 */
#ifndef TOOL_VERSION_hsc2hs
#define TOOL_VERSION_hsc2hs "0.68.7"
#endif /* TOOL_VERSION_hsc2hs */
#ifndef MIN_TOOL_VERSION_hsc2hs
#define MIN_TOOL_VERSION_hsc2hs(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 68 || \
(major1) == 0 && (major2) == 68 && (minor) <= 7)
#endif /* MIN_TOOL_VERSION_hsc2hs */
/* tool runghc-8.10.2 */
#ifndef TOOL_VERSION_runghc
#define TOOL_VERSION_runghc "8.10.2"
#endif /* TOOL_VERSION_runghc */
#ifndef MIN_TOOL_VERSION_runghc
#define MIN_TOOL_VERSION_runghc(major1,major2,minor) (\
(major1) < 8 || \
(major1) == 8 && (major2) < 10 || \
(major1) == 8 && (major2) == 10 && (minor) <= 2)
#endif /* MIN_TOOL_VERSION_runghc */
/* tool strip-2.31 */
#ifndef TOOL_VERSION_strip
#define TOOL_VERSION_strip "2.31"
#endif /* TOOL_VERSION_strip */
#ifndef MIN_TOOL_VERSION_strip
#define MIN_TOOL_VERSION_strip(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 31 || \
(major1) == 2 && (major2) == 31 && (minor) <= 0)
#endif /* MIN_TOOL_VERSION_strip */
#ifndef CURRENT_COMPONENT_ID
#define CURRENT_COMPONENT_ID "haskell-nix-test-0-inplace-haskell-nix-test-exe"
#endif /* CURRENT_COMPONENT_ID */
#ifndef CURRENT_PACKAGE_VERSION
#define CURRENT_PACKAGE_VERSION "0"
#endif /* CURRENT_PACKAGE_VERSION */

Binary file not shown.

BIN
haskell-clash/dist-newstyle/cache/config vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1 @@
{"cabal-version":"3.2.0.0","cabal-lib-version":"3.2.0.0","compiler-id":"ghc-8.10.2","os":"linux","arch":"x86_64","install-plan":[{"type":"pre-existing","id":"base-4.14.1.0","pkg-name":"base","pkg-version":"4.14.1.0","depends":["ghc-prim-0.6.1","integer-gmp-1.0.3.0","rts"]},{"type":"configured","id":"clash-test-0-inplace-haskell-nix-test-exe","pkg-name":"clash-test","pkg-version":"0","flags":{},"style":"local","pkg-src":{"type":"local","path":"/data/vap/haskell-clash/."},"dist-dir":"/data/vap/haskell-clash/dist-newstyle/build/x86_64-linux/ghc-8.10.2/clash-test-0/x/haskell-nix-test-exe","depends":["base-4.14.1.0","haskell-say-1.0.0.0-BsVCBKZRGyjE3H8ATpwpU2"],"exe-depends":[],"component-name":"exe:haskell-nix-test-exe","bin-file":"/data/vap/haskell-clash/dist-newstyle/build/x86_64-linux/ghc-8.10.2/clash-test-0/x/haskell-nix-test-exe/build/haskell-nix-test-exe/haskell-nix-test-exe"},{"type":"pre-existing","id":"ghc-prim-0.6.1","pkg-name":"ghc-prim","pkg-version":"0.6.1","depends":["rts"]},{"type":"pre-existing","id":"haskell-say-1.0.0.0-BsVCBKZRGyjE3H8ATpwpU2","pkg-name":"haskell-say","pkg-version":"1.0.0.0","depends":["base-4.14.1.0"]},{"type":"pre-existing","id":"integer-gmp-1.0.3.0","pkg-name":"integer-gmp","pkg-version":"1.0.3.0","depends":["ghc-prim-0.6.1"]},{"type":"pre-existing","id":"rts","pkg-name":"rts","pkg-version":"1.0","depends":[]}]}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,50 @@
{
"clash-compiler": {
"branch": "master",
"description": "Haskell to VHDL/Verilog/SystemVerilog compiler",
"homepage": "https://clash-lang.org/",
"owner": "clash-lang",
"repo": "clash-compiler",
"rev": "70b7b2ecb4647163d807a30072cc1faf922a3710",
"sha256": "0mg8gd9yispvvi7sk62rnqmp1x301564x88ivgk50mqz85247a8f",
"type": "tarball",
"url": "https://github.com/clash-lang/clash-compiler/archive/70b7b2ecb4647163d807a30072cc1faf922a3710.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"haskellNix": {
"branch": "master",
"description": "Alternative Haskell Infrastructure for Nixpkgs",
"homepage": "https://input-output-hk.github.io/haskell.nix",
"owner": "input-output-hk",
"repo": "haskell.nix",
"rev": "b0f217b5954e445d90ce4ac70cf82a62093052cd",
"sha256": "1gsl6c3bbsglrq5q86vnlyhi4k0l1nxm399h0kli8zzs76lfbkff",
"type": "tarball",
"url": "https://github.com/input-output-hk/haskell.nix/archive/b0f217b5954e445d90ce4ac70cf82a62093052cd.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"niv": {
"branch": "master",
"description": "Easy dependency management for Nix projects",
"homepage": "https://github.com/nmattia/niv",
"owner": "nmattia",
"repo": "niv",
"rev": "65a61b147f307d24bfd0a5cd56ce7d7b7cc61d2e",
"sha256": "17mirpsx5wyw262fpsd6n6m47jcgw8k2bwcp1iwdnrlzy4dhcgqh",
"type": "tarball",
"url": "https://github.com/nmattia/niv/archive/65a61b147f307d24bfd0a5cd56ce7d7b7cc61d2e.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "release-20.03",
"description": "Nix Packages collection",
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "eb73405ecceb1dc505b7cbbd234f8f94165e2696",
"sha256": "06k21wbyhhvq2f1xczszh3c2934p0m02by3l2ixvd6nkwrqklax7",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/eb73405ecceb1dc505b7cbbd234f8f94165e2696.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}

View file

@ -0,0 +1,174 @@
# This file has been generated by Niv.
let
#
# The fetchers. fetch_<type> fetches specs of type <type>.
#
fetch_file = pkgs: name: spec:
let
name' = sanitizeName name + "-src";
in
if spec.builtin or true then
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
else
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
fetch_tarball = pkgs: name: spec:
let
name' = sanitizeName name + "-src";
in
if spec.builtin or true then
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
else
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
fetch_git = name: spec:
let
ref =
if spec ? ref then spec.ref else
if spec ? branch then "refs/heads/${spec.branch}" else
if spec ? tag then "refs/tags/${spec.tag}" else
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
in
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
fetch_local = spec: spec.path;
fetch_builtin-tarball = name: throw
''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
$ niv modify ${name} -a type=tarball -a builtin=true'';
fetch_builtin-url = name: throw
''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
$ niv modify ${name} -a type=file -a builtin=true'';
#
# Various helpers
#
# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
sanitizeName = name:
(
concatMapStrings (s: if builtins.isList s then "-" else s)
(
builtins.split "[^[:alnum:]+._?=-]+"
((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
)
);
# The set of packages used when specs are fetched using non-builtins.
mkPkgs = sources: system:
let
sourcesNixpkgs =
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
in
if builtins.hasAttr "nixpkgs" sources
then sourcesNixpkgs
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
import <nixpkgs> {}
else
abort
''
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
add a package called "nixpkgs" to your sources.json.
'';
# The actual fetching function.
fetch = pkgs: name: spec:
if ! builtins.hasAttr "type" spec then
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
else if spec.type == "file" then fetch_file pkgs name spec
else if spec.type == "tarball" then fetch_tarball pkgs name spec
else if spec.type == "git" then fetch_git name spec
else if spec.type == "local" then fetch_local spec
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
else if spec.type == "builtin-url" then fetch_builtin-url name
else
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
# If the environment variable NIV_OVERRIDE_${name} is set, then use
# the path directly as opposed to the fetched source.
replace = name: drv:
let
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
in
if ersatz == "" then drv else
# this turns the string into an actual Nix path (for both absolute and
# relative paths)
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
# Ports of functions for older nix versions
# a Nix version of mapAttrs if the built-in doesn't exist
mapAttrs = builtins.mapAttrs or (
f: set: with builtins;
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
);
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
concatMapStrings = f: list: concatStrings (map f list);
concatStrings = builtins.concatStringsSep "";
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
optionalAttrs = cond: as: if cond then as else {};
# fetchTarball version that is compatible between all the versions of Nix
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchTarball;
in
if lessThan nixVersion "1.12" then
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
else
fetchTarball attrs;
# fetchurl version that is compatible between all the versions of Nix
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchurl;
in
if lessThan nixVersion "1.12" then
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
else
fetchurl attrs;
# Create the final "sources" from the config
mkSources = config:
mapAttrs (
name: spec:
if builtins.hasAttr "outPath" spec
then abort
"The values in sources.json should not have an 'outPath' attribute"
else
spec // { outPath = replace name (fetch config.pkgs name spec); }
) config.sources;
# The "config" used by the fetchers
mkConfig =
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
, system ? builtins.currentSystem
, pkgs ? mkPkgs sources system
}: rec {
# The sources, i.e. the attribute set of spec name to spec
inherit sources;
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
inherit pkgs;
};
in
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }

11
haskell-clash/shell.nix Normal file
View file

@ -0,0 +1,11 @@
let
clash-only-shell = import ./clash-only-shell.nix {};
in
(import ./default.nix).shellFor {
tools = {
cabal = "3.2.0.0";
hlint = "latest";
#haskell-language-server = "latest";
};
inputsFrom = [ clash-only-shell ];
}

View file

@ -0,0 +1,87 @@
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
package mac_types is
subtype rst_system is std_logic;
type tup2 is record
tup2_sel0_signed_0 : signed(63 downto 0);
tup2_sel1_signed_1 : signed(63 downto 0);
end record;
subtype clk_system is std_logic;
function toSLV (b : in boolean) return std_logic_vector;
function fromSLV (sl : in std_logic_vector) return boolean;
function tagToEnum (s : in signed) return boolean;
function dataToTag (b : in boolean) return signed;
function toSLV (sl : in std_logic) return std_logic_vector;
function fromSLV (slv : in std_logic_vector) return std_logic;
function toSLV (s : in signed) return std_logic_vector;
function fromSLV (slv : in std_logic_vector) return signed;
function toSLV (p : mac_types.tup2) return std_logic_vector;
function fromSLV (slv : in std_logic_vector) return mac_types.tup2;
end;
package body mac_types is
function toSLV (b : in boolean) return std_logic_vector is
begin
if b then
return "1";
else
return "0";
end if;
end;
function fromSLV (sl : in std_logic_vector) return boolean is
begin
if sl = "1" then
return true;
else
return false;
end if;
end;
function tagToEnum (s : in signed) return boolean is
begin
if s = to_signed(0,64) then
return false;
else
return true;
end if;
end;
function dataToTag (b : in boolean) return signed is
begin
if b then
return to_signed(1,64);
else
return to_signed(0,64);
end if;
end;
function toSLV (sl : in std_logic) return std_logic_vector is
begin
return std_logic_vector'(0 => sl);
end;
function fromSLV (slv : in std_logic_vector) return std_logic is
alias islv : std_logic_vector (0 to slv'length - 1) is slv;
begin
return islv(0);
end;
function toSLV (s : in signed) return std_logic_vector is
begin
return std_logic_vector(s);
end;
function fromSLV (slv : in std_logic_vector) return signed is
alias islv : std_logic_vector(0 to slv'length - 1) is slv;
begin
return signed(islv);
end;
function toSLV (p : mac_types.tup2) return std_logic_vector is
begin
return (toSLV(p.tup2_sel0_signed_0) & toSLV(p.tup2_sel1_signed_1));
end;
function fromSLV (slv : in std_logic_vector) return mac_types.tup2 is
alias islv : std_logic_vector(0 to slv'length - 1) is slv;
begin
return (fromSLV(islv(0 to 63)),fromSLV(islv(64 to 127)));
end;
end;

View file

@ -0,0 +1,2 @@
Manifest {manifestHash = (-1555348365264137906,Nothing), successFlags = (20,20,False), portInNames = ["clk","rst","en","\\c$arg_0\\","\\c$arg_1\\"], portInTypes = ["topentity.mac_types.clk_system","topentity.mac_types.rst_system","boolean","signed(63 downto 0)","signed(63 downto 0)"], portOutNames = ["result"], portOutTypes = ["signed(63 downto 0)"], componentNames = ["topentity"]}

View file

@ -0,0 +1,70 @@
-- Automatically generated VHDL-93
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use IEEE.MATH_REAL.ALL;
use std.textio.all;
use work.all;
use work.mac_types.all;
entity topentity is
port(-- clock
clk : in mac_types.clk_system;
-- reset
rst : in mac_types.rst_system;
en : in boolean;
\c$arg_0\ : in signed(63 downto 0);
\c$arg_1\ : in signed(63 downto 0);
result : out signed(63 downto 0));
end;
architecture structural of topentity is
-- MAC.hs:6:1-39
signal acc : signed(63 downto 0) := to_signed(0,64);
-- MAC.hs:6:1-39
signal x : signed(63 downto 0);
-- MAC.hs:6:1-39
signal y : signed(63 downto 0);
signal x_0 : signed(63 downto 0);
signal y_0 : signed(63 downto 0);
signal x_1 : signed(63 downto 0);
signal y_1 : signed(63 downto 0);
signal \c$arg\ : mac_types.tup2;
signal y_0_projection : signed(63 downto 0);
begin
\c$arg\ <= ( tup2_sel0_signed_0 => \c$arg_0\
, tup2_sel1_signed_1 => \c$arg_1\ );
-- register begin
acc_register : process(clk,rst)
begin
if rst = '1' then
acc <= to_signed(0,64);
elsif rising_edge(clk) then
if en then
acc <= ((x_0 + y_0));
end if;
end if;
end process;
-- register end
x <= \c$arg\.tup2_sel0_signed_0;
y <= \c$arg\.tup2_sel1_signed_1;
x_0 <= acc;
y_0_projection <= (resize(x_1 * y_1,64));
y_0 <= y_0_projection;
x_1 <= x;
y_1 <= y;
result <= acc;
end;