implement #[hdl] [a; N] -- an array repeat expression

This commit is contained in:
Jacob Lifshay 2024-07-16 17:19:17 -07:00
parent d610858144
commit c2e5ea8e89
Signed by: programmerjake
SSH key fingerprint: SHA256:B1iRVvUJkvd7upMIiMqn6OyxvD2SgJkAH3ZnUOj6z+c
4 changed files with 51 additions and 2 deletions

View file

@ -138,6 +138,41 @@ circuit my_module:
};
}
#[hdl_module(outline_generated)]
pub fn check_array_repeat() {
#[hdl]
let i: UInt<8> = m.input();
#[hdl]
let o: Array<[UInt<8>; 3]> = m.output();
m.connect(
o,
#[hdl]
[i; 3],
);
}
#[test]
fn test_array_repeat() {
let _n = SourceLocation::normalize_files_for_tests();
let m = check_array_repeat();
dbg!(m);
#[rustfmt::skip] // work around https://github.com/rust-lang/rustfmt/issues/6161
assert_export_firrtl! {
m =>
"/test/check_array_repeat.fir": r"FIRRTL version 3.2.0
circuit check_array_repeat:
module check_array_repeat: @[module-XXXXXXXXXX.rs 1:1]
input i: UInt<8> @[module-XXXXXXXXXX.rs 2:1]
output o: UInt<8>[3] @[module-XXXXXXXXXX.rs 3:1]
wire _array_literal_expr: UInt<8>[3]
connect _array_literal_expr[0], i
connect _array_literal_expr[1], i
connect _array_literal_expr[2], i
connect o, _array_literal_expr @[module-XXXXXXXXXX.rs 4:1]
",
};
}
#[hdl_module(outline_generated)]
pub fn check_partially_written() {
#[hdl]