Display Controller
Display Controller
//
// This module puts 4 hexadecimal values (from O to F) on the 4-digit 7-segment
display unit
//
// Inputs/Outputs:
// clk: the system clock on the BASYS3 board
// in3, in2, in1, in0: the input hexadecimal values. in3(left), in2, in1,
in0(right)
// seg: the signals going to the segments of a digit.
// seg[6] is CA for the a segment, seg[5] is CB for the b segment, etc
// an: anode, 4 bit enable signal, one bit for each digit
// an[3] is the left-most digit, an[2] is the second-left-most, etc
// dp: digital point
//
// Usage for CS224 Lab4-5:
// - Give the system clock of BASYS3 and the hexadecimal values you want to
display as inputs.
// - Send outputs to 7-segment display of BASYS3, using the .XDC file
//
// Note: the an, seg and dp outputs are active-low, for the BASYS3 board
//
// For correct connections, carefully plan what should be in the .XDC file
//
////////////////////////////////////////////////////////
module display_controller(
input clk,
input [3:0] in3, in2, in1, in0,
output [6:0]seg, logic dp,
output [3:0] an
);
localparam N = 18;
logic [4:0]digit_val;
logic [3:0]digit_en;
always@ (*)
begin
digit_en = 4'b1111;
digit_val = in0;
case(count[N-1:N-2])
begin
digit_val = {1'b0, in0};
digit_en = 4'b1110;
end
begin
digit_val = {1'b0, in2};
digit_en = 4'b1011;
end
begin
digit_val = {1'b0, in3};
digit_en = 4'b0111;
end
endcase
end
assign an = digit_en;
endmodule