Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# While using flakes, bazel might pickup the sources used
# as flake input stored in direnv and lead to a broken build.
.direnv
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ It has been tested with the Artix-7 [counter example][counter-example], where it

## Usage

First, install [Bazel][bazel] and ensure you have a basic C/C++ toolchain set up. Then run:
First, install [Bazel][bazel] and ensure you have a basic C/C++ toolchain set up.

> [!NOTE]
> If you are using Nix or NixOS, ensure you have [flakes enabled][enable-flakes] and enter the development shell via `nix develop`.

Then run:

```
bazel run -c opt //fpga:fpga-as -- --prjxray_db_path=/some/path/prjxray-db/artix7 --part=xc7a35tcsg324-1 < /some/path.fasm > output.bit
Expand Down Expand Up @@ -66,3 +71,4 @@ Using this metadata, you can search the segbits database for the specific featur
[bazel]: https://bazel.build/
[counter-example]: https://github.com/chipsalliance/f4pga-examples/blob/13f11197b33dae1cde3bf146f317d63f0134eacf/xc7/counter_test/counter.v
[open-fpga-loader]: https://github.com/trabucayre/openFPGALoader
[enable-flakes]: https://nixos.wiki/wiki/Flakes#Enable_flakes_permanently_in_NixOS
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
description = "fpga-assembler";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd probably fix that to a commit or 24.11 so that we don't create a new flake derivation every day nixos-unstable changes.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I studied a bit more flakes, as long as the flake.lock doesn't get updated, the channel is pinned.

"rev": "2c8d3f48d33929642c1c12cd243df4cc7d2ce434",

Copy link
Collaborator

Choose a reason for hiding this comment

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

I prefer to be explicit.
The lock file is a non-human readable format to be explicit.
So we should put the version in the flake.nix to be human readably explicit.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Upsie! I'll make a commit that adds a specific revision then!

flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
in {
devShells.default =
let
bazel = pkgs.bazel_7;

# There is too much volatility between even micro-versions of
# newer clang-format. Use slightly older version for now.
clang_for_formatting = pkgs.llvmPackages_17.clang-tools;

# clang tidy: use latest.
clang_for_tidy = pkgs.llvmPackages_18.clang-tools;
in with pkgs; pkgs.mkShell{
packages = with pkgs; [
git
bazel
jdk
bash
gdb

# For clang-tidy and clang-format.
clang_for_formatting
clang_for_tidy

# For buildifier, buildozer.
bazel-buildtools
bant

# Profiling and sanitizers.
linuxPackages_latest.perf
pprof
perf_data_converter
valgrind

# FPGA utils.
openfpgaloader
];

CLANG_TIDY="${clang_for_tidy}/bin/clang-tidy";
CLANG_FORMAT="${clang_for_formatting}/bin/clang-format";
};
}
);
}
41 changes: 0 additions & 41 deletions shell.nix

This file was deleted.