a matrix multiplier with 2 MAC in parallel, and a sparse matrix vector multiplier based on CSR format
The matrix is instansiated as a 88 matrix A and B with 8 bits signed value, the result C is 18 bit signed value matrix. Here's the result of one channel MAC matrix_multiplier based on three stage pipeline which is , memory access, mac, write back. The address fetching is based on a counter , the code is in file matrix_mux1.v The performace is 514 clock cyclein total , which is 648 mac calculation, with 2 initial pipeline stage delay .
![image](https://private-user-images.githubusercontent.com/58079218/336945909-1971d2ec-0b7d-4dbb-8e43-6918f1c71642.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyMTM5ODMsIm5iZiI6MTcyNTIxMzY4MywicGF0aCI6Ii81ODA3OTIxOC8zMzY5NDU5MDktMTk3MWQyZWMtMGI3ZC00ZGJiLThlNDMtNjkxOGYxYzcxNjQyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAxVDE4MDEyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk3YjIyOTk3MzRhMDgxOGFkN2ExMGI0MWJhYmI0ZDg5NzU4NmM0MDA4YmYxNTVjNDNjYWZhZWQ4MGVmOWNlMjkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.7M_dqeBD1zZiUdfoe2Mcyx1atqciWXVQqrzY3iTQa0o)
Here's the result of two channel MAC matrix_multiplier based on three stage pipeline which is , memory access, mac, write back. The address fetching is also based on a counter , the code is in file matrix_mux.v The performace is 260 clock cyclein total , which is 32*8 mac calculation, with 2 initial pipeline stage delay , 2 write back buffer delay (casue we assume here the write back is single port)
![image](https://private-user-images.githubusercontent.com/58079218/336948171-433c7f61-951f-4eea-9629-59c1811034ca.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyMTM5ODMsIm5iZiI6MTcyNTIxMzY4MywicGF0aCI6Ii81ODA3OTIxOC8zMzY5NDgxNzEtNDMzYzdmNjEtOTUxZi00ZWVhLTk2MjktNTljMTgxMTAzNGNhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAxVDE4MDEyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWUzNWE4NjJiN2ViNWI0NzMxNWQyYTcxNWExMjljZGMxMDU3MDVkNzgxMjU4OTczYmU2YjIwZDVkODk4NDJmYTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.ZkFqR4qVzXgQncsdElS-DJ_tBREwWybffM-E2p1FLpQ)
Here's the sparse matrix vector multiplier, which is wildly used , the function is S*v=d , the compression format is CSR. link of CSR format The module in SpMV.v (spares matrix vector multi plier) is one channel mac, which is four stage pipeline. First stage is to fetch row_index, S vector and column_index. Second stage is fetch v based on column_index which in dicate in this rwo, where is not empty and should be multiplied with element in vector. Third stage is mac calculation, then the write back stage.
he main principle is to obtain the target address through row_index. When the self-increment address is equal to the target address, the value of the next row of the s matrix is obtained. AS seen in simulation this four-stage pipeline. Each row has four calculations, so when clock_counter=8, macc_clear is set and the data is written to the result. The result data is datac4 and the address is addrd.
![image](https://private-user-images.githubusercontent.com/58079218/336950694-d9204463-60c7-40a4-9c56-3ed84650b2e7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyMTM5ODMsIm5iZiI6MTcyNTIxMzY4MywicGF0aCI6Ii81ODA3OTIxOC8zMzY5NTA2OTQtZDkyMDQ0NjMtNjBjNy00MGE0LTljNTYtM2VkODQ2NTBiMmU3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAxVDE4MDEyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU4OWJhZjE0ZDk5NjE2YmI3YTljN2U4NDlkNzFhNmY1MmJmZjFhMzZjODUzNDZkODYxYjBmY2IzZjhhOGY1MmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.WBGy5Aq7NxHuGs4uyBQaHYJYClhnkfWn3JWYl5pvsDA)