Debian Codegraph @

examples/blinky-oddr.v

raw
1 /*
2 * led[0] is connected directly, led[1] --- via ODDR. This primitive needs 4 clock cycles to start working, so be patient:)
3 */
4 module top (
5 input clk,
6 input key_i,
7 input rst_i,
8 output [`LEDS_NR-1:0] led
9 );
10
11 wire key = key_i ^ `INV_BTN;
12 wire rst = rst_i ^ `INV_BTN;
13
14 reg [24:0] ctr_q;
15 wire [24:0] ctr_d;
16
17 // Sequential code (flip-flop)
18 always @(posedge clk) begin
19 if (rst) begin
20 ctr_q <= ctr_d;
21 end
22 end
23
24 // Combinational code (boolean logic)
25 assign ctr_d = ctr_q + 1'b1;
26 assign led[`LEDS_NR-1:2] = {(`LEDS_NR - 2){1'b1}};
27 assign led[0] = ~ctr_q[24:24];
28
29 wire aux_wire;
30
31 IODELAY delay0(
32 .DI(aux_wire),
33 .DO(led[1]),
34 .SDTAP(1'b0),
35 .SETN(1'b1),
36 .VALUE(1'b0),
37 .DF()
38 );
39 defparam delay0.C_STATIC_DLY=100;
40
41 ODDRC oddr_0(
42 .D0(1'b0),
43 .D1(1'b1),
44 .CLK(ctr_q[24:24]),
45 .Q0(aux_wire),
46 .Q1(),
47 .TX(1'b1),
48 .CLEAR(!key)
49 );
50
51 endmodule