forked from lowRISC/opentitan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[memutil] Allow use without scrambled memories
The scrambled memory primitive prim_ram_1p_scr includes the header file prim_util_get_scramble_params.svh, which defines and exports (on the SV side) two functions (simutil_get_scramble_key() and simutil_get_scramble_nonce()). These functions are used by scrambled_ecc32_mem_area.[cc|h]. Currently, the file scrambled_ecc32_mem_area.cc is always built as part of the memutil library. However, the functions exported over DPI in prim_util_get_scramble_params.svh are only built if prim_ram_1p_scr is used. None of that really matters in OpenTitan, since prim_ram_1p_scr is used and the DPI exports will always be present (globally). However we also use memutil in Ibex, and there no scrambled memories are used. We therefore have to make sure that scrambled_ecc32_mem_area.cc is not part of the build, which is what this commit does. As part of enabling memutil to be used in Ibex again I also had to make a connected change: sram_ctrl is using prim_ram_1p_scr in DV code, but did not include the build options for scrambled memories in its dvsim configuration. This worked in the past because all memory-related build options (include paths) were always included globally. With that not the case any more after this split we need to explicitly include the scrambled memory include build options. While at it I also refactored the dvsim OTBN configuration to avoid duplicating the build options. Signed-off-by: Philipp Wagner <[email protected]>
- Loading branch information
Showing
9 changed files
with
84 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
CAPI=2: | ||
# Copyright lowRISC contributors. | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: "lowrisc:dv_verilator:memutil_dpi_scrambled" | ||
description: "DPI memory utilities for scrambled memories" | ||
filesets: | ||
files_cpp: | ||
depend: | ||
- lowrisc:dv_verilator:memutil_dpi | ||
- lowrisc:dv:scramble_model | ||
files: | ||
- cpp/scrambled_ecc32_mem_area.cc | ||
- cpp/scrambled_ecc32_mem_area.h: { is_include_file: true } | ||
file_type: cppSource | ||
|
||
targets: | ||
default: | ||
filesets: | ||
- files_cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright lowRISC contributors. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
{ | ||
// Additional build-time options needed to compile C++ sources in | ||
// simulators such as VCS and Xcelium for anything that uses | ||
// memutil_dpi_scrambled. | ||
memutil_dpi_core: "lowrisc:dv_verilator:memutil_dpi:0" | ||
memutil_dpi_src_dir: "{eval_cmd} echo \"{memutil_dpi_core}\" | tr ':' '_'" | ||
|
||
memutil_dpi_scrambled_core: "lowrisc:dv_verilator:memutil_dpi_scrambled:0" | ||
memutil_dpi_scrambled_src_dir: "{eval_cmd} echo \"{memutil_dpi_scrambled_core}\" | tr ':' '_'" | ||
|
||
secded_enc_core: "lowrisc:dv:secded_enc:0" | ||
secded_enc_src_dir: "{eval_cmd} echo \"{secded_enc_core}\" | tr ':' '_'" | ||
|
||
scramble_model_core: "lowrisc:dv:scramble_model:0" | ||
scramble_model_dir: "{eval_cmd} echo \"{scramble_model_core}\" | tr ':' '_'" | ||
|
||
prince_ref_core: "lowrisc:dv:crypto_prince_ref:0.1" | ||
prince_ref_src_dir: "{eval_cmd} echo \"{prince_ref_core}\" | tr ':' '_'" | ||
|
||
|
||
build_modes: [ | ||
{ | ||
name: vcs_memutil_dpi_scrambled_build_opts | ||
build_opts: ["-CFLAGS -I{build_dir}/src/{memutil_dpi_src_dir}/cpp", | ||
"-CFLAGS -I{build_dir}/src/{memutil_dpi_scrambled_src_dir}/cpp", | ||
"-CFLAGS -I{build_dir}/src/{secded_enc_src_dir}", | ||
"-CFLAGS -I{build_dir}/src/{scramble_model_dir}", | ||
"-CFLAGS -I{build_dir}/src/{prince_ref_src_dir}", | ||
"-lelf"] | ||
} | ||
|
||
{ | ||
name: xcelium_memutil_dpi_scrambled_build_opts | ||
build_opts: ["-I{build_dir}/src/{memutil_dpi_src_dir}/cpp", | ||
"-I{build_dir}/src/{memutil_dpi_scrambled_src_dir}/cpp", | ||
"-I{build_dir}/src/{prince_ref_src_dir}", | ||
"-I{build_dir}/src/{scramble_model_dir}", | ||
"-lelf"] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters