//This is the application for part 1 and part 2. //Rename this to main.cc #include #include "system.h" #include "altera_avalon_performance_counter.h" #define H_LENGTH 226 #define X_LENGTH 226 #define LENGTH 226 int h[] = {638,451,45,787,365,138,657,497,451,846,262,473,851,426,1010,938,236,192,629,753,935,200,906,525,499,237,744,279,861,688,238,66,453,351,619,388,914,946,112,869,331,708,219,7,1008,1008,658,840,761,240,246,159,987,452,175,387,408,425,647,687,731,553,430,900,634,997,37,688,882,784,125,998,801,230,666,947,342,553,99,579,582,854,119,283,160,713,179,738,507,867,283,543,477,784,903,138,520,641,87,716,1021,576,750,425,504,578,893,755,760,659,946,781,330,531,244,477,355,357,126,254,126,363,945,73,881,260,561,885,278,179,538,243,737,417,125,491,440,658,925,217,205,125,168,516,794,179,720,918,459,163,133,103,77,576,81,910,456,474,877,633,160,518,534,257,884,662,171,29,436,148,542,40,236,4,370,572,343,229,461,527,515,148,571,923,713,652,383,735,803,539,94,706,128,1019,167,440,527,594,627,562,1019,224,270,464,302,475,762,754,239,739,926,391,642,316,797,416,63,96,111,702,794,575,976,10,16,752}; int x[] = {876,727,355,891,403,270,946,551,151,600,680,575,369,864,680,705,30,420,1006,647,817,603,982,752,884,172,605,991,293,658,463,571,729,499,1014,635,679,702,564,457,693,505,334,889,716,674,699,302,551,175,1021,385,446,49,910,158,611,366,787,217,252,656,261,540,572,902,838,936,165,449,1002,172,705,837,985,615,232,737,585,404,389,199,2,555,858,932,759,415,200,985,470,629,726,298,536,835,881,1013,4,154,270,937,867,708,318,773,656,856,398,976,144,883,961,453,240,479,257,610,500,943,173,615,161,587,30,472,422,525,147,389,568,496,385,332,759,392,235,994,776,584,626,526,758,1008,31,486,8,907,683,773,702,44,824,805,570,492,251,224,50,184,834,911,774,363,418,994,231,486,672,118,408,662,431,528,748,311,386,790,644,791,850,382,199,167,287,123,816,943,32,21,342,678,703,625,82,945,799,183,130,847,523,14,570,471,245,985,568,256,256,39,312,49,718,459,875,71,319,908,359,888,109,493,804,445,324,70}; int testFunction(); int main() { PERF_RESET(PERFORMANCE_COUNTER_0_BASE); PERF_START_MEASURING(PERFORMANCE_COUNTER_0_BASE); int result = 0; result = testFunction(); PERF_STOP_MEASURING(PERFORMANCE_COUNTER_0_BASE); alt_u64 time = 0; time = perf_get_section_time(PERFORMANCE_COUNTER_0_BASE, 1); printf("That was fun, the answer is %d, it took %d cycles\n", result, time); /* Event loop never exits. */ while (1); return 0; } int testFunction(){ int i; int j; int y = 0; PERF_BEGIN(PERFORMANCE_COUNTER_0_BASE,1); for(j = 0; j<1000; j++){ for ( i=0; i < LENGTH; i++) { y = y + h[i]*x[i]; } } PERF_END(PERFORMANCE_COUNTER_0_BASE,1); return y; }