cancel
Showing results for
Show  only  | Search instead for
Did you mean:
Visitor
1,090 Views
Registered: ‎03-22-2018

## Floating point mean(average) calculation

I want to calculate the mean of the matrix rows. the matrix size is [8*8].I have done it with Fixpoint by sending [1*8] row. But my data is in floating point.

I have also designed IEEE 754 adder but I'm facing the problem when I call it in always block.What is the solution for it?

my floating point IEEE754 module is fpu_add(a,b,out).

fix point calculation:

module sm(invec,o);
input[13:0]invec;
output [31:0]o;
reg [18:0]vecsize=4'b111;
reg [31:0]o=0;
reg [13:0]a[0:7];

reg [31:0]b=0;
reg [31:0]m=0;
reg [31:0]mean=0;

integer k=0;

always@*
begin
if(m<=7)
begin
a[m]=invec;

b[m]=b[m]+a[m];
\$display("a=%b",a[m]);
\$display("b=%b",b);
m=m+1;
end
else
begin
mean=b/vecsize;
o=mean;
\$display("o=%b",o);
\$display("mean=%b",mean);
end
end
endmodule

3 Replies
Moderator
1,003 Views
Registered: ‎07-21-2014

>>I have also designed IEEE 754 adder but I'm facing the problem when I call it in always block

Can you please elaborate the issue here?

Thanks

Anusheel

Visitor
976 Views
Registered: ‎03-22-2018

Thanks for your reply.The previous one was solved,But I have new problem now.I have designed 32 bit floating point adder fpadd(a,b,out) .By using this I want to regenerate it n times.I tried it with generate for loop but its showing an error. How we can generate fpadd n times.

parameter N = 64;
input [31:0] a[0:N];
output [31:0]s[0:N];

genvar i;
generate for (i=0; i<N; i=i+1) begin : u1

if(i==0)
begin
end

else
begin
end

endmodule

Moderator
947 Views
Registered: ‎07-21-2014