With the current setup both digits are being driven to the same 7-segment display. To make matters worse, segment_data
has competing drivers. For code reuse, create a new module for bcd to 7-segment conversion. For example:
module segment7dec (output reg [6:0] display, input [3:0] bcd);
always @* begin
case(bcd)
4'b0000: display = 7'b1111110;
4'b0001: display = 7'b0110000;
4'b0010: display = 7'b1101101;
4'b0011: display = 7'b1111001;
4'b0100: display = 7'b0110011;
4'b0101: display = 7'b1011011;
4'b0110: display = 7'b1011111;
4'b0111: display = 7'b1110000;
4'b1000: display = 7'b1111111;
4'b1001: display = 7'b1111011;
default: display = 7'b0000000; //IMPORTANT, otherwise latches are inferred
endcase
display = ~display; // invert
end
endmodule
Now connect the new module into BCDcountmod
. Remember to remove the old segment_*
code.
module BCDcountmod(
input Clock, Clear, E, updown,
output [6:0] display1, display0 );
reg [3:0] BCD1, BCD0;
always @(posedge Clock) begin
/* Your logic for BCD1,BCD0
*
*/
end
segment7dec disp1( .display(display1), .bcd(BCD1) );
segment7dec disp0( .display(display0), .bcd(BCD0) );
endmodule
Example : http://www.edaplayground.com/s/6/398