Line 1... |
Line 1... |
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
---- operand_mem_gen ----
|
---- operand_mem ----
|
---- ----
|
---- ----
|
---- This file is part of the ----
|
---- This file is part of the ----
|
---- Modular Simultaneous Exponentiation Core project ----
|
---- Modular Simultaneous Exponentiation Core project ----
|
---- http://www.opencores.org/cores/mod_sim_exp/ ----
|
---- http://www.opencores.org/cores/mod_sim_exp/ ----
|
---- ----
|
---- ----
|
---- Description ----
|
---- Description ----
|
---- BRAM memory and logic to the store 4 (1536-bit) operands ----
|
---- RAM memory and logic to the store operands and the ----
|
---- and the modulus for the montgomery multiplier ----
|
---- modulus for the montgomery multiplier, the user has a ----
|
|
---- choise between 3 memory styles, more detail in the ----
|
|
---- documentation ----
|
---- ----
|
---- ----
|
---- Dependencies: ----
|
---- Dependencies: ----
|
|
---- - operand_ram ----
|
|
---- - modulus_ram ----
|
---- - operand_ram_gen ----
|
---- - operand_ram_gen ----
|
---- - modulus_ram_gen ----
|
---- - modulus_ram_gen ----
|
|
---- - operand_ram_asym ----
|
|
---- - modulus_ram_asym ----
|
---- ----
|
---- ----
|
---- Authors: ----
|
---- Authors: ----
|
---- - Geoffrey Ottoy, DraMCo research group ----
|
---- - Geoffrey Ottoy, DraMCo research group ----
|
---- - Jonas De Craene, JonasDC@opencores.org ----
|
---- - Jonas De Craene, JonasDC@opencores.org ----
|
---- ----
|
---- ----
|
Line 58... |
Line 64... |
-- '0': operands
|
-- '0': operands
|
-- bits: (highest-1)-log2(width/32) -> operand_in_sel in case of highest bit = '0'
|
-- bits: (highest-1)-log2(width/32) -> operand_in_sel in case of highest bit = '0'
|
-- modulus_in_sel in case of highest bit = '1'
|
-- modulus_in_sel in case of highest bit = '1'
|
-- bits: (log2(width/32)-1)-0 -> modulus_addr / operand_addr resp.
|
-- bits: (log2(width/32)-1)-0 -> modulus_addr / operand_addr resp.
|
--
|
--
|
entity operand_mem_gen is
|
entity operand_mem is
|
generic(
|
generic(
|
width : integer := 1536; -- width of the operands
|
width : integer := 1536; -- width of the operands
|
nr_op : integer := 4; -- nr of operand storages, has to be greater than nr_m
|
nr_op : integer := 4; -- nr of operand storages, has to be greater than nr_m
|
nr_m : integer := 2 -- nr of modulus storages
|
nr_m : integer := 2; -- nr of modulus storages
|
|
mem_style : string := "asym"; -- xil_prim, generic, asym are valid options
|
|
device : string := "altera" -- xilinx, altera are valid options
|
);
|
);
|
port(
|
port(
|
-- system clock
|
-- system clock
|
clk : in std_logic;
|
clk : in std_logic;
|
-- data interface (plb side)
|
-- data interface (plb side)
|
Line 83... |
Line 91... |
load_result : in std_logic;
|
load_result : in std_logic;
|
result_dest_op : in std_logic_vector(log2(nr_op)-1 downto 0);
|
result_dest_op : in std_logic_vector(log2(nr_op)-1 downto 0);
|
collision : out std_logic;
|
collision : out std_logic;
|
modulus_sel : in std_logic_vector(log2(nr_m)-1 downto 0)
|
modulus_sel : in std_logic_vector(log2(nr_m)-1 downto 0)
|
);
|
);
|
end operand_mem_gen;
|
end operand_mem;
|
|
|
architecture Behavioral of operand_mem_gen is
|
architecture structural of operand_mem is
|
|
-- constants
|
constant wordaddr_aw : integer := log2(width/32);
|
constant wordaddr_aw : integer := log2(width/32);
|
constant opaddr_aw : integer := log2(nr_op);
|
constant opaddr_aw : integer := log2(nr_op);
|
constant maddr_aw : integer := log2(nr_m);
|
constant maddr_aw : integer := log2(nr_m);
|
constant total_aw : integer := 1+opaddr_aw+wordaddr_aw;
|
constant total_aw : integer := 1+opaddr_aw+wordaddr_aw;
|
|
|
|
-- internal signals
|
signal xy_data_i : std_logic_vector(31 downto 0);
|
signal xy_data_i : std_logic_vector(31 downto 0);
|
signal xy_addr_i : std_logic_vector(wordaddr_aw-1 downto 0);
|
signal xy_addr_i : std_logic_vector(wordaddr_aw-1 downto 0);
|
signal operand_in_sel_i : std_logic_vector(opaddr_aw-1 downto 0);
|
signal operand_in_sel_i : std_logic_vector(opaddr_aw-1 downto 0);
|
signal modulus_in_sel_i : std_logic_vector(maddr_aw-1 downto 0);
|
signal modulus_in_sel_i : std_logic_vector(maddr_aw-1 downto 0);
|
|
|
Line 112... |
Line 122... |
operand_in_sel_i <= rw_address(total_aw-2 downto wordaddr_aw);
|
operand_in_sel_i <= rw_address(total_aw-2 downto wordaddr_aw);
|
modulus_in_sel_i <= rw_address(wordaddr_aw+maddr_aw-1 downto wordaddr_aw);
|
modulus_in_sel_i <= rw_address(wordaddr_aw+maddr_aw-1 downto wordaddr_aw);
|
xy_data_i <= data_in;
|
xy_data_i <= data_in;
|
m_data_i <= data_in;
|
m_data_i <= data_in;
|
|
|
|
-- select right memory with highest address bit
|
load_op <= write_enable when (rw_address(total_aw-1) = '0') else '0';
|
load_op <= write_enable when (rw_address(total_aw-1) = '0') else '0';
|
load_m <= write_enable when (rw_address(total_aw-1) = '1') else '0';
|
load_m <= write_enable when (rw_address(total_aw-1) = '1') else '0';
|
|
|
|
xil_prim_RAM : if mem_style="xil_prim" generate
|
-- xy operand storage
|
-- xy operand storage
|
xy_ram : operand_ram_gen
|
xy_ram_xil : operand_ram
|
|
port map(
|
|
clk => clk,
|
|
collision => collision,
|
|
operand_addr => xy_addr_i,
|
|
operand_in => xy_data_i,
|
|
operand_in_sel => operand_in_sel_i,
|
|
result_out => data_out,
|
|
write_operand => load_op,
|
|
operand_out => xy_out,
|
|
operand_out_sel => op_sel,
|
|
result_dest_op => result_dest_op,
|
|
write_result => load_result,
|
|
result_in => result_in
|
|
);
|
|
|
|
-- modulus storage
|
|
m_ram_xil : modulus_ram
|
|
port map(
|
|
clk => clk,
|
|
modulus_addr => m_addr_i,
|
|
write_modulus => load_m,
|
|
modulus_in => m_data_i,
|
|
modulus_out => m
|
|
);
|
|
end generate;
|
|
|
|
gen_RAM : if mem_style="generic" generate
|
|
-- xy operand storage
|
|
xy_ram_gen : operand_ram_gen
|
generic map(
|
generic map(
|
width => width,
|
width => width,
|
depth => nr_op
|
depth => nr_op
|
)
|
)
|
port map(
|
port map(
|
Line 137... |
Line 178... |
write_result => load_result,
|
write_result => load_result,
|
result_in => result_in
|
result_in => result_in
|
);
|
);
|
|
|
-- modulus storage
|
-- modulus storage
|
m_ram : modulus_ram_gen
|
m_ram_gen : modulus_ram_gen
|
generic map(
|
generic map(
|
width => width,
|
width => width,
|
depth => nr_m
|
depth => nr_m
|
)
|
)
|
port map(
|
port map(
|
Line 151... |
Line 192... |
write_modulus => load_m,
|
write_modulus => load_m,
|
modulus_in => m_data_i,
|
modulus_in => m_data_i,
|
modulus_out => m,
|
modulus_out => m,
|
modulus_sel => modulus_sel
|
modulus_sel => modulus_sel
|
);
|
);
|
|
end generate;
|
|
|
|
asym_RAM : if mem_style="asym" generate
|
|
-- xy operand storage
|
|
xy_ram_asym : operand_ram_asym
|
|
generic map(
|
|
width => width,
|
|
depth => nr_op,
|
|
device => device
|
|
)
|
|
port map(
|
|
clk => clk,
|
|
collision => collision,
|
|
operand_addr => xy_addr_i,
|
|
operand_in => xy_data_i,
|
|
operand_in_sel => operand_in_sel_i,
|
|
result_out => data_out,
|
|
write_operand => load_op,
|
|
operand_out => xy_out,
|
|
operand_out_sel => op_sel,
|
|
result_dest_op => result_dest_op,
|
|
write_result => load_result,
|
|
result_in => result_in
|
|
);
|
|
|
|
-- modulus storage
|
|
m_ram_asym : modulus_ram_asym
|
|
generic map(
|
|
width => width,
|
|
depth => nr_m,
|
|
device => device
|
|
)
|
|
port map(
|
|
clk => clk,
|
|
modulus_in_sel => modulus_in_sel_i,
|
|
modulus_addr => m_addr_i,
|
|
write_modulus => load_m,
|
|
modulus_in => m_data_i,
|
|
modulus_out => m,
|
|
modulus_sel => modulus_sel
|
|
);
|
|
end generate;
|
|
|
end Behavioral;
|
end structural;
|
|
|
No newline at end of file
|
No newline at end of file
|