大侠,您好!<br /> 我是一个大学生,电子专业,我对FPGA很感兴趣,现在用VHDL进行编写一些小的逻辑功能程序,可是,最近我要编写一个带有算法的程序,而且还是小数和负数的运算,我不知道该怎么办.<br /> 下面简单说明一下我要实现的功能:<br /> din1: in std_logic_vector(7 downto 0);<br /> din2: in std_logic_vector(9 downto 0); <br /> led: out std_logic_vector(1 downto 0); <br /> <br /> constant :x= -10.078812453;<br /> constant :y= 3.80764200637;<br /> <br /> A=x*din1;<br /> B=y*din2;<br /> <br /> if (A+B) <-1024 then <br /> led<="00";<br /> elsif (A+B) <0 then <br /> led<="01";<br /> elsif (A+B) <512 then <br /> led<="10";<br /> else <br /> led<="11";<br /> <br /> end<br /> <br />以上是功能描述,不是原代码,<br />其中din1和din2是外部输入的数据,led是输出指示灯.<br />在VHDL中不支持小数和实数,那怎么进行运算呢?<br /><br />非常感谢, |
|