Question: I am struggling with creating a program in Verilog ( inside Quartus Prime ) which takes a series of button presses ( short and long
I am struggling with creating a program in Verilog inside Quartus Prime which takes a series of button presses short and long presses representing dots and dashes and outputs the corresponding letter in morse code. Im using a DE Lite Board with a MHz clock, which has a seven segment LED display.
The Idea is this:
Button not being pressed Idle Nothing displayed
Button pressed Short or Long? wait for next press Short or Long? etc wait until the user stops pressing arbitrary amount of time output corresponding letter on the seven segment display
When I compile, pin plan, and upload it to my board, I get no response to my button presses, and what looks like a on a seven segment display without the bottommost segment being lit is there during idle with no pressing. I am very confused, and struggling to complete this, which must be done soon. Any assistance and advice would be amazing, thank you in advance! My code is provided below!
module MorseCode
input CLK Clock signal
input BUTTON, Push button input
output reg : segments Sevensegment display output
;
reg : counter; Counter for measuring button press duration
reg : state; FSM state variable
reg : morsecode; Morse code input variable
parameter LONGPRESSTHRESHOLD ; Adjust for your clock frequency
Define Morse code patterns for letters
parameter : A b;
parameter : B b;
parameter : C b;
parameter : D b;
parameter : E b;
parameter : F b;
parameter : G b;
parameter : H b;
parameter : I b;
parameter : J b;
parameter : K b;
parameter : L b;
parameter : M b;
parameter : N b;
parameter : O b;
parameter : P b;
parameter : Q b;
parameter : R b;
parameter : S b;
parameter : T b;
parameter : U b;
parameter : V b;
parameter : W b;
parameter : X b;
parameter : Y b;
parameter : Z b;
always @posedge CLK begin
FSM logic
case state
b: begin Initial state
if BUTTON begin
counter counter ;
if counter LONGPRESSTHRESHOLD begin
state b; Long press detected
end
end else begin
if counter && counter LONGPRESSTHRESHOLD begin
state b; Short press detected
end
counter ;
end
end
b: begin Short press state
Update morsecode variable based on short press
state b; Return to initial state
end
b: begin Long press state
Update morsecode variable based on long press
state b; Return to initial state
end
endcase
Sevensegment display logic
case morsecode
b: segments A; Display A
b: segments B; Display B
b: segments C; Display C
b: segments D; Display D
b: segments E; Display E
b: segments F; Display F
b: segments G; Display G
b: segments H; Display H
b: segments I; Display I
b: segments J; Display J
b: segments K; Display K
b: segments L; Display L
b: segments M; Display M
b: segments N; Display N
b: segments O; Display O
b: segments P; Display P
b: segments Q; Display Q
b: segments R; Display R
b: segments S; Display S
b: segments T; Display T
b: segments U; Display U
b: segments V; Display V
b: segments W; Display W
b: segments X; Display X
b: segments Y; Display Y
b: segments Z; Display Z
default: segments b; All segments off idle state
endcase
end
endmodule
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
