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