Altera_Forum
Honored Contributor
14 years agoA very new FPGA developer is very stuck. I think I have timing issues
Hi!
I am working on my first FPGA project ever. I have an Altera DE2 board and was following their "Quartus II introduction using verilog design" document. Got through the tutorial with no issues(skipped simulation... probably my later issue) Now, my first step for my learning is to make 4 leds light up and move across the red led array on the board. here is the code in verilog(my first attempt so probably not that good)
module binaryShift(
// this is the 27MHZ 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;
always @(negedge KEY or negedge KEY)
begin
if(!KEY)
begin
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 begin
paddle <= ~paddle;
end
end
assign LEDR = paddle;
endmodule
the code seems pretty straight forward, but what happens is when I press the button the leds do follow the shifting pattern sort of, but after a press or 2 I get odd patterns not in the case statements... things like 10110111000000000.... My guess is that this is an issue in the timing because I get a lot of warnings about it. The problem now is I have 10.1 web edition which no longer has the vector waveform files like the tutorial shows. I have read through the forums that this question has been asked but only found people telling that the solution does exist and go find it. I know modelsim is the partial solution to doing the timing simulation but have not been able to figure out how to go from quartus to modelsim and back to the board. Has altera put out a tutorial for the newer version of quartus? any help would be fantastic and greatly appreciated.