Forum Discussion
Altera_Forum
Honored Contributor
14 years agoYour digit1,digit2,digit3,digit4 are single bit registers they can store 0 or 1 but you are trying to increment it from binary values 0 to 9.
use reg [3:0] digit1 and so on to hold a binary value of 9 or 1001. one more thing use digit1==4'b1001 or 4'd9 as the condition instead of 9 after you change the declarations for digits. Yes addign to what DAIXIWEN said the current status of the code might increase the digit values in all 4 block wrt to the clk . If you want to increase the digit value when timer ==16000000 then it should be something like this if (timer==16000000) digit1<=digit1+1'b1; this is not exactly what you should write but to make you understand when you should increase the digit1 value. for your digit2 block it should be something like this always @ (posedge clk) begin if (rst==0) begin digit2<=0; end else if(c1==1'b1) begin digit2<=digit2+1'b1; end else begin digit2<=digit2; end assign c2=(c1 && (digit2==4'd9)); and if its the same code you are implementing you have to write begin -end for the always block too. like always @(..) begin if(..) begin .. end else begin .. end end //for always block begin and yes the specs are not clear to me its a rough code i have written which are subjected to changes so be clear with what you are doing