Forum Discussion
DSP Builder Matrix Vector Product
Hello,
We have implemented and tested a controller with a simulink model. The next step is to translate it into vhdl code with DSP Builder for Intel FPGAs (Advance Blockset). Therefore, I want to exchange among others the following simulink blocks with DSP Builder blocks.
The [T_dqVSD2dqMS]^(-1) is defined as 9x9 matrix
function T_dqVSD2dqMS_inv = get_T_dqVSD2dqMS_inv(theta_e) T_dqVSD2dqMS_inv = [[0.3333333333, 0., 0., 0.3333333335 - 0.1283000598*cos(1.221730477 + 2.*theta_e) + 0.05555555556*cos(0.6981317008 + 2.*theta_e) - 0.05555555556*sin(1.221730477 + 2.*theta_e) - 0.1111111111*sin(0.1745329252 + 2.*theta_e) + 0.06415002993*sin(0.6981317008 + 2.*theta_e) + 0.03207501497*cos(0.1745329252 + 2.*theta_e), 0.3000000000e-10 - 0.05555555556*cos(1.221730477 + 2.*theta_e) - 0.1111111111*cos(0.1745329252 + 2.*theta_e) - 0.03207501497*sin(0.1745329252 + 2.*theta_e) + 0.1283000598*sin(1.221730477 + 2.*theta_e) - 0.05555555556*sin(0.6981317008 + 2.*theta_e) + 0.06415002993*cos(0.6981317008 + 2.*theta_e), -0.2222222222*cos(theta_e + 0.3490658504) + 0.2222222222*sin(theta_e + 0.8726646262) + 0.2222222222*cos(theta_e + 1.396263402), 0.3333333334 + 0.05555555556*sin(0.8726646262 + 2.*theta_e) - 0.1283000598*sin(0.3490658504 + 2.*theta_e) - 0.05555555556*cos(0.3490658504 + 2.*theta_e) - 0.1111111111*cos(1.396263402 + 2.*theta_e) + 0.06415002993*cos(0.8726646262 + 2.*theta_e) + 0.03207501497*sin(1.396263402 + 2.*theta_e), -0.3000000000e-10 + 0.05555555556*sin(0.3490658504 + 2.*theta_e) + 0.1111111111*sin(1.396263402 + 2.*theta_e) + 0.03207501497*cos(1.396263402 + 2.*theta_e) - 0.1283000598*cos(0.3490658504 + 2.*theta_e) + 0.05555555556*cos(0.8726646262 + 2.*theta_e) - 0.06415002993*sin(0.8726646262 + 2.*theta_e), -0.2222222222*sin(theta_e + 1.221730477) + 0.2222222222*cos(theta_e + 0.6981317008) + 0.2222222222*sin(theta_e + 0.1745329252)]; [0., 0.3333333333, 0., 0.5000000000e-10 - 0.05555555556*cos(1.221730477 + 2.*theta_e) - 0.1111111111*cos(0.1745329252 + 2.*theta_e) - 0.03207501497*sin(0.1745329252 + 2.*theta_e) + 0.1283000598*sin(1.221730477 + 2.*theta_e) - 0.05555555556*sin(0.6981317008 + 2.*theta_e) + 0.06415002993*cos(0.6981317008 + 2.*theta_e), 0.3333333333 + 0.05555555556*sin(1.221730477 + 2.*theta_e) + 0.1111111111*sin(0.1745329252 + 2.*theta_e) - 0.06415002993*sin(0.6981317008 + 2.*theta_e) + 0.1283000598*cos(1.221730477 + 2.*theta_e) - 0.03207501497*cos(0.1745329252 + 2.*theta_e) - 0.05555555556*cos(0.6981317008 + 2.*theta_e), 0.2222222222*sin(theta_e + 0.3490658504) + 0.2222222222*cos(theta_e + 0.8726646262) - 0.2222222222*sin(theta_e + 1.396263402), 0.3000000000e-10 + 0.05555555556*sin(0.3490658504 + 2.*theta_e) + 0.1111111111*sin(1.396263402 + 2.*theta_e) + 0.03207501497*cos(1.396263402 + 2.*theta_e) - 0.1283000598*cos(0.3490658504 + 2.*theta_e) + 0.05555555556*cos(0.8726646262 + 2.*theta_e) - 0.06415002993*sin(0.8726646262 + 2.*theta_e), 0.3333333333 + 0.05555555556*cos(0.3490658504 + 2.*theta_e) - 0.06415002993*cos(0.8726646262 + 2.*theta_e) + 0.1111111111*cos(1.396263402 + 2.*theta_e) + 0.1283000598*sin(0.3490658504 + 2.*theta_e) - 0.03207501497*sin(1.396263402 + 2.*theta_e) - 0.05555555556*sin(0.8726646262 + 2.*theta_e), -0.2222222222*cos(theta_e + 1.221730477) - 0.2222222222*sin(theta_e + 0.6981317008) + 0.2222222222*cos(theta_e + 0.1745329252)]; [0.3333333333, 0., 0., -0.1666666666 + 0.06415002993*cos(1.221730477 + 2.*theta_e) - 0.1111111111*cos(0.6981317008 + 2.*theta_e) - 0.05555555556*sin(1.221730477 + 2.*theta_e) + 0.05555555556*sin(0.1745329252 + 2.*theta_e) - 0.03207501497*sin(0.6981317008 + 2.*theta_e) + 0.1283000598*cos(0.1745329252 + 2.*theta_e), 0.2886751348 - 0.05555555556*cos(1.221730477 + 2.*theta_e) + 0.05555555556*cos(0.1745329252 + 2.*theta_e) - 0.1283000598*sin(0.1745329252 + 2.*theta_e) - 0.06415002993*sin(1.221730477 + 2.*theta_e) - 0.03207501497*cos(0.6981317008 + 2.*theta_e) + 0.1111111111*sin(0.6981317008 + 2.*theta_e), -0.2222222222*cos(theta_e + 0.3490658504) + 0.2222222222*sin(theta_e + 0.8726646262) + 0.2222222222*cos(theta_e + 1.396263402), -0.1666666666 - 0.1111111111*sin(0.8726646262 + 2.*theta_e) + 0.06415002993*sin(0.3490658504 + 2.*theta_e) - 0.05555555556*cos(0.3490658504 + 2.*theta_e) + 0.05555555556*cos(1.396263402 + 2.*theta_e) - 0.03207501497*cos(0.8726646262 + 2.*theta_e) + 0.1283000598*sin(1.396263402 + 2.*theta_e), -0.2886751348 + 0.06415002993*cos(0.3490658504 + 2.*theta_e) + 0.1283000598*cos(1.396263402 + 2.*theta_e) + 0.05555555556*sin(0.3490658504 + 2.*theta_e) - 0.05555555556*sin(1.396263402 + 2.*theta_e) - 0.1111111111*cos(0.8726646262 + 2.*theta_e) + 0.03207501497*sin(0.8726646262 + 2.*theta_e), -0.2222222222*sin(theta_e + 1.221730477) + 0.2222222222*cos(theta_e + 0.6981317008) + 0.2222222222*sin(theta_e + 0.1745329252)]; [0., -0.3333333333, 0., 0.2886751347 + 0.05555555556*cos(1.221730477 + 2.*theta_e) - 0.05555555556*cos(0.1745329252 + 2.*theta_e) + 0.1283000598*sin(0.1745329252 + 2.*theta_e) + 0.06415002993*sin(1.221730477 + 2.*theta_e) - 0.1111111111*sin(0.6981317008 + 2.*theta_e) + 0.03207501497*cos(0.6981317008 + 2.*theta_e), 0.1666666666 - 0.05555555556*sin(1.221730477 + 2.*theta_e) + 0.05555555556*sin(0.1745329252 + 2.*theta_e) - 0.03207501497*sin(0.6981317008 + 2.*theta_e) + 0.06415002993*cos(1.221730477 + 2.*theta_e) + 0.1283000598*cos(0.1745329252 + 2.*theta_e) - 0.1111111111*cos(0.6981317008 + 2.*theta_e), -0.2222222222*sin(theta_e + 0.3490658504) - 0.2222222222*cos(theta_e + 0.8726646262) + 0.2222222222*sin(theta_e + 1.396263402), -0.2886751345 - 0.05555555556*sin(0.3490658504 + 2.*theta_e) + 0.05555555556*sin(1.396263402 + 2.*theta_e) - 0.1283000598*cos(1.396263402 + 2.*theta_e) - 0.06415002993*cos(0.3490658504 + 2.*theta_e) + 0.1111111111*cos(0.8726646262 + 2.*theta_e) - 0.03207501497*sin(0.8726646262 + 2.*theta_e), 0.1666666667 - 0.05555555556*cos(0.3490658504 + 2.*theta_e) - 0.03207501497*cos(0.8726646262 + 2.*theta_e) + 0.05555555556*cos(1.396263402 + 2.*theta_e) + 0.06415002993*sin(0.3490658504 + 2.*theta_e) + 0.1283000598*sin(1.396263402 + 2.*theta_e) - 0.1111111111*sin(0.8726646262 + 2.*theta_e), 0.2222222222*cos(theta_e + 1.221730477) + 0.2222222222*sin(theta_e + 0.6981317008) - 0.2222222222*cos(theta_e + 0.1745329252)]; [0.3333333333, 0., 0., -0.1666666667 - 0.03207501497*cos(1.221730477 + 2.*theta_e) + 0.05555555556*cos(0.6981317008 + 2.*theta_e) + 0.1111111111*sin(1.221730477 + 2.*theta_e) + 0.05555555556*sin(0.1745329252 + 2.*theta_e) - 0.1283000598*sin(0.6981317008 + 2.*theta_e) - 0.06415002993*cos(0.1745329252 + 2.*theta_e), -0.2886751345 - 0.1283000598*cos(0.6981317008 + 2.*theta_e) - 0.05555555556*sin(0.6981317008 + 2.*theta_e) + 0.03207501497*sin(1.221730477 + 2.*theta_e) + 0.06415002993*sin(0.1745329252 + 2.*theta_e) + 0.05555555556*cos(0.1745329252 + 2.*theta_e) + 0.1111111111*cos(1.221730477 + 2.*theta_e), -0.2222222222*cos(theta_e + 0.3490658504) + 0.2222222222*sin(theta_e + 0.8726646262) + 0.2222222222*cos(theta_e + 1.396263402), -0.1666666668 + 0.05555555556*sin(0.8726646262 + 2.*theta_e) - 0.03207501497*sin(0.3490658504 + 2.*theta_e) + 0.1111111111*cos(0.3490658504 + 2.*theta_e) + 0.05555555556*cos(1.396263402 + 2.*theta_e) - 0.1283000598*cos(0.8726646262 + 2.*theta_e) - 0.06415002993*sin(1.396263402 + 2.*theta_e), 0.2886751344 + 0.1283000598*sin(0.8726646262 + 2.*theta_e) + 0.05555555556*cos(0.8726646262 + 2.*theta_e) - 0.03207501497*cos(0.3490658504 + 2.*theta_e) - 0.06415002993*cos(1.396263402 + 2.*theta_e) - 0.1111111111*sin(0.3490658504 + 2.*theta_e) - 0.05555555556*sin(1.396263402 + 2.*theta_e), -0.2222222222*sin(theta_e + 1.221730477) + 0.2222222222*cos(theta_e + 0.6981317008) + 0.2222222222*sin(theta_e + 0.1745329252)]; [0., 0.3333333333, 0., 0.2886751344 - 0.1283000598*cos(0.6981317008 + 2.*theta_e) - 0.05555555556*sin(0.6981317008 + 2.*theta_e) + 0.03207501497*sin(1.221730477 + 2.*theta_e) + 0.06415002993*sin(0.1745329252 + 2.*theta_e) + 0.05555555556*cos(0.1745329252 + 2.*theta_e) + 0.1111111111*cos(1.221730477 + 2.*theta_e), -0.1666666667 + 0.03207501497*cos(1.221730477 + 2.*theta_e) - 0.05555555556*cos(0.6981317008 + 2.*theta_e) - 0.1111111111*sin(1.221730477 + 2.*theta_e) - 0.05555555556*sin(0.1745329252 + 2.*theta_e) + 0.1283000598*sin(0.6981317008 + 2.*theta_e) + 0.06415002993*cos(0.1745329252 + 2.*theta_e), 0.2222222222*sin(theta_e + 0.3490658504) + 0.2222222222*cos(theta_e + 0.8726646262) - 0.2222222222*sin(theta_e + 1.396263402), -0.2886751345 + 0.1283000598*sin(0.8726646262 + 2.*theta_e) + 0.05555555556*cos(0.8726646262 + 2.*theta_e) - 0.03207501497*cos(0.3490658504 + 2.*theta_e) - 0.06415002993*cos(1.396263402 + 2.*theta_e) - 0.1111111111*sin(0.3490658504 + 2.*theta_e) - 0.05555555556*sin(1.396263402 + 2.*theta_e), -0.1666666667 - 0.1111111111*cos(0.3490658504 + 2.*theta_e) + 0.1283000598*cos(0.8726646262 + 2.*theta_e) - 0.05555555556*cos(1.396263402 + 2.*theta_e) + 0.03207501497*sin(0.3490658504 + 2.*theta_e) + 0.06415002993*sin(1.396263402 + 2.*theta_e) - 0.05555555556*sin(0.8726646262 + 2.*theta_e), -0.2222222222*cos(theta_e + 1.221730477) - 0.2222222222*sin(theta_e + 0.6981317008) + 0.2222222222*cos(theta_e + 0.1745329252)]; [0., 0., 1., 0., 0., 0., 0., 0., 0.]; [0., 0., 0., 0., 0.09622504490*sin(theta_e + 1.221730477) + 0.09622504490*cos(theta_e + 0.3490658504) - 0.09622504490*sin(theta_e + 0.1745329252) - 0.09622504490*cos(theta_e + 1.396263402) - 0.09622504490*sin(theta_e + 0.8726646262) - 0.09622504490*cos(theta_e + 0.6981317008), 1., 0., 0., 0.]; [0., 0., 0., 0., 0., 0., 0., -0.09622504490*sin(theta_e + 1.221730477) - 0.09622504490*cos(theta_e + 0.3490658504) + 0.09622504490*sin(theta_e + 0.1745329252) + 0.09622504490*cos(theta_e + 1.396263402) + 0.09622504490*sin(theta_e + 0.8726646262) + 0.09622504490*cos(theta_e + 0.6981317008), 1.]];
Is there a simpler approach than multiplying and summing up straight forward, as indicated below, using the primitive basic blocks "add" and "mult"?
The nine top inputs represent the vector, the 81 inputs underneath the matrix.
Furthermore is there any possibility to implement and calculate the matrix as code, instead of single "sin" blocks for each matrix value?
Thank you for your insights in advance.
2 Replies
- Kshitij_Intel
Frequent Contributor
Hi,
We can do the matrix multiplication with DSP Builder as well. Please refer to the link below.
Hope this will solve your issue.
Thank you
Kshitij Goel
- Kshitij_Intel
Frequent Contributor
Hi,
As we do not receive any response from you on the previous reply that we have provided. Please login to ‘https://supporttickets.intel.com’, view details of the desire request, and post a response within the next 15 days to allow me to continue to support you. After 15 days, this thread will be transitioned to community support. The community users will be able to help you on your follow-up questions.
Thank you
Kshitij Goel