mod演算器(if文使用)

掲載ページ:176、リスト番号:7.2

【VHDL記述】


library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.std_logic_unsigned.all;

entity MODULO is

port ( X, Y : in std_logic_vector(3 downto 0);

Z : out std_logic_vector(3 downto 0));

end MODULO;

architecture STUDENT_1 of MODULO is

begin

process ( X, Y )


variable TMP : std_logic_vector(3 downto 0);


begin

TMP := "000" & X(3);

if ( TMP >= Y ) then

TMP := TMP - Y;

end if;


TMP := TMP(2 downto 0) & X(2);

if ( TMP >= Y ) then

TMP := TMP - Y;

end if;


TMP := TMP(2 downto 0) & X(1);

if ( TMP >= Y ) then

TMP := TMP - Y;

end if;


TMP := TMP(2 downto 0) & X(0);

if ( TMP >= Y ) then

TMP := TMP - Y;

end if;


Z <= TMP;

end process;

end STUDENT_1;

【Verilog-HDL記述】


※ この回路のVerilog-HDL記述は、割愛させて頂きます。ご了承下さい。

【合成結果】