cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
860 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

0 Kudos
3 Replies
Highlighted
Moderator
Moderator
773 Views
Registered: ‎07-21-2014

Re: Floating point mean(average) calculation

darshaksheladiya@gmail.com

 

>>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

0 Kudos
Highlighted
746 Views
Registered: ‎03-22-2018

Re: Floating point mean(average) calculation

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.

 

module gen_fpadd(a,s);
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
fpadd inst[i+1](a[i],a[i+1],s[i]);
end


else
begin
fpadd inst[i+1](a[i+1],s[i-1],s[i]);
end

endmodule

 

 

 

 

 

 

generate_for.jpg 

0 Kudos
Highlighted
Moderator
Moderator
717 Views
Registered: ‎07-21-2014

Re: Floating point mean(average) calculation

darshaksheladiya@gmail.com Please start a new thread for every new query. Thanks.

0 Kudos