aboutsummaryrefslogtreecommitdiff
path: root/src/test/resources/features/CustomTransform.fir
blob: 99cb18003891b9d81c4e33f310ce127096528c2f (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
31
32
33
34
; SPDX-License-Identifier: Apache-2.0
circuit CustomTransform :
  ; Replaced in custom transform by an implementation
  extmodule Delay :
    input clock : Clock
    input reset : UInt<1>
    input a : UInt<32>
    input en : UInt<1>
    output b : UInt<32>

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

    reg cycle : UInt<32>, clock with : (reset => (reset, UInt<32>(0)))
    cycle <= tail(add(cycle, UInt<32>(1)), 1)

    inst delay of Delay
    delay.clock <= clock
    delay.reset <= reset
    delay.a <= UInt(0)
    delay.en <= UInt(0)

    when eq(cycle, UInt(0)) :
      delay.en <= UInt(1)
      delay.a <= UInt("hdeadbeef")
    when eq(cycle, UInt(1)) :
      when neq(delay.b, UInt("hdeadbeef")) :
        printf(clock, UInt(1), "Assertion failed!\n")
        stop(clock, UInt(1), 1)
    when eq(cycle, UInt(2)) :
      printf(clock, UInt(1), "Success!\n")
      stop(clock, UInt(1), 0)