Tengo un problema con un módulo en Verilog donde necesito escanear una matriz de botones 4x4. No puedo escanear cada fila 1 por una, pero la cosa se queda con la primera fila. ¿Puedes ayudarme a depurarlo? A mi me parece lógicamente correcto.
El código es:
module keyboardScanner(input clk,input [3:0] col, output reg [3:0] row,output reg [7:0] keyCode);
always @(posedge clk)begin
row = 4'b1000;
if(col != 4'b0000)begin
keyCode[0] = row[0];
keyCode[1] = row[1];
keyCode[2] = row[2];
keyCode[3] = row[3];
keyCode[4] = col[0];
keyCode[5] = col[1];
keyCode[6] = col[2];
keyCode[7] = col[3];
end
row = 4'b0100;
if(col != 4'b0000)begin
keyCode[0] = row[0];
keyCode[1] = row[1];
keyCode[2] = row[2];
keyCode[3] = row[3];
keyCode[4] = col[0];
keyCode[5] = col[1];
keyCode[6] = col[2];
keyCode[7] = col[3];
end
row = 4'b0010;
if(col != 4'b0000)begin
keyCode[0] = row[0];
keyCode[1] = row[1];
keyCode[2] = row[2];
keyCode[3] = row[3];
keyCode[4] = col[0];
keyCode[5] = col[1];
keyCode[6] = col[2];
keyCode[7] = col[3];
end
row = 4'b0001;
if(col != 4'b0000)begin
keyCode[0] = row[0];
keyCode[1] = row[1];
keyCode[2] = row[2];
keyCode[3] = row[3];
keyCode[4] = col[0];
keyCode[5] = col[1];
keyCode[6] = col[2];
keyCode[7] = col[3];
end
end
endmodule // keyboardScanner