From 01f5b3297e6873a587eb55cc742aaf2399d7da58 Mon Sep 17 00:00:00 2001 From: stnolting Date: Sat, 5 Feb 2022 07:46:45 +0100 Subject: [PATCH 1/8] [rtl/core] add err_o signal to IMEM modules If the IMEM is implemented as true ROM any write attempt will raise a _store access fault_ exception with "[DEVICE_ERR]" error code (from the BUSKEEPER) --- rtl/core/mem/neorv32_imem.default.vhd | 4 +++- rtl/core/mem/neorv32_imem.legacy.vhd | 4 +++- rtl/core/neorv32_imem.entity.vhd | 5 +++-- rtl/core/neorv32_package.vhd | 5 +++-- rtl/core/neorv32_top.vhd | 4 ++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/rtl/core/mem/neorv32_imem.default.vhd b/rtl/core/mem/neorv32_imem.default.vhd index d0c924d8f..41ac4f9fb 100644 --- a/rtl/core/mem/neorv32_imem.default.vhd +++ b/rtl/core/mem/neorv32_imem.default.vhd @@ -6,7 +6,7 @@ -- # ********************************************************************************************* # -- # BSD 3-Clause License # -- # # --- # Copyright (c) 2021, Stephan Nolting. All rights reserved. # +-- # Copyright (c) 2022, Stephan Nolting. All rights reserved. # -- # # -- # Redistribution and use in source and binary forms, with or without modification, are # -- # permitted provided that the following conditions are met: # @@ -166,8 +166,10 @@ begin rden <= acc_en and rden_i; if (IMEM_AS_IROM = true) then ack_o <= acc_en and rden_i; + err_o <= acc_en and wren_i; else ack_o <= acc_en and (rden_i or wren_i); + err_o <= '0'; end if; end if; end process bus_feedback; diff --git a/rtl/core/mem/neorv32_imem.legacy.vhd b/rtl/core/mem/neorv32_imem.legacy.vhd index 374927893..5a5e19dd4 100644 --- a/rtl/core/mem/neorv32_imem.legacy.vhd +++ b/rtl/core/mem/neorv32_imem.legacy.vhd @@ -6,7 +6,7 @@ -- # ********************************************************************************************* # -- # BSD 3-Clause License # -- # # --- # Copyright (c) 2021, Stephan Nolting. All rights reserved. # +-- # Copyright (c) 2022, Stephan Nolting. All rights reserved. # -- # # -- # Redistribution and use in source and binary forms, with or without modification, are # -- # permitted provided that the following conditions are met: # @@ -163,8 +163,10 @@ begin rden <= acc_en and rden_i; if (IMEM_AS_IROM = true) then ack_o <= acc_en and rden_i; + err_o <= acc_en and wren_i; else ack_o <= acc_en and (rden_i or wren_i); + err_o <= '0'; end if; end if; end process bus_feedback; diff --git a/rtl/core/neorv32_imem.entity.vhd b/rtl/core/neorv32_imem.entity.vhd index 533a317ee..fe590c35b 100644 --- a/rtl/core/neorv32_imem.entity.vhd +++ b/rtl/core/neorv32_imem.entity.vhd @@ -6,7 +6,7 @@ -- # ********************************************************************************************* # -- # BSD 3-Clause License # -- # # --- # Copyright (c) 2021, Stephan Nolting. All rights reserved. # +-- # Copyright (c) 2022, Stephan Nolting. All rights reserved. # -- # # -- # Redistribution and use in source and binary forms, with or without modification, are # -- # permitted provided that the following conditions are met: # @@ -53,6 +53,7 @@ entity neorv32_imem is addr_i : in std_ulogic_vector(31 downto 0); -- address data_i : in std_ulogic_vector(31 downto 0); -- data in data_o : out std_ulogic_vector(31 downto 0); -- data out - ack_o : out std_ulogic -- transfer acknowledge + ack_o : out std_ulogic; -- transfer acknowledge + err_o : out std_ulogic -- transfer error ); end neorv32_imem; diff --git a/rtl/core/neorv32_package.vhd b/rtl/core/neorv32_package.vhd index 8e3eb5327..4757f054d 100644 --- a/rtl/core/neorv32_package.vhd +++ b/rtl/core/neorv32_package.vhd @@ -63,7 +63,7 @@ package neorv32_package is -- Architecture Constants (do not modify!) ------------------------------------------------ -- ------------------------------------------------------------------------------------------- constant data_width_c : natural := 32; -- native data path width - do not change! - constant hw_version_c : std_ulogic_vector(31 downto 0) := x"01060703"; -- no touchy! + constant hw_version_c : std_ulogic_vector(31 downto 0) := x"01060704"; -- no touchy! constant archid_c : natural := 19; -- official NEORV32 architecture ID - hands off! -- Check if we're inside the Matrix ------------------------------------------------------- @@ -1599,7 +1599,8 @@ package neorv32_package is addr_i : in std_ulogic_vector(31 downto 0); -- address data_i : in std_ulogic_vector(31 downto 0); -- data in data_o : out std_ulogic_vector(31 downto 0); -- data out - ack_o : out std_ulogic -- transfer acknowledge + ack_o : out std_ulogic; -- transfer acknowledge + err_o : out std_ulogic -- transfer error ); end component; diff --git a/rtl/core/neorv32_top.vhd b/rtl/core/neorv32_top.vhd index fd592db8d..15a6898c6 100644 --- a/rtl/core/neorv32_top.vhd +++ b/rtl/core/neorv32_top.vhd @@ -748,9 +748,9 @@ begin addr_i => p_bus.addr, -- address data_i => p_bus.wdata, -- data in data_o => resp_bus(RESP_IMEM).rdata, -- data out - ack_o => resp_bus(RESP_IMEM).ack -- transfer acknowledge + ack_o => resp_bus(RESP_IMEM).ack, -- transfer acknowledge + err_o => resp_bus(RESP_IMEM).err -- transfer error ); - resp_bus(RESP_IMEM).err <= '0'; -- no access error possible end generate; neorv32_int_imem_inst_false: From 584c3e9b461e8ccf6d56e813351f9dcf052654d6 Mon Sep 17 00:00:00 2001 From: stnolting Date: Sat, 5 Feb 2022 07:47:09 +0100 Subject: [PATCH 2/8] [sim] add err_o signal to sim-only IMEM modules --- sim/simple/neorv32_imem.iram.simple.vhd | 3 ++- sim/simple/neorv32_imem.simple.vhd | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sim/simple/neorv32_imem.iram.simple.vhd b/sim/simple/neorv32_imem.iram.simple.vhd index cebfd9086..11c0b8dae 100644 --- a/sim/simple/neorv32_imem.iram.simple.vhd +++ b/sim/simple/neorv32_imem.iram.simple.vhd @@ -6,7 +6,7 @@ -- # ********************************************************************************************* # -- # BSD 3-Clause License # -- # # --- # Copyright (c) 2021, Stephan Nolting. All rights reserved. # +-- # Copyright (c) 2022, Stephan Nolting. All rights reserved. # -- # # -- # Redistribution and use in source and binary forms, with or without modification, are # -- # permitted provided that the following conditions are met: # @@ -125,6 +125,7 @@ begin begin if rising_edge(clk_i) then rden <= acc_en and rden_i; + err_o <= '0'; ack_o <= acc_en and (rden_i or wren_i); end if; end process bus_feedback; diff --git a/sim/simple/neorv32_imem.simple.vhd b/sim/simple/neorv32_imem.simple.vhd index c9e798d57..7e6087066 100644 --- a/sim/simple/neorv32_imem.simple.vhd +++ b/sim/simple/neorv32_imem.simple.vhd @@ -78,7 +78,8 @@ begin begin if rising_edge(clk_i) then rden <= acc_en and rden_i; - ack_o <= acc_en and (rden_i or wren_i); + ack_o <= acc_en and rden_i; + err_o <= acc_en and wren_i; addr_v := to_integer(unsigned(addr)); -- rdata <= (others => '0'); From e0b6c181dfe14773052d8ff5aefb2bff443e61c6 Mon Sep 17 00:00:00 2001 From: stnolting Date: Sat, 5 Feb 2022 07:47:36 +0100 Subject: [PATCH 3/8] [docs/datasheet] add note regarding write-accesses to read-only IMEM --- docs/datasheet/soc_imem.adoc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/datasheet/soc_imem.adoc b/docs/datasheet/soc_imem.adoc index d0e480536..dafcaeed3 100644 --- a/docs/datasheet/soc_imem.adoc +++ b/docs/datasheet/soc_imem.adoc @@ -11,7 +11,7 @@ | Top entity port: | none | | Configuration generics: | _MEM_INT_IMEM_EN_ | implement processor-internal IMEM when _true_ | | _MEM_INT_IMEM_SIZE_ | IMEM size in bytes -| | _INT_BOOTLOADER_EN_ | use internal bootloader when _true_ (implements IMEM as _uninitialized_ RAM) +| | _INT_BOOTLOADER_EN_ | use internal bootloader when _true_ (implements IMEM as _uninitialized_ RAM, otherwise the IMEM is implemented an _pre-intialized_ ROM) | CPU interrupts: | none | |======================= @@ -37,3 +37,6 @@ architecture definition (`mem/neorv32_imem.default.vhd`). This **default archite _platform independent_ memory design that (should) infers embedded memory block. You can replace/modify the architecture source file in order to use platform-specific features (like advanced memory resources) or to improve technology mapping and/or timing. + +[IMPORTANT] +If the IMEM is implemented as true ROM any write attempt to it will raise a _store access fault_ exception. From 2d02ad6cabeb5016a5f96f6b9385ebe33db94219 Mon Sep 17 00:00:00 2001 From: stnolting Date: Sat, 5 Feb 2022 07:56:13 +0100 Subject: [PATCH 4/8] [CHANGELOG] add v1.6.7.4 add err_o signal to IMEM module(s) --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ee6d37a9..9163a7fd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ The version number is globally defined by the `hw_version_c` constant in the mai | Date (*dd.mm.yyyy*) | Version | Comment | |:----------:|:-------:|:--------| +| 05.02.2022 | 1.6.7.4 | added `err_o` signal to IMEM module; if the IMEM is implemented as true ROM any write attempt will raise a _store access fault_ (with a `[DEVICE_ERR]` error); see [PR #273](https://github.com/stnolting/neorv32/pull/273) | | 03.02.2022 | 1.6.7.3 | using `LTO` (link-time-optimization) option for **bootloader**; improved bootloader user console; see [PR #268](https://github.com/stnolting/neorv32/pull/268) | | 31.01.2022 | 1.6.7.2 | :bug: fixed minor bug in **bootloader'd MTIME handling** (bootloader crashed if `Zicntr` ISA extension not enabled), fixed minor issues in MTIME and `time` CSRs handling; added MTIME example program; see [PR #267](https://github.com/stnolting/neorv32/pull/267) | | 30.01.2022 | 1.6.7.1 | :sparkles: added **`Zxcfu` ISA extension for user-defined custom RISC-V instructions**; see [PR #264](https://github.com/stnolting/neorv32/pull/264) | From 9c82cfc5ff4eb5c98a967d6c478b36e6e10f351b Mon Sep 17 00:00:00 2001 From: stnolting Date: Sat, 5 Feb 2022 08:25:25 +0100 Subject: [PATCH 5/8] [CHANGELOG] minor edits --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9163a7fd7..b25110b98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,7 +32,7 @@ The version number is globally defined by the `hw_version_c` constant in the mai | Date (*dd.mm.yyyy*) | Version | Comment | |:----------:|:-------:|:--------| -| 05.02.2022 | 1.6.7.4 | added `err_o` signal to IMEM module; if the IMEM is implemented as true ROM any write attempt will raise a _store access fault_ (with a `[DEVICE_ERR]` error); see [PR #273](https://github.com/stnolting/neorv32/pull/273) | +| 05.02.2022 | 1.6.7.4 | added `err_o` signal to **IMEM** module; if the IMEM is implemented as true ROM any write attempt will raise a _store access fault_ exception (with a `[DEVICE_ERR]` error); see [PR #273](https://github.com/stnolting/neorv32/pull/273) | | 03.02.2022 | 1.6.7.3 | using `LTO` (link-time-optimization) option for **bootloader**; improved bootloader user console; see [PR #268](https://github.com/stnolting/neorv32/pull/268) | | 31.01.2022 | 1.6.7.2 | :bug: fixed minor bug in **bootloader'd MTIME handling** (bootloader crashed if `Zicntr` ISA extension not enabled), fixed minor issues in MTIME and `time` CSRs handling; added MTIME example program; see [PR #267](https://github.com/stnolting/neorv32/pull/267) | | 30.01.2022 | 1.6.7.1 | :sparkles: added **`Zxcfu` ISA extension for user-defined custom RISC-V instructions**; see [PR #264](https://github.com/stnolting/neorv32/pull/264) | From 1297d4fa15dabeb75b71b767cbe180c89abbccf5 Mon Sep 17 00:00:00 2001 From: stnolting Date: Sat, 5 Feb 2022 14:55:40 +0100 Subject: [PATCH 6/8] [docs/datasheet] IMEM: minor edit --- docs/datasheet/soc_imem.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/datasheet/soc_imem.adoc b/docs/datasheet/soc_imem.adoc index dafcaeed3..90dad4b0e 100644 --- a/docs/datasheet/soc_imem.adoc +++ b/docs/datasheet/soc_imem.adoc @@ -38,5 +38,5 @@ _platform independent_ memory design that (should) infers embedded memory block. source file in order to use platform-specific features (like advanced memory resources) or to improve technology mapping and/or timing. -[IMPORTANT] +[NOTE] If the IMEM is implemented as true ROM any write attempt to it will raise a _store access fault_ exception. From 09ac5726f1b28b4c6b7ad6d4155219794c12b4fe Mon Sep 17 00:00:00 2001 From: stnolting Date: Sat, 5 Feb 2022 14:56:21 +0100 Subject: [PATCH 7/8] [rtl/core] added err_o signal to BOOTROM --- rtl/core/neorv32_boot_rom.vhd | 9 ++++++--- rtl/core/neorv32_package.vhd | 4 +++- rtl/core/neorv32_top.vhd | 5 +++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/rtl/core/neorv32_boot_rom.vhd b/rtl/core/neorv32_boot_rom.vhd index f80f20be9..9d03c8eab 100644 --- a/rtl/core/neorv32_boot_rom.vhd +++ b/rtl/core/neorv32_boot_rom.vhd @@ -3,7 +3,7 @@ -- # ********************************************************************************************* # -- # BSD 3-Clause License # -- # # --- # Copyright (c) 2020, Stephan Nolting. All rights reserved. # +-- # Copyright (c) 2022, Stephan Nolting. All rights reserved. # -- # # -- # Redistribution and use in source and binary forms, with or without modification, are # -- # permitted provided that the following conditions are met: # @@ -47,9 +47,11 @@ entity neorv32_boot_rom is port ( clk_i : in std_ulogic; -- global clock line rden_i : in std_ulogic; -- read enable + wren_i : in std_ulogic; -- write enable addr_i : in std_ulogic_vector(31 downto 0); -- address data_o : out std_ulogic_vector(31 downto 0); -- data out - ack_o : out std_ulogic -- transfer acknowledge + ack_o : out std_ulogic; -- transfer acknowledge + err_o : out std_ulogic -- transfer error ); end neorv32_boot_rom; @@ -91,7 +93,8 @@ begin mem_file_access: process(clk_i) begin if rising_edge(clk_i) then - rden <= rden_i and acc_en; + rden <= acc_en and rden_i; + err_o <= acc_en and wren_i; if (acc_en = '1') then -- reduce switching activity when not accessed rdata <= mem_rom(to_integer(unsigned(addr))); end if; diff --git a/rtl/core/neorv32_package.vhd b/rtl/core/neorv32_package.vhd index 4757f054d..0d7212fe3 100644 --- a/rtl/core/neorv32_package.vhd +++ b/rtl/core/neorv32_package.vhd @@ -1632,9 +1632,11 @@ package neorv32_package is port ( clk_i : in std_ulogic; -- global clock line rden_i : in std_ulogic; -- read enable + wren_i : in std_ulogic; -- write enable addr_i : in std_ulogic_vector(31 downto 0); -- address data_o : out std_ulogic_vector(31 downto 0); -- data out - ack_o : out std_ulogic -- transfer acknowledge + ack_o : out std_ulogic; -- transfer acknowledge + err_o : out std_ulogic -- transfer error ); end component; diff --git a/rtl/core/neorv32_top.vhd b/rtl/core/neorv32_top.vhd index 15a6898c6..fad4b5127 100644 --- a/rtl/core/neorv32_top.vhd +++ b/rtl/core/neorv32_top.vhd @@ -798,11 +798,12 @@ begin port map ( clk_i => clk_i, -- global clock line rden_i => p_bus.re, -- read enable + wren_i => p_bus.we, -- write enable addr_i => p_bus.addr, -- address data_o => resp_bus(RESP_BOOTROM).rdata, -- data out - ack_o => resp_bus(RESP_BOOTROM).ack -- transfer acknowledge + ack_o => resp_bus(RESP_BOOTROM).ack, -- transfer acknowledge + err_o => resp_bus(RESP_BOOTROM).err -- transfer error ); - resp_bus(RESP_BOOTROM).err <= '0'; -- no access error possible end generate; neorv32_boot_rom_inst_false: From 7eb1ef672dd37153bc65d02ecd159790f4274537 Mon Sep 17 00:00:00 2001 From: stnolting Date: Sat, 5 Feb 2022 14:56:40 +0100 Subject: [PATCH 8/8] [docs/datasheet] added note regarding write-accesses to the BOOTROM --- docs/datasheet/soc_bootrom.adoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/datasheet/soc_bootrom.adoc b/docs/datasheet/soc_bootrom.adoc index 4fd1b564c..f04043b46 100644 --- a/docs/datasheet/soc_bootrom.adoc +++ b/docs/datasheet/soc_bootrom.adoc @@ -30,6 +30,9 @@ The bootloader memory is _read-only_ and is automatically initialized with the b determined via synthesis and expanded to the next power of two. For example, if the bootloader code requires 10kB of storage, a ROM with 16kB will be generated. The maximum size must not exceed 32kB. +[NOTE] +Any write access to the BOOTROM will raise a _store access fault_ exception. + .Bootloader - Software [TIP] See section <<_bootloader>> for more information regarding the actual bootloader software/executable itself.