Altera_Forum
Honored Contributor
13 years agoRotating square in seven segment LED
now I want to make a rotating square using the seven segment.. The pattern I want to create looks something like the attached picture.
Im new to verilog so here is the code I came up with... I kind of knew it would not work as it is written in a C style but I thought combinational logic in a separate block would workreg ticker; //a 23 bit register to count to 5M, to generate a 0.1 sec tick
wire click;
reg fourth, third, second, first;
always @ (posedge clock or posedge reset)
begin //this block will generate a 0.1 sec tick
if(reset)
ticker <= 0;
else if(ticker == 5000000)
ticker <= 0;
else
ticker <= ticker + 1;
end
assign click = ((ticker == 5000000)?1'b1:1'b0);
always @ (click) // this will just simple rotate the square
begin
// I have equaled 1 in the seven segment display to make the top square and 2 to make the lower square
fourth = 1;
third = 1;
second = 1;
first = 1;
first = 2;
second = 2;
third = 2;
fourth = 2;
end
//Having 4 seven segment displays being multiplexed first is the right most display and fourth is the left most display
Please note that the multiplexing circuit and the block related to turning on the seven segment is not shown in the main code.. As Im sure the problem is in the above code. I know this doesnt work, when I put it on the board It just shows the top squares and it does not rotate. i dont want a fix, or some one to do this.. i just want to know why is this code wrong?? Thank you