| 12
 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
 
 | #include <iostream>
#include "matrix_mult.h"
 
using namespace std;
 
int main(double c)
{
   mat_a in_mat_a[10] = {1,1,2,3,4,5,6,7,8,9};
   mat_b in_mat_b[10] = {9,8,7,6,5,4,3,2,1,1};
   mat_prod hw_result[10], sw_result[10];
   int error_count = 0;
 
   // Generate the expected result
   // Iterate over the rows of the A matrix
   for(int i = 0; i < 9; i++) {
      for(int j = 0; j < 9; j++) {
         // Iterate over the columns of the B matrix
          int k ;
         sw_result[k] = 0;
         // Do the inner product of a row of A and col of B
         for(int k = 0; k < 9; k++) {
            sw_result[k] = in_mat_a[i] * in_mat_b[j];
         }
      }
   }
 
#ifdef HW_COSIM
   // Run the Vivado HLS matrix multiplier
   matrix_mult(in_mat_a, in_mat_b, hw_result);
#endif
 
   // Print product matrix
   for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; i++) {
#ifdef HW_COSIM
 
         // Check result of HLS vs. expected
         if (hw_result[i][j] != sw_result[i][j]) {
            error_count++;
         }
#else
         cout << sw_result[i][j];
#endif
      }
   }
 
#ifdef HW_COSIM
   if (error_count)
      cout << "TEST FAIL: " << error_count << "Results do not match!" << endl;
   else
      cout << "Test passed!" << endl;
#endif
   return error_count;
}
vector multiplication | 
Partager