p.42 今度は何かを1増やす回路を作る。何か命令の実行中に次の命令をフェッチする手段として使うとの由。さまざまな実装が考えられるようだが、とりあえず下のように半加算器を連結する形にしておく。リプルは生じるが記述が容易だ。 inc16: library ieee; use ieee.std_logic_1164.all; entity inc16 is port ( inp: in std_logic_vector(15 downto 0); outp: out std_logic_vector(15 downto 0) ); end entity; architecture behavior…
p.42 今度は16ビット加算器を作る。これまで何度も作っているが再度一から作る。半加算器から作り上げる。nand2tetrisの縛りがあるためかなり面倒くさい。キャリー先読みではなく普通のリプルアダーにする。 half_adder: library ieee; use ieee.std_logic_1164.all; entity half_adder is port ( a, b: in std_logic; sum, carry: out std_logic ); end entity; architecture behavior of half_adder is begin --sum…