	.section	.data
	.align 		2
	.globl		RV32IMAC_DSP_Lib_Table_Log2_float
RV32IMAC_DSP_Lib_Table_Log2_float:
	#taylor series coefficients a0-a7:
	#	-3.31155
	#	7.46564
	#	-8.20099
	#	6.60981
	#	-3.56155
	#	1.21642
	#	-0.238129
	#	0.0203547
	.word		0xC053F06F, 0x40EEE686, 0xC1033741, 0x40D38390, 0xC063F06F, 0x3F9BB3A7, 0xBE73D817, 0x3CA6BEE6

	.section 	.text
	.align 		2
	.globl 		RV32IMACFP_log2_float
	#float RV32IMACFP_log2_float(float arg_in);
RV32IMACFP_log2_float:
	addi 	sp,sp,-16
    sw 	 	ra,12(sp)

	la			a5,RV32IMAC_DSP_Lib_Table_Log2_float
	fmv.x.w		a0,fa0
	li			a4,0x3F800000
	flw			ft1, 0(a5)
	li			a3,0x007FFFFF
	flw			ft2, 4(a5)
	srai		a1,a0,23
	flw			ft3, 8(a5)
	addi		a2,a1,-127
	flw			ft4, 12(a5)
	fcvt.s.w	fa2,a2				#fa2: exponent term

	flw			ft5, 16(a5)
	and			a1,a0,a3
	flw  		ft6, 20(a5)
	add			a2,a4,a1
	flw 		ft7, 24(a5)
	fmv.w.x		fa0,a2				#fa0: mantissa term [1.0,2.0)
	flw			ft8, 28(a5)

	fmadd.s fa1,fa0,ft8,ft7
	fmadd.s fa1,fa0,fa1,ft6
	fmadd.s fa1,fa0,fa1,ft5
	fmadd.s fa1,fa0,fa1,ft4
	fmadd.s fa1,fa0,fa1,ft3
	fmadd.s fa1,fa0,fa1,ft2
	fmadd.s fa1,fa0,fa1,ft1
	fadd.s	fa0,fa1,fa2

    lw   	ra,12(sp)
    addi 	sp,sp,16
    ret
