--入力
signal MUL_A: std_logic_vector(11 downto 0);
signal MUL_B: std_logic_vector( 7 downto 0);
--出力
signal MUL_out: std_logic_vector(19 downto 0);
--コントロール
signal load_MUL: std_logic;
signal cls_MUL: std_logic;
signal fin_MUL: std_logic;
--内部レジスタ
signal mul_count : std_logic_vector(3 downto 0);
------------------------------------------------------
--使用するプロセス内に、ここの部分を入れてください。
------------------------------------------------------
MUL_A <="12bitの整数";
MUL_B <="8bitの整数";
cls_MUL <='0';
load_MUL <='1';
if fin_MUL ='1' and load_MUL='1' then
"回答用logic_vector"<= MUL_out;
load_MUL<='0';
flag <='1'; -- 逐次的に処理がしたい場合は、
フラッグを使用して処理をとばさないようにする。
cls_MUL <='1';
end if;
---------------------------
--掛け算メインプロセス
---------------------------
process(clk)
begin
if reset ='0' then
busy_MUL <='0';
fin_MUL <='0';
elsif clk'event and clk='1' then
if load_MUL='1' and fin_MUL='0' then
if busy_MUL = '0' then
MUL_count <="0000";
MUL_out <="00000000000000000000";
busy_MUL <= '1';
elsif fin_MUL ='0' and MUL_count <= "1001" then
MUL_count <= MUL_count + 1;
end if;
if MUL_count = "0001" and MUL_B(0) ='1' then
MUL_out(12 downto 0) <= ('0' & MUL_out(11 downto 0)) + ('0' & MUL_A);
end if;
if MUL_count = "0010" and MUL_B(1)='1' then
MUL_out(13 downto 1) <= ('0' & MUL_out(12 downto 1)) + ('0' & MUL_A);
end if;
if MUL_count = "0011" and MUL_B(2)='1' then
MUL_out(14 downto 2) <= ('0' & MUL_out(13 downto 2)) + ('0' & MUL_A);
end if;
if MUL_count = "0100" and MUL_B(3)='1' then
MUL_out(15 downto 3) <= ('0' & MUL_out(14 downto 3)) + ('0' & MUL_A);
end if;
if MUL_count = "0101" and MUL_B(4)='1' then
MUL_out(16 downto 4) <= ('0' & MUL_out(15 downto 4)) + ('0' & MUL_A);
end if;
if MUL_count = "0110" and MUL_B(5)='1' then
MUL_out(17 downto 5) <= ('0' & MUL_out(16 downto 5)) + ('0' & MUL_A);
end if;
if MUL_count = "0111" and MUL_B(6)='1' then
MUL_out(18 downto 6) <= ('0' & MUL_out(17 downto 6)) + ('0' & MUL_A);
end if;
if MUL_count = "1000" and MUL_B(7)='1' then
MUL_out(19 downto 7)<= ('0' & MUL_out(18 downto 7)) + ('0' & MUL_A);
end if;
if MUL_count = "1001" and busy_MUL ='1' then
busy_MUL <='0';
fin_MUL <='1';
end if;
end if;
if cls_MUL = '1' then
fin_MUL <= '0';
end if;
end if;
end process; |