superstar_gu 发表于 2021-3-3 16:34

【Perf-V评测】VIVADO流水灯

<p>1 硬件设计要求<br />
当复位引脚电平为低电平时,所有led引脚电平拉低,同时,计数寄存器清零,且状态位清零<br />
(1)&nbsp;&nbsp; &nbsp;SW1为高电平时,D0,D1,D2,D3按照跑马灯运行;否则D0,D1,D2,D3灯灭<br />
(2)&nbsp;&nbsp; &nbsp;SW2为高电平时,三色D4绿灯亮;否则,三色D4切换颜色<br />
(3)&nbsp;&nbsp; &nbsp;SW3为高电平时,三色D5绿灯亮;否则,三色D5切换颜色<br />
(4)&nbsp;&nbsp; &nbsp;SW4为高电平时,三色D6绿灯亮;否则,三色D6切换颜色<br />
1.2&nbsp;&nbsp; &nbsp;VIVADO设计<br />
1.2.1&nbsp;&nbsp; &nbsp;项目创建<br />
启动vivado,选择Create New Project,指定工程名字和工程存放目录,选择RTL Project,选择FPGA设备,工程创建完成后<br />
&nbsp;<br />
1.2.2&nbsp;&nbsp; &nbsp;Verilog代码<br />
开始编写verilog代码(复制例程中的LED程序),详见附件<br />
输入:时钟clk,复位rst_n, 按键开关sw1, sw2, sw3, sw4<br />
input clk;<br />
&nbsp; &nbsp; input rst_n;<br />
&nbsp; &nbsp; input sw1;<br />
&nbsp; &nbsp; input sw2;<br />
&nbsp; &nbsp; input sw3;<br />
input sw4;<br />
输出:跑马灯pio_led01234,分别有三盏三色灯pio_rgb_d4;pio_rgb_d5; pio_rgb_d6;<br />
&nbsp; &nbsp; output reg &nbsp; pio_led0123;<br />
&nbsp; &nbsp; output reg &nbsp; pio_rgb_d4;<br />
&nbsp; &nbsp; output reg &nbsp; pio_rgb_d5;<br />
&nbsp; &nbsp; output reg &nbsp; pio_rgb_d6;<br />
中间变量:<br />
26位计数寄存器cnt<br />
4位状态寄存器state<br />
常量T<br />
程序为时钟上升沿触发或复位下降沿触发启动。<br />
当复位引脚电平为低电平时,所有led引脚电平拉低,同时,计数寄存器清零,且状态位清零<br />
当按键开关被按下时,检测状态寄存器state状态信息<br />
当state为0时,pio_led0123为高电平,其他led0123引脚为低电平,计数寄存器累加,当计数到T时,state翻转为1;<br />
当state为1时,pio_led0123为高电平,其他led0123引脚为低电平,计数寄存器累加,当计数到T时,state翻转为2;<br />
当state为2时,pio_led0123为高电平,其他led0123引脚为低电平,计数寄存器累加,当计数到T时,state翻转为3;<br />
当state为3时,pio_led0123为高电平,其他led0123引脚为低电平,计数寄存器累加,当计数到T时,state翻转为4;<br />
sw2为高,pio_rgb_d4为高,否则切换;<br />
sw3为高,pio_rgb_d5为高,否则切换;<br />
sw4为高,pio_rgb_d6为高,否则切换;</p>

<p>1.2.3&nbsp;&nbsp; &nbsp;添加XDC管脚约束文件<br />
主要分配管脚分配,设置下列信号电平为LVCMOS33:<br />
时钟clk,N14<br />
&nbsp;<br />
复位rst_n, L13<br />
&nbsp;<br />
按键开关Sw1,T15<br />
&nbsp;<br />
set_property IOSTANDARD LVCMOS33 }]<br />
set_property IOSTANDARD LVCMOS33 }]<br />
set_property IOSTANDARD LVCMOS33 }]<br />
set_property IOSTANDARD LVCMOS33 }]</p>

<p>set_property IOSTANDARD LVCMOS33 }]<br />
set_property IOSTANDARD LVCMOS33 }]<br />
set_property IOSTANDARD LVCMOS33 }]</p>

<p>set_property IOSTANDARD LVCMOS33 }]<br />
set_property IOSTANDARD LVCMOS33 }]<br />
set_property IOSTANDARD LVCMOS33 }]</p>

<p>set_property IOSTANDARD LVCMOS33 }]<br />
set_property IOSTANDARD LVCMOS33 }]<br />
set_property IOSTANDARD LVCMOS33 }]</p>

<p>set_property IOSTANDARD LVCMOS33 <br />
set_property IOSTANDARD LVCMOS33 <br />
set_property IOSTANDARD LVCMOS33 <br />
set_property IOSTANDARD LVCMOS33 <br />
set_property IOSTANDARD LVCMOS33 <br />
set_property IOSTANDARD LVCMOS33 </p>

<p>set_property PACKAGE_PIN N14 <br />
set_property PACKAGE_PIN L13 </p>

<p>set_property PACKAGE_PIN T15 <br />
set_property PACKAGE_PIN M14 <br />
set_property PACKAGE_PIN L14 <br />
set_property PACKAGE_PIN K13 </p>

<p>set_property PACKAGE_PIN M16 }]<br />
set_property PACKAGE_PIN N16 }]<br />
set_property PACKAGE_PIN P15 }]<br />
set_property PACKAGE_PIN P16 }]</p>

<p>set_property PACKAGE_PIN M2 }]<br />
set_property PACKAGE_PIN L5 }]<br />
set_property PACKAGE_PIN P5 }]</p>

<p>set_property PACKAGE_PIN N12 }]<br />
set_property PACKAGE_PIN P10 }]<br />
set_property PACKAGE_PIN P11 }]</p>

<p>set_property PACKAGE_PIN R12 }]<br />
set_property PACKAGE_PIN P6 }]<br />
set_property PACKAGE_PIN K12 }]</p>

<p>1.2.4&nbsp;&nbsp; &nbsp;编译<br />
代码写好,检查无语法错误,开始进行run synthesis和run implementation<br />
&nbsp;<br />
然后指定硬件管脚,有D0~D3,sw1~sw4对应的四盏红色LED灯和四个开关:<br />
&nbsp;<br />
1.2.5&nbsp;&nbsp; &nbsp;生成下载bit文件并下载<br />
&nbsp;<br />
1.3&nbsp;&nbsp; &nbsp;程序运行结果</p>

<p><a href="javascript:;" id="attachname526680" isimage="0" onclick="insertAttachTag('526680');doane(event);" title="81009b647db56c3dc2659eeabf1224cd.mp4
上传日期: 2021-3-3 16:29
文件大小: 2.72 MB">81009b647db56c3dc2659eeab ...</a></p>

<p><a href="javascript:;" id="attachname526682" isimage="0" onclick="insertAttachTag('526682');doane(event);" title="LEDTEST02.rar
上传日期: 2021-3-3 16:31
文件大小: 545.49 KB">LEDTEST02.rar</a></p>

<p><br />
<br />
<br />
<br />
&nbsp;</p>
页: [1]
查看完整版本: 【Perf-V评测】VIVADO流水灯