Line 54... |
Line 54... |
-- data input --
|
-- data input --
|
rs1_i : in std_ulogic_vector(data_width_c-1 downto 0); -- rf source 1
|
rs1_i : in std_ulogic_vector(data_width_c-1 downto 0); -- rf source 1
|
rs2_i : in std_ulogic_vector(data_width_c-1 downto 0); -- rf source 2
|
rs2_i : in std_ulogic_vector(data_width_c-1 downto 0); -- rf source 2
|
pc2_i : in std_ulogic_vector(data_width_c-1 downto 0); -- delayed PC
|
pc2_i : in std_ulogic_vector(data_width_c-1 downto 0); -- delayed PC
|
imm_i : in std_ulogic_vector(data_width_c-1 downto 0); -- immediate
|
imm_i : in std_ulogic_vector(data_width_c-1 downto 0); -- immediate
|
csr_i : in std_ulogic_vector(data_width_c-1 downto 0); -- csr read data
|
|
-- data output --
|
-- data output --
|
cmp_o : out std_ulogic_vector(1 downto 0); -- comparator status
|
cmp_o : out std_ulogic_vector(1 downto 0); -- comparator status
|
add_o : out std_ulogic_vector(data_width_c-1 downto 0); -- OPA + OPB
|
add_o : out std_ulogic_vector(data_width_c-1 downto 0); -- OPA + OPB
|
res_o : out std_ulogic_vector(data_width_c-1 downto 0); -- ALU result
|
res_o : out std_ulogic_vector(data_width_c-1 downto 0); -- ALU result
|
-- co-processor interface --
|
-- co-processor interface --
|
cp_opa_o : out std_ulogic_vector(data_width_c-1 downto 0); -- co-processor operand a
|
|
cp_opb_o : out std_ulogic_vector(data_width_c-1 downto 0); -- co-processor operand b
|
|
cp0_start_o : out std_ulogic; -- trigger co-processor 0
|
cp0_start_o : out std_ulogic; -- trigger co-processor 0
|
cp0_data_i : in std_ulogic_vector(data_width_c-1 downto 0); -- co-processor 0 result
|
cp0_data_i : in std_ulogic_vector(data_width_c-1 downto 0); -- co-processor 0 result
|
cp0_valid_i : in std_ulogic; -- co-processor 0 result valid
|
cp0_valid_i : in std_ulogic; -- co-processor 0 result valid
|
cp1_start_o : out std_ulogic; -- trigger co-processor 1
|
cp1_start_o : out std_ulogic; -- trigger co-processor 1
|
cp1_data_i : in std_ulogic_vector(data_width_c-1 downto 0); -- co-processor 1 result
|
cp1_data_i : in std_ulogic_vector(data_width_c-1 downto 0); -- co-processor 1 result
|
Line 116... |
Line 113... |
|
|
begin
|
begin
|
|
|
-- Operand Mux ----------------------------------------------------------------------------
|
-- Operand Mux ----------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
input_op_mux: process(ctrl_i, csr_i, pc2_i, rs1_i, rs2_i, imm_i)
|
opa <= rs1_i when (ctrl_i(ctrl_alu_opa_mux_c) = '0') else pc2_i; -- operand a (first ALU input operand)
|
begin
|
opb <= rs2_i when (ctrl_i(ctrl_alu_opb_mux_c) = '0') else imm_i; -- operand b (second ALU input operand)
|
-- operand a (first ALU input operand) --
|
opc <= rs2_i when (ctrl_i(ctrl_alu_opc_mux_c) = '0') else imm_i; -- operand c (third ALU input operand for comparison and SUB)
|
case ctrl_i(ctrl_alu_opa_mux_msb_c downto ctrl_alu_opa_mux_lsb_c) is
|
|
when "00" => opa <= rs1_i;
|
|
when "01" => opa <= pc2_i;
|
|
when others => opa <= csr_i;
|
|
end case;
|
|
-- operand b (second ALU input operand) --
|
|
if (ctrl_i(ctrl_alu_opb_mux_c) = '0') then
|
|
opb <= rs2_i;
|
|
else
|
|
opb <= imm_i;
|
|
end if;
|
|
-- operand c (third ALU input operand for comparison and SUB) --
|
|
if (ctrl_i(ctrl_alu_opc_mux_c) = '0') then
|
|
opc <= rs2_i;
|
|
else
|
|
opc <= imm_i;
|
|
end if;
|
|
end process input_op_mux;
|
|
|
|
|
|
-- Comparator Unit ------------------------------------------------------------------------
|
-- Comparator Unit ------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- less than (x < y) --
|
-- less than (x < y) --
|
Line 239... |
Line 218... |
cp1_start_o <= '0'; -- not yet implemented
|
cp1_start_o <= '0'; -- not yet implemented
|
|
|
-- co-processor operation running? --
|
-- co-processor operation running? --
|
cp_ctrl.halt <= cp_ctrl.busy or cp_ctrl.start;
|
cp_ctrl.halt <= cp_ctrl.busy or cp_ctrl.start;
|
|
|
-- co-processor operands --
|
|
cp_opa_o <= opa;
|
|
cp_opb_o <= opb;
|
|
|
|
-- co-processor result --
|
-- co-processor result --
|
cp_res <= cp0_data_i or cp1_data_i; -- only the selcted cp may output data != 0
|
cp_res <= cp0_data_i or cp1_data_i; -- only the selected cp may output data != 0
|
|
|
|
|
-- ALU Function Select --------------------------------------------------------------------
|
-- ALU Function Select --------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
alu_function_mux: process(ctrl_i, opa, opb, add_res, sub_res, cmp_less, shifter.sreg)
|
alu_function_mux: process(ctrl_i, opa, opb, add_res, sub_res, cmp_less, shifter.sreg)
|
begin
|
begin
|
case ctrl_i(ctrl_alu_cmd2_c downto ctrl_alu_cmd0_c) is
|
case ctrl_i(ctrl_alu_cmd2_c downto ctrl_alu_cmd0_c) is
|
when alu_cmd_xor_c => alu_res <= opa xor opb;
|
when alu_cmd_xor_c => alu_res <= opa xor opb;
|
when alu_cmd_or_c => alu_res <= opa or opb;
|
when alu_cmd_or_c => alu_res <= opa or opb;
|
when alu_cmd_and_c => alu_res <= opa and opb;
|
when alu_cmd_and_c => alu_res <= opa and opb;
|
when alu_cmd_bclr_c => alu_res <= opa and (not opb);
|
when alu_cmd_movb_c => alu_res <= opb;
|
when alu_cmd_sub_c => alu_res <= sub_res;
|
when alu_cmd_sub_c => alu_res <= sub_res;
|
when alu_cmd_add_c => alu_res <= add_res;
|
when alu_cmd_add_c => alu_res <= add_res;
|
when alu_cmd_shift_c => alu_res <= shifter.sreg;
|
when alu_cmd_shift_c => alu_res <= shifter.sreg;
|
when alu_cmd_slt_c => alu_res <= (others => '0'); alu_res(0) <= cmp_less;
|
when alu_cmd_slt_c => alu_res <= (others => '0'); alu_res(0) <= cmp_less;
|
when others => alu_res <= (others => '0'); -- undefined
|
when others => alu_res <= (others => '0'); -- undefined
|