我来我网
https://5come5.cn
 
您尚未 登录  注册 | 菠菜 | 软件站 | 音乐站 | 邮箱1 | 邮箱2 | 风格选择 | 更多 » 
 

本页主题: 讨论一下这个VHDL程序(实现二进制补码乘法中的Booth算法) 显示签名 | 打印 | 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题

老子不怕您



性别: 帅哥 状态: 该用户目前不在线
等级: 栋梁之材
发贴: 623
威望: 0
浮云: 1333
在线等级:
注册时间: 2004-09-09
最后登陆: 2008-03-08

5come5帮你背单词 [ blush /blΛ/ vi. 脸红,羞愧,觉得难为情;n. 脸红,难为情 ]


讨论一下这个VHDL程序(实现二进制补码乘法中的Booth算法)


近日我看了一段程序,搞不懂其中的步骤细节,哪位愿意探讨的请多指点!
另外有个问题是我用max+plusII编译时软件总是告知IEEE.numeric_std库不存在,这是怎么回事?

程序如下。
程序来源:Digital System Design with VHDL (Second Edition), p126 ISBN 7-5053-9919-7
注释是我后加的。

其功能是实现二进制补码乘法运算中的Booth算法(Booth's Algorithm,相关信息请见附件一)
代码如下(代码.vhd程序请见附件二)
附件一实在太难上传!


Quote:

Copy code
---------------------------------------------------------------------
--   BOOTH'S ALGORITHM REALIZAION WITH VHDL   --
--   From <Digital System Design with VHDL> p126   --
---------------------------------------------------------------------

--   Program Key Points
  -- alais
  -- generic defines the type and assign the initial value
  -- algorithm in porgramming
  -- "+" "-" and shift_right(vector, num)  
  -- count variable for loop control

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;

entity booth is
  generic(al : NATRUAL := 16;
        bl : NATRUAL := 16;
        ql : NATRUAL := 16);
  port(ain : in std_logic_vector(al-1 downto 0);
      bin : in std_logic_vector(bl-1 downto 0);
      qout : out std_logic_vector(ql-1 downto 0);
      clk : in std_logic;
      load : in std_logic;
      ready : out std_logic);
end entity booth;

architecture rtl of booth is
begin
  process (clk) is
    variable count : INTEGER range 0 to al;
    variable pa : signed((al + bl) downto 0);
    variable a_1 : std_logic;
    alias p : signed(bl downto 0) is pa((al + bl) downto al );
  begin
    if (rising_edge(clk)) then
        if (load='1')
          p := (others => '0');
          pa(al - 1 downto 0) := signed(ain);
          a_1 := '0';
          count := al;
          ready <= '0';
        elsif (count>0) then
            case std_logic_vector'(pa(0), a_1) is
              when "01" =>
                p := p + signed(bin);
              when "10" =>
                p := p - signed(bin);
              when others =>
                null;
          end case;
          a_1 := pa(0);
          pa := shift_right(pa, 1);
          count := count - 1;        
        end if;
        if (count=0) then
          ready <= '1';
        end if;
        qout <= std_logic_vector( pa((al + bl - 1) downto 0) );
    end if;
  end process;
end architecture rtl;




[ 此贴被老子不怕您在2007-04-10 21:44重新编辑 ]
顶端 Posted: 2007-04-10 21:00 | [楼 主]
我来我网·5come5 Forum » 电子设计·数学建模

Total 0.014236(s) query 4, Time now is:05-09 01:57, Gzip enabled
Powered by PHPWind v5.3, Localized by 5come5 Tech Team, 黔ICP备16009856号