@@ -117,7 +117,8 @@ void freg_set_riscv(Engine *E, State *S, uint8_t n, uint64_t data)
117
117
118
118
119
119
120
- Histogram Histogram_AddDist (Histogram hist1 , Histogram hist2 , Histogram histDest ){
120
+ void
121
+ Histogram_AddDist (Histogram * hist1 , Histogram * hist2 , Histogram * histDest ){
121
122
/*
122
123
* Add two distributions, considering overflow
123
124
*/
@@ -132,33 +133,53 @@ Histogram Histogram_AddDist(Histogram hist1, Histogram hist2, Histogram histDest
132
133
// TODO Alexa wrote "just in case" -- why?
133
134
// Presumably this is to say it is our responsibility to initialise
134
135
for (int k = 0 ; k < kNBINS ; k ++ ){
135
- histDest . bins [k ] = 0 ;
136
+ histDest -> bins [k ] = 0 ;
136
137
}
137
138
138
139
// Iterate, adding with overflow
139
140
for (int j = 0 ; j < kNBINS ; j ++ ){
140
141
for (int i = 0 ; i < kNBINS ; i ++ ){
141
142
overflow_wid = i + j ;
143
+ /*printf("overflow_wid = %u\n", overflow_wid);*/
142
144
143
145
if (overflow_wid < kNBINS ){
144
- overflow_hi = histDest .bins [i + j ] + (uint32_t )((uint32_t )hist1 .bins [i ] * hist2 .bins [j ]);
146
+ overflow_hi = histDest -> bins [i + j ] + (uint32_t )((uint32_t )hist1 -> bins [i ] * hist2 -> bins [j ]);
147
+ /*printf("histdestbinsij = %u\n", histDest->bins[i+j]);*/
148
+ /*printf("hist1i = %u\n", hist1->bins[i]);*/
149
+ /*printf("hist2j = %u\n", hist2->bins[j]);*/
150
+ /*printf("overflow_hi = %u\n", overflow_hi);*/
145
151
146
152
if (overflow_hi < 65536 ){
147
- histDest .bins [i + j ] += hist1 .bins [i ] * hist2 .bins [j ];
153
+ /*printf("overflow_hi<65536\n");*/
154
+ histDest -> bins [i + j ] += hist1 -> bins [i ] * hist2 -> bins [j ];
148
155
}
149
156
else {
150
157
// Bin overflow error
151
- // TODO implement (also missing from original implementation)
158
+ // TODO implement (also missing from original implementation -- how to handle?)
159
+ printf ("UNIMPLEMENTED bin overflow error\n" );
152
160
}
153
161
}
154
162
else {
155
163
// Value overflow error
156
- // TODO implement (also missing from original implementation)
164
+ // TODO implement (also missing from original implementation -- how to handle?)
165
+ printf ("UNIMPLEMENTED value overflow error\n" );
157
166
}
158
167
}
159
168
}
160
169
161
- return histDest ;
170
+ // TODO Idea: normalise to same mean frequency?
171
+ /*double meanFreq = Histogram_MeanFrequency(histDest);*/
172
+ /*for (int i = 0; i < kNBINS; i++){*/
173
+ /*histDest->bins[i] /= (meanFreq);*/
174
+ /*}*/
175
+
176
+ // TODO Idea: normalise to same full scale (say, 255?)
177
+ /*for (int i = 0; i < kNBINS; i++){*/
178
+ /*histDest->bins[i] /= ;*/
179
+ /*}*/
180
+
181
+
182
+ return ;
162
183
}
163
184
164
185
void Histogram_LDDist (Histogram * histogram , HistogramBinDatatype * bins ){
@@ -235,7 +256,6 @@ void Histogram_PrettyPrint(Engine *E, State *S, Histogram *histogram){
235
256
normalised [i ] = histogram -> bins [i ] / FULLSCALE ;
236
257
}
237
258
238
- mprint (E , S , nodeinfo , "Printing information for register __TODO__\n" );
239
259
mprint (E , S , nodeinfo , "Histogram mean frequency (mean bin occupation): %.3f\n" , meanFreq );
240
260
mprint (E , S , nodeinfo , "bin | val | graphical representation (scaled rel. to mean freq)\n" );
241
261
mprint (E , S , nodeinfo , "----+-----+----------------------------------------------------\n" );
0 commit comments