OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [rtl/] [core/] [neorv32_cpu_alu.vhd] - Diff between revs 63 and 65

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 63 Rev 65
Line 61... Line 61...
    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
    csr_i       : in  std_ulogic_vector(data_width_c-1 downto 0); -- CSR read data
    cmp_i       : in  std_ulogic_vector(1 downto 0); -- comparator status
 
    -- data output --
    -- data output --
 
    cmp_o       : out std_ulogic_vector(1 downto 0); -- comparator status
    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
    add_o       : out std_ulogic_vector(data_width_c-1 downto 0); -- address computation result
    add_o       : out std_ulogic_vector(data_width_c-1 downto 0); -- address computation result
    fpu_flags_o : out std_ulogic_vector(4 downto 0); -- FPU exception flags
    fpu_flags_o : out std_ulogic_vector(4 downto 0); -- FPU exception flags
    -- status --
    -- status --
    idone_o     : out std_ulogic -- iterative processing units done?
    idone_o     : out std_ulogic -- iterative processing units done?
  );
  );
end neorv32_cpu_alu;
end neorv32_cpu_alu;
 
 
architecture neorv32_cpu_cpu_rtl of neorv32_cpu_alu is
architecture neorv32_cpu_cpu_rtl of neorv32_cpu_alu is
 
 
 
  -- comparator --
 
  signal cmp_opx : std_ulogic_vector(data_width_c downto 0);
 
  signal cmp_opy : std_ulogic_vector(data_width_c downto 0);
 
  signal cmp     : std_ulogic_vector(1 downto 0); -- comparator status
 
 
  -- operands --
  -- operands --
  signal opa, opb : std_ulogic_vector(data_width_c-1 downto 0);
  signal opa, opb : std_ulogic_vector(data_width_c-1 downto 0);
 
 
  -- results --
  -- results --
  signal addsub_res : std_ulogic_vector(data_width_c downto 0);
  signal addsub_res : std_ulogic_vector(data_width_c downto 0);
Line 100... Line 105...
  signal cp_valid  : std_ulogic_vector(3 downto 0); -- co-processor i done
  signal cp_valid  : std_ulogic_vector(3 downto 0); -- co-processor i done
  signal cp_result : cp_data_if_t; -- co-processor result
  signal cp_result : cp_data_if_t; -- co-processor result
 
 
begin
begin
 
 
  -- Operand Mux ----------------------------------------------------------------------------
  -- Comparator Unit (for conditional branches) ---------------------------------------------
 
  -- -------------------------------------------------------------------------------------------
 
  cmp_opx <= (rs1_i(rs1_i'left) and (not ctrl_i(ctrl_alu_unsigned_c))) & rs1_i;
 
  cmp_opy <= (rs2_i(rs2_i'left) and (not ctrl_i(ctrl_alu_unsigned_c))) & rs2_i;
 
 
 
  cmp(cmp_equal_c) <= '1' when (rs1_i = rs2_i) else '0';
 
  cmp(cmp_less_c)  <= '1' when (signed(cmp_opx) < signed(cmp_opy)) else '0';
 
  cmp_o            <= cmp;
 
 
 
 
 
  -- ALU Input Operand Mux ------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  opa <= pc2_i when (ctrl_i(ctrl_alu_opa_mux_c) = '1') else rs1_i; -- operand a (first ALU input operand), only required for arithmetic ops
  opa <= pc2_i when (ctrl_i(ctrl_alu_opa_mux_c) = '1') else rs1_i; -- operand a (first ALU input operand), only required for arithmetic ops
  opb <= imm_i when (ctrl_i(ctrl_alu_opb_mux_c) = '1') else rs2_i; -- operand b (second ALU input operand)
  opb <= imm_i when (ctrl_i(ctrl_alu_opb_mux_c) = '1') else rs2_i; -- operand b (second ALU input operand)
 
 
 
 
Line 277... Line 292...
    cp_result(1) <= (others => '0');
    cp_result(1) <= (others => '0');
    cp_valid(1)  <= cp_start(1); -- to make sure CPU does not get stalled if there is an accidental access
    cp_valid(1)  <= cp_start(1); -- to make sure CPU does not get stalled if there is an accidental access
  end generate;
  end generate;
 
 
 
 
  -- Co-Processor 2: Bit-Manipulation Unit ('Zbb' Extension) --------------------------------
  -- Co-Processor 2: Bit-Manipulation Unit ('B'/'Zbb' Extension) ----------------------------
  -- -------------------------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  neorv32_cpu_cp_bitmanip_inst_true:
  neorv32_cpu_cp_bitmanip_inst_true:
  if (CPU_EXTENSION_RISCV_Zbb = true) generate
  if (CPU_EXTENSION_RISCV_Zbb = true) generate
    neorv32_cpu_cp_bitmanip_inst: neorv32_cpu_cp_bitmanip
    neorv32_cpu_cp_bitmanip_inst: neorv32_cpu_cp_bitmanip
    generic map (
    generic map (
Line 292... Line 307...
      clk_i    => clk_i,        -- global clock, rising edge
      clk_i    => clk_i,        -- global clock, rising edge
      rstn_i   => rstn_i,       -- global reset, low-active, async
      rstn_i   => rstn_i,       -- global reset, low-active, async
      ctrl_i   => ctrl_i,       -- main control bus
      ctrl_i   => ctrl_i,       -- main control bus
      start_i  => cp_start(2),  -- trigger operation
      start_i  => cp_start(2),  -- trigger operation
      -- data input --
      -- data input --
      cmp_i    => cmp_i,        -- comparator status
      cmp_i    => cmp,          -- comparator status
      rs1_i    => rs1_i,        -- rf source 1
      rs1_i    => rs1_i,        -- rf source 1
      rs2_i    => rs2_i,        -- rf source 2
      rs2_i    => rs2_i,        -- rf source 2
      -- result and status --
      -- result and status --
      res_o    => cp_result(2), -- operation result
      res_o    => cp_result(2), -- operation result
      valid_o  => cp_valid(2)   -- data output valid
      valid_o  => cp_valid(2)   -- data output valid
Line 320... Line 335...
      clk_i    => clk_i,        -- global clock, rising edge
      clk_i    => clk_i,        -- global clock, rising edge
      rstn_i   => rstn_i,       -- global reset, low-active, async
      rstn_i   => rstn_i,       -- global reset, low-active, async
      ctrl_i   => ctrl_i,       -- main control bus
      ctrl_i   => ctrl_i,       -- main control bus
      start_i  => cp_start(3),  -- trigger operation
      start_i  => cp_start(3),  -- trigger operation
      -- data input --
      -- data input --
      cmp_i    => cmp_i,        -- comparator status
      cmp_i    => cmp,          -- comparator status
      rs1_i    => rs1_i,        -- rf source 1
      rs1_i    => rs1_i,        -- rf source 1
      rs2_i    => rs2_i,        -- rf source 2
      rs2_i    => rs2_i,        -- rf source 2
      -- result and status --
      -- result and status --
      res_o    => cp_result(3), -- operation result
      res_o    => cp_result(3), -- operation result
      fflags_o => fpu_flags_o,  -- exception flags
      fflags_o => fpu_flags_o,  -- exception flags

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.