28 #include "in_config.h" 36 static __inline uint8_t hwacc_get_intr_status()
38 return RD_WORD(HWACC_REG_INTR_STATUS);
41 static __inline uint8_t hwacc_get_mask_status()
43 return RD_WORD(HWACC_REG_INTR_MASK_STATUS);
46 static __inline
void hwacc_intr_clear()
48 WR_WORD(HWACC_REG_INTR_CLEAR, (HWACC_REG_INTR_CLEAR_HWACC_DONE | HWACC_REG_INTR_CLEAR_FAULT_DETECTED));
51 static __inline
void hwacc_intr_set()
53 WR_WORD(HWACC_REG_INTR_SET, (HWACC_REG_INTR_SET_HWACC_DONE | HWACC_REG_INTR_SET_FAULT_DETECTED));
56 static __inline
void hwacc_mask_clear()
58 WR_WORD(HWACC_REG_INTR_MASK_CLEAR, (HWACC_REG_INTR_MASK_CLEAR_HWACC_DONE | HWACC_REG_INTR_MASK_CLEAR_FAULT_DETECTED));
61 static __inline
void hwacc_mask_set()
63 WR_WORD(HWACC_REG_INTR_MASK_SET, (HWACC_REG_INTR_MASK_SET_HWACC_DONE | HWACC_REG_INTR_MASK_SET_FAULT_DETECTED));
66 static __inline
void hwacc_enable()
68 uint32_t reg = RD_WORD(HWACC_REG_MISC_CTRL);
69 reg |= HWACC_REG_MISC_CTRL_CTL_ENABLE;
70 WR_WORD(HWACC_REG_MISC_CTRL, reg);
73 static __inline
void hwacc_disable()
75 uint32_t reg = RD_WORD(HWACC_REG_MISC_CTRL);
76 reg &= ~HWACC_REG_MISC_CTRL_CTL_ENABLE;
77 WR_WORD(HWACC_REG_MISC_CTRL, reg);
80 static __inline
void hwacc_start()
82 uint32_t reg = RD_WORD(HWACC_REG_MISC_CTRL);
83 reg |= HWACC_REG_MISC_CTRL_CTL_START;
84 WR_WORD(HWACC_REG_MISC_CTRL, reg);
86 reg &= ~HWACC_REG_MISC_CTRL_CTL_START;
87 WR_WORD(HWACC_REG_MISC_CTRL, reg);
90 static __inline
void hwacc_set_num_inst(uint16_t num_inst)
92 uint32_t reg = RD_WORD(HWACC_REG_MISC_CTRL);
93 reg &= ~HWACC_REG_MISC_CTRL_CTL_NUM_INSTRUCTION;
94 reg |= ((num_inst & HWACC_REG_MISC_CTRL_CTL_NUM_INSTRUCTION_MASK) << HWACC_REG_MISC_CTRL_CTL_NUM_INSTRUCTION_SHIFT);
95 WR_WORD(HWACC_REG_MISC_CTRL, reg);
98 static __inline
void hwacc_set_inst_addr(uint16_t inst_addr)
100 uint32_t reg = RD_WORD(HWACC_REG_MISC_CTRL);
101 reg &= ~HWACC_REG_MISC_CTRL_CTL_INSTRUCTION_ADDRESS;
102 reg |= ((inst_addr & HWACC_REG_MISC_CTRL_CTL_INSTRUCTION_ADDRESS_MASK) << HWACC_REG_MISC_CTRL_CTL_INSTRUCTION_ADDRESS_SHIFT);
103 WR_WORD(HWACC_REG_MISC_CTRL, reg);
106 static __inline
void hwacc_mem_acc_ahb()
108 WR_WORD(HWACC_REG_MEM_ACC_CTRL, HWACC_REG_MEM_ACC_CTRL_DEFAULT);
111 static __inline
void hwacc_mem_acc_comp_core()
113 WR_WORD(HWACC_REG_MEM_ACC_CTRL, HWACC_REG_MEM_ACC_CTRL_CTL_MEM_A_ACC_SEL | HWACC_REG_MEM_ACC_CTRL_CTL_MEM_B_ACC_SEL | HWACC_REG_MEM_ACC_CTRL_CTL_MEM_C_ACC_SEL | HWACC_REG_MEM_ACC_CTRL_CTL_MEM_D_ACC_SEL);
116 static __inline
void hwacc_pv_search_enable()
118 uint32_t reg = RD_WORD(HWACC_REG_INVERSE_CTRL);
119 reg |= HWACC_REG_INVERSE_CTRL_CTL_PV_SEARCH_ON;
120 WR_WORD(HWACC_REG_INVERSE_CTRL, reg);
123 static __inline
void hwacc_pv_search_disable()
125 uint32_t reg = RD_WORD(HWACC_REG_INVERSE_CTRL);
126 reg &= ~HWACC_REG_INVERSE_CTRL_CTL_PV_SEARCH_ON;
127 WR_WORD(HWACC_REG_INVERSE_CTRL, reg);
130 static __inline
void hwacc_check_min_pv_enable()
132 uint32_t reg = RD_WORD(HWACC_REG_INVERSE_CTRL);
133 reg |= HWACC_REG_INVERSE_CTRL_CTL_CHECK_MIN_PV_ON;
134 WR_WORD(HWACC_REG_INVERSE_CTRL, reg);
137 static __inline
void hwacc_check_min_pv_disable()
139 uint32_t reg = RD_WORD(HWACC_REG_INVERSE_CTRL);
140 reg &= ~HWACC_REG_INVERSE_CTRL_CTL_CHECK_MIN_PV_ON;
141 WR_WORD(HWACC_REG_INVERSE_CTRL, reg);
144 static __inline
void hwacc_check_zero_pv_enable()
146 uint32_t reg = RD_WORD(HWACC_REG_INVERSE_CTRL);
147 reg |= HWACC_REG_INVERSE_CTRL_CTL_CHECK_ZERO_PV_ON;
148 WR_WORD(HWACC_REG_INVERSE_CTRL, reg);
151 static __inline
void hwacc_check_zero_pv_disable()
153 uint32_t reg = RD_WORD(HWACC_REG_INVERSE_CTRL);
154 reg &= ~HWACC_REG_INVERSE_CTRL_CTL_CHECK_ZERO_PV_ON;
155 WR_WORD(HWACC_REG_INVERSE_CTRL, reg);
158 static __inline
void hwacc_set_min_pv(uint32_t min_pv)
160 WR_WORD(HWACC_REG_INVERSE_MIN_PV, min_pv);
163 static __inline uint32_t hwacc_get_curr_inst_word_0()
165 return RD_WORD(HWACC_REG_CURR_INST_WORD0);
168 static __inline uint32_t hwacc_get_curr_inst_word_1()
170 return RD_WORD(HWACC_REG_CURR_INST_WORD1);
173 static __inline uint32_t hwacc_get_curr_inst_word_2()
175 return RD_WORD(HWACC_REG_CURR_INST_WORD2);
178 static __inline uint32_t hwacc_get_curr_inst_cycle_cnt()
180 return RD_WORD(HWACC_REG_CURR_INST_CYCLE_CNT);
189 #define HWACC_MEM_0_BASE_ADDR 0x44007000 190 #define HWACC_MEM_1_BASE_ADDR 0x44007800 191 #define HWACC_MEM_2_BASE_ADDR 0x44008000 192 #define HWACC_MEM_3_BASE_ADDR 0x44008400 224 } hwacc_matrix_desc_t;
306 int hal_hwacc_insert_inst(hwacc_matrix_desc_t *matrix_C,
int C_symm, hwacc_matrix_desc_t *matrix_A,
int A_trans, hwacc_matrix_desc_t *matrix_B,
int B_trans,
hwacc_op_t op);
Matrix addition: (C = A + B) Addition of A/B (each from a different memory), result saved to another ...
Definition: hal_hwacc.h:199
int hal_hwacc_write_matrix(hwacc_matrix_desc_t *matrix, const float *head)
Write matrix into hardware accelerator memory blocks.
Matrix scale: (C = A * B) Scale A by B (b is a scalar 1x1 matrix).
Definition: hal_hwacc.h:212
Matrix clear: (C = A * 0) C is zero matrix matching size of A. (Clear memory bank and offset of C wit...
Definition: hal_hwacc.h:210
Matrix copy: (C = B) Copy B from one memory location to another memory location (same or different me...
Definition: hal_hwacc.h:197
int hal_hwacc_open(void)
Initialize hardware accelerator driver.
HWACC unable to initialize.
Definition: hal_hwacc.h:239
Matrix dimension mismatch within instruction operation.
Definition: hal_hwacc.h:241
HWACC driver already initialized with hwacc_open().
Definition: hal_hwacc.h:235
HWACC driver not yet initialized with hwacc_open().
Definition: hal_hwacc.h:237
Hardware configuration error detected.
Definition: hal_hwacc.h:231
hwacc_op_t
hwacc operator
Definition: hal_hwacc.h:195
HWACC input issue.
Definition: hal_hwacc.h:243
int hal_hwacc_insert_inst(hwacc_matrix_desc_t *matrix_C, int C_symm, hwacc_matrix_desc_t *matrix_A, int A_trans, hwacc_matrix_desc_t *matrix_B, int B_trans, hwacc_op_t op)
Insert instruction into queue.
No error. Good status.
Definition: hal_hwacc.h:229
int hal_hwacc_close(void)
Clean-up hardware accelerator driver.
Matrix subtraction: (C = A - B) Subtraction of B from A (each from a different memory), result saved to another memory. A/B/C must have same size.
Definition: hal_hwacc.h:201
int hal_hwacc_execute(void)
Execute HW Accelerator instructions in queue.
Definition: hal_hwacc.h:208
Matrix multiplication: (C = AB) Multiplication of A/B (each from a different memory), result saved to another memory. Dimensions must match.
Definition: hal_hwacc.h:203
hwacc_status_t
HWACC function status return.
Definition: hal_hwacc.h:227
Matrix inversion: (C = A^-1) Inversion of A, result saved to another memory, at return: C = A^-1...
Definition: hal_hwacc.h:205
Instruction overflow detected. Too many instructions inserted.
Definition: hal_hwacc.h:233
int hal_hwacc_read_matrix(hwacc_matrix_desc_t *matrix, float *head)
Read matrix data from hardware accelerator memory blocks.