Describe the bug
DSLX has a system where you can use configured_value_or<ty>("ident", default_value) to create build-time set constants similar to rusts cfg! or -D macros in C/C++. These values are set using either the configured_values option on build targets that create verilog/xls-ir or with the --configured_values flag on ir_convert.
With the way that these values are propagated right now however only flags in files directly in the srcs build attribute of the ir/verilog target, or in the list of the cmdline have their value set. All other uses of configured_value_or in imported files have their default value, even if the same value is used in the 'top' files.
This behavior is very surprising and is done entirely silently.
To Reproduce
library.x
pub fn foo() -> u32 {
configured_value_or<u32>("foo", u32:0)
}
main.x
import library;
fn main() -> (u32, u32) {
(library::foo(), configured_value_or<u32>("foo", u32:0))
}
BUILD
dslx_library(
name = "lib",
srcs = ["library.x"]
)
xls_dslx_opt_ir(
name = "foo_is_42",
srcs = ["main.x"],
dslx_top = "main",
deps = [":lib"],
configured_values = {"foo": "u32:42"},
)
xls_dslx_opt_ir(
name = "foo_is_0",
srcs = ["main.x"],
dslx_top = "main",
deps = [":lib"],
)
Looking at the IR
foo_is_42 returns (0, 42)
foo_is_0 returns (0, 0)
Expected behavior
either:
- foo_is_42 returns
(42, 42)
or
- have a way to set configured_values on the dslx_library too so you can do
BUILD
dslx_library(
name = "lib",
srcs = ["library.x"]
)
dslx_library(
name = "lib_is_42",
srcs = ["library.x"],
configured_values = {"foo", "u32:42"},
)
xls_dslx_opt_ir(
name = "foo_is_42",
srcs = ["main.x"],
dslx_top = "main",
deps = [":lib_is_42"],
configured_values = {"foo": "u32:42"},
)
xls_dslx_opt_ir(
name = "foo_is_0",
srcs = ["main.x"],
dslx_top = "main",
deps = [":lib"],
)
#4985 is an implementation of (1) though there were some objections that having the config values be globally scoped like that is undesirable.
Describe the bug
DSLX has a system where you can use
configured_value_or<ty>("ident", default_value)to create build-time set constants similar to rustscfg!or -D macros in C/C++. These values are set using either theconfigured_valuesoption on build targets that create verilog/xls-ir or with the--configured_valuesflag on ir_convert.With the way that these values are propagated right now however only flags in files directly in the
srcsbuild attribute of the ir/verilog target, or in the list of the cmdline have their value set. All other uses ofconfigured_value_orin imported files have their default value, even if the same value is used in the 'top' files.This behavior is very surprising and is done entirely silently.
To Reproduce
library.x
main.x
BUILD
Looking at the IR
foo_is_42 returns
(0, 42)foo_is_0 returns (0, 0)
Expected behavior
either:
(42, 42)or
BUILD
#4985 is an implementation of (1) though there were some objections that having the config values be globally scoped like that is undesirable.