当前位置:首页 > 报告详情

使用延续的硬件可合成异常.pdf

上传人: 芦苇 编号:651827 2025-05-01 50页 512.23KB

1、Hardware Synthesizable Exceptions using ContinuationsPaul TengMcGill University,CanadaChristophe DubachMcGill University/MILA,Canada1ASPDAC 25,Thursday,January 23,2025,Tokyo,Japanint mydiv(int r)return 100/r;int main(int n)return mydiv(n);2Code that is potentially erroneousint mydiv(int r)return 100

2、/r;int main(int n)return mydiv(n);3Code that is potentially erroneousMaybe your codeDivides by zeroOverflows during computationAccesses invalid parts of an arraySomething else?Solution:Runtime Exceptions4int mydiv(int r)if(r=0)throw std:runtime_error(Cannot divide by zero);return 100/r;int main(int

3、n)return mydiv(n);5throw:an abort that can be handled laterint mydiv(int r)if(r=0)throw std:runtime_error(Cannot divide by zero);return 100/r;int main(int n)return mydiv(n);6int mydiv(int r)if(r=0)throw std:runtime_error(Cannot divide by zero);return 100/r;int main(int n)try return mydiv(n);catch(.)

4、return INT_MAX;7try/catch:the handler for the abortsRuntime exceptions:try/catch/throwEither throws on error or continues on success(error and success cases are disjoint)Typical software implementation depends a call stack +HLS prefers plain state machines over call stack =HLS tools do not support e

5、xceptions8Stepping through runtime exceptions9 1.int mydiv(int r)2.if(r=0)3.throw std:runtime_error(Cannot divide by zero);4.return 100/r;5.6.int main(int n)7.try 8.return mydiv(n);9.catch(.)10.return INT_MAX;11.12.10 1.int mydiv(int r)2.if(r=0)3.throw std:runtime_error(Cannot divide by zero);4.retu

6、rn 100/r;5.6.int main(int n)7.try 8.return mydiv(n);9.catch(.)10.return INT_MAX;11.12.11main(0)External code 1.int mydiv(int r)2.if(r=0)3.throw std:runtime_error(Cannot divide by zero);4.return 100/r;5.6.int main(int n)7.try 8.return mydiv(n);9.catch(.)10.return INT_MAX;11.12.12main(0)External code

word格式文档无特别注明外均可编辑修改,预览文件经过压缩,下载原文更清晰!
三个皮匠报告文库所有资源均是客户上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作商用。
本文探讨了在硬件可合成异常处理中使用 Continuation Passing Style(CPS)的方法。CPS 将程序转换为状态机,允许在硬件中实现异常处理。文章提到,通过将返回值替换为 Continuation,编译器可以将软件中的 try/catch/throw 结构转换为硬件友好的异常处理。这种方法减少了调用栈的使用,并允许在硬件生成过程中进行优化。文章还提到了一个具体的例子,将软件中的除法异常处理转换为 CPS 形式,并通过 Intel Quartus Prime 23.1 自动生成硬件代码,用于 MAX 10 FPGA。此外,文章还讨论了在编译过程中,如何通过 Continuation 将错误处理与正常流程分离,从而使编译器能够进行优化。最后,文章提出了一个包含 19 个程序的基准测试套件,用于加速器中心的研究,并手动将其中 12 个程序转换为 CPS 形式,以评估这种方法的效果。
如何实现?" 原理与实践" 挑战与解决方案"
客服
商务合作
小程序
服务号
折叠