Многострадальный модуль, задача которого генерировать сигналы строчной и кадровой развертки с необходимыми параметрами.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
module generete_row_and_col_for_cheap ( input CLK_50MHZ, input CLK_20MHZ, input [7:0] adress_from_UART, input [15:0]UART_to_SPI, input D1, output D2, //resV input D3, output reg D4, output D5, //clkV output D6, //rstH output reg D7, output D8, //ClkH input D9, output reg D10, output reg [11:0]numRow =0, output reg [11:0]numCol =0, input [15:0]D4_start, input [15:0]D4_stop, input [15:0]countRow, input [15:0]countCol, input COM_TX_ON, input clk960, input [15:0]D10_start ); //reg [15:0]countRow = 323; //823; //423 //reg [15:0]countCol = 585;//2896;// 1896 reg clkH; reg clkV; reg resH; reg resV; reg userD4; reg userD7; reg userD10; reg [1:0] D4mux =0; reg [1:0] D7mux =0; reg [1:0] D10mux =0; reg [15:0] countStrob = 0; reg [15:0] countStrob_start = 400; reg [15:0] countStrob_end = 600; reg [15:0] countDeadTime = 0; reg [15:0] countDeadTime_end = 200; reg [15:0] maxTimeresH = 0; reg [17:0] clkCounter = 0; reg [17:0] count100Mhz; reg strob = 0; reg DeadTime = 0; //reg [15:0]D4_start ; //reg [15:0]D4_stop ; reg [15:0]D7_start ; reg [15:0]D7_stop ; //reg [15:0]D10_start; reg [15:0]D10_stop ; reg [7:0]CLOCK_divider = 10; reg clk_H_last; reg [15:0] col_max; reg [15:0] col_max_last; reg col_max_update; reg [15:0] row_max; reg [15:0] row_max_last; reg [15:0] row_max_update; assign D8 = clkH ; assign D5 = clkV ; assign D6 = resH ; assign D2 = resV ; always @ (posedge CLK_20MHZ) clkV <= ~clkV; //// задание определенных значений по UART always @ (posedge CLK_20MHZ) begin case(adress_from_UART) 113: case(UART_to_SPI) 0: D4 <= 0; 1: D4 <= 1; 2: D4 <= strob; 3: D4 <= userD4; endcase 114: case(UART_to_SPI) 0: D7 <= 0; 1: D7 <= 1; 2: D7 <= strob; 3: D7 <= userD7; endcase 115: case(UART_to_SPI) 0: D10 <= 0; 1: D10 <= 1; 2: D10 <= strob; 3: D10 <= userD10; endcase endcase /////////////////////////////////////// генерация нужного клока if (clkCounter < 100) begin //38 clkCounter <= clkCounter + 1; end else begin if (~DeadTime) begin clkCounter <= 0; //clkV_from_100 <= ~clkV_from_100; end end ////////////////////////////////////// генерация строба if (resH && clkH) // generate strob countStrob <= countStrob + 1; else countStrob <= 0; if (countStrob > countStrob_start && countStrob < countStrob_end) strob <= 1; else strob <= 0; ///////////////////////////////////// мертвое время if (resH && ~clkH) countDeadTime <= countDeadTime + 1; else countDeadTime <= 0; if (countDeadTime < countDeadTime_end && countDeadTime ) DeadTime <= 1; else DeadTime <= 0; //////////////////////////////////////////////// определение параметров if (countStrob > maxTimeresH ) begin maxTimeresH <= countStrob; countStrob_end <= maxTimeresH - 5; countStrob_start <= maxTimeresH - 205; end ////////////////////////////////////////////// генерация resV if(clkV) begin if (numRow == countRow)begin numRow <= 0; resV <=1; end else begin numRow <= numRow + 1; resV <= 0; end /////////////////////////////////////////////// генерация clkH if (numRow == countRow[11:1]) clkH <= 1; else if (numRow == countRow) clkH <= 0; end clk_H_last <= clkH; /////////////////////////////////////////////// генерация resH if (clk_H_last && ~clkH) if (numCol == countCol)begin numCol <= 0; resH <=1; end else begin numCol <= numCol + 1; resH <= 0; end end endmodule |

