Skip to content

Instantly share code, notes, and snippets.

@bit-hack
Last active October 3, 2018 22:06
Show Gist options
  • Save bit-hack/28651af29791f3a4cb9ec45eb0dd7b1c to your computer and use it in GitHub Desktop.
Save bit-hack/28651af29791f3a4cb9ec45eb0dd7b1c to your computer and use it in GitHub Desktop.
decode seven segment display for Altera DE1 kit
// decode 7 seg on DE1 kit
module decode_seven_seg(
input clk,
input [3:0] dec,
output [6:0] out);
reg [6:0] val;
initial val = 0;
always @(posedge clk) begin
case (dec)
4'h0: val <= 7'b1000000;
4'h1: val <= 7'b1111001;
4'h2: val <= 7'b0100100;
4'h3: val <= 7'b0110000;
4'h4: val <= 7'b0011001;
4'h5: val <= 7'b0010010;
4'h6: val <= 7'b0000010;
4'h7: val <= 7'b1111000;
4'h8: val <= 7'b0000000;
4'h9: val <= 7'b0011000;
4'ha: val <= 7'b0001000;
4'hb: val <= 7'b0000011;
4'hc: val <= 7'b1000110;
4'hd: val <= 7'b0100001;
4'he: val <= 7'b0000110;
4'hf: val <= 7'b0001110;
endcase
end
assign out = val;
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment