返回顶部
返回首页 会员充值 我的足迹 返回上一页

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

2025-05-01
文档编号:651827
文档页数:50
文档大小:512.23KB
下载积分:VIP专享
文档格式:PDF

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

使用延续的硬件可合成异常.pdf_第1页
使用延续的硬件可合成异常.pdf_第2页
使用延续的硬件可合成异常.pdf_第3页
使用延续的硬件可合成异常.pdf_第4页
使用延续的硬件可合成异常.pdf_第5页

点击查看更多