|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Data Operation Circuit (DOC) driver implementation. More...
#include "ra8_doc.h"#include <stdint.h>#include "ra8_attributes.h"#include "ra8_check.h"#include "ra8_doc_regs.h"#include "ra8_err.h"#include "ra8_log.h"#include "ra8_mstp.h"Go to the source code of this file.
Functions | |
| static void | internal_ra8_doc_set_mode_16 (ra8_docr_oms_t mode) |
| Write mode into DOCR.OMS[1:0], clearing DOBW for 16-bit ops. | |
| static uint16_t | internal_ra8_doc_run_16 (uint16_t seed, uint16_t operand) |
| Run the 16-bit DOC operation sequence and return the result. | |
| ra8_err_t | ra8_doc_init (void) |
| Reset the DOC control register to its reset state. | |
| ra8_err_t | ra8_doc_add16 (uint16_t a, uint16_t b, uint16_t *out_sum) |
| Perform a 16-bit hardware add. | |
| ra8_err_t | ra8_doc_sub16 (uint16_t a, uint16_t b, uint16_t *out_diff) |
| Perform a 16-bit hardware subtract. | |
| ra8_err_t | ra8_doc_set_window (uint16_t lower, uint16_t upper, ra8_doc_window_polarity_t polarity) |
| Implementation of ra8_doc_set_window() – programs DOCR/DODSR0/DODSR1. | |
| ra8_err_t | ra8_doc_window_compare (uint16_t value, bool *out_flag) |
| Implementation of ra8_doc_window_compare() – writes DODIR, reads DOPCF. | |
Variables | |
| static const char * | s_tag = "DOC" |
Data Operation Circuit (DOC) driver implementation.
Thin wrapper that drives the DOC_B block through its add / sub / compare modes. Register writes go through the accessor from ra8_doc_regs.h, which returns a pointer to host RAM in RA8_OFF_TARGET and a real hardware address on target.
Per HUM Ch 57.2 p 3521 the DODSR0 register holds the running accumulator AND the operand reference; DODIR is the data input register. The hardware updates DODSR0 in place: writing DODIR triggers the operation, so the sequence is:
Definition in file ra8_doc.c.
|
inlinestatic |
Run the 16-bit DOC operation sequence and return the result.
Per HUM Ch 57.2.4 / 57.2.5 p 3521 the operation is triggered by writing DODIR. Writes happen at 16-bit width because DOCR.DOBW=0 (set by internal_ra8_doc_set_mode_16). The DODSR0 readback is the silicon operation engine's result. The RAM-backed host register file has no operation engine, so on the unit-test build the readback is simply the seed value: host tests assert the register trace (DOCR / DODSR0 / DODIR) instead of the arithmetic, which the doc_demo HIL app proves on silicon.
| [in] | seed | Initial DODSR0 value (operand A). |
| [in] | operand | DODIR value (operand B). |
| 0..UINT16_MAX | The DODSR0 value after the DODIR trigger write. |
Definition at line 87 of file ra8_doc.c.
References r_doc_regs_t::DODIR, r_doc_regs_t::DODSR0, ra8_doc(), and RA8_INTERNAL.
Referenced by ra8_doc_add16(), and ra8_doc_sub16().
|
inlinestatic |
Write mode into DOCR.OMS[1:0], clearing DOBW for 16-bit ops.
Programmes the operation-mode select bits and forces DOBW=0 (16-bit operand width per HUM Ch 57.2.1 p 3519). DCSEL is left at 0 since the 16-bit add / subtract APIs don't use compare-mode detection.
| [in] | mode | Operation mode to programme. |
Definition at line 54 of file ra8_doc.c.
References r_doc_regs_t::DOCR, ra8_doc(), and RA8_INTERNAL.
Referenced by ra8_doc_add16(), and ra8_doc_sub16().
|
nodiscard |
Perform a 16-bit hardware add.
| [in] | a | First operand. |
| [in] | b | Second operand. |
| [out] | out_sum | Receives a + b (wraps mod 2^16). |
Definition at line 127 of file ra8_doc.c.
References internal_ra8_doc_run_16(), internal_ra8_doc_set_mode_16(), k_ra8_doc_mode_add, k_ra8_ok, RA8_CHECK_NULL_PTR, and s_tag.
Referenced by internal_hw_sum().
|
nodiscard |
Reset the DOC control register to its reset state.
Clears DOCR, DODIR, and DODSR0. Leaves the block disabled until the first operation.
Definition at line 103 of file ra8_doc.c.
References r_doc_regs_t::DOCR, r_doc_regs_t::DODIR, r_doc_regs_t::DODSR0, r_doc_regs_t::DODSR1, r_doc_regs_t::DOSCR, k_ra8_doc_mask_dopcfcl, k_ra8_mstp_doc, k_ra8_ok, ra8_doc(), ra8_log_info, ra8_mstp_enable(), RA8_RETURN_ON_ERROR, and s_tag.
Referenced by internal_setup_or_halt().
|
nodiscard |
Implementation of ra8_doc_set_window() – programs DOCR/DODSR0/DODSR1.
Configure the DOC for 16-bit window comparison.
Definition at line 152 of file ra8_doc.c.
References r_doc_regs_t::DOCR, r_doc_regs_t::DODSR0, r_doc_regs_t::DODSR1, r_doc_regs_t::DOSCR, k_ra8_doc_bit_dcsel, k_ra8_doc_dcsel_inside, k_ra8_doc_dcsel_outside, k_ra8_doc_mask_dcsel, k_ra8_doc_mask_dopcfcl, k_ra8_doc_window_outside, k_ra8_err_invalid_arg, k_ra8_ok, ra8_doc(), ra8_log_error, ra8_log_info, and s_tag.
|
nodiscard |
Perform a 16-bit hardware subtract.
| [in] | a | Minuend. |
| [in] | b | Subtrahend. |
| [out] | out_diff | Receives a - b (wraps mod 2^16). |
Definition at line 136 of file ra8_doc.c.
References internal_ra8_doc_run_16(), internal_ra8_doc_set_mode_16(), k_ra8_doc_mode_subtract, k_ra8_ok, RA8_CHECK_NULL_PTR, and s_tag.
|
nodiscard |
Implementation of ra8_doc_window_compare() – writes DODIR, reads DOPCF.
Trigger a 16-bit window comparison and return the DOPCF flag.
Definition at line 193 of file ra8_doc.c.
References r_doc_regs_t::DOCR, r_doc_regs_t::DODIR, r_doc_regs_t::DOSCR, r_doc_regs_t::DOSR, k_ra8_doc_mask_dopcf, k_ra8_doc_mask_dopcfcl, k_ra8_doc_mask_oms, k_ra8_err_invalid_state, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_doc(), ra8_log_error, and s_tag.