我生成了随机浮点数(十进制格式),并将它们保存在一个文本文件中。我用VHDL写了一个读取这个文件的代码。现在我想将这些浮点数转换成IEEE格式(32 bir或64位)。有没有我可以用来工作的图书馆?或者在VHDL中有任何代码。
谢谢
发布于 2012-10-15 23:40:31
有一个VHDL浮点程序包:
http://vhdl.org/fphdl/index.html
发布于 2013-04-15 23:31:20
您可以通过纯软件脚本将浮点数转换为IEEE754(例如1.0 -> 0x3F800000):
将实数转换为IEEE754浮点格式的数字的Matlab程序http://users.eecs.northwestern.edu/~ismail/courses/c92/fpu/
使用ieee-floats中定义的encode-float32,可以进行快速转换。(defun fix2float ( fp ) (format t "~%~x~T~x“fp (ieee-floats:encode-float32 fp) (fix2float 1.1)
至于硬件库,Vfloat(王晓军,2010)值得一试。
发布于 2012-10-15 19:18:40
如果你想在VHDL语言中使用随机数,为什么不使用*math_real*库中的统一函数呢?Uniform是您的函数,其用法在定义中解释
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);https://stackoverflow.com/questions/12894064
复制相似问题