Debian Codegraph @

examples/ovideo.v

raw
1 `default_nettype none
2 /*
3 * This example allows you to generate OVIDEO primitive and then check
4 * it with a logic analyzer. The PCLK, FCLK and Q outputs of the primitives
5 * are connected to the board pins.
6 */
7 module top(input wire clk,
8 input wire rst_i,
9 output wire oser_out,
10 output wire pclk_o,
11 output wire fclk_o);
12
13 wire rst = rst_i ^ `INV_BTN;
14 OVIDEO os(
15 .D0(1'b1),
16 .D1(1'b0),
17 .D2(1'b1),
18 .D3(1'b0),
19 .D4(1'b1),
20 .D5(1'b0),
21 .D6(1'b1),
22 .FCLK(fclk_w),
23 .PCLK(pclk_w),
24 .RESET(1'b0),
25 .Q(oser_out)
26 );
27 defparam os.GSREN = "false";
28 defparam os.LSREN = "true";
29
30 wire clk_w;
31 wire pclk_w;
32 wire fclk_w;
33
34 assign pclk_o = pclk_w;
35 assign fclk_o = fclk_w;
36
37 // div by 3.5
38 reg [6:0]cnt_r;
39 reg ps0_r;
40 reg ps3_r;
41 reg ps4_r;
42 always @(posedge fclk_w) begin
43 if (!rst) begin
44 cnt_r[6:0] <= 7'b000_0001;
45 end else begin
46 cnt_r[6:0] <= {cnt_r[5:0], cnt_r[6]};
47 end
48 end
49
50 always @(negedge fclk_w) begin
51 if (!rst) begin
52 ps0_r <= 1'b0;
53 ps3_r <= 1'b0;
54 ps4_r <= 1'b0;
55 end else begin
56 ps0_r <= cnt_r[0];
57 ps3_r <= cnt_r[3];
58 ps4_r <= cnt_r[4];
59 end
60 end
61 assign pclk_w = (ps0_r | cnt_r[0] | cnt_r[1]) | (ps3_r | ps4_r | cnt_r[4]);
62
63 // slow
64 reg [24:0] ctr_q;
65 wire [24:0] ctr_d;
66 wire tick_w;
67
68 // Sequential code (flip-flop)
69 always @(posedge clk)
70 ctr_q <= ctr_d;
71
72 // Combinational code (boolean logic)
73 assign ctr_d = ctr_q + 1'b1;
74 assign tick_w = ctr_q[24];
75
76 assign fclk_w = tick_w;
77 endmodule