當前位置:編程學習大全網 - 網站源碼 - 用vhdl語言設計二位全加器

用vhdl語言設計二位全加器

library ieee;

use ieee.std_logic_1164.all;

entity product_adder_subtracter is

port(

a,b:in std_logic_vector(7 downto 0);

s:out std_logic_vector(8 downto 0));

end;

architecture behavioral of product_adder_subtracter is

begin

behavior:process(a,b) is

variable carry_in:std_logic;

variable carry_out:std_logic;

variable op2:std_logic_vector(b'range);

begin

op2:=b;

end if;

for index in 0 to 7 loop

carry_in:=carry_out;

s(index)<=a(index) xor op2(index)xor carry_in ;

carry_out:=(a(index)and op2(index))

or(carry_in and (a(index) xor op2(index)));

end loop;

s(8)<=a(7) xor op2(7) xor carry_out;

end process;

end;

  • 上一篇:任丘市建設東路上的那個檢測站叫啥
  • 下一篇:winform dev的GridView雙擊事件怎麽實現
  • copyright 2024編程學習大全網