Debian Codegraph @

examples/gw5a/blinky-osc.v

raw
1 module top (
2 input key_i,
3 output [`LEDS_NR-1:0] led
4 );
5
6 wire clk;
7
8 `ifdef OSC_TYPE_OSC
9 OSC osc(
10 .OSCOUT(clk)
11 );
12 defparam osc.FREQ_DIV=32;
13 `elsif OSC_TYPE_OSCZ
14 OSCZ osc(
15 .OSCEN(1'b1),
16 .OSCOUT(clk)
17 );
18 defparam osc.FREQ_DIV=32;
19 `elsif OSC_TYPE_OSCF
20 OSCF osc(
21 .OSCEN(1'b1),
22 .OSCOUT(clk),
23 .OSCOUT30M()
24 );
25 defparam osc.FREQ_DIV=32;
26 `elsif OSC_TYPE_OSCH
27 OSCH osc(
28 .OSCOUT(clk)
29 );
30 defparam osc.FREQ_DIV=32;
31 `elsif OSC_TYPE_OSCA
32 OSCA osc(
33 .OSCEN(1'b1),
34 .OSCOUT(clk)
35 );
36 defparam osc.FREQ_DIV=64;
37 `endif
38
39 wire key = key_i ^ `INV_BTN;
40
41 reg [25:0] ctr_q;
42 wire [25:0] ctr_d;
43
44 // Sequential code (flip-flop)
45 always @(posedge clk) begin
46 if (key) begin
47 ctr_q <= ctr_d;
48 end
49 end
50
51 // Combinational code (boolean logic)
52 assign ctr_d = ctr_q + 1'b1;
53 assign led = {ctr_q[25:25-(`LEDS_NR - 2)], |ctr_q[25-(`LEDS_NR - 1):25-(`LEDS_NR)] };
54
55 endmodule