]>
Commit | Line | Data |
---|---|---|
782690d0 MG |
1 | //---------------------------------------------------------------------\r |
2 | // FPGA MOONCRESTA H & V COUNTER \r | |
3 | //\r | |
4 | // Version : 2.00\r | |
5 | //\r | |
6 | // Copyright(c) 2004 Katsumi Degawa , All rights reserved\r | |
7 | //\r | |
8 | // Important !\r | |
9 | //\r | |
10 | // This program is freeware for non-commercial use. \r | |
11 | // An author does no guarantee about this program.\r | |
12 | // You can use this under your own risk.\r | |
13 | //\r | |
14 | // 2004- 9-22 \r | |
15 | //---------------------------------------------------------------------\r | |
16 | // MoonCrest hv_count\r | |
17 | // H_CNT 0 - 255 , 384 - 511 Total 384 count\r | |
18 | // V_CNT 0 - 255 , 504 - 511 Total 264 count\r | |
19 | //-----------------------------------------------------------------------------------------\r | |
20 | // H_CNT[0],H_CNT[1],H_CNT[2],H_CNT[3],H_CNT[4],H_CNT[5],H_CNT[6],H_CNT[7],H_CNT[8], \r | |
21 | // 1 H 2 H 4H 8H 16 H 32H 64 H 128 H 256 H\r | |
22 | //-----------------------------------------------------------------------------------------\r | |
23 | // V_CNT[0], V_CNT[1], V_CNT[2], V_CNT[3], V_CNT[4], V_CNT[5], V_CNT[6], V_CNT[7] \r | |
24 | // 1 V 2 V 4 V 8 V 16 V 32 V 64 V 128 V \r | |
25 | //-----------------------------------------------------------------------------------------\r | |
26 | \r | |
27 | module mc_hv_count(\r | |
28 | \r | |
29 | I_CLK, // 6MHz\r | |
30 | I_RSTn,\r | |
31 | \r | |
32 | O_H_CNT,\r | |
33 | O_H_SYNC,\r | |
34 | O_H_BL,\r | |
35 | O_V_CNT,\r | |
36 | O_V_SYNC,\r | |
37 | O_V_BLn,\r | |
38 | O_V_BL2n,\r | |
39 | O_C_BLn\r | |
40 | \r | |
41 | );\r | |
42 | \r | |
43 | input I_CLK,I_RSTn;\r | |
44 | output [8:0]O_H_CNT;\r | |
45 | output O_H_SYNC;\r | |
46 | output O_H_BL;\r | |
47 | output O_V_BL2n;\r | |
48 | output [7:0]O_V_CNT;\r | |
49 | output O_V_SYNC;\r | |
50 | output O_V_BLn;\r | |
51 | \r | |
52 | output O_C_BLn;\r | |
53 | \r | |
54 | //------- H_COUNT ---------------------------------------- \r | |
55 | reg [8:0]H_CNT;\r | |
56 | always@(posedge I_CLK)\r | |
57 | begin\r | |
58 | H_CNT <= H_CNT==255 ? 384 : H_CNT +1 ;\r | |
59 | end\r | |
60 | assign O_H_CNT = H_CNT[8:0];\r | |
61 | \r | |
62 | //------- H_SYNC ----------------------------------------\r | |
63 | \r | |
64 | reg H_SYNCn;\r | |
65 | wire H_SYNC = ~H_SYNCn;\r | |
66 | always@(posedge H_CNT[4] or negedge H_CNT[8]) \r | |
67 | begin\r | |
68 | if(H_CNT[8]==1'b0) H_SYNCn <= 1'b1;\r | |
69 | else H_SYNCn <= ~(~H_CNT[6]& H_CNT[5]);\r | |
70 | end\r | |
71 | \r | |
72 | assign O_H_SYNC = H_SYNC;\r | |
73 | //------- H_BL ------------------------------------------\r | |
74 | \r | |
75 | reg H_BL;\r | |
76 | \r | |
77 | always@(posedge I_CLK)\r | |
78 | begin\r | |
79 | case(H_CNT[8:0])\r | |
80 | 387:H_BL<=1'b1;\r | |
81 | 503:H_BL<=1'b0;\r | |
82 | default:;\r | |
83 | endcase\r | |
84 | end\r | |
85 | \r | |
86 | assign O_H_BL = H_BL;\r | |
87 | //------- V_COUNT ---------------------------------------- \r | |
88 | reg [8:0]V_CNT;\r | |
89 | always@(posedge H_SYNC or negedge I_RSTn)\r | |
90 | begin\r | |
91 | if(I_RSTn==1'b0)\r | |
92 | V_CNT <= 0;\r | |
93 | else\r | |
94 | V_CNT <= V_CNT==255 ? 504 : V_CNT +1 ;\r | |
95 | end\r | |
96 | assign O_V_CNT = V_CNT[7:0];\r | |
97 | assign O_V_SYNC = V_CNT[8];\r | |
98 | \r | |
99 | //------- V_BLn ------------------------------------------\r | |
100 | \r | |
101 | reg V_BLn;\r | |
102 | always@(posedge H_SYNC)\r | |
103 | begin\r | |
104 | case(V_CNT[7:0])\r | |
105 | 239: V_BLn <= 0;\r | |
106 | 15: V_BLn <= 1;\r | |
107 | default:;\r | |
108 | endcase\r | |
109 | end\r | |
110 | \r | |
111 | reg V_BL2n;\r | |
112 | always@(posedge H_SYNC)\r | |
113 | begin\r | |
114 | case(V_CNT[7:0])\r | |
115 | 239: V_BL2n <= 0;\r | |
116 | 16: V_BL2n <= 1;\r | |
117 | default:;\r | |
118 | endcase\r | |
119 | end\r | |
120 | \r | |
121 | assign O_V_BLn = V_BLn;\r | |
122 | assign O_V_BL2n = V_BL2n;\r | |
123 | //------- C_BLn ------------------------------------------\r | |
124 | \r | |
125 | assign O_C_BLn = ~(~V_BLn | H_CNT[8]);\r | |
126 | \r | |
127 | endmodule |