i hv written the program of gauss siedel for 3 by 3 matrix in verilog....
i dont know how to define the value 0.005 in verilog...
its giving an error when i am defining it using real variables.
i read ur post which says real values are not synthesisable...but i am not able to find a solution for it.. please help me wid this.
prog:
module gss_seidel(sol0,sol1,sol2,matrx00,matrx01, matrx02, matrx10, matrx11, matrx12,matrx20, matrx21, matrx22);
output [7:0]sol0,sol1,sol2;
input [7:0]matrx00,matrx01, matrx02, matrx10, matrx11, matrx12,matrx20, matrx21, matrx22;
wire [7:0]r,s,m,p1,p2,p3;
reg matx[2:0][3:0];
reg solutions[2:0];
integer i,j,k;
reg [7:0]result, diff, pivotalrow, pivotalelement, t;
real maxdiff;
always@(matrx00,matrx01, matrx02, matrx10, matrx11, matrx12,matrx20, matrx21, matrx22)
begin
$display("\n GAUSS-SEIDEL ITERATIVE METHOD\n\n");
matx[0][0]= matrx00;
matx[0][1]= matrx01;
matx[0][2] = matrx02;
matx[1][0]= matrx10;
matx[1][1]= matrx11;
matx[1][2]= matrx12;
matx[2][0]= matrx20;
matx[2][1]= matrx21;
matx[2][2]= matrx22;
for(i=0; i<3; i=i+1)
begin
pivotalelement=matx;
pivotalrow=i;
for(j=pivotalrow+1; j<3; j=j+1)
if (pivotalelement < matx[j])
begin
pivotalelement = matx[j];
pivotalrow=j;
end
for(j=0;j<=3; j=j+1)
begin
t=matx[j];
matx[j]=matx[pivotalrow][j];
matx[pivotalrow][j]=t;
end
end
/* using Gauss-Seidel iterative method */
maxdiff = 5E-4;
k=0;
while(maxdiff>=5E-4)
begin
k=k+1;
maxdiff = 0;
/* rowwise scanning, substituting estimates of (nofequations-i) unknowns
to get Xi in the ith row */
for(i=0; i<3; i=i+1)
begin
result=matx[3] ;
/* columnwise scanning, to get the solution of ith unknown in ith row */
for(j=0; j<3; j=j+1)
if(i!=j)
result= result-matx[j]*solutions[j];
result=result/matx ;
diff=solutions-result;
if(diff>maxdiff)
maxdiff = diff;
solutions=result;
end /* end of outer for loop */
$display("\n\n No. of iterations= %d", k) ; /* gives the no. of iterations performed */
for(j=0; j<3; j=j+1)
$display(" %f",solutions[j]) ; /* current estimated solutions will be printed */
$display(" %f",maxdiff);
end /* end of outermost while loop */
$display("\n\n\n");
/* printing solutions */
for(i=0; i<3; i=i+1)
$display(" X%d = %f \n", i, solutions) ;
end
assign p1 = solutions[0],
p2 = solutions[1],
p3 = solutions[2];
endmodule
ERROR:Xst:2228 - "gss_seidel.v" line 31: Unsupported Real variable.