Debian Codegraph @

examples/gw5a/oddr-tlvds.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 [7:0] led,
9 output tlvds_p,
10 output tlvds_n
11 );
12
13 wire key = key_i ^ `INV_BTN;
14 reg [24:0] ctr_q;
15 wire [24:0] ctr_d;
16 wire i_tick;
17 wire w_ddr;
18
19 // Sequential code (flip-flop)
20 always @(posedge clk)
21 ctr_q <= ctr_d;
22
23 // Combinational code (boolean logic)
24 assign ctr_d = ctr_q + 1'b1;
25 assign i_tick = |ctr_q[24:23];
26
27 assign led[0] = i_tick;
28
29 wire w_oen;
30
31 ODDR oddr_0(
32 .D0(1'b0),
33 .D1(1'b1),
34 .CLK(i_tick),
35 .Q0(w_ddr),
36 .Q1(w_oen),
37 .TX(~key)
38 );
39
40 TLVDS_TBUF diff_buf(
41 .OEN(w_oen),
42 .O(tlvds_p),
43 .OB(tlvds_n),
44 .I(w_ddr)
45 );
46
47 endmodule
48