0
\$\begingroup\$

I have a 4x4 keybord matrix fsm scanner but it generates only high keycode setting all last 4 bits to 1 and second and fourth digits to high. Is there anything wrong in my code here?

module keyboardScanner (input clk, input [3:0] col,output reg [3:0] row, output reg [7:0] keyCode);
reg [1:0]state=2'b00;
reg [1:0]nextState=2'b00;
//state register
always@(posedge clk) begin
 state <= nextState;
end
//output CL
always@(posedge clk) begin
 case (state)
 2'b00: row <= 4'b0001;
 2'b01: row <= 4'b0010;
 2'b10: row <= 4'b0100;
 2'b11: row <= 4'b1000;
 default: row <= 4'b0001;
 endcase
 if (col != 4'b0000) begin
 keyCode <= {row[0],row[1],row[2],row[3], col[0],col[1],col[2],col[3]};
 end
end
//next state CL
always @(posedge clk) begin
 case (state)
 2'b00: nextState <= 2'b01;
 2'b01: nextState <= 2'b10;
 2'b10: nextState <= 2'b11;
 2'b11: nextState <= 2'b00;
 default: nextState <= 2'b00;
 endcase
end
endmodule

Please help me. It used to work 2 days ago, but now... :/

asked Nov 8, 2015 at 17:51
\$\endgroup\$
9
  • \$\begingroup\$ Do you have any documentation or schematic for us? \$\endgroup\$ Commented Nov 8, 2015 at 18:27
  • \$\begingroup\$ Are you using the Digilent keypad as a Pmod device? There is the possibiliy of floating inputs ... you should enable pullups in the FPGA's IOBs. \$\endgroup\$ Commented Nov 8, 2015 at 20:43
  • \$\begingroup\$ I found the original Digilent example code for the 4×4 keypad. You have to drive column and read row! This prevents you from having floating inputs. \$\endgroup\$ Commented Nov 8, 2015 at 21:06
  • \$\begingroup\$ Ok, I have found a board picture, but I can't find any schematic. Have a look at the Digilent PmodKYPD and its schematic. As you can see the columns have no pullup or pulldown resistor, whereas the rows have. That means columns have to be driven and rows to read. Please compare it to your beti board schematic. \$\endgroup\$ Commented Nov 9, 2015 at 6:50
  • \$\begingroup\$ There is no resistor in either of them in beti board so its quite different. No matter if you choose row or col as driver it will be the same. Thanks for information, it will be helpful knowledge :) \$\endgroup\$ Commented Nov 9, 2015 at 11:55

1 Answer 1

1
\$\begingroup\$

I found the answer. It was a clock halt problem. Clock was grounded and it destroyed the thing. Now it works fine!

answered Nov 8, 2015 at 18:42
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.