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

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [rtl/] [core/] [neorv32_cpu_regfile.vhd] - Diff between revs 62 and 65

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

Rev 62 Rev 65
Line 2... Line 2...
-- # << NEORV32 - CPU General Purpose Data Register File >>                                        #
-- # << NEORV32 - CPU General Purpose Data Register File >>                                        #
-- # ********************************************************************************************* #
-- # ********************************************************************************************* #
-- # General purpose data register file. 32 entries (= 1024 bit) for normal mode (RV32I),          #
-- # General purpose data register file. 32 entries (= 1024 bit) for normal mode (RV32I),          #
-- # 16 entries (= 512 bit) for embedded mode (RV32E) when RISC-V "E" extension is enabled.        #
-- # 16 entries (= 512 bit) for embedded mode (RV32E) when RISC-V "E" extension is enabled.        #
-- #                                                                                               #
-- #                                                                                               #
-- # Register zero (r0/x0) is a "normal" physical reg that has to be initialized to zero by the    #
-- # Register zero (r0/x0) is a "normal" physical register that has to be initialized to zero by   #
-- # CPU control system. For normal operations register zero cannot be written.                    #
-- # the early boot code. Register zero is always set to zero when written.                        #
-- #                                                                                               #
-- #                                                                                               #
-- # The register file uses synchronous read accesses and a *single* (multiplexed) address port    #
-- # The register file uses synchronous read accesses and a *single* (multiplexed) address port    #
-- # for writing and reading rs1 and a single read-only port for rs2. Therefore, the whole         #
-- # for writing and reading rd/rs1 and a single read-only port for rs2. Therefore, the whole      #
-- # register file can be mapped to a single true dual-port block RAM.                             #
-- # register file can be mapped to a single true-dual-port block RAM.                             #
-- # ********************************************************************************************* #
-- # ********************************************************************************************* #
-- # BSD 3-Clause License                                                                          #
-- # BSD 3-Clause License                                                                          #
-- #                                                                                               #
-- #                                                                                               #
-- # Copyright (c) 2021, Stephan Nolting. All rights reserved.                                     #
-- # Copyright (c) 2021, Stephan Nolting. All rights reserved.                                     #
-- #                                                                                               #
-- #                                                                                               #
Line 60... Line 60...
    -- data input --
    -- data input --
    mem_i  : in  std_ulogic_vector(data_width_c-1 downto 0); -- memory read data
    mem_i  : in  std_ulogic_vector(data_width_c-1 downto 0); -- memory read data
    alu_i  : in  std_ulogic_vector(data_width_c-1 downto 0); -- ALU result
    alu_i  : in  std_ulogic_vector(data_width_c-1 downto 0); -- ALU result
    -- data output --
    -- data output --
    rs1_o  : out std_ulogic_vector(data_width_c-1 downto 0); -- operand 1
    rs1_o  : out std_ulogic_vector(data_width_c-1 downto 0); -- operand 1
    rs2_o  : out std_ulogic_vector(data_width_c-1 downto 0); -- operand 2
    rs2_o  : out std_ulogic_vector(data_width_c-1 downto 0)  -- operand 2
    cmp_o  : out std_ulogic_vector(1 downto 0) -- comparator status
 
  );
  );
end neorv32_cpu_regfile;
end neorv32_cpu_regfile;
 
 
architecture neorv32_cpu_regfile_rtl of neorv32_cpu_regfile is
architecture neorv32_cpu_regfile_rtl of neorv32_cpu_regfile is
 
 
Line 79... Line 78...
  signal dst_addr     : std_ulogic_vector(4 downto 0); -- destination address
  signal dst_addr     : std_ulogic_vector(4 downto 0); -- destination address
  signal opa_addr     : std_ulogic_vector(4 downto 0); -- rs1/dst address
  signal opa_addr     : std_ulogic_vector(4 downto 0); -- rs1/dst address
  signal opb_addr     : std_ulogic_vector(4 downto 0); -- rs2 address
  signal opb_addr     : std_ulogic_vector(4 downto 0); -- rs2 address
  signal rs1, rs2     : std_ulogic_vector(data_width_c-1 downto 0); -- read data
  signal rs1, rs2     : std_ulogic_vector(data_width_c-1 downto 0); -- read data
 
 
  -- comparator --
 
  signal cmp_opx : std_ulogic_vector(data_width_c downto 0);
 
  signal cmp_opy : std_ulogic_vector(data_width_c downto 0);
 
 
 
begin
begin
 
 
  -- Data Input Mux -------------------------------------------------------------------------
  -- Data Input Mux -------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  input_mux: process(rd_is_r0, ctrl_i, alu_i, mem_i)
  input_mux: process(rd_is_r0, ctrl_i, alu_i, mem_i)
Line 135... Line 130...
  -- data output --
  -- data output --
  rs1_o <= rs1;
  rs1_o <= rs1;
  rs2_o <= rs2;
  rs2_o <= rs2;
 
 
 
 
  -- Comparator Unit (for conditional branches) ---------------------------------------------
 
  -- -------------------------------------------------------------------------------------------
 
  cmp_opx <= (rs1(rs1'left) and (not ctrl_i(ctrl_alu_unsigned_c))) & rs1;
 
  cmp_opy <= (rs2(rs2'left) and (not ctrl_i(ctrl_alu_unsigned_c))) & rs2;
 
 
 
  cmp_o(cmp_equal_c) <= '1' when (rs1 = rs2) else '0';
 
  cmp_o(cmp_less_c)  <= '1' when (signed(cmp_opx) < signed(cmp_opy)) else '0';
 
 
 
 
 
end neorv32_cpu_regfile_rtl;
end neorv32_cpu_regfile_rtl;
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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