1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// SPDX-License-Identifier: LGPL-3.0-or-later
// See Notices.txt for copyright information
//! # `#[hdl]` Struct/Variant Expressions
//!
//! Note: Structs are also known as [Bundles] when used in Fayalite, the Bundle name comes from [FIRRTL].
//!
//! [Bundles]: crate::bundle::BundleType
//! [FIRRTL]: https://github.com/chipsalliance/firrtl-spec
//!
//! `#[hdl]` can be used on Struct Expressions to construct a value of that
//! struct's type. They can also be used on tuples.
//!
//! ```
//! # use fayalite::prelude::*;
//! #[hdl]
//! pub struct MyStruct {
//! pub a: UInt<8>,
//! pub b: UInt<16>,
//! }
//!
//! #[hdl]
//! pub enum MyEnum {
//! A,
//! B(UInt<32>),
//! }
//!
//! # #[hdl_module]
//! # fn module() {
//! #[hdl]
//! let v: UInt<8> = m.input();
//! #[hdl]
//! let my_struct: MyStruct = wire();
//! connect(
//! my_struct,
//! #[hdl]
//! MyStruct {
//! a: v,
//! b: 1234_hdl_u16,
//! },
//! );
//! #[hdl]
//! let my_enum: MyEnum = wire();
//! connect(
//! my_enum,
//! MyEnum.B(12345678_hdl_u32),
//! );
//! #[hdl]
//! let some_tuple: (UInt<4>, UInt<12>) = wire();
//! connect(
//! some_tuple,
//! #[hdl]
//! (12_hdl_u4, 3421_hdl_u12),
//! );
//! # }
//! ```
use crate*;