Skip to content

Commit

Permalink
add new soc ctrl regs
Browse files Browse the repository at this point in the history
  • Loading branch information
davideschiavone committed Sep 14, 2023
1 parent 29ef98c commit cf81e42
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
4 changes: 2 additions & 2 deletions hw/core-v-mini-mcu/system_bus.sv.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ module system_bus
assign bus_error_address_o = error_slave_req.addr;
assign error_slave_resp.gnt = error_slave_req.req;
assign error_slave_resp.rvalid = error_slave_resp_rvalid;
assign error_slave_resp.rdata = 32'hdeadbeef;
assign error_slave_resp.rdata = 32'hbada55e5;

// Internal master requests
assign int_master_req[core_v_mini_mcu_pkg::CORE_INSTR_IDX] = core_instr_req_i;
Expand Down Expand Up @@ -206,7 +206,7 @@ module system_bus
error_slave_resp_rvalid <= 1'b0;
end else begin
`ifndef SYNTHESIS
if(rst_ni)
if(rst_ni && bus_error_o)
$display("%t Out of bound memory access 0x%08x", $time, error_slave_req.addr);
`endif
error_slave_resp_rvalid <= error_slave_resp.gnt;
Expand Down
14 changes: 13 additions & 1 deletion sw/device/lib/drivers/soc_ctrl/soc_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,16 @@ void soc_ctrl_select_spi_host(const soc_ctrl_t *soc_ctrl) {

uint32_t get_spi_flash_mode(const soc_ctrl_t *soc_ctrl) {
return mmio_region_read32(soc_ctrl->base_addr, (ptrdiff_t)(SOC_CTRL_USE_SPIMEMIO_REG_OFFSET));
}
}

uint32_t get_bus_error(const soc_ctrl_t *soc_ctrl) {
return mmio_region_read32(soc_ctrl->base_addr, (ptrdiff_t)(SOC_CTRL_BUS_ERROR_REG_OFFSET));
}

void clear_bus_error(const soc_ctrl_t *soc_ctrl) {
mmio_region_write32(soc_ctrl->base_addr, (ptrdiff_t)(SOC_CTRL_BUS_ERROR_REG_OFFSET), 0x0);
}

uint32_t get_bus_error_address(const soc_ctrl_t *soc_ctrl) {
return mmio_region_read32(soc_ctrl->base_addr, (ptrdiff_t)(SOC_CTRL_BUS_ERROR_ADDRESS_REG_OFFSET));
}
24 changes: 24 additions & 0 deletions sw/device/lib/drivers/soc_ctrl/soc_ctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,30 @@ void soc_ctrl_select_spi_host(const soc_ctrl_t *soc_ctrl);

uint32_t get_spi_flash_mode(const soc_ctrl_t *soc_ctrl);

/**
* Get the bus error
* @param soc_ctrl Pointer to soc_ctrl_t represting the target SOC CTRL.
*/

uint32_t get_bus_error(const soc_ctrl_t *soc_ctrl);

/**
* Clear the bus error
* @param soc_ctrl Pointer to soc_ctrl_t represting the target SOC CTRL.
*/

void clear_bus_error(const soc_ctrl_t *soc_ctrl);

/**
* Get the bus error address
* @param soc_ctrl Pointer to soc_ctrl_t represting the target SOC CTRL.
*/

uint32_t get_bus_error_address(const soc_ctrl_t *soc_ctrl);




#ifdef __cplusplus
}
#endif
Expand Down
7 changes: 7 additions & 0 deletions sw/device/lib/drivers/soc_ctrl/soc_ctrl_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ extern "C" {
// system is running (in Hz)
#define SOC_CTRL_SYSTEM_FREQUENCY_HZ_REG_OFFSET 0x1c

// Bus access error
#define SOC_CTRL_BUS_ERROR_REG_OFFSET 0x20
#define SOC_CTRL_BUS_ERROR_BUS_ERROR_BIT 0

// Bus access error address
#define SOC_CTRL_BUS_ERROR_ADDRESS_REG_OFFSET 0x24

#ifdef __cplusplus
} // extern "C"
#endif
Expand Down

0 comments on commit cf81e42

Please sign in to comment.