How to get you loop streaming to work in HDL coder for an update law of the form x[k+1] = A*x[k] + B*u[k]
조회 수: 2 (최근 30일)
이전 댓글 표시
I cannot seem to get streaming to work with a very basic function in HDL coder. I am trying to implement a state update law of the form x[k+1] = A*x[k] + B*u[k]. The body of the code is shown below. My problem is that no matter what I do or how many intermediate variables I introduce, I cannot get HDL coder to stream the calculation where A*x is computed. The code generation always gives this warning: "Warning 'x' : Loop streaming failed because a state variable, 'x', is being defined both inside and outside the loop." Streaming appears to work fine for the Y = C*X part of the algorithm however. What is the trick here?
=============================================================
function y = iir_filter(u)
persistent x
if isempty(x)
x = zeros(4,1);
end
C = [ -9.0031e-02 6.6989e-02 -8.6417e-02 -8.9795e-02];
A = [ 9.9094e-01 6.0518e-02 -1.1782e-02 -1.9578e-02; -6.0518e-02 9.9258e-01 1.9302e-02 1.0499e-02; -1.1782e-02 -1.9302e-02 9.3524e-01 -2.9776e-01; 1.9578e-02 1.0499e-02 2.9776e-01 9.0906e-01];
B = [ -9.0031e-02; -6.6989e-02; -8.6417e-02; 8.9795e-02 ];
y = C*x;
x_temp = x;
x_next = A*x_temp + B*u;
x = x_next;
end
댓글 수: 0
답변 (1개)
Chun-Yu
2015년 10월 6일
Hi Robert,
This is because we do not support loop streaming of matrix multiplication -- the A*x_temp operation is inhibiting loop streaming here. I don't believe there is any sort of workaround or other way you can get HDL Coder to stream this loop, other than not using a matrix multiply there.
Hope that helps,
Chun-Yu
댓글 수: 0
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!