1 用 VHDL 设计的一位二进制全加器的示例程序
library ieee;
use ieee.std_logic_1164.all;
entity adder is port(a, b,ci : in bit;
sum : out bit);
end adder;
architecture a of adder is
begin
sum<=a xor b xor ci;
co<=((a or b) and ci) or ( a and b);
end a;
2 用 vhdl 语言实现一个脉冲信号的十分频
ibrary ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity div is
generic (duty : integer := 5);
port (clk : in std_logic;
Q : out std_logic);
end div ;
architecture divlo of div is
constart period : integer := 10;
signal count : integer range 0 to period-1;
begin
process (clk)
begin
if rising_edge ( clk ) then
if count < duty then
Q <= ‘0’ ;
count <= count+1;
else if count < period-1 then
Q <= ‘1’ ;
count <= count+1 ;
else count <= ‘0’ ;
end if ;
end if ;
end process ;
end divlo ;