首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VHDL :需要库

VHDL :需要库
EN

Stack Overflow用户
提问于 2012-10-15 18:51:33
回答 3查看 3.2K关注 0票数 2

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

谢谢

EN

回答 3

Stack Overflow用户

发布于 2012-10-15 23:40:31

有一个VHDL浮点程序包:

http://vhdl.org/fphdl/index.html

票数 0
EN

Stack Overflow用户

发布于 2013-04-15 23:31:20

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

  1. matlab脚本:

将实数转换为IEEE754浮点格式的数字的Matlab程序http://users.eecs.northwestern.edu/~ismail/courses/c92/fpu/

  • lisp脚本:http://common-lisp.net/project/ieee-floats/

使用ieee-floats中定义的encode-float32,可以进行快速转换。(defun fix2float ( fp ) (format t "~%~x~T~x“fp (ieee-floats:encode-float32 fp) (fix2float 1.1)

至于硬件库,Vfloat(王晓军,2010)值得一试。

票数 0
EN

Stack Overflow用户

发布于 2012-10-15 19:18:40

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

代码语言:javascript
复制
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*包读取数据:

代码语言:javascript
复制
procedure READ(L:inout LINE; VALUE: out real; GOOD : out BOOLEAN);
procedure READ(L:inout LINE; VALUE: out real);
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12894064

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档