File tree Expand file tree Collapse file tree
examples/brs-100-gw1nr9/blinky Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ; Apio project configuration file.
2+ ; See https://fpgawars.github.io/apio/project-file for details.
3+
4+ [env:default]
5+ board = brs-100-gw1nr9
6+ top-module = blinky
7+
8+ default-testbench = blinky_tb.v
9+
Original file line number Diff line number Diff line change 1+ module blinky #(
2+ // Num of clock cycle per led transition.
3+ parameter integer DIV = (27000000 / 6 )
4+ ) (
5+ input sys_clk,
6+ output reg [5 :0 ] leds // Active low
7+ );
8+
9+ // ---- Reset generator.
10+
11+ reg [3 :0 ] reset_counter = 0 ;
12+ reg sys_reset = 1 ;
13+
14+ always @(posedge sys_clk) begin
15+ if (reset_counter < 3 ) begin
16+ sys_reset <= 1 ;
17+ reset_counter <= reset_counter + 1 ;
18+ end else begin
19+ sys_reset <= 0 ;
20+ end
21+ end
22+
23+ // ---- Blinker
24+
25+ reg [31 :0 ] blink_counter;
26+
27+ always @(posedge sys_clk) begin
28+ if (sys_reset) begin
29+ // Reset
30+ blink_counter <= 0 ;
31+ leds <= 6'b111110 ;
32+ end else if (blink_counter < (DIV - 1 )) begin
33+ // Delay
34+ blink_counter <= blink_counter + 1 ;
35+ end else begin
36+ // Transition
37+ blink_counter <= 0 ;
38+ leds = {leds[4 :0 ], leds[5 ]};
39+ end
40+ end
41+
42+ endmodule
Original file line number Diff line number Diff line change 1+ [*]
2+ [*] GTKWave Analyzer v3.4.0 (w)1999-2022 BSI
3+ [*] Tue Feb 24 05:21:33 2026
4+ [*]
5+ [dumpfile] "/Users/user/work-brisbane/_build/default/blinky_tb.vcd"
6+ [dumpfile_mtime] "Tue Feb 24 05:19:52 2026"
7+ [dumpfile_size] 4425
8+ [savefile] "/Users/user/work-brisbane/blinky_tb.gtkw"
9+ [timestart] 0
10+ [size] 1280 600
11+ [pos] -1 -1
12+ *-12.255525 1900 -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] blinky_tb.
14+ [sst_width] 253
15+ [signals_width] 185
16+ [sst_expanded] 1
17+ [sst_vpaned_height] 158
18+ @200
19+ -Clock
20+ @420
21+ blinky_tb.clk_num
22+ @28
23+ blinky_tb.sys_clk
24+ @200
25+ -
26+ -Reset Generator
27+ @22
28+ blinky_tb.ticker.reset_counter[3:0]
29+ @28
30+ blinky_tb.ticker.sys_reset
31+ @200
32+ -
33+ -
34+ -LED Blinker
35+ @22
36+ blinky_tb.ticker.blink_counter[31:0]
37+ @200
38+ -
39+ @800022
40+ blinky_tb.leds[5:0]
41+ @28
42+ (0)blinky_tb.leds[5:0]
43+ (1)blinky_tb.leds[5:0]
44+ (2)blinky_tb.leds[5:0]
45+ (3)blinky_tb.leds[5:0]
46+ (4)blinky_tb.leds[5:0]
47+ (5)blinky_tb.leds[5:0]
48+ @1001200
49+ -group_end
50+ [pattern_trace] 1
51+ [pattern_trace] 0
Original file line number Diff line number Diff line change 1+ // A testbench for testing the blinky module.
2+
3+ `timescale 10 ns / 1 ns
4+
5+ module blinky_tb ();
6+
7+ // Clock.
8+ reg sys_clk = 0 ;
9+ integer clk_num = 0 ;
10+
11+ always begin
12+ #10 sys_clk = ~ sys_clk;
13+ if (sys_clk) clk_num = clk_num + 1 ;
14+ end
15+
16+ // Outputs.
17+ wire [5 :0 ] leds;
18+
19+ // Tested module. Transition the leds every 5 clocks.
20+ blinky #(
21+ .DIV(5 )
22+ ) ticker (
23+ .sys_clk(sys_clk),
24+ .leds(leds)
25+ );
26+
27+ // Test main
28+ initial begin
29+ $dumpvars (0 , blinky_tb);
30+
31+ // Wait 100 clocks.
32+ repeat (100 ) @(posedge sys_clk);
33+
34+ // End of test
35+ $display ("End of simulation" );
36+ $finish ;
37+ end
38+
39+ endmodule
Original file line number Diff line number Diff line change 1+ Blinking led
Original file line number Diff line number Diff line change 1+
2+ // On board 27Mhz oscilator.
3+ IO_LOC "sys_clk" 52;
4+ IO_PORT "sys_clk" IO_TYPE=LVCMOS33 PULL_MODE=NONE;
5+
6+ // LEDs
7+ IO_LOC "leds[0]" 16;
8+ IO_LOC "leds[1]" 15;
9+ IO_LOC "leds[2]" 14;
10+ IO_LOC "leds[3]" 13;
11+ IO_LOC "leds[4]" 11;
12+ IO_LOC "leds[5]" 10;
13+
14+ IO_PORT "leds[0]" IO_TYPE=LVCMOS33 PULL_MODE=UP DRIVE=8;
15+ IO_PORT "leds[1]" IO_TYPE=LVCMOS33 PULL_MODE=UP DRIVE=8;
16+ IO_PORT "leds[2]" IO_TYPE=LVCMOS33 PULL_MODE=UP DRIVE=8;
17+ IO_PORT "leds[3]" IO_TYPE=LVCMOS33 PULL_MODE=UP DRIVE=8;
18+ IO_PORT "leds[4]" IO_TYPE=LVCMOS33 PULL_MODE=UP DRIVE=8;
19+ IO_PORT "leds[5]" IO_TYPE=LVCMOS33 PULL_MODE=UP DRIVE=8;
You can’t perform that action at this time.
0 commit comments