VHDLのようなハードウェア記述言語を用いると,加算や減算のような複雑なハー ドウェアも演算子ひとつで表現できるという特長があります.8ビットのバイ ナリ・カウンタを加算演算子`+'を用いて表現してみましょう.
-- ライブラリ宣言 library IEEE; use IEEE.std_logic_1164.all; library ARITHMETIC; use ARITHMETIC.std_logic_arith.all; -- エンティティ宣言 entity counter8 is port (COUNT : out std_logic_vector( 7 downto 0 ); CY : out std_logic; -- 桁上がり CLK : in std_logic; RESET : in std_logic); end counter8; -- アーキテクチャ本体 architecture counter8_body of counter8 is signal TMP : std_logic_vector( 8 downto 0 ) := "000000000"; begin process( CLK, RESET ) begin if RESET = '1' then -- 非同期リセット TMP <= "000000000"; elsif CLK'event and CLK = '1' then TMP <= TMP + "000000001"; end if; end process; COUNT <= TMP( 7 downto 0 ); CY <= TMP( 8 ); end counter8_body;
library ARITHMETIC; use ARITHMETIC.std_logic_arith.all;
8ビット・バイナリ・カウンタのように多少複雑な回路をゲートレベルで記述 すると,レジスタや1インクリメント・アダーなどを用意する必要があり,そ の記述は膨大になります.