Skip to content

Commit 79d6b01

Browse files
committed
add back needed files
1 parent 9df6a43 commit 79d6b01

File tree

4 files changed

+125
-0
lines changed

4 files changed

+125
-0
lines changed

src/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Makefile
2+
# See https://docs.cocotb.org/en/stable/quickstart.html for more info
3+
4+
# defaults
5+
SIM ?= icarus
6+
TOPLEVEL_LANG ?= verilog
7+
8+
VERILOG_SOURCES += $(PWD)/tb.v $(PWD)/counter.v $(PWD)/decoder.v
9+
10+
# TOPLEVEL is the name of the toplevel module in your Verilog or VHDL file
11+
TOPLEVEL = tb
12+
13+
# MODULE is the basename of the Python test file
14+
MODULE = test
15+
16+
# include cocotb's make rules to take care of the simulator setup
17+
include $(shell cocotb-config --makefiles)/Makefile.sim
18+

src/counter.v

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
`default_nettype none
2+
3+
module seven_segment_seconds #( parameter MAX_COUNT = 1000 ) (
4+
input [7:0] io_in,
5+
output [7:0] io_out
6+
);
7+
8+
wire clk = io_in[0];
9+
wire reset = io_in[1];
10+
wire [6:0] led_out;
11+
assign io_out[6:0] = led_out;
12+
13+
// external clock is 1000Hz, so need 10 bit counter
14+
reg [9:0] second_counter;
15+
reg [3:0] digit;
16+
17+
always @(posedge clk) begin
18+
// if reset, set counter to 0
19+
if (reset) begin
20+
second_counter <= 0;
21+
digit <= 0;
22+
end else begin
23+
// if up to 16e6
24+
if (second_counter == MAX_COUNT) begin
25+
// reset
26+
second_counter <= 0;
27+
28+
// increment digit
29+
digit <= digit + 1'b1;
30+
31+
// only count from 0 to 9
32+
if (digit == 9)
33+
digit <= 0;
34+
35+
end else
36+
// increment counter
37+
second_counter <= second_counter + 1'b1;
38+
end
39+
end
40+
41+
// instantiate segment display
42+
seg7 seg7(.counter(digit), .segments(led_out));
43+
44+
endmodule

src/decoder.v

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
/*
3+
-- 1 --
4+
| |
5+
6 2
6+
| |
7+
-- 7 --
8+
| |
9+
5 3
10+
| |
11+
-- 4 --
12+
*/
13+
14+
module seg7 (
15+
input wire [3:0] counter,
16+
output reg [6:0] segments
17+
);
18+
19+
always @(*) begin
20+
case(counter)
21+
// 7654321
22+
0: segments = 7'b0111111;
23+
1: segments = 7'b0000110;
24+
2: segments = 7'b1011011;
25+
3: segments = 7'b1001111;
26+
4: segments = 7'b1100110;
27+
5: segments = 7'b1101101;
28+
6: segments = 7'b1111100;
29+
7: segments = 7'b0000111;
30+
8: segments = 7'b1111111;
31+
9: segments = 7'b1100111;
32+
default:
33+
segments = 7'b0000000;
34+
endcase
35+
end
36+
37+
endmodule
38+

src/tb.gtkw

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[*]
2+
[*] GTKWave Analyzer v3.4.0 (w)1999-2022 BSI
3+
[*] Thu Oct 27 10:17:53 2022
4+
[*]
5+
[dumpfile] "/home/matt/work/asic-workshop/shuttle7/tt02-submission-template/src/tb.vcd"
6+
[dumpfile_mtime] "Thu Oct 27 10:17:11 2022"
7+
[dumpfile_size] 14468
8+
[savefile] "/home/matt/work/asic-workshop/shuttle7/tt02-submission-template/src/tb.gtkw"
9+
[timestart] 0
10+
[size] 2286 698
11+
[pos] -1 -1
12+
*-30.600000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
13+
[treeopen] tb.
14+
[sst_width] 343
15+
[signals_width] 264
16+
[sst_expanded] 1
17+
[sst_vpaned_height] 190
18+
@28
19+
tb.clk
20+
@29
21+
tb.rst
22+
@22
23+
tb.segments[6:0]
24+
[pattern_trace] 1
25+
[pattern_trace] 0

0 commit comments

Comments
 (0)