参考: 動かしてわかる CPUの作り方10講, pp.153ff.
これまではすべて実際に回路を動かしてロジアナ、オシロ、LEDなどで動作を見てきたが、今度はModelSimでシミュレートしてみる。
↓この回路の動作をシミュレートする。単なる2入力ANDである。
library ieee; use ieee.std_logic_1164.all; entity sute_and is port( a, b: in std_logic; y: out std_logic ); end entity; architecture rtl of sute_and is begin y <= a and b; end architecture;
↓これがテストベンチ。シミュレートすべき回路をコンポーネントとして呼び出す。entity
内にport()
は記述せず、代わりに内部シグナルを定義し、入力波形をprocess
として記述する。
library ieee; use ieee.std_logic_1164.all; entity sute_and_sim is end entity; architecture sim of sute_and_sim is component sute_and port( a, b: in std_logic; y: out std_logic ); end component; signal a_sim: std_logic; signal b_sim: std_logic; signal y_sim: std_logic; begin module_sute_and_sim: sute_and port map( a => a_sim, b => b_sim, y => y_sim ); process begin a_sim <= '0'; wait for 10 ns; a_sim <= '1'; wait for 10 ns; a_sim <= '0'; wait for 10 ns; a_sim <= '1'; wait for 10 ns; a_sim <= '0'; wait for 10 ns; end process; process begin b_sim <= '0'; wait for 20 ns; b_sim <= '1'; wait for 20 ns; b_sim <= '0'; wait for 10 ns; end process; end architecture;
↓ これがシミュレーション結果。ヒゲの出そうな入力波形にしたがRTLシミュレーションでは発見できないとの由。