{"id":275001,"date":"2016-02-26T10:41:04","date_gmt":"2016-02-26T07:41:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=275001"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=275001","title":{"rendered":"\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0433\u043e UART, \u0441\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e 921600 baud \u0438 \u0431\u043e\u043b\u0435\u0435, \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 Verilog \u043f\u043e\u0434 \u041f\u041b\u0418\u0421"},"content":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b36\/8bc\/2c9\/b368bc2c94344822b2c0e1e4fc92598a.jpg\"\/><\/p>\n<p>  \u041f\u0430\u0440\u0443 \u043d\u0435\u0434\u0435\u043b\u044c \u043d\u0430\u0437\u0430\u0434 \u044f \u043d\u0430\u0447\u0430\u043b \u043f\u043e\u0442\u0438\u0445\u043e\u043d\u044c\u043a\u0443 \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0434 \u041f\u041b\u0418\u0421. \u0414\u043b\u044f \u044d\u0442\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u043c\u043d\u043e\u044e \u0431\u044b\u043b\u0430 \u0437\u0430\u043a\u0430\u0437\u0430\u043d\u0430 \u0443 \u043a\u0438\u0442\u0430\u0439\u0446\u0435\u0432 \u0441\u0430\u043c\u0430\u044f \u0434\u0435\u0448\u0435\u0432\u0430\u044f \u043f\u043b\u0430\u0442\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 Altera Max II EPM240T100C5N \u0447\u0438\u043f\u0430. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432 Quartus v15, \u0441\u0442\u0430\u043b \u0438\u0437\u0443\u0447\u0430\u0442\u044c Verilog \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 2001 \u0433\u043e\u0434\u0430. \u041d\u0430\u043c\u043e\u0440\u0433\u0430\u0432\u0448\u0438\u0441\u044c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430\u043c\u0438 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u043c \u0441\u0442\u0430\u043b UART. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u043d\u0430 \u0447\u0443\u0436\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0432 \u0441\u0435\u0442\u0438, \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043c\u043d\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0438\u0437\u043b\u0438\u0448\u043d\u0435\u0435 \u043d\u0430\u0433\u0440\u043e\u043c\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043b\u043e\u0433\u0438\u043a\u0438, \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u043e\u0432, \u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0432 \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u0435 \u0438, \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430 \u0432\u044b\u0441\u043e\u043a\u0438\u0445 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044f\u0445. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435, \u0434\u0430 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0441 \u00ab\u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c\u00bb, \u043d\u043e \u0442\u0430\u043a \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0441\u043f\u043e\u0440\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0418\u0442\u0430\u043a, \u0441\u0442\u043e\u044f\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439, \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 8-\u043c\u0438 \u0431\u0438\u0442\u043d\u044b\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u0435\u043c\u043e\u043f\u0435\u0440\u0435\u0434\u0430\u0442\u0447\u0438\u043a \u0441 1-\u043c \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u043c \u0438 1-\u043c \u0441\u0442\u043e\u043f\u043e\u0432\u044b\u043c \u0431\u0438\u0442\u043e\u043c. \u041e\u0434\u043d\u0438\u043c \u0441\u043b\u043e\u0432\u043e\u043c \u2014 \u043a\u043b\u0430\u0441\u0441\u0438\u043a\u0430. \u041d\u043e \u043a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0435 \u0442\u0430\u043a\u0430\u044f \u0443\u0436 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f, \u043a\u0430\u043a\u043e\u0439 \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434. \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0432 \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u0447\u0438\u043a \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0437\u0430 \u043e\u0434\u0438\u043d \u0432\u0435\u0447\u0435\u0440, \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0435\u0449\u0435 \u0434\u0432\u0430, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u044b \u043d\u0435 \u043f\u0440\u043e\u0433\u043b\u0430\u0442\u044b\u0432\u0430\u0442\u044c, \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0438 \u043e\u0442\u0441\u044b\u043b\u0430\u0442\u044c \u043f\u043e\u0442\u043e\u043a \u0431\u0430\u0439\u0442, \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u044e\u0441\u044c \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0447\u0442\u043e, \u043a\u0430\u043a \u0438 \u0437\u0430\u0447\u0435\u043c. \u0412\u0435\u0441\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 4-\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439:<\/p>\n<ul>\n<li><strong>Main<\/strong><\/li>\n<li><strong>UART<\/strong><\/li>\n<li><strong>UART_RX<\/strong><\/li>\n<li><strong>UART_TX<\/strong><\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/917\/aed\/b25\/917aedb259674f71aa5dabeacb7467c7.jpg\"\/><\/p>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043c\u043e\u0434\u0443\u043b\u044f UART_TX:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">UART_TX.v<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"vhdl\">module UART_TX # ( \tparameter CLOCK_FREQUENCY = 50_000_000, \tparameter BAUD_RATE       = 9600 ) ( \tinput  clockIN, \tinput  nTxResetIN, \tinput  [7:0] txDataIN, \tinput  txLoadIN, \toutput wire txIdleOUT, \toutput wire txReadyOUT, \toutput wire txOUT );  localparam HALF_BAUD_CLK_COMPARE_REG_VALUE = (CLOCK_FREQUENCY \/ BAUD_RATE \/ 2 - 1); localparam HALF_BAUD_CLK_COMPARE_REG_SIZE  = $clog2(HALF_BAUD_CLK_COMPARE_REG_VALUE);  reg [HALF_BAUD_CLK_COMPARE_REG_SIZE-1:0] txClkCounter = 0; reg txBaudClk = 1'b0;  reg [7:0] txReg   = 8'h00; reg [3:0] txIndex = 4'hA; reg       txPin   = 1'b1;  wire [8:0] txData = {1'b1, txReg[7:0]};  assign txReadyOUT = (txIndex[3] & (txIndex[1] | txIndex[0])); \/\/4'b1xx1 (4'h9) || 4'b1x1x (4'hA) assign txIdleOUT  = (txIndex[3] & txIndex[1]); \/\/4'b1x1x (4'hA) assign txOUT      = txPin;  always @(posedge clockIN) begin : tx_clock_generate \tif(txIdleOUT & (~txLoadIN)) begin \t\ttxClkCounter &lt;= HALF_BAUD_CLK_COMPARE_REG_VALUE; \t\ttxBaudClk    &lt;= 1'b0; \tend \telse if(txClkCounter == HALF_BAUD_CLK_COMPARE_REG_VALUE) begin \t\ttxClkCounter &lt;= 0; \t\ttxBaudClk    &lt;= ~txBaudClk; \tend \telse begin \t\ttxClkCounter &lt;= txClkCounter + 1'b1; \tend end  always @(posedge txBaudClk or negedge nTxResetIN) begin : tx_transmit \tif(~nTxResetIN) begin \t\ttxIndex &lt;= 4'hA; \tend \telse if(~txReadyOUT) begin \t\ttxPin = txData[txIndex]; \t\ttxIndex = txIndex + 1'b1; \tend \telse if(txLoadIN) begin \t\ttxReg[7:0] &lt;= txDataIN[7:0]; \t\ttxIndex &lt;= 4'h0; \t\ttxPin &lt;= 1'b0; \tend \telse begin \t\ttxIndex &lt;= 4'hA; \tend end  endmodule <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0432\u0441\u0435 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443:<\/p>\n<pre><code class=\"vhdl\">module UART_TX # ( \tparameter CLOCK_FREQUENCY = 50_000_000, \tparameter BAUD_RATE       = 9600 ) ( \tinput  clockIN, \tinput  nTxResetIN, \tinput  [7:0] txDataIN, \tinput  txLoadIN, \toutput wire txIdleOUT, \toutput wire txReadyOUT, \toutput wire txOUT ); <\/code><\/pre>\n<p>  \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b <strong>CLOCK_FREQUENCY<\/strong> \u0438 <strong>BAUD_RATE<\/strong> \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043a\u0432\u0430\u0440\u0446\u0435\u0432\u043e\u0433\u043e \u0440\u0435\u0437\u043e\u043d\u0430\u0442\u043e\u0440\u0430 \u0438 \u0447\u0430\u0441\u0442\u043e\u0442\u0430 UART \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>  \u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u043e\u0440\u0442\u044b: <\/p>\n<p>  <strong>clockIN<\/strong> \u2014 \u043f\u043e\u0440\u0442 \u0442\u0430\u043a\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0441 \u043a\u0432\u0430\u0440\u0446\u0435\u0432\u043e\u0433\u043e \u0440\u0435\u0437\u043e\u043d\u0430\u0442\u043e\u0440\u0430. <br \/>  <strong>nTxResetIN<\/strong> \u2014 \u043f\u043e\u0440\u0442 \u0441\u0431\u0440\u043e\u0441\u0430 \u043f\u043e \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443. <br \/>  <strong>txDataIN<\/strong> \u2014 \u0432\u043e\u0441\u044c\u043c\u0438\u0431\u0438\u0442\u043d\u0430\u044f \u0448\u0438\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. <br \/>  <strong>txLoadIN<\/strong> \u2014 \u043f\u043e\u0440\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u0418\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u043e\u0440\u0442\u044b: <\/p>\n<p>  <strong>txIdleOUT<\/strong> \u2014 \u043f\u043e\u0440\u0442 \u00ab\u043f\u0440\u043e\u0441\u0442\u043e\u044f\u00bb \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u0447\u0438\u043a\u0430, \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043b\u043e\u0433. 1 \u043f\u0440\u0438 \u043f\u043e\u043b\u043d\u043e\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0446\u0438\u043a\u043b\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0431\u0430\u0439\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0435\u0441\u043b\u0438 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>txLoadIN<\/strong> \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0433. 1. <br \/>  <strong>txReadyOUT<\/strong> \u2014 \u043f\u043e\u0440\u0442, \u043b\u043e\u0433. 1 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c, \u0431\u0443\u0434\u0435\u0442 \u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u0447\u0442\u043e \u0441\u0442\u043e\u043f\u043e\u0432\u044b\u0439 \u0431\u0438\u0442 \u0431\u044b\u043b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d, \u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. <br \/>  <strong>txOUT<\/strong> \u2014 \u043f\u043e\u0440\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u043d\u0430 \u043d\u043e\u0436\u043a\u0443 \u041f\u041b\u0418\u0421.<\/p>\n<pre><code class=\"vhdl\">localparam HALF_BAUD_CLK_COMPARE_REG_VALUE = (CLOCK_FREQUENCY \/ BAUD_RATE \/ 2 - 1); localparam HALF_BAUD_CLK_COMPARE_REG_SIZE  = $clog2(HALF_BAUD_CLK_COMPARE_REG_VALUE);  reg [HALF_BAUD_CLK_COMPARE_REG_SIZE-1:0] txClkCounter = 0; reg txBaudClk = 1'b0;  reg [7:0] txReg   = 8'h00; reg [3:0] txIndex = 4'hA; reg       txPin = 1'b1;  wire [8:0] txData = {1'b1, txReg[7:0]};  assign txReadyOUT = (txIndex[3] & (txIndex[1] | txIndex[0])); \/\/4'b1xx1 (4'h9) || 4'b1x1x (4'hA) assign txIdleOUT  = (txIndex[3] & txIndex[1]); \/\/4'b1x1x (4'hA) assign txOUT      = txPin; <\/code><\/pre>\n<p>  \u041b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <strong>HALF_BAUD_CLK_COMPARE_REG_VALUE<\/strong> \u2014 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430-\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043f\u043e\u043b\u0443\u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0442\u0430\u043a\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 UART. \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435 <strong>CLOCK_FREQUENCY \/ BAUD_RATE \/ 2 \u2014 1<\/strong>.<\/p>\n<p>  \u041b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <strong>HALF_BAUD_CLK_COMPARE_REG_SIZE<\/strong> \u2014 \u0440\u0430\u0437\u0440\u044f\u0434\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430. \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0443\u0434\u0435\u0441\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 $clog2 \u2014 \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u043e\u043c \u043f\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044e 2 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <strong>HALF_BAUD_CLK_COMPARE_REG_VALUE<\/strong>.<\/p>\n<p>  \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u044b reg: <\/p>\n<p>  <strong>txClkCounter<\/strong> \u2014 \u0441\u0447\u0435\u0442\u0447\u0438\u043a-\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0442\u0430\u043a\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430. <br \/>  <strong>txBaudClk<\/strong> \u2014 \u0442\u0430\u043a\u0442\u043e\u0432\u044b\u0439 \u0441\u0438\u0433\u043d\u0430\u043b \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u0447\u0438\u043a\u0430. <br \/>  <strong>txReg<\/strong> \u2014 \u0437\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0431\u0430\u0439\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443. <br \/>  <strong>txIndex<\/strong> \u2014 \u0438\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0431\u0438\u0442\u0430 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438. <br \/>  <strong>txPin<\/strong> \u2014 \u0440\u0435\u0433\u0438\u0441\u0442\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u043e\u0440\u0442\u0430 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u041f\u0440\u043e\u0432\u043e\u0434\u0430 wire: <\/p>\n<p>  <strong>txData<\/strong> \u2014 \u0448\u0438\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435. \u0421\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 8 \u0431\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 <strong>txReg<\/strong> (\u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u0431\u0438\u0442 0 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u043b\u0430\u043d \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u043f\u0440\u0438 \u043b\u043e\u0433. 1 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>txLoadIN<\/strong>), \u0438 \u0441\u0442\u043e\u043f\u043e\u0432\u043e\u0433\u043e \u0431\u0438\u0442\u0430 1.<br \/>  <strong>txReadyOUT<\/strong> \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435\u043c \u043d\u0430 1-\u0439 2-\u0439 \u0438 4-\u0439 \u0431\u0438\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 <strong>txIndex<\/strong> \u0447\u0435\u0440\u0435\u0437 \u0434\u0432\u0430 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u0430 AND \u0438 OR. \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043b\u043e\u0433. 1 \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u043e\u043c <strong>txIndex<\/strong> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 9 (4&#8217;h9) \u0438\u043b\u0438 10 (4&#8217;hA). <br \/>  <strong>txIdleOUT<\/strong> \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435\u043c \u043d\u0430 2-\u0439 \u0438 4-\u0439 \u0431\u0438\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 <strong>txIndex<\/strong> \u0447\u0435\u0440\u0435\u0437 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432 AND. \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043b\u043e\u0433. 1 \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u043e\u043c <strong>txIndex<\/strong> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 10 (4&#8217;hA).<br \/>  <strong>txOUT<\/strong> \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <strong>txPin<\/strong><\/p>\n<p>  \u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"vhdl\">always @(posedge txBaudClk or negedge nTxResetIN) begin : tx_transmit \tif(~nTxResetIN) begin \t\ttxIndex &lt;= 4'hA; \tend \telse if(~txReadyOUT) begin \t\ttxPin = txData[txIndex]; \t\ttxIndex = txIndex + 1'b1; \tend \telse if(txLoadIN) begin \t\ttxReg[7:0] &lt;= txDataIN[7:0]; \t\ttxIndex &lt;= 4'h0; \t\ttxPin &lt;= 1'b0; \tend \telse begin \t\ttxIndex &lt;= 4'hA; \tend end <\/code><\/pre>\n<p>  \u041f\u043e \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>nTxResetIN<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u0438, \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <strong>txIndex<\/strong> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 10 (4&#8217;hA), \u0438 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0430\u0445 <strong>txIdleOUT<\/strong> \u0438 <strong>txReadyOUT<\/strong> \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433. 1. <\/p>\n<p>  \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>txBaudClk<\/strong> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u043f\u043e\u0440\u0442\u0430 <strong>txReadyOUT<\/strong>, \u0438, \u043f\u0440\u0438 \u043b\u043e\u0433. 0, \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u043c \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0435\u043c \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <strong>txPin<\/strong> \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0431\u0438\u0442 \u0438\u0437 <strong>txData<\/strong> \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 <strong>txIndex<\/strong>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a <strong>txIndex<\/strong> \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443, \u0438 \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 9 (4&#8217;h9) \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 <strong>txReadyOUT<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u043b\u043e\u0433. 1.<\/p>\n<p>  \u0418\u043d\u0430\u0447\u0435 \u043f\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>txBaudClk<\/strong> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0441\u0438\u0433\u043d\u0430\u043b \u043f\u043e\u0440\u0442\u0430 <strong>txLoadIN<\/strong>, \u0438, \u043f\u0440\u0438 \u043b\u043e\u0433. 1, \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <strong>txReg<\/strong> \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e \u0432\u0445\u043e\u0434\u0430 <strong>txDataIN<\/strong>, \u0441\u0447\u0435\u0442\u0447\u0438\u043a <strong>txIndex<\/strong> \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 0 \u2014 \u0447\u0442\u043e \u0434\u0430\u0441\u0442 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0440\u043e\u043d\u0442 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0430\u0445 <strong>txIdleOUT<\/strong> \u0438 <strong>txReadyOUT<\/strong>, \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <strong>txPin<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0441\u0431\u0440\u043e\u0448\u0435\u043d \u0432 \u043b\u043e\u0433 0 \u2014 \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0438\u0433\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u0431\u0438\u0442).<\/p>\n<p>  \u0418\u043d\u0430\u0447\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <strong>txIndex<\/strong> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 10 (4&#8217;hA), \u0438 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0430\u0445 <strong>txIdleOUT<\/strong> \u0438 <strong>txReadyOUT<\/strong> \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433. 1. <\/p>\n<p>  \u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0447\u0442\u043e \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0435 \u043f\u0440\u0438 \u043b\u043e\u0433. 1 \u043d\u0430 <strong>txLoadIN<\/strong> \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0437\u0430\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441\u043e \u0432\u0445\u043e\u0434\u0430 <strong>txDataIN<\/strong> \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <strong>txReg<\/strong> \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u044b\u0445\u043e\u0434 <strong>txOUT<\/strong>. \u0422.\u0435. \u0434\u043b\u044f \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u0430\u043a\u0435\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0443\u0436\u043d\u043e \u0441\u0431\u0440\u043e\u0441\u0438\u0442\u044c <strong>txLoadIN<\/strong> \u0432 \u043b\u043e\u0433. 0 \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u043d \u0441\u0442\u043e\u043f\u043e\u0432\u044b\u0439 \u0431\u0438\u0442. \u041b\u0443\u0447\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u2014 \u044d\u0442\u043e \u0441\u0431\u0440\u043e\u0441 <strong>txLoadIN<\/strong> \u043f\u043e \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>txReadyOUT<\/strong>. \u041f\u0440\u0435\u0440\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0431\u0430\u0439\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043d\u0443\u043b\u0435\u043c \u043d\u0430 <strong>txLoadIN<\/strong> \u043d\u0435\u043b\u044c\u0437\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <strong>nTxResetIN<\/strong>. <\/p>\n<p>  \u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u0447\u0438\u043a\u0430:<\/p>\n<pre><code class=\"vhdl\">always @(posedge clockIN) begin : tx_clock_generate \tif(txIdleOUT & (~txLoadIN)) begin \t\ttxClkCounter &lt;= HALF_BAUD_CLK_COMPARE_REG_VALUE; \t\ttxBaudClk    &lt;= 1'b0; \tend \telse if(txClkCounter == HALF_BAUD_CLK_COMPARE_REG_VALUE) begin \t\ttxClkCounter &lt;= 0; \t\ttxBaudClk    &lt;= ~txBaudClk; \tend \telse begin \t\ttxClkCounter &lt;= txClkCounter + 1'b1; \tend end <\/code><\/pre>\n<p>  \u041f\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443 \u0442\u0430\u043a\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>clockIN<\/strong> \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433. 1 \u043d\u0430 <strong>txIdleOUT<\/strong> \u0438 \u043b\u043e\u0433. 0 \u043d\u0430 <strong>txLoadIN<\/strong>, \u0438 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443 <strong>txClkCounter<\/strong> \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 <strong>HALF_BAUD_CLK_COMPARE_REG_VALUE<\/strong>, \u0430 \u043d\u0430 \u0442\u0430\u043a\u0442\u043e\u0432\u043e\u043c \u0441\u0438\u0433\u043d\u0430\u043b\u0435 <strong>txBaudClk<\/strong> \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u043e\u0433. 0. \u0422.\u0435. \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043c\u044b \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u043c \u0447\u0442\u043e \u043f\u0440\u0438 \u043b\u043e\u0433. 1 \u043d\u0430 <strong>txDataIN<\/strong> \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u0447\u0438\u043a \u043d\u0430\u0447\u043d\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u0436\u0435 \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443 <strong>clockIN<\/strong>.<\/p>\n<p>  \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <strong>txClkCounter<\/strong> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c <strong>HALF_BAUD_CLK_COMPARE_REG_VALUE<\/strong>, \u0438 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f <strong>txClkCounter<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0441\u0431\u0440\u043e\u0448\u0435\u043d \u0432 0 \u0430 <strong>txBaudClk<\/strong> \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<p>  \u0418\u043d\u0430\u0447\u0435 <strong>txClkCounter<\/strong> \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442 \u0441\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 1.<\/p>\n<p>  \u0412\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432 \u043c\u043e\u0434\u0443\u043b\u044f UART_TX:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/cab\/ed2\/ef4\/cabed2ef46cf4e16a813c3ce21e878b1.png\"\/><\/p>\n<p>  \u041c\u043e\u0434\u0443\u043b\u044c UART_RX:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">UART_RX.v<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"vhdl\">module UART_RX # ( \tparameter CLOCK_FREQUENCY = 50_000_000, \tparameter BAUD_RATE       = 9600 ) ( \tinput  clockIN, \tinput  nRxResetIN, \tinput  rxIN,  \toutput wire rxIdleOUT, \toutput wire rxReadyOUT, \toutput wire [7:0] rxDataOUT );  localparam HALF_BAUD_CLK_COMPARE_REG_VALUE = (CLOCK_FREQUENCY \/ BAUD_RATE \/ 2 - 1); localparam HALF_BAUD_CLK_COMPARE_REG_SIZE  = $clog2(HALF_BAUD_CLK_COMPARE_REG_VALUE);  reg [HALF_BAUD_CLK_COMPARE_REG_SIZE-1:0] rxClkCounter = 0; reg rxBaudClk = 1'b0;  reg [8:0] rxReg      = 9'h000; reg [3:0] rxIndex    = 4'h9;  assign rxIdleOUT = (rxIndex[3] & rxIndex[0]); \/\/4'b1xx1 || 4'h9 assign rxReadyOUT = (rxIdleOUT & rxReg[8]); assign rxDataOUT[7:0] = rxReg[7:0];  always @(posedge clockIN) begin : rx_clock_generate \tif(rxIN & rxIdleOUT) begin \t\trxClkCounter &lt;= 0; \t\trxBaudClk    &lt;= 0; \tend \telse if(rxClkCounter == HALF_BAUD_CLK_COMPARE_REG_VALUE) begin \t\trxClkCounter &lt;= 0; \t\trxBaudClk &lt;= ~rxBaudClk; \tend \telse begin \t\trxClkCounter &lt;= rxClkCounter + 1'b1; \tend end  always @(posedge rxBaudClk or negedge nRxResetIN) begin : rx_receive \tif(~nRxResetIN) begin \t\trxReg[8] &lt;= 1'b0; \t\trxIndex  &lt;= 4'h9; \tend \telse if(~rxIdleOUT) begin \t\trxReg[rxIndex] = rxIN; \t\trxIndex = rxIndex + 1'b1; \tend \telse if(~rxIN) begin \t\trxIndex &lt;= 4'h0; \tend end  endmodule <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<pre><code class=\"vhdl\">module UART_RX # ( \tparameter CLOCK_FREQUENCY = 50_000_000, \tparameter BAUD_RATE       = 9600 ) ( \tinput  clockIN, \tinput  nRxResetIN, \tinput  rxIN,  \toutput wire rxIdleOUT, \toutput wire rxReadyOUT, \toutput wire [7:0] rxDataOUT ); <\/code><\/pre>\n<p>  \u0412\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u043c\u043e\u0434\u0443\u043b\u044c UART_TX.<\/p>\n<p>  \u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u043e\u0440\u0442\u044b: <\/p>\n<p>  <strong>clockIN<\/strong> \u0438 <strong>nRxResetIN<\/strong> \u0438\u043c\u0435\u044e\u0442 \u0442\u0435-\u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0447\u0442\u043e \u0438 \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 <strong>UART_RX<\/strong> <br \/>  <strong>rxIN<\/strong> \u2014 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u043e\u0440\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u043d\u0430 \u043d\u043e\u0436\u043a\u0443 \u041f\u041b\u0418\u0421.<\/p>\n<p>  \u0418\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u043e\u0440\u0442\u044b:<\/p>\n<p>  <strong>rxIdleOUT<\/strong> \u2014 \u043f\u043e\u0440\u0442 \u00ab\u043f\u0440\u043e\u0441\u0442\u043e\u044f\u00bb \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u0430, \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043b\u043e\u0433. 1 \u043f\u0440\u0438 \u043f\u043e\u043b\u043d\u043e\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0446\u0438\u043a\u043b\u0430 \u043f\u0440\u0438\u0435\u043c\u0430 \u0431\u0430\u0439\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<br \/>  <strong>rxReadyOUT<\/strong> \u2014 \u043f\u043e\u0440\u0442 \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u0430. \u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u0432 \u043b\u043e\u0433. 1 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0431\u044b\u043b \u043f\u0440\u0438\u043d\u044f\u0442 \u0431\u0430\u0439\u0442 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0441\u044f \u0441\u0442\u043e\u043f\u043e\u0432\u044b\u043c \u0431\u0438\u0442\u043e\u043c (\u043b\u043e\u0433. 1). \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043b\u043e\u0433. 0 \u043f\u0440\u0438 \u043b\u043e\u0433. 0 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>nRxResetIN<\/strong> \u0438\u043b\u0438 \u043f\u0440\u0438 \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0440\u0438\u0435\u043c\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0431\u0430\u0439\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<br \/>  <strong>rxDataOUT<\/strong> \u2014 \u0432\u043e\u0441\u044c\u043c\u0438\u0431\u0438\u0442\u043d\u0430\u044f \u0448\u0438\u043d\u0430 \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"vhdl\">localparam HALF_BAUD_CLK_COMPARE_REG_VALUE = (CLOCK_FREQUENCY \/ BAUD_RATE \/ 2 - 1); localparam HALF_BAUD_CLK_COMPARE_REG_SIZE  = $clog2(HALF_BAUD_CLK_COMPARE_REG_VALUE);  reg [HALF_BAUD_CLK_COMPARE_REG_SIZE-1:0] rxClkCounter = 0; reg rxBaudClk = 1'b0;  reg [8:0] rxReg      = 9'h000; reg [3:0] rxIndex    = 4'h9;  assign rxIdleOUT = (rxIndex[3] & rxIndex[0]); \/\/4'b1xx1 || 4'h9 assign rxReadyOUT = (rxIdleOUT & rxReg[8]); assign rxDataOUT[7:0] = rxReg[7:0]; <\/code><\/pre>\n<p>  \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u044b reg: <\/p>\n<p>  <strong>rxClkCounter<\/strong> \u2014 \u0441\u0447\u0435\u0442\u0447\u0438\u043a-\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0442\u0430\u043a\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430. <br \/>  <strong>rxBaudClk<\/strong> \u2014 \u0442\u0430\u043a\u0442\u043e\u0432\u044b\u0439 \u0441\u0438\u0433\u043d\u0430\u043b \u0434\u043b\u044f \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u0430. <br \/>  <strong>rxReg<\/strong> \u2014 \u0440\u0435\u0433\u0438\u0441\u0442\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u0440\u0430\u043d\u0438\u0442 8 \u0431\u0438\u0442 \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 9-\u0439 \u0441\u0442\u043e\u043f\u043e\u0432\u044b\u0439 \u0431\u0438\u0442.<br \/>  <strong>rxIndex<\/strong> \u2014 \u0438\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0431\u0438\u0442\u0430 \u043f\u0440\u0438\u0435\u043c\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>  \u041f\u0440\u043e\u0432\u043e\u0434\u0430 wire: <\/p>\n<p>  <strong>rxIdleOUT<\/strong> \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u043d\u0430 0-\u0439 \u0438 4-\u0439 \u0431\u0438\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 <strong>rxIndex<\/strong> \u0447\u0435\u0440\u0435\u0437 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432 AND. \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043b\u043e\u0433. 1 \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u043e\u043c <strong>rxIndex<\/strong> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 9 (4&#8217;h9).<br \/>  <strong>rxReadyOUT<\/strong> \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u043d\u0430 \u043f\u043e\u0440\u0442 <strong>rxIdleOUT<\/strong> \u0438 9-\u0439 \u0431\u0438\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 <strong>rxReg<\/strong> \u0447\u0435\u0440\u0435\u0437 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432 AND. \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043b\u043e\u0433. 1 \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u044b\u043b \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d \u0438 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 <strong>rxReg<\/strong> 9-\u0439 \u0431\u0438\u0442 \u043f\u0440\u0438\u043d\u044f\u043b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043b\u043e\u0433. 1 (\u0441\u0442\u043e\u043f\u043e\u0432\u044b\u0439 \u0431\u0438\u0442). <br \/>  <strong>rxDataOUT<\/strong> \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u043d\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <strong>rxReg<\/strong>.<\/p>\n<p>  \u041f\u0440\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"vhdl\">always @(posedge rxBaudClk or negedge nRxResetIN) begin : rx_receive \tif(~nRxResetIN) begin \t\trxReg[8] &lt;= 1'b0; \t\trxIndex  &lt;= 4'h9; \tend \telse if(~rxIdleOUT) begin \t\trxReg[rxIndex] = rxIN; \t\trxIndex = rxIndex + 1'b1; \tend \telse if(~rxIN) begin \t\trxIndex &lt;= 4'h0; \tend end <\/code><\/pre>\n<p>  \u041f\u043e \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>nRxResetIN<\/strong>, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u043f\u0435\u0440\u0432\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435, \u0438 9-\u0439 \u0431\u0438\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 <strong>rxReg<\/strong> \u0441\u0431\u0440\u043e\u0441\u0438\u0442\u0441\u044f \u0432 \u043b\u043e\u0433. 0, \u0447\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442 \u043b\u043e\u0433. 0 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>rxReadyOUT<\/strong>. \u0410 \u0442\u0430\u043a-\u0436\u0435 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <strong>rxIndex<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0447\u0438\u0441\u043b\u043e 9 (4&#8217;h9), \u0447\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442 \u043b\u0438\u043d\u0438\u044e <strong>rxIdleOUT<\/strong> \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043b\u043e\u0433. 1. <\/p>\n<p>  \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438 \u043b\u043e\u0433. 0 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>rxIdleOUT<\/strong> \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u043c \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0435\u043c \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <strong>rxReg<\/strong> \u043f\u043e\u0434 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c <strong>rxIndex<\/strong> \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>rxIN<\/strong>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a <strong>rxIndex<\/strong> \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443, \u0438 \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 9 (4&#8217;h9) \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 <strong>rxIdleOUT<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u043b\u043e\u0433. 1, \u0438 \u043b\u043e\u0433. 1 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 <strong>rxReadyOUT<\/strong>, \u0435\u0441\u043b\u0438 \u0432 9-\u0439 \u0431\u0438\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 <strong>rxReg<\/strong> \u0431\u044b\u043b \u043f\u0440\u0438\u043d\u044f\u0442 \u0441\u0442\u043e\u043f\u043e\u0432\u044b\u0439 \u0431\u0438\u0442 (\u043b\u043e\u0433. 1).<\/p>\n<p>  \u0418\u043d\u0430\u0447\u0435 \u043b\u043e\u0433. 0 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>rxIN<\/strong> \u0431\u0443\u0434\u0435\u0442 \u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u0431\u0438\u0442), \u0438 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <strong>rxIndex<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0430\u043d 0.<\/p>\n<p>  \u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u0430:<\/p>\n<pre><code class=\"vhdl\">always @(posedge clockIN) begin : rx_clock_generate \tif(rxIN & rxIdleOUT) begin \t\trxClkCounter &lt;= 0; \t\trxBaudClk    &lt;= 0; \tend \telse if(rxClkCounter == HALF_BAUD_CLK_COMPARE_REG_VALUE) begin \t\trxClkCounter &lt;= 0; \t\trxBaudClk &lt;= ~rxBaudClk; \tend \telse begin \t\trxClkCounter &lt;= rxClkCounter + 1'b1; \tend end <\/code><\/pre>\n<p>  \u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f UART_TX \u2014 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0434\u043b\u044f \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u0430.<\/p>\n<p>  \u0412 \u043f\u0435\u0440\u0432\u043e\u043c-\u0436\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442\u0441\u044f \u043b\u043e\u0433. 1 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 <strong>rxIN<\/strong> \u0438 \u043b\u043e\u0433. 1 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 <strong>rxIdleOUT<\/strong>, \u0438 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u0447\u0435\u0442\u0447\u0438\u043a <strong>rxClkCounter<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0441\u0431\u0440\u043e\u0448\u0435\u043d \u0432 0, \u0430 \u043d\u0430 <strong>rxBaudClk<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043b\u043e\u0433. 0. <\/p>\n<p>  \u0422.\u0435. \u043f\u0440\u0438 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u043b\u043e\u0433. 0 (\u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u0431\u0438\u0442) \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>rxIN<\/strong>, \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u043e\u0442\u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0442\u0430\u043a\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u0430, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0447\u0430\u0442 \u043f\u0440\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u0412\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432 \u043c\u043e\u0434\u0443\u043b\u044f UART_RX:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/a80\/22b\/917\/a8022b917bec4ce9b831238a4aafbc5c.png\"\/><\/p>\n<p>  \u041c\u043e\u0434\u0443\u043b\u044c UART:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">UART.v<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"vhdl\">module UART # ( \tparameter CLOCK_FREQUENCY = 50_000_000, \tparameter BAUD_RATE       = 9600 ) ( \tinput  clockIN, \t \tinput  nTxResetIN, \tinput  [7:0] txDataIN, \tinput  txLoadIN, \toutput wire txIdleOUT, \toutput wire txReadyOUT, \toutput wire txOUT, \t \tinput  nRxResetIN, \tinput  rxIN,  \toutput wire rxIdleOUT, \toutput wire rxReadyOUT, \toutput wire [7:0] rxDataOUT );  defparam  uart_tx.CLOCK_FREQUENCY = CLOCK_FREQUENCY; defparam  uart_tx.BAUD_RATE       = BAUD_RATE; UART_TX uart_tx ( \t.clockIN(clockIN), \t.nTxResetIN(nTxResetIN), \t.txDataIN(txDataIN), \t.txLoadIN(txLoadIN), \t.txIdleOUT(txIdleOUT), \t.txReadyOUT(txReadyOUT), \t.txOUT(txOUT) );  defparam  uart_rx.CLOCK_FREQUENCY = CLOCK_FREQUENCY; defparam  uart_rx.BAUD_RATE       = BAUD_RATE; UART_RX uart_rx ( \t.clockIN(clockIN), \t.nRxResetIN(nRxResetIN), \t.rxIN(rxIN),  \t.rxIdleOUT(rxIdleOUT), \t.rxReadyOUT(rxReadyOUT), \t.rxDataOUT(rxDataOUT) );  endmodule <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0434\u0432\u0430 \u043c\u043e\u0434\u0443\u043b\u044f UART_RX \u0438 UART_TX \u0432 \u0435\u0434\u0438\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435, \u043f\u0440\u043e\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044f \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0438 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0441\u0438\u0433\u043d\u0430\u043b\u044b, \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043a\u0432\u0430\u0440\u0446\u0435\u0432\u043e\u0433\u043e \u0440\u0435\u0437\u043e\u043d\u0430\u0442\u043e\u0440\u0430 \u0438 \u0447\u0430\u0441\u0442\u043e\u0442\u044b UART \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u0447\u0438\u043a\u0430.<\/p>\n<p>  \u0418 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u043e\u0434\u0443\u043b\u044c \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f Main:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Main.v<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"vhdl\">module Main ( \tinput  wire clockIN, \tinput  wire uartRxIN, \toutput wire uartTxOUT );  defparam uart.CLOCK_FREQUENCY = 50_000_000; defparam uart.BAUD_RATE       = 921600;  reg [7:0] txData; reg txLoad  = 1'b0;  wire txReset = 1'b1; wire rxReset = 1'b1; wire [7:0] rxData; wire txIdle; wire txReady; wire rxIdle; wire rxReady;  UART uart ( \t.clockIN(clockIN), \t \t.nTxResetIN(txReset), \t.txDataIN(txData), \t.txLoadIN(txLoad), \t.txIdleOUT(txIdle), \t.txReadyOUT(txReady), \t.txOUT(uartTxOUT), \t \t.nRxResetIN(rxReset), \t.rxIN(uartRxIN),  \t.rxIdleOUT(rxIdle), \t.rxReadyOUT(rxReady), \t.rxDataOUT(rxData) );  always @(posedge rxReady or negedge txReady) begin \tif(~txReady) \t\ttxLoad &lt;= 1'b0; \telse if(rxReady) begin \t\ttxLoad &lt;= 1'b1; \t\ttxData &lt;= rxData; \tend end  endmodule <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u042f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0441\u0443\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u00ab\u044d\u0445\u043e\u00bb \u0442\u0435\u0441\u0442\u043e\u043c. <\/p>\n<p>  \u041f\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>rxReady<\/strong> \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <strong>txData<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u043d\u0430 \u0432\u0445\u043e\u0434 <strong>txDataIN<\/strong> \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u0447\u0438\u043a\u0430, \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <strong>txLoad<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u0447\u0438\u043a\u0430 <strong>txLoadIN<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432 \u043b\u043e\u0433. 1, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438. <\/p>\n<p>  \u041f\u043e \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443 \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>txReady<\/strong>, \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <strong>txLoad<\/strong> \u043f\u0440\u0438\u043c\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043b\u043e\u0433. 0.<\/p>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0431\u044b\u043b \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u043d\u0430 \u043f\u043b\u0430\u0442\u0435 \u0441 Altera Max II EPM240T100C5N \u0447\u0438\u043f\u043e\u043c \u0438 \u043a\u0432\u0430\u0440\u0446\u0435\u0432\u044b\u043c \u0440\u0435\u0437\u043e\u043d\u0430\u0442\u043e\u0440\u043e\u043c \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 50 \u043c\u0435\u0433\u0430\u0433\u0435\u0440\u0446, \u0441\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e UART \u0432 921600 baud (\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u043e\u0439 USB-UART \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043d\u0438\u043a).<\/p>\n<p>  \u041f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443, \u0434\u043b\u044f \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u0430, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0433\u043e \u0431\u0438\u0442\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0432 16 \u0440\u0430\u0437 \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b UART. \u0422\u0430\u043a \u0447\u0442\u043e \u0434\u043b\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u0440\u0438 921600 baud rate, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043a\u0432\u0430\u0440\u0446\u0435\u0432\u043e\u0433\u043e \u0440\u0435\u0437\u043e\u043d\u0430\u0442\u043e\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043d\u0435 \u043d\u0438\u0436\u0435 921600 * 16 = 14&#8217;745&#8217;600 \u0433\u0435\u0440\u0446. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0439\u0434\u0435\u0442 \u043a\u0440\u0438\u0441\u0442\u0430\u043b\u043b \u043d\u0430 16 \u043c\u0435\u0433\u0430\u0433\u0435\u0440\u0446.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0438\u0441\u0442\u043e\u0440 \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u0430.<\/p>\n<p>  \u041b\u044e\u0431\u044b\u0435 \u0441\u043e\u0432\u0435\u0442\u044b \u043f\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0438 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u0441\u044f.<\/p>\n<p>  \u0421\u043a\u0430\u0447\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/dl.dropboxusercontent.com\/u\/41082176\/geektimes\/files\/UART.zip\">\u0442\u0443\u0442<\/a>.       <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/278005\/\"> https:\/\/habrahabr.ru\/post\/278005\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b36\/8bc\/2c9\/b368bc2c94344822b2c0e1e4fc92598a.jpg\"\/><\/p>\n<p>  \u041f\u0430\u0440\u0443 \u043d\u0435\u0434\u0435\u043b\u044c \u043d\u0430\u0437\u0430\u0434 \u044f \u043d\u0430\u0447\u0430\u043b \u043f\u043e\u0442\u0438\u0445\u043e\u043d\u044c\u043a\u0443 \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0434 \u041f\u041b\u0418\u0421. \u0414\u043b\u044f \u044d\u0442\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u043c\u043d\u043e\u044e \u0431\u044b\u043b\u0430 \u0437\u0430\u043a\u0430\u0437\u0430\u043d\u0430 \u0443 \u043a\u0438\u0442\u0430\u0439\u0446\u0435\u0432 \u0441\u0430\u043c\u0430\u044f \u0434\u0435\u0448\u0435\u0432\u0430\u044f \u043f\u043b\u0430\u0442\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 Altera Max II EPM240T100C5N \u0447\u0438\u043f\u0430. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432 Quartus v15, \u0441\u0442\u0430\u043b \u0438\u0437\u0443\u0447\u0430\u0442\u044c Verilog \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 2001 \u0433\u043e\u0434\u0430. \u041d\u0430\u043c\u043e\u0440\u0433\u0430\u0432\u0448\u0438\u0441\u044c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430\u043c\u0438 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u043c \u0441\u0442\u0430\u043b UART. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u043d\u0430 \u0447\u0443\u0436\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0432 \u0441\u0435\u0442\u0438, \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043c\u043d\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0438\u0437\u043b\u0438\u0448\u043d\u0435\u0435 \u043d\u0430\u0433\u0440\u043e\u043c\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043b\u043e\u0433\u0438\u043a\u0438, \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u043e\u0432, \u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0432 \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u0435 \u0438, \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430 \u0432\u044b\u0441\u043e\u043a\u0438\u0445 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044f\u0445. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435, \u0434\u0430 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0441 \u00ab\u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c\u00bb, \u043d\u043e \u0442\u0430\u043a \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0441\u043f\u043e\u0440\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-275001","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/275001","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=275001"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/275001\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=275001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=275001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=275001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}