-
Notifications
You must be signed in to change notification settings - Fork 147
/
Clash_Sized_Internal_Index.primitives
171 lines (171 loc) · 5.72 KB
/
Clash_Sized_Internal_Index.primitives
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
[ { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.pack#"
, "workInfo" : "Never"
, "kind" : "Expression"
, "type" : "pack# :: Index n -> BitVector (CLog 2 n)"
, "template" : "std_logic_vector(~ARG[0])"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.unpack#"
, "workInfo" : "Never"
, "kind" : "Expression"
, "type" : "unpack# :: (KnownNat n, 1 <= n) => BitVector (CLog 2 n) -> Index n"
, "template" : "unsigned(~ARG[2])"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.eq#"
, "kind" : "Expression"
, "type" : "eq# :: Index n -> Index n -> Bool"
, "template" : "~IF~SIZE[~TYP[0]]~THEN~ARG[0] = ~ARG[1]~ELSEtrue~FI"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.neq#"
, "kind" : "Expression"
, "type" : "neq# :: Index n -> Index n -> Bool"
, "template" : "~IF~SIZE[~TYP[0]]~THEN~ARG[0] /= ~ARG[1]~ELSEfalse~FI"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.lt#"
, "kind" : "Expression"
, "type" : "lt# :: Index n -> Index n -> Bool"
, "template" : "~IF~SIZE[~TYP[0]]~THEN~ARG[0] < ~ARG[1]~ELSEfalse~FI"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.ge#"
, "kind" : "Expression"
, "type" : "ge# :: Index n -> Index n -> Bool"
, "template" : "~IF~SIZE[~TYP[0]]~THEN~ARG[0] >= ~ARG[1]~ELSEtrue~FI"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.gt#"
, "kind" : "Expression"
, "type" : "gt# :: Index n -> Index n -> Bool"
, "template" : "~IF~SIZE[~TYP[0]]~THEN~ARG[0] > ~ARG[1]~ELSEfalse~FI"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.le#"
, "kind" : "Expression"
, "type" : "le# :: Index n -> Index n -> Bool"
, "template" : "~IF~SIZE[~TYP[0]]~THEN~ARG[0] <= ~ARG[1]~ELSEtrue~FI"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.maxBound#"
, "workInfo" : "Constant"
, "kind" : "Expression"
, "type" : "maxBound# :: KnownNat n => Index n"
, "template" : "to_unsigned(~LIT[0]-1,~SIZE[~TYPO])"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.toEnum#"
, "workInfo" : "Never"
, "kind" : "Expression"
, "type" : "toEnum# :: KnownNat n => Int -> Index n"
, "template" : "resize(unsigned(std_logic_vector(~ARG[1])),~SIZE[~TYPO])"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.fromEnum#"
, "workInfo" : "Never"
, "kind" : "Expression"
, "type" : "fromEnum# :: KnownNat n => Index n -> Int"
, "template" : "~IF~SIZE[~TYP[1]]~THENsigned(std_logic_vector(resize(~ARG[1],~SIZE[~TYPO])))~ELSEto_signed(0,~SIZE[~TYPO])~FI"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.+#"
, "kind" : "Expression"
, "type" : "(+#) :: KnownNat n => Index n -> Index n -> Index n"
, "template" : "~ARG[1] + ~ARG[2]"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.-#"
, "kind" : "Expression"
, "type" : "(-#) :: KnownNat n => Index n -> Index n -> Index n"
, "template" : "~ARG[1] - ~ARG[2]"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.*#"
, "kind" : "Expression"
, "type" : "(*#) :: KnownNat n => Index n -> Index n -> Index n"
, "template" : "resize(~ARG[1] * ~ARG[2], ~SIZE[~TYPO])"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.fromInteger#"
, "workInfo" : "Never"
, "kind" : "Expression"
, "type" : "fromInteger# :: KnownNat n => Integer -> Index n"
, "template" : "resize(unsigned(std_logic_vector(~ARG[1])),~SIZE[~TYPO])"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.plus#"
, "kind" : "Expression"
, "type" : "Index m -> Index n -> Index (m + n - 1)"
, "template" : "resize(~ARG[0],~SIZE[~TYPO]) + resize(~ARG[1],~SIZE[~TYPO])"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.minus#"
, "kind" : "Expression"
, "type" : "Index m -> Index n -> Index (m + n - 1)"
, "template" : "resize(~ARG[0],~SIZE[~TYPO]) - resize(~ARG[1],~SIZE[~TYPO])"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.times#"
, "kind" : "Expression"
, "type" : "Index m -> Index n -> Index (((m-1) * (n-1)) + 1)"
, "template" : "resize(~ARG[0] * ~ARG[1],~SIZE[~TYPO])"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.rem#"
, "kind" : "Declaration"
, "type" : "rem# :: Index n -> Index n -> Index n"
, "template" :
"~RESULT <= ~ARG[0] rem ~ARG[1]
-- pragma translate_off
when (~ARG[1] /= 0) else (others => 'X')
-- pragma translate_on
;"
}
}
, { "BlackBoxHaskell" :
{ "name" : "Clash.Sized.Internal.Index.toInteger#"
, "workInfo" : "Never"
, "templateFunction" : "Clash.Primitives.Sized.ToInteger.indexToIntegerVHDL"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.resize#"
, "workInfo" : "Never"
, "kind" : "Expression"
, "type" : "resize# :: KnownNat m => Index n -> Index m"
, "template" : "~IF~SIZE[~TYP[1]]~THENresize(~ARG[1],~SIZE[~TYPO])~ELSEunsigned'(~SIZE[~TYPO]-1 downto 0 => '0')~FI"
}
}
, { "BlackBox" :
{ "name" : "Clash.Sized.Internal.Index.quot#"
, "kind" : "Declaration"
, "type" : "quot# :: Index n -> Index n -> Index n"
, "template" :
"~RESULT <= ~ARG[0] / ~ARG[1]
-- pragma translate_off
when (~ARG[1] /= 0) else (others => 'X')
-- pragma translate_on
;"
}
}
]