新建两个工程:led1、led4
工程1:led1,led1的间断闪烁
module led1
(
input wire sys_clk,
output reg led1
);
localparam LOOP_TIME = 24'd500_0000;
reg [23:0] cnt_loop;
always @(posedge sys_clk)
begin
if(cnt_loop==LOOP_TIME)
cnt_loop <= 24'd0;
else
cnt_loop <= cnt_loop + 1'b1;
end
always @(posedge sys_clk)
begin
if(cnt_loop==LOOP_TIME)
led1 <= ~led1;
else
led1 <= led1;
end
endmodule
set_property PACKAGE_PIN N21 [get_ports sys_clk]
set_property IOSTANDARD LVCMOS15 [get_ports sys_clk]
set_property PACKAGE_PIN M15 [get_ports led1]
set_property IOSTANDARD LVCMOS15 [get_ports led1]
set_property CFGBVS VCCO [current_design]
set_property CONFIG_VOLTAGE 3.3 [current_design]
set_property BITSTREAM.GENERAL.COMPRESS TRUE [current_design]
set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design]
set_property BITSTREAM.CONFIG.CONFIGFALLBACK ENABLE [current_design]
set_property BITSTREAM.CONFIG.NEXT_CONFIG_ADDR 0x00400000 [current_design]
#set_property BITSTREAM.CONFIG.NEXT_CONFIG_REBOOT ENABLE [current_design]
#set_property BITSTREAM.CONFIG.SPI_32BIT_ADDR YES [current_design]
(1)XDC文件中,CFGBVS是一个逻辑输入,VCCO_0和GND之间的引脚引用。当CFGBVS引脚为高(例如,连接VCCO_0提供3.3V或2.5V),在bank0上的配置和JTAG I/O支持在配置期间和配置后,在3.3V或2.5V下运行;当CFGBVS引脚为Low时(例如,连接到GND),bank0的I/O支持1.8V或1.5V运行(或者说:在硬件上,当VCCO_0连接2.5V或3.3V电压时,CFGBVS需要连接至VCCO_0;而当VCCO_0连接1.5V或1.8V电压时,CFGBVS需要连接至GND),如果在配置期间使用bank 14 和 15 ,其应该匹配应用于 bank 0 的 VCCO 电平。CFGBVS 引脚在 Virtex-7 HT 器件上不可用。 Virtex-7 HT 器件仅支持 bank 0 的 1.8V/1.5V 操作。
(2)
set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design]
set_property BITSTREAM.CONFIG.CONFIGFALLBACK ENABLE [current_design]
set_property BITSTREAM.CONFIG.NEXT_CONFIG_ADDR 0x00400000 [current_design]
这三条命令分别用来设置:
配置flash时SPI的数据线宽度(普通SPI还是qspi);
当配置失败时,使能加载默认的bit文件;
使用下一个配置映像的启动地址设置热启动地址(WBSTAR[28:0]位)寄存器
工程2:led4,led4的间断闪烁
module led4
(
input wire sys_clk,
output reg led4
);
localparam LOOP_TIME = 24'd500_0000;
reg [23:0] cnt_loop;
always @(posedge sys_clk)
begin
if(cnt_loop==LOOP_TIME)
cnt_loop <= 24'd0;
else
cnt_loop <= cnt_loop + 1'b1;
end
always @(posedge sys_clk)
begin
if(cnt_loop==LOOP_TIME)
led4 <= ~led4;
else
led4 <= led4;
end
endmodule
set_property PACKAGE_PIN N21 [get_ports sys_clk]
set_property IOSTANDARD LVCMOS15 [get_ports sys_clk]
set_property PACKAGE_PIN M16 [get_ports led4]
set_property IOSTANDARD LVCMOS15 [get_ports led4]
set_property CFGBVS VCCO [current_design]
set_property CONFIG_VOLTAGE 3.3 [current_design]
set_property BITSTREAM.GENERAL.COMPRESS TRUE [current_design]
set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design]
set_property BITSTREAM.CONFIG.CONFIGFALLBACK ENABLE [current_design]
#set_property BITSTREAM.CONFIG.SPI_32BIT_ADDR YES [current_design]
将两个工程的bit文件:led1.bit与led4.bit组合生成.mcs文件(此处提供两种方法:Tcl与GUI)
方法1(GUI):
Tools -> generate memory configuration file
其中1为flash型号;2为指定生成的.mcs文件;3为指定SPI接口类型和bit文件
(2)方法2(tcl命令):
write_cfgmem -format mcs -interface SPIX4 -size 16 -loadbit "up 0 <path>/golden.bit up
0x0400000 <path>/update.bit" <path>/filename.mcs
下载mcs至flash
选择相应的flash型号
查看结果
发现执行了led4工程
破坏led4.bit文件,然后重新生成.mcs文件,发现led1闪烁