add buttons into example

This commit is contained in:
nekomona 2022-04-02 10:10:54 +08:00 committed by Zihao Yu
parent 23e79f86a6
commit 731fa8f41c
4 changed files with 11 additions and 7 deletions

View File

@ -5,7 +5,7 @@
该示例的演示效果如下:
1. 左边8个LED为流水灯效果
1. 拨动右边的8个拨码开关, 可控制对应LED的亮灭
1. 按下按钮可将8~12号中对应的LED亮灭效果取反
1. 8个数码管流水显示数字0-7
1. 按钮暂无展示效果
1. 窗口右侧为VGA输出, 将会展示一张图片
1. 敲击键盘, 终端将会输出按键的扫描码

View File

@ -1,15 +1,16 @@
top=top
# VGA_CLK is set to clk in this example
VGA_VSYNC VGA_VSYNC
VGA_HSYNC VGA_HSYNC
VGA_BLANK_N VGA_BLANK_N
VGA_R (VGA_R7, VGA_R6, VGA_R5, VGA_R4, VGA_R3, VGA_R2, VGA_R1, VGA_R0)
VGA_G (VGA_G7, VGA_G6, VGA_G5, VGA_G4, VGA_G3, VGA_G2, VGA_G1, VGA_G0)
VGA_B (VGA_B7, VGA_B6, VGA_B5, VGA_B4, VGA_B3, VGA_B2, VGA_B1, VGA_B0)
ledr (LD15, LD14, LD13, LD12, LD11, LD10, LD9, LD8, LD7, LD6, LD5, LD4, LD3, LD2, LD1, LD0)
sw (SW7, SW6, SW5, SW4, SW3, SW2, SW1, SW0)
btn (BTNL, BTNU, BTNC, BTND, BTNR)
seg0 (SEG0A, SEG0B, SEG0C, SEG0D, SEG0E, SEG0F, SEG0G, DEC0P)
seg1 (SEG1A, SEG1B, SEG1C, SEG1D, SEG1E, SEG1F, SEG1G, DEC1P)
seg2 (SEG2A, SEG2B, SEG2C, SEG2D, SEG2E, SEG2F, SEG2G, DEC2P)

View File

@ -1,6 +1,7 @@
module led(
input clk,
input rst,
input [4:0] btn,
input [7:0] sw,
output [15:0] ledr
);
@ -14,5 +15,5 @@ module led(
end
end
assign ledr = {led, sw};
assign ledr = {led[7:5], led[4:0] ^ btn, sw};
endmodule

View File

@ -1,6 +1,7 @@
module top (
module top(
input clk,
input rst,
input [4:0] btn,
input [7:0] sw,
input ps2_clk,
input ps2_data,
@ -22,9 +23,10 @@ module top (
output [7:0] seg7
);
led led1(
led my_led(
.clk(clk),
.rst(rst),
.btn(btn),
.sw(sw),
.ledr(ledr)
);
@ -56,7 +58,7 @@ ps2_keyboard my_keyboard(
.ps2_data(ps2_data)
);
seg mu_seg(
seg my_seg(
.clk(clk),
.rst(rst),
.o_seg0(seg0),
@ -77,7 +79,7 @@ vmem my_vmem(
endmodule
module vmem (
module vmem(
input [9:0] h_addr,
input [8:0] v_addr,
output [23:0] vga_data