1.VHDL语言
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cnt4 is
port(clk : in std_logic;
q : buffer std_logic_vector(3 downto 0));
end cnt4;
architecture behave of cnt4 is
begin
process(clk)
begin
if clk'event and clk = '1' then
if q = 15 then
q <= "0000";
else
q <= q+1;
end if;
end if;
end process;
end behave;
2.注意
2.1.使用整型Integer时,必须定义整数取值范围
2.2.加减算术符的适用范围——整数
2.3.整数和位的表达方式:1 + 5; ‘1’;“1011”