Debian Codegraph @

examples/oddr-elvds.v

raw
1 /* Using an oscilloscope you can see on pins tlvds_p and tlvds_n the signal with changing polarity.
2 * You can also use a 100 Ohm resistor and two LEDs connected in opposite directions between these pins.
3 * ODDR needs 4 clock cycles to start working, so be patient:)
4 */
5 module top (
6 input clk,
7 input key_i,
8 output [`LEDS_NR-1:0] led,
9 output elvds_p,
10 output elvds_n
11 );
12
13 wire key = key_i ^ `INV_BTN;
14
15 reg [24:0] ctr_q;
16 wire [24:0] ctr_d;
17 wire i_tick;
18 wire w_ddr;
19 wire oen;
20
21 // Sequential code (flip-flop)
22 always @(posedge clk)
23 ctr_q <= ctr_d;
24
25 // Combinational code (boolean logic)
26 assign ctr_d = ctr_q + 1'b1;
27 assign i_tick = |ctr_q[24:23];
28
29 assign led = i_tick;
30
31 ODDR oddr_0(
32 .D0(1'b0),
33 .D1(1'b1),
34 .CLK(i_tick),
35 .Q0(w_ddr),
36 .Q1(oen),
37 .TX(~key)
38 );
39
40 ELVDS_TBUF diff_buf(
41 .OEN(oen),
42 .O(elvds_p),
43 .OB(elvds_n),
44 .I(w_ddr)
45 );
46
47 endmodule
48