zaidali
Newbie level 5
- Joined
- Jul 5, 2013
- Messages
- 8
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 118
hi
below is a matlab code for computing the QR decomposition ,i need the same program in vhdl , i tried to convert it but the result which i get after simulation is always wrong , i think my problem is in using the for loop statement in vhdl, i don't know how to use a nested loops , so plz if someone can help me coz i have to complete this program in a very short time
a=[1 2 3 4;1 1 2 5;1 2 4 1;3 3 2 1];
q=[0 0 0 0;0 0 0 0;0 0 0 0;0 0 0 0]
R=[0 0 0 0;0 0 0 0;0 0 0 0;0 0 0 0]
[m,n]=size(a)
for k=1:1:n
s=0;
for j=1:1:m;
s=s+a(j,k)^2
end
R(k,k)=sqrt(s)
for j=1:1:m
q(j,k)=a(j,k)/R(k,k)
end
for i=k+1:1:n
s=0;
for j=1:1:m
s=s+a(j,i)*q(j,k)
end
R(k,i)=s
for j=1:1:m
f=R(k,i)*q(j,k)
a(j,i)=a(j,i)-f
end
end
end
below is a matlab code for computing the QR decomposition ,i need the same program in vhdl , i tried to convert it but the result which i get after simulation is always wrong , i think my problem is in using the for loop statement in vhdl, i don't know how to use a nested loops , so plz if someone can help me coz i have to complete this program in a very short time
a=[1 2 3 4;1 1 2 5;1 2 4 1;3 3 2 1];
q=[0 0 0 0;0 0 0 0;0 0 0 0;0 0 0 0]
R=[0 0 0 0;0 0 0 0;0 0 0 0;0 0 0 0]
[m,n]=size(a)
for k=1:1:n
s=0;
for j=1:1:m;
s=s+a(j,k)^2
end
R(k,k)=sqrt(s)
for j=1:1:m
q(j,k)=a(j,k)/R(k,k)
end
for i=k+1:1:n
s=0;
for j=1:1:m
s=s+a(j,i)*q(j,k)
end
R(k,i)=s
for j=1:1:m
f=R(k,i)*q(j,k)
a(j,i)=a(j,i)-f
end
end
end