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

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [rtl/] [core/] [neorv32_cpu.vhd] - Diff between revs 3 and 6

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

Rev 3 Rev 6
Line 51... Line 51...
  generic (
  generic (
    -- General --
    -- General --
    CLOCK_FREQUENCY           : natural := 0; -- clock frequency of clk_i in Hz
    CLOCK_FREQUENCY           : natural := 0; -- clock frequency of clk_i in Hz
    HART_ID                   : std_ulogic_vector(31 downto 0) := x"00000000"; -- custom hardware thread ID
    HART_ID                   : std_ulogic_vector(31 downto 0) := x"00000000"; -- custom hardware thread ID
    BOOTLOADER_USE            : boolean := true;   -- implement processor-internal bootloader?
    BOOTLOADER_USE            : boolean := true;   -- implement processor-internal bootloader?
 
    CSR_COUNTERS_USE          : boolean := true;   -- implement RISC-V perf. counters ([m]instret[h], [m]cycle[h], time[h])?
    -- RISC-V CPU Extensions --
    -- RISC-V CPU Extensions --
    CPU_EXTENSION_RISCV_C     : boolean := false;  -- implement compressed extension?
    CPU_EXTENSION_RISCV_C     : boolean := false;  -- implement compressed extension?
    CPU_EXTENSION_RISCV_E     : boolean := false;  -- implement embedded RF extension?
    CPU_EXTENSION_RISCV_E     : boolean := false;  -- implement embedded RF extension?
    CPU_EXTENSION_RISCV_M     : boolean := false;  -- implement muld/div extension?
    CPU_EXTENSION_RISCV_M     : boolean := false;  -- implement muld/div extension?
    CPU_EXTENSION_RISCV_Zicsr : boolean := true;   -- implement CSR system?
    CPU_EXTENSION_RISCV_Zicsr : boolean := true;   -- implement CSR system?
Line 107... Line 108...
 
 
  -- local signals --
  -- local signals --
  signal ctrl        : std_ulogic_vector(ctrl_width_c-1 downto 0); -- main control bus
  signal ctrl        : std_ulogic_vector(ctrl_width_c-1 downto 0); -- main control bus
  signal alu_cmp     : std_ulogic_vector(1 downto 0); -- alu comparator result
  signal alu_cmp     : std_ulogic_vector(1 downto 0); -- alu comparator result
  signal imm         : std_ulogic_vector(data_width_c-1 downto 0); -- immediate
  signal imm         : std_ulogic_vector(data_width_c-1 downto 0); -- immediate
  signal pc          : std_ulogic_vector(data_width_c-1 downto 0); -- current program counter
 
  signal pc_delayed  : std_ulogic_vector(data_width_c-1 downto 0); -- delayed program counter
 
  signal instr       : std_ulogic_vector(data_width_c-1 downto 0); -- new instruction
  signal instr       : std_ulogic_vector(data_width_c-1 downto 0); -- new instruction
  signal rs1, rs2    : std_ulogic_vector(data_width_c-1 downto 0); -- source registers
  signal rs1, rs2    : std_ulogic_vector(data_width_c-1 downto 0); -- source registers
  signal alu_res     : std_ulogic_vector(data_width_c-1 downto 0); -- alu result
  signal alu_res     : std_ulogic_vector(data_width_c-1 downto 0); -- alu result
  signal alu_add     : std_ulogic_vector(data_width_c-1 downto 0); -- alu adder result
  signal alu_add     : std_ulogic_vector(data_width_c-1 downto 0); -- alu adder result
  signal rdata       : std_ulogic_vector(data_width_c-1 downto 0); -- memory read data
  signal rdata       : std_ulogic_vector(data_width_c-1 downto 0); -- memory read data
Line 125... Line 124...
  signal ma_store    : std_ulogic; -- misaligned store data address
  signal ma_store    : std_ulogic; -- misaligned store data address
  signal be_instr    : std_ulogic; -- bus error on instruction access
  signal be_instr    : std_ulogic; -- bus error on instruction access
  signal be_load     : std_ulogic; -- bus error on load data access
  signal be_load     : std_ulogic; -- bus error on load data access
  signal be_store    : std_ulogic; -- bus error on store data access
  signal be_store    : std_ulogic; -- bus error on store data access
  signal bus_exc_ack : std_ulogic; -- bus exception error acknowledge
  signal bus_exc_ack : std_ulogic; -- bus exception error acknowledge
 
  signal bus_busy    : std_ulogic; -- bus unit is busy
 
  signal fetch_pc    : std_ulogic_vector(data_width_c-1 downto 0); -- pc for instruction fetch
 
  signal curr_pc     : std_ulogic_vector(data_width_c-1 downto 0); -- current pc (for current executed instruction)
 
  signal next_pc     : std_ulogic_vector(data_width_c-1 downto 0); -- next pc (for current executed instruction)
 
 
  -- co-processor interface --
  -- co-processor interface --
  signal cp0_data,  cp1_data  : std_ulogic_vector(data_width_c-1 downto 0);
  signal cp0_data,  cp1_data  : std_ulogic_vector(data_width_c-1 downto 0);
  signal cp0_valid, cp1_valid : std_ulogic;
  signal cp0_valid, cp1_valid : std_ulogic;
 
 
Line 140... Line 143...
  generic map (
  generic map (
    -- General --
    -- General --
    CLOCK_FREQUENCY           => CLOCK_FREQUENCY, -- clock frequency of clk_i in Hz
    CLOCK_FREQUENCY           => CLOCK_FREQUENCY, -- clock frequency of clk_i in Hz
    HART_ID                   => HART_ID,         -- custom hardware thread ID
    HART_ID                   => HART_ID,         -- custom hardware thread ID
    BOOTLOADER_USE            => BOOTLOADER_USE,  -- implement processor-internal bootloader?
    BOOTLOADER_USE            => BOOTLOADER_USE,  -- implement processor-internal bootloader?
 
    CSR_COUNTERS_USE          => CSR_COUNTERS_USE, -- implement RISC-V perf. counters ([m]instret[h], [m]cycle[h], time[h])?
    -- RISC-V CPU Extensions --
    -- RISC-V CPU Extensions --
    CPU_EXTENSION_RISCV_C     => CPU_EXTENSION_RISCV_C,     -- implement compressed extension?
    CPU_EXTENSION_RISCV_C     => CPU_EXTENSION_RISCV_C,     -- implement compressed extension?
    CPU_EXTENSION_RISCV_E     => CPU_EXTENSION_RISCV_E,     -- implement embedded RF extension?
    CPU_EXTENSION_RISCV_E     => CPU_EXTENSION_RISCV_E,     -- implement embedded RF extension?
    CPU_EXTENSION_RISCV_M     => CPU_EXTENSION_RISCV_M,     -- implement muld/div extension?
    CPU_EXTENSION_RISCV_M     => CPU_EXTENSION_RISCV_M,     -- implement muld/div extension?
    CPU_EXTENSION_RISCV_Zicsr => CPU_EXTENSION_RISCV_Zicsr, -- implement CSR system?
    CPU_EXTENSION_RISCV_Zicsr => CPU_EXTENSION_RISCV_Zicsr, -- implement CSR system?
Line 184... Line 188...
    instr_i       => instr,       -- instruction
    instr_i       => instr,       -- instruction
    cmp_i         => alu_cmp,     -- comparator status
    cmp_i         => alu_cmp,     -- comparator status
    alu_add_i     => alu_add,     -- ALU.add result
    alu_add_i     => alu_add,     -- ALU.add result
    -- data output --
    -- data output --
    imm_o         => imm,         -- immediate
    imm_o         => imm,         -- immediate
    pc_o          => pc,          -- current PC
    fetch_pc_o    => fetch_pc,    -- PC for instruction fetch
    alu_pc_o      => pc_delayed,  -- delayed PC for ALU
    curr_pc_o     => curr_pc,     -- current PC (corresponding to current instruction)
 
    next_pc_o     => next_pc,     -- next PC (corresponding to current instruction)
    -- csr interface --
    -- csr interface --
    csr_wdata_i   => alu_res,     -- CSR write data
    csr_wdata_i   => alu_res,     -- CSR write data
    csr_rdata_o   => csr_rdata,   -- CSR read data
    csr_rdata_o   => csr_rdata,   -- CSR read data
    -- external interrupt --
    -- external interrupt --
    clic_irq_i    => clic_irq_i,  -- CLIC interrupt request
    clic_irq_i    => clic_irq_i,  -- CLIC interrupt request
Line 200... Line 205...
    ma_load_i     => ma_load,     -- misaligned load data address
    ma_load_i     => ma_load,     -- misaligned load data address
    ma_store_i    => ma_store,    -- misaligned store data address
    ma_store_i    => ma_store,    -- misaligned store data address
    be_instr_i    => be_instr,    -- bus error on instruction access
    be_instr_i    => be_instr,    -- bus error on instruction access
    be_load_i     => be_load,     -- bus error on load data access
    be_load_i     => be_load,     -- bus error on load data access
    be_store_i    => be_store,    -- bus error on store data access
    be_store_i    => be_store,    -- bus error on store data access
    bus_exc_ack_o => bus_exc_ack  -- bus exception error acknowledge
    bus_exc_ack_o => bus_exc_ack, -- bus exception error acknowledge
 
    bus_busy_i    => bus_busy     -- bus unit is busy
  );
  );
 
 
 
 
  -- Register File --------------------------------------------------------------------------
  -- Register File --------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
Line 218... Line 224...
    ctrl_i => ctrl,               -- main control bus
    ctrl_i => ctrl,               -- main control bus
    -- data input --
    -- data input --
    mem_i  => rdata,              -- memory read data
    mem_i  => rdata,              -- memory read data
    alu_i  => alu_res,            -- ALU result
    alu_i  => alu_res,            -- ALU result
    csr_i  => csr_rdata,          -- CSR read data
    csr_i  => csr_rdata,          -- CSR read data
    pc_i   => pc,                 -- current pc
    pc_i   => next_pc,            -- next pc
    -- data output --
    -- data output --
    rs1_o  => rs1,                -- operand 1
    rs1_o  => rs1,                -- operand 1
    rs2_o  => rs2                 -- operand 2
    rs2_o  => rs2                 -- operand 2
  );
  );
 
 
 
 
  -- ALU ------------------------------------------------------------------------------------
  -- ALU ------------------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  neorv32_cpu_alu_inst: neorv32_cpu_alu
  neorv32_cpu_alu_inst: neorv32_cpu_alu
  generic map (
 
    CPU_EXTENSION_RISCV_C => CPU_EXTENSION_RISCV_C, -- implement compressed extension?
 
    CPU_EXTENSION_RISCV_M => CPU_EXTENSION_RISCV_M  -- implement mul/div extension?
 
  )
 
  port map (
  port map (
    -- global control --
    -- global control --
    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,          -- main control bus
    ctrl_i      => ctrl,          -- main control bus
    -- data input --
    -- data input --
    rs1_i       => rs1,           -- rf source 1
    rs1_i       => rs1,           -- rf source 1
    rs2_i       => rs2,           -- rf source 2
    rs2_i       => rs2,           -- rf source 2
    pc_i        => pc,            -- current PC
    pc2_i       => curr_pc,       -- delayed PC
    pc2_i       => pc_delayed,    -- delayed PC
 
    imm_i       => imm,           -- immediate
    imm_i       => imm,           -- immediate
    csr_i       => csr_rdata,     -- csr read data
    csr_i       => csr_rdata,     -- csr read data
    -- data output --
    -- data output --
    cmp_o       => alu_cmp,       -- comparator status
    cmp_o       => alu_cmp,       -- comparator status
    add_o       => alu_add,       -- OPA + OPB
    add_o       => alu_add,       -- OPA + OPB
Line 294... Line 295...
 
 
  -- Bus Unit -------------------------------------------------------------------------------
  -- Bus Unit -------------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  neorv32_cpu_bus_inst: neorv32_cpu_bus
  neorv32_cpu_bus_inst: neorv32_cpu_bus
  generic map (
  generic map (
    CPU_EXTENSION_RISCV_C => CPU_EXTENSION_RISCV_C, -- implement compressed extension?
 
    MEM_EXT_TIMEOUT       => MEM_EXT_TIMEOUT        -- cycles after which a valid bus access will timeout
    MEM_EXT_TIMEOUT       => MEM_EXT_TIMEOUT        -- cycles after which a valid bus access will timeout
  )
  )
  port map (
  port map (
    -- global control --
    -- global control --
    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,          -- main control bus
    ctrl_i      => ctrl,          -- main control bus
    -- data input --
    -- data input --
    wdata_i     => rs2,           -- write data
    wdata_i     => rs2,           -- write data
    pc_i        => pc,            -- current PC
    pc_i        => fetch_pc,      -- current PC for instruction fetch
    alu_i       => alu_res,       -- ALU result
    alu_i       => alu_res,       -- ALU result
    -- data output --
    -- data output --
    instr_o     => instr,         -- instruction
    instr_o     => instr,         -- instruction
    rdata_o     => rdata,         -- read data
    rdata_o     => rdata,         -- read data
    -- status --
    -- status --
Line 318... Line 318...
    ma_store_o  => ma_store,      -- misaligned store data address
    ma_store_o  => ma_store,      -- misaligned store data address
    be_instr_o  => be_instr,      -- bus error on instruction access
    be_instr_o  => be_instr,      -- bus error on instruction access
    be_load_o   => be_load,       -- bus error on load data access
    be_load_o   => be_load,       -- bus error on load data access
    be_store_o  => be_store,      -- bus error on store data access
    be_store_o  => be_store,      -- bus error on store data access
    bus_wait_o  => bus_wait,      -- wait for bus operation to finish
    bus_wait_o  => bus_wait,      -- wait for bus operation to finish
 
    bus_busy_o  => bus_busy,      -- bus unit is busy
    exc_ack_i   => bus_exc_ack,   -- exception controller ACK
    exc_ack_i   => bus_exc_ack,   -- exception controller ACK
    -- bus system --
    -- bus system --
    bus_addr_o  => bus_addr_o,    -- bus access address
    bus_addr_o  => bus_addr_o,    -- bus access address
    bus_rdata_i => bus_rdata_i,   -- bus read data
    bus_rdata_i => bus_rdata_i,   -- bus read data
    bus_wdata_o => bus_wdata_o,   -- bus write data
    bus_wdata_o => bus_wdata_o,   -- bus write data

powered by: WebSVN 2.1.0

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