d_rose_davidson
Newbie level 4
Hey there, I'm doing a Verilog project where I need to use a 7 segment display to display the seconds and minutes of a timer. I'm using the Digilent NEXYS4DDR Artix 7 FPGA board.
My code (shown below) gives me the minutes and seconds appropriately, but I dont quite know how to implement them on the FGPA board. Also, I dont really know to get binary into BCD.
My project is supposed to work as follows: Theres 5 buttons on the board, I press one (S) and it starts the count, 1 second per, and then I press the second button (R) and it resets. Yet it may be better to have R be a button that holds the value, and then S will start and reset the timer.
Here is my code. I commented the beginning of the 7 segment display because it affected my synthesis. Any help is appreciated
My code (shown below) gives me the minutes and seconds appropriately, but I dont quite know how to implement them on the FGPA board. Also, I dont really know to get binary into BCD.
My project is supposed to work as follows: Theres 5 buttons on the board, I press one (S) and it starts the count, 1 second per, and then I press the second button (R) and it resets. Yet it may be better to have R be a button that holds the value, and then S will start and reset the timer.
Here is my code. I commented the beginning of the 7 segment display because it affected my synthesis. Any help is appreciated
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 module Timer( ); reg Q,clock,S,R; integer Cnansec = 0; integer Csec = 0; integer Cmin = 0; initial begin S = 0; R = 0; clock = 0; Q = 0; end always @(*) #1 clock <= ~clock; always@(S, R, clock) begin if (clock) begin if (S == 1 && R == 0) begin Q = 1; end else if (S == 0 && R == 1) begin Q = 1'b0; end end end always @(clock)begin Cnansec = Cnansec + 1; if(R != 1)begin if(Csec == 59 && Cnansec == 1000000000)begin Cmin = Cmin + 1; Csec = 0; Cnansec = 0; end else if (Cnansec == 1000000000) begin Csec = Csec + 1; Cnansec = 0; end end if (S)begin Cnansec = 0; Cmin = 0; Csec = 0; end end always @(clock) begin #1 S = 1; R = 0; #10 S=0; R=0; #100000 S = 0; R = 1; end // output reg [0:6] seg; // output [0:7] an; // assign an = 8'b0111_1111; // always @(*) // begin // case(seg) // 0:seg = 7'b0000001; // 1:seg = 7'b1001111; // 2:seg = 7'b0010010; // 3:seg = 7'b0000110; // 4:seg = 7'b1001100; // 5:seg = 7'b0100100; // 6:seg = 7'b0100000; // 7:seg = 7'b0001111; // 8:seg = 7'b0000000; // 9:seg = 7'b0000100; // 10:seg = 7'b0001000; // 11:seg = 7'b1100000; // 12:seg = 7'b0110001; // 13:seg = 7'b1000010; // 14:seg = 7'b0110000; // 15:seg = 7'b0111000; // endcase // end endmodule
Last edited by a moderator: