完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
你好,
我正在研究一个VHDL项目,我需要将两个数字相乘,M1 et M2。 M1在8位上定义为带符号的定点数:“0 0.000000” M2是16位有符号整数“0 000000000000000” 从数学上讲,乘法的答案应编码为24位(“0 00000000000000000000000”) 在VHDL中,我们可以将两个长度不相同的数字相乘吗? 如果没有,我们必须用符号位扩展最小值。 M1' 它会产生32位的乘法结果(M1'xM2),但24个足以编码“真实”结果...... 因此,我试过: Res:std_logic_vector(23 downto 0); ... RES 但在这种情况下,我在合成中发出警告,告诉我有一个长度不匹配... 然后我写道: 实体Synchro_voies是 港口 ( Clk:在std_logic中; 拉兹:在std_logic; M1:在std_logic_vector(15 downto 0); M2:在std_logic_vector(7 downto 0); Res:在std_logic_vector(23 downto 0) ); 结束Synchro_voies; 建筑行为的Synchro_voies是 信号Res1:std_logic_vector(31 downto 0); 开始 Res'0'); elsif Clk'event和Clk ='1'然后 RES1 但在这种情况下,Res1注册人是强制/有用的??? 亚历克斯 以上来自于谷歌翻译 以下为原文 Hello, I am working on a VHDL project, in which i need to multiply two numbers, M1 et M2. M1 is defined on 8 bits as a signed fixed point number : "0 0.000000" M2 is a 16 bits signed integer "0 000000000000000" Mathematically speaking the answer of the multiplication should be coded on 24 bit ("0 00000000000000000000000") In VHDL, can we multiply two numbers that do not have the same length? If not, we must then extend the smallest with its sign bit. M1' <= (M1(7)& M1(7)& M1(7)& M1(7)& M1(7)& M1(7)& M1(7)& M1(7)&M1); It induces a multiplication result (M1'xM2) of 32 bits but 24 are enough to code the "real" resul... Therefore, i tried that : Res : std_logic_vector ( 23 downto 0); ...Res <= ((M1(7)& M1(7)& M1(7)& M1(7)& M1(7)& M1(7)& M1(7)& M1(7)&M1))*M2; But in this case, i have warning in the synthesys, telling that i have a lenght missmatch... I then wrote that : entity Synchro_voies is PORT ( Clk :in std_logic; Raz : in std_logic; M1:instd_logic_vector (15 downto 0); M2:instd_logic_vector (7 downto 0); Res:instd_logic_vector (23 downto 0));end Synchro_voies;architecture Behavioral of Synchro_voies issignal Res1: std_logic_vector (31 downto 0);beginRes <= Res1 (23 downto 0);Phase_treat : process (Clk, RAZ)beginif Raz = '1' then Res1 <= (others => '0');elsif Clk'event and Clk = '1' then Res1 <= ((M2(7)&M2(7)&M2(7)&M2(7)&M2(7)&M2(7)&M2(7)&M2(7)&M2)*M1);end if;end process;end Behavioral; But in this case, is the Res1 registrer mandatory/usefull??? Alex |
|
相关推荐
2个回答
|
|
你好Alex,
而不是连接我建议你看看函数RESIZE。 另外,在ieee.numeric_std中还定义了很多其他功能。 例如,用于基于签名的信号的算术运算符。 所以你可以声明两个信号: 信号A:签名(15 downto 0);信号B:签名(15 downto 0); 然后在分配时动态调整M1 一个 调整大小将保留签名的MSB位。 函数RESIZE(ARG:SIGNED; NEW_SIZE:NATURAL)返回SIGNED; - 结果子类型:SIGNED(NEW_SIZE-1 downto 0) - 结果:将SIGNED向量ARG的大小调整为指定大小。 - 为了创建一个更大的向量,新的[最左边]位位置 - 用符号位(ARG'LEFT)填充。 截断时, - 符号位与最右边的部分一起保留。 希望有所帮助。 编辑: 我忘了补充一下。 是的,结果寄存器可能不是一个坏主意。 但是,如果您将结果分配给同步过程中的输出端口,它也应该导致注册的分配。 还有一件事,请记住,您可能希望处理固定点值与基于整数的值不同。 消息由tembridis.com编辑于11-17-2009 01:18 PM 以上来自于谷歌翻译 以下为原文 Hello Alex, instead of concatenating I would suggest you have a look at function RESIZE. Plus, in ieee.numeric_std there are quite alot other functions defined as well. Like for example arithmetic operators for signed based signals. So you could declare two signals: signal A : signed (15 downto 0); signal B : signed (15 downto 0); And then resize M1 on the fly while assigning it A <= RESIZE(signed(M1),16) Resize will preserve the signed MSB bit. function RESIZE (ARG: SIGNED; NEW_SIZE: NATURAL) return SIGNED; -- Result subtype: SIGNED(NEW_SIZE-1 downto 0) -- Result: Resizes the SIGNED vector ARG to the specified size. -- To create a larger vector, the new [leftmost] bit positions -- are filled with the sign bit (ARG'LEFT). When truncating, -- the sign bit is retained along with the rightmost part. Hope that helps. EDIT: I forgot to add. Yes, that result register might not be a bad idea. Though, if you would assign the result to the output port within the synchronous process, it should result into a registered assignement as well. One more thing, remember that you might want to handle fixed point values differently than integer based values. Message Edited by tembridis.com on 11-17-2009 01:18 PM |
|
|
|
>在VHDL中,我们可以将两个长度不相同的数字相乘吗?
是的,那完全没问题。 XST支持签名数据类型,您只需使用IEEE numeric_std包。 例如 信号mult_a:signed(7 downto 0);信号mult_b:signed(15 downto 0);信号mult_p:signed(23 downto 0); mult_p 干杯,吉姆 以上来自于谷歌翻译 以下为原文 >In VHDL, can we multiply two numbers that do not have the same length? Yes, that's perfectly OK. signed data type is supported by XST, all you need is to use the IEEE numeric_std package. e.g. signal mult_a : signed(7 downto 0); signal mult_b : signed(15 downto 0); signal mult_p : signed(23 downto 0); mult_p <= mult_a * mult_b; Cheers, Jim |
|
|
|
只有小组成员才能发言,加入小组>>
2423 浏览 7 评论
2824 浏览 4 评论
Spartan 3-AN时钟和VHDL让ISE合成时出现错误该怎么办?
2294 浏览 9 评论
3374 浏览 0 评论
如何在RTL或xilinx spartan fpga的约束文件中插入1.56ns延迟缓冲区?
2465 浏览 15 评论
有输入,但是LVDS_25的FPGA内部接收不到数据,为什么?
1190浏览 1评论
请问vc707的电源线是如何连接的,我这边可能出现了缺失元件的情况导致无法供电
590浏览 1评论
求一块XILINX开发板KC705,VC707,KC105和KCU1500
452浏览 1评论
2006浏览 0评论
731浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 07:00 , Processed in 1.298204 second(s), Total 80, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号