必备知识:
1.1 Verilog 教程 | 菜鸟教程 (runoob.com)
(36条消息) vivado使用方法_beca_se的博客-CSDN博客_vivado使用教程
(54条消息) MIPS 指令集(共31条)_goodlinux的博客-CSDN博客_32位mips指令
Q&A
xlink
1怎么样创建新项目并导入BASYS3?
- 创建3个文件,包括design,simulative resources,和comstrain文件
- run implementation(代码执行)
- generate bitstream(生成比特流;rt机器指令)
- open target(连接硬件)
- program device(上传指令)
实操练习:
7段数码管
source file
`timescale 1ns / 1ps
module display_7seg(
input CLK, // 时钟信号
input SW_in, // 开关
output reg[10:0] display_out // 输出寄存器
);
reg [19:0] count = 0;//20位计数寄存器
reg [2:0] sel = 0;//3位选择码
parameter T1MS = 50000;//时间参数
always @(posedge CLK) begin //上升沿来临时开始运行
if(SW_in == 0) begin //如果未拨下开关
case(sel) //7段译码器对应亮的段数
0: display_out <= 11'b0111_1001111;
1: display_out <= 11'b1011_0010010;
2: display_out <= 11'b1101_0000110;
3: display_out <= 11'b1110_1001100;
default: display_out <= 11'b1111_1111111;
endcase
end
else begin//如果拨下开关
case(sel)
0: display_out <= 11'b1110_1001111;
1: display_out <= 11'b1101_0010010;
2: display_out <= 11'b1011_0000110;
3: display_out <= 11'b0111_1001100;
default: display_out <= 11'b1111_1111111;
endcase
end
end
always @(posedge CLK) begin//时钟上升沿计数器开始计数
count <= count + 1;
if(count == T1MS) begin//每到固定时间就刷新
count <= 0;//count被赋值为0
sel <= sel + 1;//逐步选择亮的灯
if(sel == 4)//如果选择4就重新选择0
sel <= 0;
end
end
endmodule
simulation resources
`timescale 1ns / 1ps
module display_7seg_tb();
reg clk;
reg switch;
wire [10:0] display_out;
display_7seg mydisplay(clk, switch, display_out);//实例化变量
initial begin//初始时输入
clk = 0;
switch = 0;
end
always @(*) begin//每隔5ps时钟输入取反
#5 clk <= ~clk;
end
endmodule
module display_7seg_tb(
input CLK,
input SW_in,
output [10:0] display_out
);
endmodule
Constrains
set_property PACKAGE_PIN W5 [get_ports CLK]
set_property PACKAGE_PIN V17 [get_ports SW_in]
set_property IOSTANDARD LVCMOS33 [get_ports SW_in]
set_property IOSTANDARD LVCMOS33 [get_ports CLK]
set_property PACKAGE_PIN W4 [get_ports {display_out[10]}]
set_property PACKAGE_PIN V4 [get_ports {display_out[9]}]
set_property PACKAGE_PIN U4 [get_ports {display_out[8]}]
set_property PACKAGE_PIN U2 [get_ports {display_out[7]}]
set_property PACKAGE_PIN W7 [get_ports {display_out[6]}]
set_property PACKAGE_PIN W6 [get_ports {display_out[5]}]
set_property PACKAGE_PIN U8 [get_ports {display_out[4]}]
set_property PACKAGE_PIN V8 [get_ports {display_out[3]}]
set_property PACKAGE_PIN U5 [get_ports {display_out[2]}]
set_property PACKAGE_PIN V5 [get_ports {display_out[1]}]
set_property PACKAGE_PIN U7 [get_ports {display_out[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports {display_out[9]}]
set_property IOSTANDARD LVCMOS33 [get_ports {display_out[8]}]
set_property IOSTANDARD LVCMOS33 [get_ports {display_out[7]}]
set_property IOSTANDARD LVCMOS33 [get_ports {display_out[6]}]
set_property IOSTANDARD LVCMOS33 [get_ports {display_out[5]}]
set_property IOSTANDARD LVCMOS33 [get_ports {display_out[4]}]
set_property IOSTANDARD LVCMOS33 [get_ports {display_out[3]}]
set_property IOSTANDARD LVCMOS33 [get_ports {display_out[1]}]
set_property IOSTANDARD LVCMOS33 [get_ports {display_out[2]}]
set_property IOSTANDARD LVCMOS33 [get_ports {display_out[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports {display_out[10]}]