Line 63... |
Line 63... |
generic(
|
generic(
|
C_NR_BITS_TOTAL : integer := 1536;
|
C_NR_BITS_TOTAL : integer := 1536;
|
C_NR_STAGES_TOTAL : integer := 96;
|
C_NR_STAGES_TOTAL : integer := 96;
|
C_NR_STAGES_LOW : integer := 32;
|
C_NR_STAGES_LOW : integer := 32;
|
C_SPLIT_PIPELINE : boolean := true;
|
C_SPLIT_PIPELINE : boolean := true;
|
C_NR_OP : integer := 4;
|
|
C_NR_M : integer := 2;
|
|
C_FIFO_DEPTH : integer := 32;
|
C_FIFO_DEPTH : integer := 32;
|
C_MEM_STYLE : string := "xil_prim"; -- xil_prim, generic, asym are valid options
|
C_MEM_STYLE : string := "xil_prim"; -- xil_prim, generic, asym are valid options
|
C_DEVICE : string := "xilinx" -- xilinx, altera are valid options
|
C_DEVICE : string := "xilinx" -- xilinx, altera are valid options
|
);
|
);
|
port(
|
port(
|
clk : in std_logic;
|
clk : in std_logic;
|
reset : in std_logic;
|
reset : in std_logic;
|
-- operand memory interface (plb shared memory)
|
-- operand memory interface (plb shared memory)
|
write_enable : in std_logic; -- write data to operand ram
|
write_enable : in std_logic; -- write data to operand ram
|
data_in : in std_logic_vector (31 downto 0); -- operand ram data in
|
data_in : in std_logic_vector (31 downto 0); -- operand ram data in
|
rw_address : in std_logic_vector (log2(C_NR_OP)+log2(C_NR_BITS_TOTAL/32) downto 0); -- operand ram address bus
|
rw_address : in std_logic_vector (8 downto 0); -- operand ram address bus
|
data_out : out std_logic_vector (31 downto 0); -- operand ram data out
|
data_out : out std_logic_vector (31 downto 0); -- operand ram data out
|
collision : out std_logic; -- write collision
|
collision : out std_logic; -- write collision
|
-- op_sel fifo interface
|
-- op_sel fifo interface
|
fifo_din : in std_logic_vector (31 downto 0); -- exponent fifo data in
|
fifo_din : in std_logic_vector (31 downto 0); -- exponent fifo data in
|
fifo_push : in std_logic; -- push data in exponent fifo
|
fifo_push : in std_logic; -- push data in exponent fifo
|
Line 87... |
Line 85... |
fifo_nopush : out std_logic; -- high if error during push
|
fifo_nopush : out std_logic; -- high if error during push
|
-- control signals
|
-- control signals
|
start : in std_logic; -- start multiplication/exponentiation
|
start : in std_logic; -- start multiplication/exponentiation
|
exp_m : in std_logic; -- single multiplication if low, exponentiation if high
|
exp_m : in std_logic; -- single multiplication if low, exponentiation if high
|
ready : out std_logic; -- calculations done
|
ready : out std_logic; -- calculations done
|
x_sel_single : in std_logic_vector (log2(C_NR_OP)-1 downto 0); -- single multiplication x operand selection
|
x_sel_single : in std_logic_vector (1 downto 0); -- single multiplication x operand selection
|
y_sel_single : in std_logic_vector (log2(C_NR_OP)-1 downto 0); -- single multiplication y operand selection
|
y_sel_single : in std_logic_vector (1 downto 0); -- single multiplication y operand selection
|
dest_op_single : in std_logic_vector (log2(C_NR_OP)-1 downto 0); -- result destination operand selection
|
dest_op_single : in std_logic_vector (1 downto 0); -- result destination operand selection
|
p_sel : in std_logic_vector (1 downto 0); -- pipeline part selection
|
p_sel : in std_logic_vector (1 downto 0); -- pipeline part selection
|
calc_time : out std_logic;
|
calc_time : out std_logic;
|
modulus_sel : in std_logic_vector(log2(C_NR_M)-1 downto 0) -- selects which modulus to use for multiplications
|
modulus_sel : in std_logic -- selects which modulus to use for multiplications
|
);
|
);
|
end mod_sim_exp_core;
|
end mod_sim_exp_core;
|
|
|
|
|
architecture Structural of mod_sim_exp_core is
|
architecture Structural of mod_sim_exp_core is
|
|
-- constants
|
|
constant nr_op : integer := 4;
|
|
constant nr_m : integer := 2;
|
|
|
-- data busses
|
-- data busses
|
signal xy : std_logic_vector(C_NR_BITS_TOTAL-1 downto 0); -- x and y operand data bus RAM -> multiplier
|
signal xy : std_logic_vector(C_NR_BITS_TOTAL-1 downto 0); -- x and y operand data bus RAM -> multiplier
|
signal m : std_logic_vector(C_NR_BITS_TOTAL-1 downto 0); -- modulus data bus RAM -> multiplier
|
signal m : std_logic_vector(C_NR_BITS_TOTAL-1 downto 0); -- modulus data bus RAM -> multiplier
|
signal r : std_logic_vector(C_NR_BITS_TOTAL-1 downto 0); -- result data bus RAM <- multiplier
|
signal r : std_logic_vector(C_NR_BITS_TOTAL-1 downto 0); -- result data bus RAM <- multiplier
|
|
|
Line 110... |
Line 112... |
signal result_dest_op : std_logic_vector(1 downto 0); -- result destination operand
|
signal result_dest_op : std_logic_vector(1 downto 0); -- result destination operand
|
signal mult_ready : std_logic;
|
signal mult_ready : std_logic;
|
signal start_mult : std_logic;
|
signal start_mult : std_logic;
|
signal load_x : std_logic;
|
signal load_x : std_logic;
|
signal load_result : std_logic;
|
signal load_result : std_logic;
|
|
signal modulus_sel_i : std_logic_vector(0 downto 0);
|
|
|
-- fifo signals
|
-- fifo signals
|
signal fifo_empty : std_logic;
|
signal fifo_empty : std_logic;
|
signal fifo_pop : std_logic;
|
signal fifo_pop : std_logic;
|
signal fifo_nopop : std_logic;
|
signal fifo_nopop : std_logic;
|
Line 142... |
Line 145... |
|
|
-- Block ram memory for storing the operands and the modulus
|
-- Block ram memory for storing the operands and the modulus
|
the_memory : operand_mem
|
the_memory : operand_mem
|
generic map(
|
generic map(
|
width => C_NR_BITS_TOTAL,
|
width => C_NR_BITS_TOTAL,
|
nr_op => C_NR_OP,
|
nr_op => nr_op,
|
nr_m => C_NR_M,
|
nr_m => nr_m,
|
mem_style => C_MEM_STYLE,
|
mem_style => C_MEM_STYLE,
|
device => C_DEVICE
|
device => C_DEVICE
|
)
|
)
|
port map(
|
port map(
|
data_in => data_in,
|
data_in => data_in,
|
Line 160... |
Line 163... |
result_in => r,
|
result_in => r,
|
load_result => load_result,
|
load_result => load_result,
|
result_dest_op => result_dest_op,
|
result_dest_op => result_dest_op,
|
collision => collision,
|
collision => collision,
|
clk => clk,
|
clk => clk,
|
modulus_sel => modulus_sel
|
modulus_sel => modulus_sel_i
|
);
|
);
|
|
|
|
modulus_sel_i(0) <= modulus_sel;
|
result_dest_op <= dest_op_single when exp_m = '0' else "11"; -- in autorun mode we always store the result in operand3
|
result_dest_op <= dest_op_single when exp_m = '0' else "11"; -- in autorun mode we always store the result in operand3
|
|
|
-- A fifo for exponentiation mode
|
-- A fifo for exponentiation mode
|
xil_prim_fifo : if C_MEM_STYLE="xil_prim" generate
|
xil_prim_fifo : if C_MEM_STYLE="xil_prim" generate
|
the_exponent_fifo : fifo_primitive
|
the_exponent_fifo : fifo_primitive
|