[Open-graphics] Re: float25 multiplier

André Pouliot andre.pouliot at gmail.com
Sun Feb 3 23:55:49 EST 2008


Here is the new version for the floating point multiplier.  The thread
is from July but I just had the time to rework on it.

This version is basically the same except some amelioration like the
result is forced to zero when one of the input value is a denormalized
number or zero. For the case that the value is infinite or NaN the
result is forced to infinite except if multiplied by zero.

There is also a C++ test bench generator to build a verilog test bench
with random value and some fix corner case. That generator is based on
the float25 class in the old OGA model. The generator for now is
relatively basic and could be ameliorated.

Actually there seem to have a bug somewhere in the code. The bug seem to
be a rounding problem that cause a variation of "1" in the result of the
multiplication.  I'm not sure if it's from the C++ code or the verilog
that is the cause of the bug.

Timothy Normand Miller wrote:
> Yeah.  Use the new_model code, and define an actual class for float25
> that limits the precision and also has this new behavior as well.
>
> On 7/30/07, Nicolas Boulay <nicolas.boulay at gmail.com> wrote:
>   
>> For the float25, is it possible to use the C model to see the beavior
>> of this inf*zero=zero feature ?
>>     


-------------- next part --------------
A non-text attachment was scrubbed...
Name: TbGenMult_float25.cpp
Type: text/x-c++src
Size: 6775 bytes
Desc: not available
Url : http://lists.duskglow.com/open-graphics/attachments/20080203/0e0ad2b1/TbGenMult_float25.bin
-------------- next part --------------
module tb_floatmult25();

reg clock;
reg [24:0] mult_input_a, mult_input_b;
wire [24:0] mult_output;

floatmult25 mult (clock, mult_input_a, mult_input_b, mult_output); 
always #5 clock    <= !clock;

initial begin
   // do reset or whatever
   // ...
   clock = 0;
   mult_input_a = 'h0;
   mult_input_b = 'h0;
   pe; pe; pe; pe; pe;
   test_mult('h7f0000, 'h7f0000, 'h7f0000);
   test_mult('h17f0000, 'h7f0000, 'h17f0000);
   test_mult('h7f0000, 'h0, 'h0);
   test_mult('h1fe0000, 'h0, 'h0);
   test_mult('hff0000, 'h0, 'h0);
   test_mult('hff0000, 'h34fff0, 'hff0000);
   test_mult('h1ff0000, 'h34fff0, 'h1ff0000);
   test_mult('h7f8000, 'h82e000, 'h836800);
   // ... more generated code...
   $finish;
end

task test_mult;
input [24:0] ina, inb, outc;
begin
    mult_input_a = ina;
    mult_input_b = inb;
    pe; pe; pe; pe; pe;
    if (mult_output != outc) begin
		$display("Value mismatch In_a : %h In_b %h:  Out_not: %h  Result : %h ",ina, inb, outc, mult_output );
//    end else begin
//		$display("Value match In_a : %h In_b %h:  Out_not: %h  Result : %h ",ina, inb, outc, mult_output );		
	end
end
endtask

task pe;
	begin
    	@(posedge clock);
	end
endtask
			
endmodule

-------------- next part --------------

CXX := g++
CXXFLAGS := -g -Wall


Generator_SOURCES = float25.cpp TbGenMult_float25.cpp

TbGenerator: $(Generator_SOURCES)
	$(CXX) $+ -o$@
	TbGenerator > TbAutoGenMult_float25.v
simulMult: float25Mult.v TbAutoGenMult_float25.v
	iverilog -o$@ float25Mult.v TbAutoGenMult_float25.v
startSimul: simulMult
	simulMult > result.log
all : $(Generator_SOURCES)
	$(CXX) $+ -o TbGenerator
	TbGenerator > TbAutoGenMult_float25.v
	iverilog -o simulMult float25Mult.v TbAutoGenMult_float25.v
	simulMult > result.log
clean:
	rm -f simulMult TbGenerator TbAutoGenMult_float25.v result.log
PHONY: TbGenerator simulMult


More information about the Open-graphics mailing list