class SoCCSRHandler(SoCLocHandler):
supported_data_width = [8, 32]
supported_address_width = [14+i for i in range(4)]
- supported_alignment = [32, 64]
+ supported_alignment = [32]
supported_paging = [0x800*2**i for i in range(4)]
# Creation -------------------------------------------------------------------------------------
self.logger.info("CSR Handler {}.".format(colorer("created", color="green")))
- # Update CSR Alignment ----------------------------------------------------------------------------
- def update_alignment(self, alignment):
- # Check Alignment
- if alignment not in self.supported_alignment:
- self.logger.error("Unsupported {}: {} supporteds: {:s}".format(
- colorer("Alignment", color="red"),
- colorer(alignment),
- colorer(", ".join(str(x) for x in self.supported_alignment))))
- raise
- self.logger.info("Alignment {} from {}-bit to {}-bit.".format(
- colorer("updated", color="cyan"),
- colorer(self.alignment),
- colorer(alignment)))
- self.alignment = alignment
-
# Add Master -----------------------------------------------------------------------------------
def add_master(self, name=None, master=None):
if name is None:
csr_data_width = 32,
csr_address_width = 14,
- csr_alignment = 32,
csr_paging = 0x800,
csr_reserved_csrs = {},
self.submodules.csr = SoCCSRHandler(
data_width = csr_data_width,
address_width = csr_address_width,
- alignment = csr_alignment,
+ alignment = 32,
paging = csr_paging,
reserved_csrs = csr_reserved_csrs,
)
self.mem_map.update(self.cpu.mem_map) # FIXME
# Add Bus Masters/CSR/IRQs
if not isinstance(self.cpu, cpu.CPUNone):
- self.csr.update_alignment(self.cpu.data_width)
if reset_address is None:
reset_address = self.mem_map["rom"]
self.cpu.set_reset_address(reset_address)
CONFIG_BUS_STANDARD,
CONFIG_BUS_DATA_WIDTH,
(1 << (CONFIG_BUS_ADDRESS_WIDTH - 30)));
- printf("\e[1mCSR\e[0m: %d-bit data - %d-bit aligned\n",
- CONFIG_CSR_DATA_WIDTH,
- CONFIG_CSR_ALIGNMENT);
+ printf("\e[1mCSR\e[0m: %d-bit data\n",
+ CONFIG_CSR_DATA_WIDTH);
printf("\e[1mROM\e[0m: %dKiB\n", ROM_SIZE/1024);
printf("\e[1mSRAM\e[0m: %dKiB\n", SRAM_SIZE/1024);
#ifdef CONFIG_L2_SIZE
* (base) address. */
#include <generated/soc.h>
-#if !defined(CONFIG_CSR_ALIGNMENT) || !defined(CONFIG_CSR_DATA_WIDTH)
-#error csr alignment and data-width MUST be set before including this file!
+#if !defined(CONFIG_CSR_DATA_WIDTH)
+#error CSR_DATA_WIDTH MUST be set before including this file!
#endif
-#if CONFIG_CSR_DATA_WIDTH > CONFIG_CSR_ALIGNMENT
-#error invalid CONFIG_CSR_DATA_WIDTH (must not exceed CONFIG_CSR_ALIGNMENT)!
-#endif
-
-/* FIXME: preprocessor can't evaluate 'sizeof()' operator, is there a better
- * way to implement the following assertion?
- * #if sizeof(unsigned long) != CONFIG_CSR_ALIGNMENT/8
- * #error invalid CONFIG_CSR_ALIGNMENT (must match native CPU word size)!
- * #endif
- */
-
-/* CSR subregisters (a.k.a. "simple CSRs") are embedded inside native CPU-word
+/* CSR subregisters (a.k.a. "simple CSRs") are embedded inside uint32_t
* aligned locations: */
-#if CONFIG_CSR_ALIGNMENT == 32
#define MMPTR(a) (*((volatile uint32_t *)(a)))
-#elif CONFIG_CSR_ALIGNMENT == 64
-#define MMPTR(a) (*((volatile uint64_t *)(a)))
-#else
-#error Unsupported CSR alignment
-#endif
static inline void csr_write_simple(unsigned long v, unsigned long a)
{
/* CSR data width (subreg. width) in bytes, for direct comparson to sizeof() */
#define CSR_DW_BYTES (CONFIG_CSR_DATA_WIDTH/8)
-#define CSR_OFFSET_BYTES (CONFIG_CSR_ALIGNMENT/8)
+#define CSR_OFFSET_BYTES 4
#ifndef __ASSEMBLER__