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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
reg r: UInt(16)
=>
reg r: UInt(16)
wire r_init : UInt(16)
r_init := NULL
when reset :
r := r_init
===============
reg r: UInt(16)
r.init := UInt(0)
=>
reg r: UInt(16)
wire r_init : UInt(16)
r_init := NULL
r_init := UInt(0)
when reset :
r := r_init
=>
reg r: UInt(16)
wire r_init2 : UInt(16)
r_init2 := NULL
wire r_init : UInt(16)
r_init := NULL
r_init := UInt(0)
when reset :
r := r_init
when reset :
r := r_init2
======
We continue to simplify from the previous example. Here's the input we had (but with the incorrect lines removed).
reg r: UInt(16)
wire r_init2 : UInt(16)
r_init2 := NULL
wire r_init : UInt(16)
r_init := NULL
r_init := UInt(0)
when reset :
r := r_init
when reset :
r := r_init2
One of the following passes will turn wires into nodes, by scanning to see what they are connected to.
reg r: UInt(16)
node r_init2 = NULL
node r_init = UInt(0)
when reset :
r := r_init
when reset :
r := r_init2
Another pass will compute the final value connected to the register, expressed as a bunch of muxes. The default value for a register is set to itself.
node r_init2 = NULL
node r_init = UInt(0)
reg r:UInt(16) = Mux(reset, r_init2, Mux(reset, r_init, r))
Next we inline all the nodes with NULL in them, to arrive at the final expression for the register.
reg r:UInt(16) = Mux(reset, NULL, Mux(reset, r_init, r))
NULL's do nothing, so any expression of the form Mux(a, NULL, b) can be simplified to b. Arriving finally at:
reg r:UInt(16) = Mux(reset, r_init, r)
which is what we wanted.
|