为了在电脑端设置一系列的数据而不用使用拨位开关,我们这里使用VIO(Virtual Input-Output)核进行操作,按照https://www.cnblogs.com/kingstacker/p/9810704.html中的方法,如果我们想要使用虚拟IO代替拨位开关的话,可以将VIO核配置如下,然后在PROBE_OUT_Ports中将probe_width 设为16即可。
代码如下:
wire [15:0] SW;
vio_0 vio_inst(.clk(Clk),.probe_in0(),.probe_out0(SW));
多输出端口
重新生成bitstream之后要program!
如果我们有如下的分开赋值的操作,我们可能需要把这十六位分成两部分:
assign Num1 = {SW[15:8]}; //2 bit BCD code
assign Num2 = {SW[7:0]};
我们尝试添加新的VIO核和将原来的VIO核改为8输出然后实例化两次,都失败了,比如添加新的VIO的代码如下:
vio_0 vio_inst0(.clk(Clk),.probe_in0(),.probe_out0(Num1));
vio_1 vio_inst1(.clk(Clk),.probe_in0(),.probe_out0(Num2));
会得到如下的结果。猜测原因是一块Basys3上只有一个对应IP核?
可能并不是,具体没有测试,但是重新编辑IP核之后,移除先前的文件仍然会在srcs中保存,干扰配置。
这仍然不是核心解决方法。查看Tcl shell
WARNING: [Labtools 27-1972] Mismatch between the design programmed into the device xc7a35t (JTAG device index = 0) and the probes file(s) D:/OneDrive - pku.edu.cn/xilinxproj/lab4-final/lab4-final.runs/impl_1/Top_module.ltx.
The core at location uuid_10B6415846A85B7596E07529A8F6E526 has different widths for VIO input port 0. Port width in the device core is 16, but port width in the probes file is 1.
Resolution:
1. Reprogram device with the correct programming file and associated probes file(s) OR
2. Goto device properties and associate the correct probes file(s) with the programming file already programmed in the device.
随后重新配置,并尝试重新program即可
对应地,将代码改为
vio_0 vio_inst0(.clk(Clk),.probe_in0(),.probe_out0(Num1),.probe_out1(Num2));
另外还可以调整进制,以使得输入变得更加自然。