Floating point VHDL:需要库

Floating point VHDL:需要库,floating-point,vhdl,ieee-754,Floating Point,Vhdl,Ieee 754,我生成了十进制格式的随机浮点数,并将它们保存在一个文本文件中。我用VHDL编写了一个读取该文件的代码。现在我想把这些浮点数转换成IEEE格式的32BIR或64位。有没有图书馆可以供我使用。 或者VHDL中有任何代码 谢谢如果您想在VHDL中使用随机数,为什么不使用*math_real*库中的统一函数呢?统一是您的功能,定义中解释了用法 procedure UNIFORM (variable Seed1,Seed2:inout integer; variable X:out real);

我生成了十进制格式的随机浮点数,并将它们保存在一个文本文件中。我用VHDL编写了一个读取该文件的代码。现在我想把这些浮点数转换成IEEE格式的32BIR或64位。有没有图书馆可以供我使用。 或者VHDL中有任何代码


谢谢

如果您想在VHDL中使用随机数,为什么不使用*math_real*库中的统一函数呢?统一是您的功能,定义中解释了用法

procedure UNIFORM (variable Seed1,Seed2:inout integer; variable X:out real);
    -- returns a pseudo-random number with uniform distribution in the 
    -- interval (0.0, 1.0).
    -- Before the first call to UNIFORM, the seed values (Seed1, Seed2) must
    -- be initialized to values in the range [1, 2147483562] and 
    -- [1, 2147483398] respectively.  The seed values are modified after 
    -- each call to UNIFORM.
    -- This random number generator is portable for 32-bit computers, and
    -- it has period ~2.30584*(10**18) for each set of seed values.
    --
    -- For VHDL-1992, the seeds will be global variables, functions to 
    -- initialize their values (INIT_SEED) will be provided, and the UNIFORM
    -- procedure call will be modified accordingly.  
如果您不需要,请使用*std_textio*包读取数据:

procedure READ(L:inout LINE; VALUE: out real; GOOD : out BOOLEAN);
procedure READ(L:inout LINE; VALUE: out real);

如果您想在VHDL中使用随机数,为什么不使用*math_real*库中的统一函数?统一是您的功能,定义中解释了用法

procedure UNIFORM (variable Seed1,Seed2:inout integer; variable X:out real);
    -- returns a pseudo-random number with uniform distribution in the 
    -- interval (0.0, 1.0).
    -- Before the first call to UNIFORM, the seed values (Seed1, Seed2) must
    -- be initialized to values in the range [1, 2147483562] and 
    -- [1, 2147483398] respectively.  The seed values are modified after 
    -- each call to UNIFORM.
    -- This random number generator is portable for 32-bit computers, and
    -- it has period ~2.30584*(10**18) for each set of seed values.
    --
    -- For VHDL-1992, the seeds will be global variables, functions to 
    -- initialize their values (INIT_SEED) will be provided, and the UNIFORM
    -- procedure call will be modified accordingly.  
如果您不需要,请使用*std_textio*包读取数据:

procedure READ(L:inout LINE; VALUE: out real; GOOD : out BOOLEAN);
procedure READ(L:inout LINE; VALUE: out real);

有一个VHDL浮点包:


有一个VHDL浮点包:


您可以通过纯软件脚本将浮点数转换为IEEE 754,例如1.0->0x3F800000:

matlab脚本:

将实数转换为IEEE 754浮点格式的数字的Matlab程序

lisp脚本:

使用ieee floats中定义的encode-float32,可以进行快速转换

(defun fix2float (fp)
     (format t "~%~x~T~x" fp (ieee-floats:encode-float32 fp)))
 (fix2float 1.1)

至于硬件库,VfloatXiaojun Wang,2010值得一试。

您可以通过纯软件脚本将浮点数转换为IEEE 754,例如1.0->0x3F800000:

matlab脚本:

将实数转换为IEEE 754浮点格式的数字的Matlab程序

lisp脚本:

使用ieee floats中定义的encode-float32,可以进行快速转换

(defun fix2float (fp)
     (format t "~%~x~T~x" fp (ieee-floats:encode-float32 fp)))
 (fix2float 1.1)

至于硬件库,VfloatXiaojun Wang,2010值得一试。

谢谢BennyBarns。问题不在于读取文件。我已经这么做了。现在我想把这些浮点数转换成IEEE格式。我应该使用图书馆吗?那么你应该更精确,而不是否决一个答案。你是说IEEE754?我以为你在说ieee.std_logic_1164!在这种情况下,您将为754操作使用某种块集,它将提供转换。。。我记得synplicity并不是说我生成了一个文本文件,其中浮点数是这样的1.9832,0.211,-1.12我用VHDL编写了代码,可以读取这个。现在我想把这些数字转换成IEEE-754 32位格式。为了这个,我需要哪个图书馆。谢谢BennyBarns。问题不在于读取文件。我已经这么做了。现在我想把这些浮点数转换成IEEE格式。我应该使用图书馆吗?那么你应该更精确,而不是否决一个答案。你是说IEEE754?我以为你在说ieee.std_logic_1164!在这种情况下,您将为754操作使用某种块集,它将提供转换。。。我记得synplicity并不是说我生成了一个文本文件,其中浮点数是这样的1.9832,0.211,-1.12我用VHDL编写了代码,可以读取这个。现在我想把这些数字转换成IEEE-754 32位格式。对于这个,我需要哪个库。