Hi Fit,
To compute the matrix multiplication ( T = C \times X ), where both ( C ) and ( X ) are ( 8 \times 8 ) matrices, follow the standard matrix multiplication procedure, which involves the dot product of rows and columns.Here are the steps:
Step 1: Matrix Multiplication
For each element ( T_{ij} ) in the resulting matrix ( T ):
[ T_{ij} = \sum_{k=1}^{8} C_{ik} \times X_{kj} ]
This means you multiply each element of the ( i )-th row of ( C ) by the corresponding element of the ( j )-th column of ( X ), then sum these products.
Step 2: Implementing with Fixed Wordlengths
Given that your multiplier has a 16-bit wordlength and your adder has a 17-bit wordlength, you need to ensure that:
- Multiplication: Each multiplication operation results in a 16-bit product. If the inputs are also 16 bits, the product could be up to 32 bits (in a typical unsigned multiplication), so you may need to handle overflow or truncate to fit within 16 bits.
- Addition: The sum of the products for each element ( T_{ij} ) must fit within 17 bits. This may require careful management of intermediate results to avoid overflow.
Step 3: Verification
To verify the correctness of the results:
- Simulate with High Precision: Perform the matrix multiplication using a software tool (e.g., MATLAB, Python with NumPy) with higher precision (e.g., double precision) to get a reference result.
- Compare Results: Compare your hardware implementation results with the reference results. Check for discrepancies due to overflow or precision loss.
- Range Checking: Ensure that all intermediate values during multiplication and addition stay within the allowable range for 16-bit and 17-bit numbers, respectively. You can do this by:
- Overflow Detection: Implement checks in your design to flag if any intermediate result exceeds the wordlength limits.
- Error Metrics: Calculate error metrics like Mean Absolute Error (MAE) or Mean Squared Error (MSE) between your results and the reference results to quantify any precision loss.
Hope this helps.