From 61b91e0688815bbe1d9c834ccd3372e8ca8b2262 Mon Sep 17 00:00:00 2001 From: SikongJueluo Date: Mon, 9 Sep 2024 21:35:00 +0800 Subject: [PATCH] use Nix devenv to manage project environment --- .envrc | 3 + .gitignore | 11 ++- Color/SaturationCorrection.sv | 4 +- devenv.lock | 122 ++++++++++++++++++++++++++++++++++ devenv.nix | 59 ++++++++++++++++ devenv.yaml | 15 +++++ 6 files changed, 211 insertions(+), 3 deletions(-) create mode 100644 .envrc mode change 100644 => 100755 .gitignore mode change 100644 => 100755 Color/SaturationCorrection.sv create mode 100644 devenv.lock create mode 100644 devenv.nix create mode 100644 devenv.yaml diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..5bf8fc1 --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +source_url "https://raw.githubusercontent.com/cachix/devenv/95f329d49a8a5289d31e0982652f7058a189bfca/direnvrc" "sha256-d+8cBpDfDBj41inrADaJt+bDWhOktwslgoP5YiGJ1v0=" + +use devenv \ No newline at end of file diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 3ed462e..0028e69 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea/ .vscode/ +.devenv/ /CFA/sim/work/** *.wlf *.mpf @@ -13,4 +14,12 @@ *.png !im.tif *.bmp -*.out \ No newline at end of file +*.out# Devenv +.devenv* +devenv.local.nix + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml diff --git a/Color/SaturationCorrection.sv b/Color/SaturationCorrection.sv old mode 100644 new mode 100755 index 7eedf67..8c07319 --- a/Color/SaturationCorrection.sv +++ b/Color/SaturationCorrection.sv @@ -116,8 +116,8 @@ module SaturationCorrection #( calState <= 3; end else if (calState == 3) begin - alpha <= (saturation_inc[31] == 0) ? ((saturation_inc + saturation >= 256) - ? (65536 / saturation) - 256 : (65536 / (256 - saturation_inc)) - 256) + alpha <= (saturation_inc[31] == 0) ? ((saturation_inc + saturation >= 255) + ? (65536 / saturation) - 255 : (65536 / (256 - saturation_inc)) - 255) : (saturation_inc); calState <= 4; diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 0000000..ad4acbd --- /dev/null +++ b/devenv.lock @@ -0,0 +1,122 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1725637114, + "owner": "cachix", + "repo": "devenv", + "rev": "c31e347a96dbb7718a0279afa993752a7dfc6a39", + "treeHash": "e0dfcbbfb0974603336900406b364bd4d1308fa4", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "treeHash": "2addb7b71a20a25ea74feeaf5c2f6a6b30898ecb", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "treeHash": "ca14199cabdfe1a06a7b1654c76ed49100a689f9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1716977621, + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "4267e705586473d3e5c8d50299e71503f16a6fb6", + "treeHash": "6d9f1f7ca0faf1bc2eeb397c78a49623260d3412", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1725693463, + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "68e7dce0a6532e876980764167ad158174402c6f", + "treeHash": "ee872ee4d2426a6c3e1e4b3fa844550ce1b52b29", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1725513492, + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "7570de7b9b504cfe92025dd1be797bf546f66528", + "treeHash": "4b46d77870afecd8f642541cb4f4927326343b59", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000..f5e8f65 --- /dev/null +++ b/devenv.nix @@ -0,0 +1,59 @@ +{ pkgs, lib, config, inputs, ... }: + +{ + # https://devenv.sh/basics/ + env.GREET = "devenv"; + + # https://devenv.sh/packages/ + packages = with pkgs; [ + git + verilator + systemc + verible + svls + gtkwave + ]; + + # https://devenv.sh/languages/ + languages.rust.enable = true; + languages.c.enable = true; + languages.cplusplus.enable = true; + + # https://devenv.sh/processes/ + # processes.cargo-watch.exec = "cargo-watch"; + + # https://devenv.sh/services/ + # services.postgres.enable = true; + + # https://devenv.sh/scripts/ + scripts.addEnv.exec = '' + export SYSTEMC_INCLUDE="${pkgs.systemc}/include" + echo $SYSTEMC_INCLUDE + export SYSTEMC_LIBDIR="${pkgs.systemc}/lib" + echo $SYSTEMC_LIBDIR + ''; + + enterShell = '' + addEnv + echo + + git --version + echo + + verilator --version + echo + + gcc --version + ''; + + # https://devenv.sh/tests/ + enterTest = '' + echo "Running tests" + git --version | grep --color=auto "${pkgs.git.version}" + ''; + + # https://devenv.sh/pre-commit-hooks/ + # pre-commit.hooks.shellcheck.enable = true; + + # See full reference at https://devenv.sh/reference/options/ +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000..116a2ad --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,15 @@ +# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json +inputs: + nixpkgs: + url: github:cachix/devenv-nixpkgs/rolling + +# If you're using non-OSS software, you can set allowUnfree to true. +# allowUnfree: true + +# If you're willing to use a package that's vulnerable +# permittedInsecurePackages: +# - "openssl-1.1.1w" + +# If you have more than one devenv you can merge them +#imports: +# - ./backend