Skip to content

Commit

Permalink
[rtl] minor edits (#599)
Browse files Browse the repository at this point in the history
  • Loading branch information
stnolting authored Apr 24, 2023
2 parents 16bf332 + 5e93502 commit 16ba058
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ mimpid = 0x01080200 => Version 01.08.02.00 => v1.8.2

| Date (*dd.mm.yyyy*) | Version | Comment |
|:-------------------:|:-------:|:--------|
| 24.04.2023 | 1.8.4.2 | minor rtl edits; shorten critical path of d-cache setup; [#599](https://github.com/stnolting/neorv32/pull/599) |
| 22.04.2023 | 1.8.4.1 | :sparkles: add optional **direct memory access controller (DMA)**; [#593](https://github.com/stnolting/neorv32/pull/593) |
| 21.04.2023 | [**:rocket:1.8.4**](https://github.com/stnolting/neorv32/releases/tag/v1.8.4) | **New release** |
| 21.04.2023 | 1.8.3.9 | :bug: fix timeout bug in **FPU** normalizer; [#592](https://github.com/stnolting/neorv32/pull/592) |
Expand Down
9 changes: 5 additions & 4 deletions rtl/core/neorv32_busswitch.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,12 @@ begin
-- ------------------------------------------------------------
arbiter.bus_sel <= '0'; -- access from port A
if (p_bus_err_i = '1') or (p_bus_ack_i = '1') then
if (cb_req_pending = '1') or (cb_req_current = '1') then -- any request from B?
arbiter.state_nxt <= B_RETIRE;
else
-- [COMMENT NOTE] Direct return to IDLE to further promote port A access requests.
-- if (cb_req_pending = '1') or (cb_req_current = '1') then -- any request from B?
-- arbiter.state_nxt <= B_RETIRE;
-- else
arbiter.state_nxt <= IDLE;
end if;
-- end if;
end if;

when A_RETIRE => -- retire port A pending access
Expand Down
4 changes: 2 additions & 2 deletions rtl/core/neorv32_cpu_control.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ begin

when BRANCH => -- update PC on taken branches and jumps
-- ------------------------------------------------------------
ctrl_nxt.rf_mux <= rf_mux_npc_c; -- return addree = next PC
ctrl_nxt.rf_mux <= rf_mux_npc_c; -- return address = next PC
execute_engine.pc_mux_sel <= '1'; -- PC <= alu.add = branch/jump destination
execute_engine.pc_we <= '1'; -- update PC with destination; will be overridden again in DISPATCH if branch not taken
if (execute_engine.ir(instr_opcode_lsb_c+2) = '1') or (execute_engine.branch_taken = '1') then -- JAL/JALR or taken branch
Expand Down Expand Up @@ -2428,7 +2428,7 @@ begin
-- base counters --
cnt.inc(0) <= cnt_event(hpmcnt_event_cy_c) and (not csr.mcountinhibit(0)) and (not debug_ctrl.running); -- cycle
cnt.inc(2) <= cnt_event(hpmcnt_event_ir_c) and (not csr.mcountinhibit(2)) and (not debug_ctrl.running); -- instret
-- hpm counters --
-- HPM counters --
for i in 0 to HPM_NUM_CNTS-1 loop
cnt.inc(3+i) <= or_reduce_f(cnt_event and hpmevent.cfg(i)) and (not csr.mcountinhibit(3+i)) and (not debug_ctrl.running);
end loop;
Expand Down
5 changes: 2 additions & 3 deletions rtl/core/neorv32_dcache.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,8 @@ begin
else -- write access
if (cache.hit = '1') then -- data word in cache -> also write to cache
ctrl.state_nxt <= S_RESYNC_WRITE;
else -- just write-through
bus_we_o <= ctrl.we_buf;
ctrl.state_nxt <= S_DIRECT_WAIT;
else -- write-through
ctrl.state_nxt <= S_DIRECT_REQ;
end if;
end if;

Expand Down
7 changes: 3 additions & 4 deletions rtl/core/neorv32_dma.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,9 @@ begin
address_inc: process(config.qsel)
begin
case config.qsel is
when qsel_b2b_c => engine.src_add <= to_unsigned(1, 32); engine.dst_add <= to_unsigned(1, 32); -- byte -> byte
when qsel_b2uw_c => engine.src_add <= to_unsigned(1, 32); engine.dst_add <= to_unsigned(4, 32); -- byte -> word
when qsel_b2sw_c => engine.src_add <= to_unsigned(1, 32); engine.dst_add <= to_unsigned(4, 32); -- byte -> word
when others => engine.src_add <= to_unsigned(4, 32); engine.dst_add <= to_unsigned(4, 32); -- word -> word
when qsel_b2b_c => engine.src_add <= to_unsigned(1, 32); engine.dst_add <= to_unsigned(1, 32); -- byte -> byte
when qsel_w2w_c => engine.src_add <= to_unsigned(4, 32); engine.dst_add <= to_unsigned(4, 32); -- word -> word
when others => engine.src_add <= to_unsigned(1, 32); engine.dst_add <= to_unsigned(4, 32); -- byte -> word
end case;
end process address_inc;

Expand Down
31 changes: 15 additions & 16 deletions rtl/core/neorv32_package.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ package neorv32_package is

-- Architecture Constants -----------------------------------------------------------------
-- -------------------------------------------------------------------------------------------
constant hw_version_c : std_ulogic_vector(31 downto 0) := x"01080401"; -- hardware version
constant hw_version_c : std_ulogic_vector(31 downto 0) := x"01080402"; -- hardware version
constant archid_c : natural := 19; -- official RISC-V architecture ID
constant XLEN : natural := 32; -- native data path width, do not change!

Expand Down Expand Up @@ -384,23 +384,24 @@ package neorv32_package is
-- RISC-V Opcodes -------------------------------------------------------------------------
-- -------------------------------------------------------------------------------------------
-- alu --
constant opcode_alui_c : std_ulogic_vector(6 downto 0) := "0010011"; -- ALU operation with immediate (operation via funct3 and funct7)
constant opcode_alu_c : std_ulogic_vector(6 downto 0) := "0110011"; -- ALU operation (operation via funct3 and funct7)
constant opcode_alui_c : std_ulogic_vector(6 downto 0) := "0010011"; -- ALU operation with immediate
constant opcode_alu_c : std_ulogic_vector(6 downto 0) := "0110011"; -- ALU operation
constant opcode_lui_c : std_ulogic_vector(6 downto 0) := "0110111"; -- load upper immediate
constant opcode_auipc_c : std_ulogic_vector(6 downto 0) := "0010111"; -- add upper immediate to PC
-- control flow --
constant opcode_jal_c : std_ulogic_vector(6 downto 0) := "1101111"; -- jump and link
constant opcode_jalr_c : std_ulogic_vector(6 downto 0) := "1100111"; -- jump and link with register
constant opcode_branch_c : std_ulogic_vector(6 downto 0) := "1100011"; -- branch (condition set via funct3)
constant opcode_branch_c : std_ulogic_vector(6 downto 0) := "1100011"; -- branch
-- memory access --
constant opcode_load_c : std_ulogic_vector(6 downto 0) := "0000011"; -- load (data type via funct3)
constant opcode_store_c : std_ulogic_vector(6 downto 0) := "0100011"; -- store (data type via funct3)
-- sync/system/csr --
constant opcode_load_c : std_ulogic_vector(6 downto 0) := "0000011"; -- load
constant opcode_store_c : std_ulogic_vector(6 downto 0) := "0100011"; -- store
constant opcode_amo_c : std_ulogic_vector(6 downto 0) := "0101111"; -- atomic memory access
constant opcode_fence_c : std_ulogic_vector(6 downto 0) := "0001111"; -- fence / fence.i
constant opcode_system_c : std_ulogic_vector(6 downto 0) := "1110011"; -- system/csr access (type via funct3)
-- system/csr --
constant opcode_system_c : std_ulogic_vector(6 downto 0) := "1110011"; -- system/csr access
-- floating point operations --
constant opcode_fop_c : std_ulogic_vector(6 downto 0) := "1010011"; -- dual/single operand instruction
-- official *custom* RISC-V opcodes - free for custom instructions --
-- official custom RISC-V opcodes - free for custom instructions --
constant opcode_cust0_c : std_ulogic_vector(6 downto 0) := "0001011"; -- custom-0
constant opcode_cust1_c : std_ulogic_vector(6 downto 0) := "0101011"; -- custom-1
constant opcode_cust2_c : std_ulogic_vector(6 downto 0) := "1011011"; -- custom-2
Expand All @@ -419,14 +420,12 @@ package neorv32_package is
constant funct3_lb_c : std_ulogic_vector(2 downto 0) := "000"; -- load byte
constant funct3_lh_c : std_ulogic_vector(2 downto 0) := "001"; -- load half word
constant funct3_lw_c : std_ulogic_vector(2 downto 0) := "010"; -- load word
constant funct3_ld_c : std_ulogic_vector(2 downto 0) := "011"; -- load half word (unsigned, rv64-only)
constant funct3_lbu_c : std_ulogic_vector(2 downto 0) := "100"; -- load byte (unsigned)
constant funct3_lhu_c : std_ulogic_vector(2 downto 0) := "101"; -- load half word (unsigned)
constant funct3_lwu_c : std_ulogic_vector(2 downto 0) := "110"; -- load word (unsigned, rv64-only)
constant funct3_lwu_c : std_ulogic_vector(2 downto 0) := "110"; -- load word (unsigned)
constant funct3_sb_c : std_ulogic_vector(2 downto 0) := "000"; -- store byte
constant funct3_sh_c : std_ulogic_vector(2 downto 0) := "001"; -- store half word
constant funct3_sw_c : std_ulogic_vector(2 downto 0) := "010"; -- store word
constant funct3_sd_c : std_ulogic_vector(2 downto 0) := "011"; -- store double-word (rv64-only)
-- alu --
constant funct3_subadd_c : std_ulogic_vector(2 downto 0) := "000"; -- sub/add via funct7
constant funct3_sll_c : std_ulogic_vector(2 downto 0) := "001"; -- shift logical left
Expand All @@ -439,12 +438,12 @@ package neorv32_package is
-- system/csr --
constant funct3_env_c : std_ulogic_vector(2 downto 0) := "000"; -- ecall, ebreak, mret, wfi, ...
constant funct3_csrrw_c : std_ulogic_vector(2 downto 0) := "001"; -- csr r/w
constant funct3_csrrs_c : std_ulogic_vector(2 downto 0) := "010"; -- csr read & set bit
constant funct3_csrrc_c : std_ulogic_vector(2 downto 0) := "011"; -- csr read & clear bit
constant funct3_csrrs_c : std_ulogic_vector(2 downto 0) := "010"; -- csr read & set
constant funct3_csrrc_c : std_ulogic_vector(2 downto 0) := "011"; -- csr read & clear
constant funct3_csril_c : std_ulogic_vector(2 downto 0) := "100"; -- undefined/illegal
constant funct3_csrrwi_c : std_ulogic_vector(2 downto 0) := "101"; -- csr r/w immediate
constant funct3_csrrsi_c : std_ulogic_vector(2 downto 0) := "110"; -- csr read & set bit immediate
constant funct3_csrrci_c : std_ulogic_vector(2 downto 0) := "111"; -- csr read & clear bit immediate
constant funct3_csrrsi_c : std_ulogic_vector(2 downto 0) := "110"; -- csr read & set immediate
constant funct3_csrrci_c : std_ulogic_vector(2 downto 0) := "111"; -- csr read & clear immediate
-- fence --
constant funct3_fence_c : std_ulogic_vector(2 downto 0) := "000"; -- fence - order IO/memory access
constant funct3_fencei_c : std_ulogic_vector(2 downto 0) := "001"; -- fence.i - instruction stream sync
Expand Down

0 comments on commit 16ba058

Please sign in to comment.