-
Notifications
You must be signed in to change notification settings - Fork 31
/
PipeTester.fir
51 lines (40 loc) · 1.21 KB
/
PipeTester.fir
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
circuit PipeTester :
; This module should simply delay a signal by 2 cycles
; Internal registers reset to 0
module Pipe :
input clock : Clock
input reset : UInt<1>
input in : UInt<4>
output out : UInt<4>
;reg r : UInt<4>, clock with : (reset => (reset, UInt(0)))
;r <= in
; This is equivalent to the above
reg r : UInt<4>, clock
r <= mux(reset, UInt(0), in)
reg s : UInt<4>, clock with : (reset => (reset, UInt(0)))
s <= r
out <= s
module PipeTester :
input clock : Clock
input reset : UInt<1>
inst pipe of Pipe
pipe.clock <= clock
pipe.reset <= reset
pipe.in <= UInt(3)
reg cycle : UInt<4>, clock with : (reset => (reset, UInt<4>(0)))
cycle <= tail(add(cycle, UInt(1)), 1)
wire fail : UInt<1>
fail <= UInt(0)
when fail :
printf(clock, not(reset), "Assertion failed!\n")
stop(clock, not(reset), 1)
when not(reset) :
when lt(cycle, UInt(2)) :
when neq(pipe.out, UInt(0)) :
fail <= UInt(1)
when eq(cycle, UInt(2)) :
when neq(pipe.out, UInt(3)) :
fail <= UInt(1)
when eq(cycle, UInt(3)) :
printf(clock, UInt(1), "Success!\n")
stop(clock, UInt(1), 0)