3 Star 5 Fork 0

北京中科昊芯科技有限公司 / haawking-tools

 / 详情

Hardware loop指令相关

已完成
任务 拥有者
创建于  
2021-02-07 09:54

昊芯的实现

问题描述

硬件循环调试

硬件

参考Pulpissimo

硬件实现(RI5CY: User Manual, V4.1, 2019.8)

To increase the efficiency of small loops, RI5CY supports hardware loops. Hardware loops make it possible to execute a piece of code multiple times, without the overhead of branches or updating a counter. Hardware loops involve zero stall cycles for jumping to the first instruction of a loop.

A hardware loop is defined by its start address (pointing to the first instruction in the loop), its end address (pointing to the instruction that will be executed last in the loop) and a counter that is decremented every time the loop body is executed. RI5CY contains two hardware loop register sets to support nested hardware loops, each of them can store these three values in separate flip flops which are mapped in the CSR address space.

If the end address of the two hardware loops is identical, loop 0 has higher priority and only the loop counter for hardware loop 0 is decremented. As soon as the counter of loop 0 reaches 1 at an end address, meaning it is decremented to 0 now, loop 1 gets active too. In this case, both counters will be decremented and the core jumps to the start of loop 1.

In order to use hardware loops, the compiler needs to setup the loop beforehand with the following instructions. Note that the minimum loop size is two instructions and the last instruction cannot be any jump or branch instruction.

For debugging and context switches, the hardware loop registers are mapped into the CSR address space and thus it is possible to read and write them via csrr and csrw instructions . Since hardware loop registers could be overwritten in when processing interrupts, the registers have to be saved in the interrupt routine together with the general purpose registers .

寄存器定义

RI5CY supports 2 levels of nested hardware loops. The loop has to be setup before entering the loop body. For this purpose, there are two methods, either the long commands that separately set start- and end-addresses of the loop and the number of iterations, or the short command that does all of this in a single instruction. The short command has a limited range for the number of instructions contained in the loop and the loop must start in the next instruction after the setup instruction.
Loop number 0 has higher priority than loop number 1 in a nested loop configuration, meaning that loop 0 represents the inner loop.

A hardware loop is subject to the following constraints:

-Minimum of 2 instructions in the loop body.
-Loop counter has to be bigger than 0, since the loop body is always entered at least once.

操作

指令编码

评论 (1)

JunningWu 创建了任务
JunningWu 关联仓库设置为JunningWu/haawking-tools
JunningWu 修改了描述
JunningWu 修改了描述
展开全部操作日志
ChenHuaOnYourRight 任务状态待办的 修改为已完成

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(1)
Violation
C
1
https://gitee.com/haawking/haawking-tools.git
git@gitee.com:haawking/haawking-tools.git
haawking
haawking-tools
haawking-tools

搜索帮助