Debian Codegraph @

examples/gw5a/oser10-clkdiv-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 rst_i,
8 input key_i,
9 output tlvds_p,
10 output tlvds_n,
11 output pclk_o,
12 output fclk_o
13 );
14
15 TLVDS_TBUF diff_buf(
16 .OEN(key_i),
17 .O(tlvds_p),
18 .OB(tlvds_n),
19 .I(oser_out)
20 );
21
22 OSER10 os(
23 .D0(1'b0),
24 .D1(1'b1),
25 .D2(1'b0),
26 .D3(1'b1),
27 .D4(1'b0),
28 .D5(1'b1),
29 .D6(1'b0),
30 .D7(1'b1),
31 .D8(1'b0),
32 .D9(1'b1),
33 .FCLK(fclk_w),
34 .PCLK(pclk_w),
35 .RESET(1'b0),
36 .Q(oser_out)
37 );
38 defparam os.GSREN = "false";
39 defparam os.LSREN = "true";
40
41 wire clk_w;
42 wire pclk_w;
43 wire fclk_w;
44
45 assign pclk_o = pclk_w;
46 assign fclk_o = fclk_w;
47
48 CLKDIV div5(
49 .HCLKIN(fclk_w),
50 .RESETN(1'b1),
51 .CLKOUT(pclk_w)
52 );
53 defparam div5.DIV_MODE = "5";
54
55 // slow
56 reg [24:0] ctr_q;
57 wire [24:0] ctr_d;
58 wire tick_w;
59
60 // Sequential code (flip-flop)
61 always @(posedge clk)
62 ctr_q <= ctr_d;
63
64 // Combinational code (boolean logic)
65 assign ctr_d = ctr_q + 1'b1;
66 assign tick_w = ctr_q[24];
67
68 assign fclk_w = tick_w;
69 assign fclk_o = fclk_w;
70 assign pclk_o = pclk_w;
71 endmodule
72