Skip to content

Commit b411d7d

Browse files
authored
setup nix flake (poorly) (#40)
* mct * lift clash sources to root * update nix * ragequit nix * non-cabal nix works * base flake, downgrade clash 1.8.1, new ci * devShell -> devShells * retry ci * fixed fr * add clash-ghc * get ci off nix * cabal bs * remove --enable-tests * move cd * remove haskell ci
1 parent 7e6fc37 commit b411d7d

File tree

26 files changed

+356
-389
lines changed

26 files changed

+356
-389
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
2121
- name: Run Simulation
2222
run: |
23-
cd hdl/sv/moving_average_accumulator
23+
cd cores/moving_average_accumulator
2424
make test
2525
2626

cores/pipelined_order_book/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!-- omit in toc -->
2+
# Simple Nix Starter Project
3+
This starter project contains the scaffolding needed to integrate Clash with the Nix Stack build system. Read [Simple Starter Project](https://github.com/clash-lang/clash-starters/blob/main/simple/README.md) for more information on the various files.
4+
5+
<!-- omit in toc -->
6+
# Table of Contents
7+
- [Getting this project](#getting-this-project)
8+
- [Building and testing this project](#building-and-testing-this-project)
9+
- [REPL](#repl)
10+
- [Adding custom dependencies / updating nix](#adding-custom-dependencies--updating-nix)
11+
12+
# Getting this project
13+
Run `nix-shell --packages stack --run "stack new my-clash-project clash-lang/simple-nix"`.
14+
15+
# Building and testing this project
16+
Build the project with:
17+
18+
```bash
19+
nix-build
20+
```
21+
22+
Verilog code will be available under the `result/share/verilog` directory.
23+
Modify the `hdl` variable in `default.nix` to configure whether to generate
24+
SystemVerilog or VHDL.
25+
26+
However development itself is more streamlined by using a Nix shell. Start one
27+
by invoking:
28+
29+
```
30+
nix-shell
31+
```
32+
33+
Then, to run the tests defined in `tests/`:
34+
35+
```bash
36+
cabal run test-library
37+
cabal run doctests
38+
```
39+
40+
To compile the project to VHDL run:
41+
42+
```bash
43+
cabal run clash -- Example.Project --vhdl
44+
```
45+
46+
You can find the HDL files in `vhdl/`. The source can be found in `src/Example/Project.hs`.
47+
48+
# REPL
49+
Clash offers a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) as a quick way to try things, similar to Python's `python` or Ruby's `irb`. Open the REPL by invoking:
50+
51+
```
52+
cabal run clashi
53+
```
54+
55+
# Adding custom dependencies / updating nix
56+
`niv` is available after opening `nix-shell`. See [niv on Hackage](https://hackage.haskell.org/package/niv) for more information.

hdl/haskell/src/cabal.project renamed to cores/pipelined_order_book/cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
packages:
2-
punt-engine-haskell-cores.cabal
2+
pipelined-order-book.cabal
33

44
write-ghc-environment-files: always
55

cores/pipelined_order_book/hie.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cradle:
2+
cabal:
3+
- path: "./src"
4+
component: "lib:pipelined-order-book"
5+
- path: "./tests/doctests.hs"
6+
component: "pipelined-order-book:doctests"
7+
- path: "./tests"
8+
component: "pipelined-order-book:test-library"
9+
- path: "./bin/Clashi.hs"
10+
component: "pipelined-order-book:exe:clashi"
11+
- path: "./bin/Clash.hs"
12+
component: "pipelined-order-book:exe:clash"

hdl/haskell/src/punt-engine-haskell-cores.cabal renamed to cores/pipelined_order_book/pipelined-order-book.cabal

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 2.4
2-
name: punt-engine-haskell-cores
2+
name: pipelined-order-book
33
version: 0.1
4-
license: MIT
4+
license: GPL-3.0-only
55
author: Race Williams <[email protected]>
66
maintainer: Race Williams <[email protected]>
77

@@ -75,6 +75,7 @@ common common-options
7575
Cabal,
7676

7777
-- clash-prelude will set suitable version bounds for the plugins
78+
-- TODO: get to work with 1.8.2
7879
clash-prelude >= 1.8.1 && < 1.10,
7980
ghc-typelits-natnormalise,
8081
ghc-typelits-extra,
@@ -85,25 +86,20 @@ library
8586
import: common-options
8687
hs-source-dirs: src
8788
exposed-modules:
88-
FixParser.Top
8989
Example.Project
9090
default-language: Haskell2010
9191

92-
-- Builds the executable 'clash', with punt-engine-haskell-cores project in scope
92+
-- Builds the executable 'clash', with pipelined-order-book project in scope
9393
executable clash
9494
main-is: bin/Clash.hs
9595
default-language: Haskell2010
96-
Build-Depends: base, clash-ghc, punt-engine-haskell-cores
97-
if !os(Windows)
98-
ghc-options: -dynamic
96+
Build-Depends: base, clash-ghc, pipelined-order-book
9997

100-
-- Builds the executable 'clashi', with punt-engine-haskell-cores project in scope
98+
-- Builds the executable 'clashi', with pipelined-order-book project in scope
10199
executable clashi
102100
main-is: bin/Clashi.hs
103101
default-language: Haskell2010
104-
if !os(Windows)
105-
ghc-options: -dynamic
106-
build-depends: base, clash-ghc, punt-engine-haskell-cores
102+
build-depends: base, clash-ghc, pipelined-order-book
107103

108104
test-suite doctests
109105
type: exitcode-stdio-1.0
@@ -113,7 +109,7 @@ test-suite doctests
113109
hs-source-dirs: tests
114110
build-depends:
115111
base,
116-
punt-engine-haskell-cores,
112+
pipelined-order-book,
117113
doctest-parallel >= 0.2 && < 0.4,
118114

119115
test-suite test-library
@@ -126,10 +122,10 @@ test-suite test-library
126122
other-modules:
127123
Tests.Example.Project
128124
build-depends:
129-
punt-engine-haskell-cores,
125+
pipelined-order-book,
130126
QuickCheck,
131127
clash-prelude-hedgehog,
132128
hedgehog,
133-
tasty >= 1.2 && < 1.5,
129+
tasty >= 1.2 && < 1.6,
134130
tasty-hedgehog,
135131
tasty-th

0 commit comments

Comments
 (0)