Forum Discussion
Altera_Forum
Honored Contributor
14 years agoWorks perfectly :). here is the modified code if snyone else has this issue:
module binaryShift(
// this is the 50MHZ onboard clock
input CLOCK_27,
//push buttons
input KEY,
//dpdt switches
input SW,
//7-SEG Displays
output HEX0, HEX1, HEX2, HEX3, HEX4, HEX5, HEX6, HEX7,
//LEDs
output LEDG, // LED Green
output LEDR, // LED Red
//GPIO CONNECTIONS
inout GPIO_0, GPIO_1
);
// Blank the unused HEX displays
assign HEX7 = 7'h7f;
assign HEX6 = 7'h7f;
assign HEX5 = 7'h7f;
assign HEX4 = 7'h7f;
assign HEX3 = 7'h7f;
assign HEX2 = 7'h7f;
assign HEX1 = 7'h7f;
assign HEX0 = 7'h7f;
//assign LEDR = 18'h12;
reg paddle;
reg pressed;
initial
begin
paddle <= 18'b111100000000000000;
pressed <= 1'b0;
end
always @( negedge CLOCK_27)
begin
if (KEY)
begin
pressed <= 1'b0;
end
if(!KEY && !pressed)
begin
pressed <= 1'b1;
case(paddle)
18'b000000000000001111 : paddle <= 18'b111100000000000000;
18'b000000000000011110 : paddle <= 18'b000000000000001111;
18'b000000000000111100 : paddle <= 18'b000000000000011110;
18'b000000000001111000 : paddle <= 18'b000000000000111100;
18'b000000000011110000 : paddle <= 18'b000000000001111000;
18'b000000000111100000 : paddle <= 18'b000000000011110000;
18'b000000001111000000 : paddle <= 18'b000000000111100000;
18'b000000011110000000 : paddle <= 18'b000000001111000000;
18'b000000111100000000 : paddle <= 18'b000000011110000000;
18'b000001111000000000 : paddle <= 18'b000000111100000000;
18'b000011110000000000 : paddle <= 18'b000001111000000000;
18'b000111100000000000 : paddle <= 18'b000011110000000000;
18'b001111000000000000 : paddle <= 18'b000111100000000000;
18'b011110000000000000 : paddle <= 18'b001111000000000000;
18'b111100000000000000 : paddle <= 18'b011110000000000000;
default: paddle <= 18'b111100000000000000;
endcase
end
else if (!KEY) begin
paddle <= ~paddle;
end
end
assign LEDR = paddle;
endmodule
now, So I added the "pressed" register so that it didn't keep cycling the case statements while the button was pressed, is there a better way to do this code? Like I said , I am still very much learning and any critique of my code will be very much appreciated.