Carnegie Mellon
33
Sometimes Always Statements are Great
module sevensegment (input [3:0] data,
output reg [6:0] segments);
always @ ( * ) // * is short for all signals
case (data) // case statement
0: segments = 7'b111_1110; // when data is 0
1: segments = 7'b011_0000; // when data is 1
2: segments = 7'b110_1101;
3: segments = 7'b111_1001;
4: segments = 7'b011_0011;
5: segments = 7'b101_1011;
// etc etc
default: segments = 7'b000_0000; // required
endcase
endmodule