国产FPGA高云GW1N-4系列开发板测评之——UART实现和嵌入式逻辑分析仪的使用
<div class='showpostmsg'><p style="text-indent:31.0pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">今天玩一玩UART FPGA实现以及高云云源软件的嵌入式逻辑分析仪的使用</span></span></span></span></span></span></span></span></p><p align="left" style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span lang="EN-US" style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt"> GAO </span></span></span></span></span><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">具有以下特性:</span></span></span></span></span></span></span></span></p>
<p align="left" style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span lang="EN-US" style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt"> </span></span></span></span></span><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">最多支持 16 个功能内核</span></span></span></span></span></span></span></span></p>
<p align="left" style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span lang="EN-US" style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt"> </span></span></span></span></span><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">每个功能内核支持一个或多个端口触发</span></span></span></span></span></span></span></span></p>
<p align="left" style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span lang="EN-US" style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt"> </span></span></span></span></span><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">每个功能内核支持一个或多个触发等级</span></span></span></span></span></span></span></span></p>
<p align="left" style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span lang="EN-US" style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt"> </span></span></span></span></span><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">每个触发端口支持一个或多个匹配单元</span></span></span></span></span></span></span></span></p>
<p align="left" style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span lang="EN-US" style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt"> </span></span></span></span></span><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">每个匹配单元均支持 6 种触发匹配类型</span></span></span></span></span></span></span></span></p>
<p align="left" style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span lang="EN-US" style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt"> </span></span></span></span></span><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">支持设置静态或者动态触发表达式</span></span></span></span></span></span></span></span></p>
<p align="left" style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span lang="EN-US" style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt"> </span></span></span></span></span><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">支持捕获 RTL 综合优化前或者综合优化后信号</span></span></span></span></span></span></span></span></p>
<p align="left" style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span lang="EN-US" style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt"> </span></span></span></span></span><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">功能内核采用窗口采集模式,支持一个或多个窗口采集</span></span></span></span></span></span></span></span></p>
<p align="left" style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span lang="EN-US" style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt"> </span></span></span></span></span><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">支持导出 csv、vcd 和 prn 三种格式的波形数据文件</span></span></span></span></span></span></span></span></p>
<p align="left" style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span lang="EN-US" style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt"> </span></span></span></span></span><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">使用数据端口,节省器件资源</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">首先新建工程添加UART实现代码,实现单字节回环UART接收发送,实现代码网上很多,高云也提供,稍作修改,随附件提供在帖子后面:</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">添加物理和主时钟约束后编译没问题后添加创建嵌入式配置文件(.gao/.rao),其中.rao为选择类型“For RTL Design”用于捕获综合优化前的RTL信号,.gao为类型“For Post-Synthesis Netlist”,用于捕获综合优化后的Netlist信号,我们已经编译了工程就以优化后的netlist信号为例:</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">打开配置文件后,AoCore中右键可以添加新核16个,每个核有16个触发端口,每个端口可接宽度最大64bit信号,双击Trigger Port0即可添加Netlist信号如下图:</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">添加完信号后在Math Units单元中设置添加信号的触发条件,如果后面Expressions中选择static则触发条件可选择16个,如果选择Dynamic的话触发条件最多10个,勾选Match Unit后双击可打开Math Unit 配置窗口,Math Type中根据需要选择检测类型,类型不同资源会不一样。Value中注意“R”表示上升沿,“F”表示下降沿,“B”表示两者均可。Counter窗可以设置满足几次条件后触发抓取</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">然后就是表达式窗口设置了,设置几种触发信号之间的关系,一个核可设16个表达式当然资源是不一样的,之前提到了选择 静态表达式和动态表达式的资源也是不一样的,动态表达式可以在下载抓取程序后在Gowin Analyzer Osxilloscope中动态的修改</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">然后是抓取选项窗口设置,设置采样时钟,一般要设置成同源时钟且遵循采样定理,设置采样点数,可以看到消耗的资源如下图:</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">完事后保存配置文件重新编译生成bit流打开Gowin Analyzer Osxilloscope,嵌入式抓取工具:</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span lang="EN-US" style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">Gowin Analyzer Osxilloscope </span></span></span></span></span><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">中集成了编程下载工具,勾选使能窗口可看见新生成的带嵌入式抓取核的bit流文件ao_0.fs。</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">连接串口,上电后板子连接如图:</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">然后单击下载程序,噢噢果然没那么顺利:</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">出错了下载失败,啥原因没个提示,看看工具栏有没有什么,找到一个器件扫描试试:</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">提示找不到器件,怪了测试的坛友也遇到类似的问题吗?检查一下下载线连接,打开下载工具发现下载没有问题,单单就这个Gowin Analyzer Osxilloscope 中集成的下载工具下载不了,好吧认不到端口莫非是我的串口跟下载线在同一台电脑上让工具迷路了?果断拔下串口线,下载还是失败:</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">关闭工具重新打开再试成功!</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">串口发送”A”,串口工具已经收到”A”了,抓取的波形如图:</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">示波器抓取如图:</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span lang="EN-US" style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">“A”</span></span></span></span></span><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">的ASCII码为01000001,串口低位在前高位在后:如下图是“B”:</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:宋体"><span style="color:#444444"><span style="letter-spacing:.75pt">好,FPGA串口实现和嵌入式逻辑分析仪使用学习到这里。</span></span></span></span></span></span></span></span></p>
<p style="text-align:justify"> </p>
</div><script> var loginstr = '<div class="locked">查看精华帖全部内容,请<a href="javascript:;" style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
if(parseInt(discuz_uid)==0){
(function($){
var postHeight = getTextHeight(400);
$(".showpostmsg").html($(".showpostmsg").html());
$(".showpostmsg").after(loginstr);
$(".showpostmsg").css({height:postHeight,overflow:"hidden"});
})(jQuery);
}
</script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script> <p>嵌入式逻辑分析仪是芯片自带的功能吗?</p>
<p>是的,看来你没有用过FPGA吧?FPGA带有的具有嵌入式探测功能的模块,是用于在线调试逻辑时抓取信号使用的。</p>
<p>看你们玩,不太会fpga,牛逼!</p>
页:
[1]