Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor HDL cleanups and otimizations #1014

Merged
merged 11 commits into from
Sep 13, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ mimpid = 0x01040312 -> Version 01.04.03.12 -> v1.4.3.12

| Date | Version | Comment | Ticket |
|:----:|:-------:|:--------|:------:|
| 13.09.2024 | 1.10.3.5 | rtl code cleanups; minor CPU control optimizations | [#1014](https://github.com/stnolting/neorv32/pull/1014) |
| 08.09.2024 | 1.10.3.4 | minor rtl/CSR optimizations | [#1010](https://github.com/stnolting/neorv32/pull/1010) |
| 08.09.2024 | 1.10.3.3 | optimize CSR address logic (to reduce switching activity) | [#1008](https://github.com/stnolting/neorv32/pull/1008) |
| 05.09.2024 | 1.10.3.2 | :test_tube: Remove "for loop" construct from memory initialization function as the max. number of loop/unrolling iterations might be constrained | [#1005](https://github.com/stnolting/neorv32/pull/1005) |
Expand Down
24 changes: 12 additions & 12 deletions rtl/core/neorv32_cache.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ begin

-- Check if Direct/Uncached Access --------------------------------------------------------
-- -------------------------------------------------------------------------------------------
dir_acc_d <= '1' when (UC_ENABLE = true) and -- direct accesses implemented
dir_acc_d <= '1' when UC_ENABLE and -- direct accesses implemented
((host_req_i.addr(31 downto 28) >= UC_BEGIN) or -- uncached memory page
(host_req_i.rvso = '1')) else '0'; -- atomic (reservation set) operation

Expand Down Expand Up @@ -210,7 +210,7 @@ begin
dir_acc_q <= '0';
end if;
-- bus request buffer --
if (READ_ONLY = true) then -- do not propagate STB on write access, issue ERR instead
if READ_ONLY then -- do not propagate STB on write access, issue ERR instead
dir_req_q <= dir_req_d;
dir_req_q.stb <= dir_req_d.stb and (not dir_req_d.rw); -- read accesses only
dir_rsp_q <= dir_rsp_d;
Expand Down Expand Up @@ -485,7 +485,7 @@ begin
bus_sync_o <= '1'; -- trigger bus unit: sync operation
ctrl.state_nxt <= S_WAIT_SYNC;
elsif (req_i.stb = '1') or (ctrl.req_buf = '1') then -- (pending) access request
if (req_i.rw = '1') and (READ_ONLY = true) then -- invalid write access?
if (req_i.rw = '1') and READ_ONLY then -- invalid write access?
ctrl.state_nxt <= S_ERROR;
else
ctrl.state_nxt <= S_CHECK;
Expand All @@ -497,7 +497,7 @@ begin
rsp_o.data <= rdata_i; -- output read data
ctrl.req_buf_nxt <= '0'; -- access request completed
if (hit_i = '1') then
if (req_i.rw = '1') and (READ_ONLY = false) then -- write access
if (req_i.rw = '1') and (not READ_ONLY) then -- write access
dirty_o <= '1'; -- cache block is dirty now
we_o <= req_i.ben; -- finalize write access
end if;
Expand Down Expand Up @@ -683,7 +683,7 @@ begin
-- Access Status (1 Cycle Latency) --------------------------------------------------------
-- -------------------------------------------------------------------------------------------
hit_o <= '1' when (valid_mem_rd = '1') and (tag_mem_rd = acc_tag_ff) else '0'; -- cache access hit
dirty_o <= '1' when (valid_mem_rd = '1') and (dirty_mem_rd = '1') and (READ_ONLY = false) else '0'; -- accessed block is dirty
dirty_o <= '1' when (valid_mem_rd = '1') and (dirty_mem_rd = '1') and (not READ_ONLY) else '0'; -- accessed block is dirty

-- base address of accessed block --
base_o(31 downto 31-(tag_size_c-1)) <= tag_mem_rd;
Expand All @@ -698,10 +698,10 @@ begin
if rising_edge(clk_i) then
-- write access --
if (we_i(0) = '1') then
data_mem_b0(to_integer(unsigned(acc_adr))) <= wdata_i(07 downto 00);
data_mem_b0(to_integer(unsigned(acc_adr))) <= wdata_i(7 downto 0);
end if;
if (we_i(1) = '1') then
data_mem_b1(to_integer(unsigned(acc_adr))) <= wdata_i(15 downto 08);
data_mem_b1(to_integer(unsigned(acc_adr))) <= wdata_i(15 downto 8);
end if;
if (we_i(2) = '1') then
data_mem_b2(to_integer(unsigned(acc_adr))) <= wdata_i(23 downto 16);
Expand Down Expand Up @@ -882,7 +882,7 @@ begin
-- ------------------------------------------------------------
upret_nxt <= S_DOWNLOAD_REQ; -- go straight to S_DOWNLOAD_REQ when S_UPLOAD_GET has completed (if executed)
addr_nxt.idx <= baddr.idx; -- index of reference cache block
if (dirty_i = '1') and (READ_ONLY = false) then -- block is dirty, upload first
if (dirty_i = '1') and (not READ_ONLY) then -- block is dirty, upload first
addr_nxt.tag <= baddr.tag; -- base address (tag + index) of accessed block
state_nxt <= S_UPLOAD_GET;
else -- block is clean, download new block
Expand Down Expand Up @@ -915,7 +915,7 @@ begin

when S_UPLOAD_GET => -- upload dirty cache block: read word from cache
-- ------------------------------------------------------------
if (READ_ONLY = true) then
if READ_ONLY then
state_nxt <= S_IDLE;
else
bus_req_o.rw <= '1'; -- write access
Expand All @@ -924,7 +924,7 @@ begin

when S_UPLOAD_REQ => -- upload dirty cache block: request bus write
-- ------------------------------------------------------------
if (READ_ONLY = true) then
if READ_ONLY then
state_nxt <= S_IDLE;
else
bus_req_o.rw <= '1'; -- write access
Expand All @@ -934,7 +934,7 @@ begin

when S_UPLOAD_RSP => -- upload dirty cache block: wait for bus response
-- ------------------------------------------------------------
if (READ_ONLY = true) then
if READ_ONLY then
state_nxt <= S_IDLE;
else
bus_req_o.rw <= '1'; -- write access
Expand Down Expand Up @@ -964,7 +964,7 @@ begin
-- ------------------------------------------------------------
addr_nxt.tag <= baddr.tag; -- tag of currently index block
inval_o <= '1'; -- invalidate currently index block
if (dirty_i = '1') and (READ_ONLY = false) then -- block dirty?
if (dirty_i = '1') and (not READ_ONLY) then -- block dirty?
state_nxt <= S_UPLOAD_GET;
else -- move on to next block
addr_nxt.idx <= std_ulogic_vector(unsigned(addr.idx) + 1);
Expand Down
Loading