aboutsummaryrefslogtreecommitdiff
path: root/src/test/resources/features/NestedSubAccessTester.fir
blob: f81ab25148d94431b2b252123f25ab6ad6c73718 (plain)
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
; SPDX-License-Identifier: Apache-2.0
circuit NestedSubAccessTester :
  module NestedSubAccess :
    input foo : UInt<1>[4]
    input index : UInt<2>
    output out : UInt<4>

    wire vec : UInt<4>[2]
    vec[0] <= UInt(3)
    vec[1] <= UInt(4)

    out <= vec[foo[index]]

  module NestedSubAccessTester :
    input clock : Clock
    input reset : UInt<1>

    inst dut of NestedSubAccess

    dut.foo is invalid
    dut.index <= UInt(2)
    dut.foo[2] <= UInt(1)

    when neq(dut.out, UInt(4)) :
      printf(clock, not(reset), "Assertion failed\nTest Failed!\n")
      stop(clock, not(reset), 1)
    else :
      stop(clock, not(reset), 0)