Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Active high 7 Segment Display #26

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions seg7/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Active High 7 Segment Decoder

### 7 Segment Decoder

Every digit from 0 to 9 can be displayed using the 7 segments labelled a through g as follows:

![7 segment display](Untitled.png)

### Input

4 bit number ranging from 0 to 9

### Output

7 bit number with MSB corresponding to A and LSB to G. The output is in accordance with the definiton of the active high condition, with

1 = ON

0 = OFF
Binary file added seg7/Untitled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions seg7/seg7.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module seg7(
bcd,
seg
);

input [3:0] bcd;
output reg [6:0] seg;
//reg [6:0] seg;

always @(bcd) begin
case (bcd)
0 : seg = 7'b1111110;
1 : seg = 7'b0110000;
2 : seg = 7'b1101101;
3 : seg = 7'b1111001;
4 : seg = 7'b0110011;
5 : seg = 7'b1011011;
6 : seg = 7'b1011111;
7 : seg = 7'b1110000;
8 : seg = 7'b1111111;
9 : seg = 7'b1111011;
//switch off 7 segment character when the bcd digit is not a decimal number.
default : seg = 7'b0000000;

endcase
end

endmodule
85 changes: 85 additions & 0 deletions seg7/seg7_tb.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
`include "seg7.v"

module seg7_tb();

reg [3:0] bcd;
wire [6:0] seg;

seg7 uut(
.bcd(bcd),
.seg(seg)
);

initial begin
$dumpfile("seg7_tb.vcd");
$dumpvars(0, seg7_tb);

bcd = 4'b0;

#200 $finish;
end

always #20 bcd = bcd + 1;

always @(bcd) begin
#5;
$display("%b",seg);
$write(" ");

if (seg[6]) begin //a
$write("_");
end
else begin
$write(" ");
end

$write("\n");

if (seg[1]) begin //f
$write("|");
end
else begin
$write(" ");
end

if (seg[0]) begin //g
$write("_");
end
else begin
$write(" ");
end

if (seg[5]) begin //b
$write("|");
end
else begin
$write(" ");
end

$write("\n");

if (seg[2]) begin //e
$write("|");
end
else begin
$write(" ");
end

if (seg[3]) begin //d
$write("_");
end
else begin
$write(" ");
end

if (seg[4]) begin //c
$write("|");
end
else begin
$write(" ");
end

$write("\n\n");
end

endmodule