Debian Codegraph @

examples/oser10-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 rst_i,
8 output elvds_p,
9 output elvds_n,
10 output LED_B
11 );
12
13 ELVDS_TBUF diff_buf(
14 .OEN(w_oen),
15 .O(elvds_p),
16 .OB(elvds_n),
17 .I(oser_out)
18 );
19
20 OSER10 os(
21 .D0(1'b0),
22 .D1(1'b1),
23 .D2(1'b0),
24 .D3(1'b1),
25 .D4(1'b0),
26 .D5(1'b1),
27 .D6(1'b0),
28 .D7(1'b1),
29 .D8(1'b0),
30 .D9(1'b1),
31 .FCLK(fclk_w),
32 .PCLK(pclk_w),
33 .RESET(1'b0),
34 .Q(oser_out)
35 );
36 defparam os.GSREN = "false";
37 defparam os.LSREN = "true";
38
39 wire clk_w;
40 wire pclk_w;
41 wire fclk_w;
42
43 assign pclk_o = pclk_w;
44 assign fclk_o = fclk_w;
45
46 reg [2:0] count;
47 wire clkA;
48 reg clkB;
49 always @(posedge fclk_w) begin
50 if (!rst_i) begin
51 count <= 0;
52 end else begin
53 if (count == 3'd4) begin
54 count <= 0;
55 end else begin
56 count <= count+1;
57 end
58 end
59 end
60 assign clkA = count[1];
61
62 always@(negedge fclk_w) begin
63 clkB <= clkA;
64 end
65 assign pclk_w = clkA | clkB;
66
67 // slow
68 reg [24:0] ctr_q;
69 wire [24:0] ctr_d;
70 wire tick_w;
71
72 // Sequential code (flip-flop)
73 always @(posedge clk)
74 ctr_q <= ctr_d;
75
76 // Combinational code (boolean logic)
77 assign ctr_d = ctr_q + 1'b1;
78 assign tick_w = ctr_q[24];
79
80 assign fclk_w = tick_w;
81 assign LED_B = tick_w;
82 endmodule
83