Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull in Sonata fixes #74

Merged
merged 4 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
106 changes: 55 additions & 51 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,19 @@
extra-trusted-public-keys = ["nix-cache.lowrisc.org-public-1:O6JLD0yXzaJDPiQW1meVu32JIDViuaPtGDfjlOopU7o="];
};

outputs = inputs@{self, ...}:
let

# System types to support.
supportedSystems = with inputs.flake-utils.lib.system; [
x86_64-linux
];

# The .#formal shellHook always checks for jg on the path.
# Should we check for a given version of the tool as well?
check_jg_version = false;
expected_jaspergold_version = "2021.12 FCS 64 bits";

in inputs.flake-utils.lib.eachSystem supportedSystems (system:
let

outputs = inputs @ {self, ...}: let
# System types to support.
supportedSystems = with inputs.flake-utils.lib.system; [
x86_64-linux
];

# The .#formal shellHook always checks for jg on the path.
# Should we check for a given version of the tool as well?
check_jg_version = false;
expected_jaspergold_version = "2021.12 FCS 64 bits";
in
inputs.flake-utils.lib.eachSystem supportedSystems (
system: let
pkgs = import inputs.nixpkgs {
inherit system;
};
Expand All @@ -72,10 +69,12 @@
};

# RISCV Sail model with changes for Ibex
lowrisc_cheriot_sail.src = (import ./nix/lowrisc_cheriot_sail.nix {
inherit pkgs;
src = inputs.lowrisc_cheriot_sail;
}).src;
lowrisc_cheriot_sail.src =
(import ./nix/lowrisc_cheriot_sail.nix {
inherit pkgs;
src = inputs.lowrisc_cheriot_sail;
})
.src;

# Create a python package set suitable for the formal flow
# - The file dv/formal/pyproject.toml defines the package set for this environment
Expand All @@ -93,33 +92,36 @@
poetry2nix.defaultPoetryOverrides
];
};

in {
packages = {
# Export the package for the lowrisc fork of the sail compiler. This allows us
# to re-use its build environment.
inherit lowrisc_sail;
};
devShells = rec {
formal = mkshell-minimal {
packages = [
in {
packages = {
# Export the package for the lowrisc fork of the sail compiler. This allows us
# to re-use its build environment.
inherit lowrisc_sail;
};
devShells = rec {
formal = mkshell-minimal {
packages =
[
inputs.psgen.packages.${system}.default
lowrisc_sail
formal_python_env
] ++ (with pkgs; [
]
++ (with pkgs; [
gnumake
patch
]);
shellHook = let
# The formal environment has an untracked external requirement on Cadence JasperGold.
# Add a check here which will prevent launching the devShell if JasperGold is not found on the user's path.
# TODO: Is this robust? Do we want to check available features?
check_jg = ''
shellHook = let
# The formal environment has an untracked external requirement on Cadence JasperGold.
# Add a check here which will prevent launching the devShell if JasperGold is not found on the user's path.
# TODO: Is this robust? Do we want to check available features?
check_jg =
''
if ! command -v jg &>/dev/null; then
echo "JasperGold not found on path. Not launching devShell."
exit 1
fi
'' + lib.optionalString check_jg_version ''
''
+ lib.optionalString check_jg_version ''
jg_version=$(jg -version -allow_unsupported_OS)
if [[ $jg_version != "${expected_jaspergold_version}" ]]; then
echo "Incorrect JasperGold version found on path."
Expand All @@ -128,18 +130,20 @@
exit 1
fi
'';
in ''
${check_jg}
# The following environment variables are used by the formal build scripts to pick up the locations
# of the external source-file dependencies.
# The can be re-exported manually for development (see .#formal-dev)
export LOWRISC_SAIL_SRC=${lowrisc_sail.src}
export LOWRISC_CHERIOT_SAIL_SRC=${lowrisc_cheriot_sail.src}
'';
};
in ''
${check_jg}
# The following environment variables are used by the formal build scripts to pick up the locations
# of the external source-file dependencies.
# The can be re-exported manually for development (see .#formal-dev)
export LOWRISC_SAIL_SRC=${lowrisc_sail.src}
export LOWRISC_CHERIOT_SAIL_SRC=${lowrisc_cheriot_sail.src}
'';
};

formal-dev = formal.overrideAttrs (prev: {
shellHook = prev.shellHook + ''
formal-dev = formal.overrideAttrs (prev: {
shellHook =
prev.shellHook
+ ''
cat << EOF
======================================================================================
This is a development shell, by default it is identical to the full formal shell.
Expand All @@ -152,8 +156,8 @@
======================================================================================
EOF
'';
});
};
}
});
};
}
);
}
5 changes: 1 addition & 4 deletions nix/lowrisc_cheriot_sail.nix
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

# CHERIoT Sail model with changes for Ibex
{
pkgs,
src,
}:

pkgs.sail-riscv-rv32.overrideAttrs {
pname = "lowrisc_cheriot_sail";
inherit src;

# The upstream patches does not apply to our older version of riscv_sail.
patches = [ ];
patches = [];
}

8 changes: 4 additions & 4 deletions nix/lowrisc_sail.nix
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

# Override the upstream sail package definition to use the lowRISC fork
{
pkgs,
src,
}:

pkgs.ocamlPackages.sail.overrideAttrs (prev: {
pname = "lowrisc_sail";
inherit src;

# The lowRISC fork is older than upstream, and requires additional dependencies
# from those specified upsteam to build. Add them here.
propagatedBuildInputs =
prev.propagatedBuildInputs ++ (with pkgs.ocamlPackages; [
prev.propagatedBuildInputs
++ (with pkgs.ocamlPackages; [
menhirLib
]) ++ (with pkgs; [
])
++ (with pkgs; [
z3
]);
})
1 change: 1 addition & 0 deletions python-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ git+https://github.com/lowRISC/edalize.git@ot
# Development version with OT-specific changes
git+https://github.com/lowRISC/fusesoc.git@ot

packaging
pyyaml
mako
junit-xml
Expand Down
2 changes: 1 addition & 1 deletion rtl/cheri_ex.sv
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ module cheri_ex import cheri_pkg::*; #(
unique case (1'b1)
cheri_operator_i[CGET_PERM]:
begin
result_data_o = {19'h0, rf_fullcap_a.perms};
result_data_o = {20'h0, rf_fullcap_a.perms};
result_cap_o = NULL_REG_CAP; // zerout the cap msw
cheri_rf_we_raw = 1'b1;
cheri_ex_valid_raw = 1'b1;
Expand Down
2 changes: 1 addition & 1 deletion rtl/cheri_trvk_stage.sv
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module cheri_trvk_stage #(
logic [2:1] range_ok_q;


assign base32 = get_bound33(in_cap_q.base, {2{in_cap_q.base_cor}}, in_cap_q.exp, in_data_q);
assign base32 = 32'(get_bound33(in_cap_q.base, {2{in_cap_q.base_cor}}, in_cap_q.exp, in_data_q));
assign tsmap_ptr = (base32 - HeapBase) >> 3;

assign tsmap_addr_o = tsmap_ptr[15:5];
Expand Down
2 changes: 1 addition & 1 deletion rtl/ibexc_top.sv
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ module ibex_top import ibex_pkg::*; import cheri_pkg::*; #(
.MHPMCounterWidth (MHPMCounterWidth),
.RV32E (RV32E),
.RV32M (RV32M),
.RV32B (RV32BNone),
.RV32B (RV32B),
.BranchTargetALU (1'b1),
.ICache (1'b0),
.ICacheECC (1'b0),
Expand Down
3 changes: 2 additions & 1 deletion rtl/ibexc_top_tracing.sv
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module ibex_top_tracing import ibex_pkg::*; import cheri_pkg::*; #(
parameter int unsigned DmHaltAddr = 32'h1A110800,
parameter int unsigned DmExceptionAddr = 32'h1A110808,
parameter bit RV32E = 1'b0,
parameter rv32b_e RV32B = RV32BNone,
parameter bit CheriTBRE = 1'b1,
parameter bit CheriStkZ = 1'b1,
parameter int unsigned HeapBase = 32'h2001_0000,
Expand Down Expand Up @@ -147,7 +148,7 @@ module ibex_top_tracing import ibex_pkg::*; import cheri_pkg::*; #(
.DbgTriggerEn (1'b1),
.DbgHwBreakNum (4),
.RV32E (RV32E),
.RV32B (RV32BFull),
.RV32B (RV32B),
.WritebackStage (1'b1),
.BranchPredictor (1'b0),
.CHERIoTEn (1'b1),
Expand Down
19 changes: 10 additions & 9 deletions util/check_tool_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
# SPDX-License-Identifier: Apache-2.0

import argparse
from distutils.version import StrictVersion
from importlib.metadata import version
import logging as log
import os
from packaging.version import Version
import re
import shlex
import subprocess
Expand Down Expand Up @@ -156,7 +157,7 @@ def check(self):
'Failed to convert requirement to semantic version: {}'
.format(err))
try:
min_sv = StrictVersion(min_semver)
min_sv = Version(min_semver)
except ValueError as err:
return (False,
'Bad semver inferred from required version ({}): {}'
Expand All @@ -174,7 +175,7 @@ def check(self):
'Failed to convert installed to semantic version: {}'
.format(err))
try:
actual_sv = StrictVersion(actual_semver)
actual_sv = Version(actual_semver)
except ValueError as err:
return (False,
'Bad semver inferred from installed version ({}): {}'
Expand Down Expand Up @@ -213,7 +214,7 @@ class VeribleToolReq(ToolReq):

def to_semver(self, version, from_req):
# Drop the hash suffix and convert into version string that
# is compatible with StrictVersion in check_version below.
# is compatible with Version in check_version below.
# Example: v0.0-808-g1e17daa -> 0.0.808
m = re.fullmatch(r'v([0-9]+)\.([0-9]+)-([0-9]+)-g[0-9a-f]+$', version)
if m is None:
Expand All @@ -238,7 +239,7 @@ def to_semver(self, version, from_req):
# already. A version always has the "2020.03" (year and month) part,
# and may also have an -SP<n> and/or -<patch> suffix.
#
# Since StrictVersion expects a 3 digit versioning scheme, we multiply
# Since Version expects a 3 digit versioning scheme, we multiply
# any SP number by 100, which should work as long as the patch version
# isn't greater than 99.
#
Expand All @@ -262,11 +263,11 @@ def to_semver(self, version, from_req):

class PyModuleToolReq(ToolReq):
'''A tool in a Python module (its version can be found by running pip)'''
version_regex = re.compile(r'Version: (.*)')

def _get_tool_cmd(self):
return ['pip3', 'show', self.tool]

# For Python modules, use metadata directly instead of call into pip3, which
# may not always be available for some systems.
def get_version(self):
return version(self.tool)

def dict_to_tool_req(path, tool, raw):
'''Parse a dict (as read from Python) as a ToolReq
Expand Down