上次,我提出了一个 现场可编程门阵列教程 关于如何控制 4位7段显示 在 Basys 3 现场可编程门阵列 板。充分 Verilog 和 甚高密度脂蛋白 显示4位数字的代码 7段显示 的 现场可编程门阵列 Basys 3 还提供了。
这个 现场可编程门阵列教程 告诉您如何将鼠标与 Xilinx Basys 3 现场可编程门阵列板。的 现场可编程门阵列教程 还提供了 Verilog代码 用于与鼠标接口 现场可编程门阵列 Basys 3.

机载 辅助功能微控制器 PIC24FJ128 允许 Basys 3 现场可编程门阵列 具有 USB HID主机 能力。一旦 现场可编程门阵列 被编程, 微控制器 在 USB HID 主机模式可以连接 现场可编程门阵列 与 鼠 要么 键盘 连接到 USB A型连接器 (J2)如下图所示。

如图所示 如上图所示,微控制器的PS2_CLK和PS2_DAT信号用于实现 PS / 2接口 for communication 与 鼠 要么 键盘. The other signals 是 to program the 现场可编程门阵列 from a USB随身碟 连接到 USB-HID端口 (J2)当JP1编程模式跳线设置为“ USB”时。
在这个 现场可编程门阵列教程,我们只关注板载的PS / 2接口 微控制器 与鼠标通信。在这种情况下,微控制器的行为就像 PS / 2总线 和连接到 USB-HID端口 可以使用 两线制(时钟和数据)串行总线(PS / 2协议)与 现场可编程门阵列 作为主持人。鼠标将时钟和数据信号发送到 现场可编程门阵列 when it is moved as shown in the following figure; otherwise, these signals 是 held high.
在这个 现场可编程门阵列教程,我们只关注板载的PS / 2接口 微控制器 与鼠标通信。在这种情况下,微控制器的行为就像 PS / 2总线 和连接到 USB-HID端口 可以使用 两线制(时钟和数据)串行总线(PS / 2协议)与 现场可编程门阵列 作为主持人。鼠标将时钟和数据信号发送到 现场可编程门阵列 when it is moved as shown in the following figure; otherwise, these signals 是 held high.


鼠标的三字节移动数据包括鼠标状态字节,X方向字节和Y方向字节。该数据仅在时钟信号的下降沿有效。 X方向和Y方向字节用于显示鼠标的相对坐标,该鼠标左右移动将生成正/负X,而移动到顶部/底部将生成正/负Y。鼠标状态字节用作X和Y的“符号”位。 X 和 Y the 鼠标速度更快; XY和YY位指示运动溢出。鼠标状态字节中的L和R位用于指示是否按下了鼠标的向左和向右按钮。
简而言之,鼠标总是发送上图所示格式的33位数据信号到 Basys 3 现场可编程门阵列 每当鼠标移动时。左键单击状态显示在数据的第二位,而第三位表示右键单击状态 of the 鼠. X和Y坐标 are 分别从33位数据的第13至20位和24至30位发送。
在这个 现场可编程门阵列教程, a Verilog代码 用于与鼠标接口 现场可编程门阵列 Basys 3 被呈现。每次单击鼠标左键,都会在显示屏的7段显示屏上显示一个4位数字。 Basys 3 现场可编程门阵列板 增加一。另一方面,鼠标右键单击将显示的数字减一。
Verilog代码 用于与鼠标接口 Basys 3 现场可编程门阵列板:
// hzgifts.cn: 现场可编程门阵列项目, Verilog projects, 甚高密度脂蛋白 projects // 现场可编程门阵列教程: 如何将鼠标与Basys 3 现场可编程门阵列接口 // Verilog代码 用于将鼠标与Basys 3接口 现场可编程门阵列 board module 鼠_basys3_澳门在线( input clock_100Mhz, // 100 Mhz clock source on Basys 3 现场可编程门阵列 input reset, // reset input Mouse_Data, // Mouse PS2 data input Mouse_Clk, // Mouse PS2 Clock output reg [3:0] Anode_Activate, // anode signals 的 the 7-segment LED display output reg [6:0] LED_out// cathode patterns 的 the 7-segment LED display ); reg [5:0] Mouse_bits; // count number 的 bits receiving from the PS2 鼠 reg [26:0] one_second_counter; // counter for generating 1 second clock enable wire one_second_enable;// one second enable for counting numbers reg [15:0] displayed_number; // Number to be increased 和 decreased by the 鼠 reg [3:0] LED_BCD; // Signals for displaying on 7-segment LED 的 Basys 3 现场可编程门阵列 reg [20:0] refresh_counter; // the first 19-bit for creating 190Hz refresh rate // the other 2-bit for creating 4 LED-activating signals wire [1:0] LED_activating_counter; // counting the number 的 bits receiving from the Mouse Data // 33 bits to be received from the Mouse always @(posedge Mouse_Clk 要么 posedge reset) begin if(reset==1) Mouse_bits <= 0; else if(Mouse_bits <=31) Mouse_bits <= Mouse_bits + 1; else Mouse_bits <= 0; end // Increase/Decrease the number when pressing Left/Right Mouse always @(negedge Mouse_Clk 要么 posedge reset) begin if(reset) displayed_number <= 0; else begin if(Mouse_bits==1) begin if(Mouse_Data==1) // if The 鼠 is left clicked, increase the number displayed_number <= displayed_number + 1; end else if(Mouse_bits==2) begin if(Mouse_Data==1&&displayed_number>0)// if The 鼠 is right clicked, decrease the number displayed_number <= displayed_number - 1; end end end // refreshing the 4位7段显示 on Basys 3 现场可编程门阵列 always @(posedge clock_100Mhz 要么 posedge reset) begin if(reset==1) refresh_counter <= 0; else refresh_counter <= refresh_counter + 1; end assign LED_activating_counter = refresh_counter[20:19]; // anode activating signals for 4 LEDs // decoder to generate anode signals always @(*) begin case(LED_activating_counter) 2'b00: begin Anode_Activate = 4'b0111; // activate LED1 和 Deactivate LED2, LED3, LED4 LED_BCD = displayed_number/1000; // the first digit 的 the 16-bit number end 2'b01: begin Anode_Activate = 4'b1011; // activate LED2 和 Deactivate LED1, LED3, LED4 LED_BCD = (displayed_number % 1000)/100; // the second digit 的 the 16-bit number end 2'b10: begin Anode_Activate = 4'b1101; // activate LED3 和 Deactivate LED2, LED1, LED4 LED_BCD = ((displayed_number % 1000)%100)/10; // the third digit 的 the 16-bit number end 2'b11: begin Anode_Activate = 4'b1110; // activate LED4 和 Deactivate LED2, LED3, LED1 LED_BCD = ((displayed_number % 1000)%100)%10; // the fourth digit 的 the 16-bit number end endcase end // Cathode patterns 的 the 7-segment LED display always @(*) begin case(LED_BCD) 4'b0000: LED_out = 7'b0000001; // "0" 4'b0001: LED_out = 7'b1001111; // "1" 4'b0010: LED_out = 7'b0010010; // "2" 4'b0011: LED_out = 7'b0000110; // "3" 4'b0100: LED_out = 7'b1001100; // "4" 4'b0101: LED_out = 7'b0100100; // "5" 4'b0110: LED_out = 7'b0100000; // "6" 4'b0111: LED_out = 7'b0001111; // "7" 4'b1000: LED_out = 7'b0000000; // "8" 4'b1001: LED_out = 7'b0000100; // "9" default: LED_out = 7'b0000001; // "0" endcase end endmodule
销约束文件 用于将鼠标与Basys 3接口 现场可编程门阵列:
# fpga4student.com: 现场可编程门阵列 projects, Verilog projects, 甚高密度脂蛋白 projects # 现场可编程门阵列 tutorial: How to interface a 鼠 with Basys 3 现场可编程门阵列 # Verilog代码 for interfacing a 鼠 with the Basys 3 现场可编程门阵列 board ##USB HID (PS/2) set_property PACKAGE_PIN C17 [get_ports Mouse_Clk] set_property IOSTANDARD LVCMOS33 [get_ports Mouse_Clk] set_property PULLUP true [get_ports Mouse_Clk] set_property PACKAGE_PIN B17 [get_ports Mouse_Data] set_property IOSTANDARD LVCMOS33 [get_ports Mouse_Data] set_property PULLUP true [get_ports Mouse_Data] # Clock signal set_property PACKAGE_PIN W5 [get_ports clock_100Mhz] set_property IOSTANDARD LVCMOS33 [get_ports clock_100Mhz] set_property PACKAGE_PIN R2 [get_ports reset] set_property IOSTANDARD LVCMOS33 [get_ports reset] #seven-segment LED display set_property PACKAGE_PIN W7 [get_ports {LED_out[6]}] set_property IOSTANDARD LVCMOS33 [get_ports {LED_out[6]}] set_property PACKAGE_PIN W6 [get_ports {LED_out[5]}] set_property IOSTANDARD LVCMOS33 [get_ports {LED_out[5]}] set_property PACKAGE_PIN U8 [get_ports {LED_out[4]}] set_property IOSTANDARD LVCMOS33 [get_ports {LED_out[4]}] set_property PACKAGE_PIN V8 [get_ports {LED_out[3]}] set_property IOSTANDARD LVCMOS33 [get_ports {LED_out[3]}] set_property PACKAGE_PIN U5 [get_ports {LED_out[2]}] set_property IOSTANDARD LVCMOS33 [get_ports {LED_out[2]}] set_property PACKAGE_PIN V5 [get_ports {LED_out[1]}] set_property IOSTANDARD LVCMOS33 [get_ports {LED_out[1]}] set_property PACKAGE_PIN U7 [get_ports {LED_out[0]}] set_property IOSTANDARD LVCMOS33 [get_ports {LED_out[0]}] set_property PACKAGE_PIN U2 [get_ports {Anode_Activate[0]}] set_property IOSTANDARD LVCMOS33 [get_ports {Anode_Activate[0]}] set_property PACKAGE_PIN U4 [get_ports {Anode_Activate[1]}] set_property IOSTANDARD LVCMOS33 [get_ports {Anode_Activate[1]}] set_property PACKAGE_PIN V4 [get_ports {Anode_Activate[2]}] set_property IOSTANDARD LVCMOS33 [get_ports {Anode_Activate[2]}] set_property PACKAGE_PIN W4 [get_ports {Anode_Activate[3]}] set_property IOSTANDARD LVCMOS33 [get_ports {Anode_Activate[3]}]
喂我'将此文件上传到我的Basys3板上,但对我不起作用。您对我应该注意的某些方面有什么建议吗?
回复删除1.确保单击时移动鼠标。
删除2.确保在运行之前重置电路。复位= 1以复位电路,然后复位= 0以进行操作
就我而言,它也不起作用。显示屏仅显示0.000,当我将其重置为0时。~~~,它仍然没有't detect the 鼠's displacement.
删除我刚刚上传了整个Vivado项目文件,该文件在视频中的澳门在线上进行了演示。您可以下载并重试。
删除