Point Mult - VHD
Point Mult - VHD
-- Company:
-- Engineer:
--
-- Create Date: 07.05.2024 15:12:04
-- Design Name:
-- Module Name: Point_multx - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity Point_mult is
GENERIC (
wid : INTEGER := 256
);
PORT(
Px : IN STD_LOGIC_VECTOR(wid - 1 DOWNTO 0);
Py : IN STD_LOGIC_VECTOR(wid - 1 DOWNTO 0);
d : IN STD_LOGIC_VECTOR(wid - 1 DOWNTO 0);
clk : IN STD_LOGIC;
rst : IN STD_LOGIC;
start : IN STD_LOGIC;
Rx : OUT STD_LOGIC_VECTOR(wid - 1 downto 0);
Ry : OUT STD_LOGIC_VECTOR(wid - 1 downto 0);
done : OUT STD_LOGIC
);
end Point_mult;
component Point_double is
GENERIC (
wid : INTEGER := 256
);
PORT(
Px : IN STD_LOGIC_VECTOR(wid - 1 DOWNTO 0);
Py : IN STD_LOGIC_VECTOR(wid - 1 DOWNTO 0);
clk : IN STD_LOGIC;
rst : IN STD_LOGIC;
start : IN STD_LOGIC;
Rx : OUT STD_LOGIC_VECTOR(wid - 1 downto 0);
Ry : OUT STD_LOGIC_VECTOR(wid - 1 downto 0);
done : OUT STD_LOGIC
);
end component;
component Point_add is
GENERIC (
wid : INTEGER := 256
);
PORT(
Px : IN STD_LOGIC_VECTOR(wid - 1 DOWNTO 0);
Py : IN STD_LOGIC_VECTOR(wid - 1 DOWNTO 0);
Qx : IN STD_LOGIC_VECTOR(wid - 1 DOWNTO 0);
Qy : IN STD_LOGIC_VECTOR(wid - 1 DOWNTO 0);
clk : IN STD_LOGIC;
rst : IN STD_LOGIC;
start : IN STD_LOGIC;
Rx : OUT STD_LOGIC_VECTOR(wid - 1 downto 0);
Ry : OUT STD_LOGIC_VECTOR(wid - 1 downto 0);
done : OUT STD_LOGIC
);
end component;
type state_type is (idle, prep, shift, op_dbl, wait_dbl, get_dbl, op_add, wait_add,
get_add, fin);
signal state_reg, state_next : state_type;
begin
bt <= tmp_d(i);
process(clk, rst)
begin
if (rst='1') then
state_reg <= idle;
elsif (clk'event and clk='1') then
state_reg <= state_next;
end if;
end process;
process(clk, state_reg)
begin
if (rising_edge(clk)) then
if (state_reg = fin) then
done <= '1';
else
done <= '0';
end if;
end if;
end process;
process(clk, state_reg)
begin
if (rising_edge(clk)) then
if (rst='1') then
Rx <= (others => '0');
Ry <= (others => '0');
elsif (state_reg = fin) then
Rx <= res_x;
Ry <= res_y;
end if;
end if;
end process;
process(state_reg)
begin
if (state_reg = op_add) then
add_start <= '1';
else
add_start <= '0';
end if;
end process;
process(state_reg)
begin
if (state_reg = op_dbl) then
dbl_start <= '1';
else
dbl_start <= '0';
end if;
end process;
Point_double_b: Point_double
GENERIC map(
wid => wid
)
PORT map(
Px => res_x,
Py => res_y,
clk => clk,
rst => rst,
start => dbl_start,
Rx => dbl_x,
Ry => dbl_y,
done => dbl_done
);
Point_add_b: Point_add
GENERIC map(
wid => wid
)
PORT map(
Px => res_x,
Py => res_y,
Qx => tmp_x,
Qy => tmp_y,
clk => clk,
rst => rst,
start => add_start,
Rx => add_x,
Ry => add_y,
done => add_done
);
end Behavioral;