Verilog에 익숙하지 않으며 keybord의 키를 누를 때 뭔가를 표시해야하는 첫 번째 프로그램 중 하나를 만들려고합니다. Verilog 교과서의 예제 코드를 사용하고 싶지만, 핀 할당 (Altera의 DE2-70을 사용)에 문제가 있습니다.Verilog의 Keybord 인터페이스 디자인
- 왜 나는
input ReadKB;
을 가지고 있는데, 모듈 정의에는 이와 같은 것이 없습니까? - KBclk 및 KB 데이터에 할당되어야하는 핀을 알고 있습니다. ? 어떤 ResetKB에 대한 (
PS2_KBCLK PIN_F24 PS/2 Clock
및 (PS2_KBDAT PIN_E24 PS/2 Data
)
은 교재에서 아무런 설명이없는 나는 그것에 대해 정말 courious입니다
코드 :.!
module KeyboardInterface(KBclk, KBdata, ResetKB, SYNclk, ScanRdy, ScanCode, KeyReleased);
input KBclk;
input KBdata;
input ResetKB;
input ReadKB;
input SYNclk;
output ScanRdy;
output ScanCode;
output KeyReleased;
//Generate an internal synchronized clock
reg Clock;
always @(posedge SYNclk) Clock = KBclk;
reg[3:0] BitCount;
reg StartBitDetected, ScanRdy;
reg[7:0] ScanCode;
//Count the number of serial bits and collect data into ScanCode
always @(posedge Clock) begin
if(ResetKB) begin
BitCount=0; StartBitDetected =0;
end else begin
if(KBdata == 0 && StartBitDetected == 0) begin
StartBitDetected=1;
ScanRdy = 0;
end else if (StartBitDetected) begin
if(BitCount < 8) begin
BitCount = BitCount + 1;
ScanCode = {KBdata, ScanCode[7:1]};
end else begin
StartBitDetected = 0;
BitCount = 0;
ScanRdy = 1;
end
end
end
end
reg [1:0] CompletionState;
wire KeyReleased;
//keep track of the state of Scan Codes outputted
always @(posedge SYNclk) begin
if(ResetKB) CompletionState = 0;
else case(CompletionState)
0: if(ScanCode == 8'h70 && ScanRdy == 1) CompletionState =1;
else CompletionState =0;
1: if(ScanRdy == 1) CompletionState =1;
else CompletionState =2;
2: if(ScanRdy == 0) CompletionState = 2;
else CompletionState = 0;
3: CompletionState = 0;
endcase
end
assign KeyReleased = CompletionState == 3 ? 1 : 0;
endmodule
감사합니다
# 1은 오타처럼 보입니다. 그냥 실종 와이어를 defn 모듈에 추가하십시오. 나는 # 2를 이해하지 못한다; "핀을 찾을 수있다"는 것은 무엇을 의미합니까? 정확히 어떤 작업을하고 있습니까? – Tim
@Tim, 내 질문을 편집했습니다. 내 말은 : 어떤 핀을 지정해야하는지 알고 있습니다. – alicjasalamon
당신이 묻는 것이 실제로 키보드에서 리셋되지는 않습니다. 사용 가능한 경우 알테라의 푸시 버튼에 연결합니다. – Tim