Привет этот код, чтобы сделать операцию деления двух двоичных чисел, каждое число является 4-битным, мне нужно изменить этот код, чтобы получить результат дробной части, например, для иллюстрации моя идея 1010 (10), деленная на 0011 (3) = 11.010101 (3.3333 ) так, какую часть нужно было изменить, чтобы отобразить результат в двоичном виде на выходе схемы
заранее спасибо
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_unsigned.All;
entity division4bits is
generic(SIZE: INTEGER := 4);
port(reset: in STD_LOGIC;
en: in STD_LOGIC;
clk: in STD_LOGIC;
num: in STD_LOGIC_VECTOR((SIZE - 1) downto 0);
den: in STD_LOGIC_VECTOR((SIZE - 1) downto 0);
result: out STD_LOGIC_VECTOR((SIZE - 1) downto 0);
remender: out STD_LOGIC_VECTOR((SIZE - 1) downto 0)
);
end division4bits;
architecture Behavioral of division4bits is
signal buf: STD_LOGIC_VECTOR((2 * SIZE - 1) downto 0);
signal dbuf: STD_LOGIC_VECTOR((SIZE - 1) downto 0);
signal sm: INTEGER range 0 to SIZE;
alias buf1 is buf((2 * SIZE - 1) downto SIZE);
alias buf2 is buf((SIZE - 1) downto 0);
begin
p_001: process(reset, en, clk)
begin
if reset = '1' then
result <= (others => '0');
remender <= (others => '0');
sm <= 0;
elsif rising_edge(clk) then
if en = '1' then
case sm is
when 0 =>
buf1 <= (others => '0');
buf2 <= num;
dbuf <= den;
result <= buf2;
remender <= buf1;
sm <= sm + 1;
when others =>
if buf((2 * SIZE - 2) downto (SIZE - 1)) >= dbuf then
buf1 <= '0' & (buf((2 * SIZE - 3) downto (SIZE - 1)) -
dbuf((SIZE - 2) downto 0));
buf2 <= buf2((SIZE - 2) downto 0) & '1';
else
buf <= buf((2 * SIZE - 2) downto 0) & '0';
end if;
if sm /= SIZE then
sm <= sm + 1;
else
sm <= 0;
end if;
end case;
end if;
end if;
end process;
end Behavioral;