0
votes

So I am working with 64 bit floating point numbers on Verilog for synthesis, all are in the region of {-1,1}. Now, I am trying to create something like a Histogram which I guess I could do by creating a RAM to work like a 2D array. But I am facing issues with the rounding.

For Example,

I have a value 0.94394(FltPt). I would like to convert this into just,

0.82394 = 8 and 0.8862 =9 (All data are in 64 bit flt pt)

so that I can access that specific address on the RAM.

What would be the the most ideal way to round this, using another multiplier is too much overhead. Is there some trick I could do by truncating a part of the bits? Should I convert them to Fixed Point?

1
What are you trying to create a Histogram of?Morgan
The the floating point data,I have coordinate pairs. so if I have (.933,.5) I want to add 1 count to Ram [9][5].user2045143

1 Answers

0
votes

Two options I can think of: The simplest is to change your bins so the boundaries are powers of 2. Then you can just use the some of bits of the input directly to address your histogram. I would have to go look at the floating point format to know which bits to use.

The other possibility is to just do a bunch of comparisons to see what bin to put it. L You would have do this for both of the coordinates.

reg [4:0] ram_aadr;

always @* begin
  if(data < -.95)
    ram_addr = 5'd0;
  else if(data < -.85)
    ram_addr = 5'd1;
...
  else if(data < .95)
    ram_addr = 5'd19;
  else
    ram_addr = 5'd20;
end