seb_
New Contributor
2 years agoDSP 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.