全加算器

p.116
ここまで読んでやっとVHDLの話に入る。

VHDLで全加算器を作る -のときとは違って、真理値表から導いた論理式をそのまま記述する。

-- entity宣言で入出力ポートを宣言する。
entity full_adder_unit is
    port(
        a, b, cin: in  bit;
        sum, cout: out bit
    );
end entity full_adder_unit;

------------------------------------------------------

/*
architectureボディで回路の挙動または構造を記述する。
信号に値を割り当てる場合は <= を使う。
VHDL 2008だと複数行コメントアウトができる。
*/

architecture boolean_equations of full_adder_unit is
begin
    sum  <= a xor b xor cin;
    cout <= (a and b) or (a and cin) or (b and cin);
end architecture boolean_equations;

f:id:ti-nspire:20210326114749p:plain:w500

動作確認:
f:id:ti-nspire:20210326134157j:plain:w500