http://portal-ed.ru/index.php/primery-verilog 2020-02-17T17:43:24+00:00 Joomla! - Open Source Content Management
Пример реализации UART
2013-10-08T02:22:00+00:00 2013-10-08T02:22:00+00:00 http://portal-ed.ru/index.php/primery-verilog/162-primer-realizatsii-uart EngineerDeveloper® [email protected]
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : uart</span><br /><span style="color: #008000;">// Имя файла : uart.v</span><br /><span style="color: #008000;">// Функц. назначение : Простой UART</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><strong><span style="color: #0000ff;">module</span></strong> uart (<br />reset ,<br />txclk ,<br />ld_tx_data ,<br />tx_data ,<br />tx_enable ,<br />tx_out ,<br />tx_empty ,<br />rxclk ,<br />uld_rx_data ,<br />rx_data ,<br />rx_enable ,<br />rx_in ,<br />rx_empty<br />);<br /><span style="color: #008000;">// Объявление портов</span><br /><strong><span style="color: #0000ff;">input</span></strong> reset ;<br /><strong><span style="color: #0000ff;">input</span></strong> txclk ;<br /><strong><span style="color: #0000ff;">input</span></strong> ld_tx_data ;<br /><strong><span style="color: #0000ff;">input</span></strong> [7:0] tx_data ;<br /><strong><span style="color: #0000ff;">input</span></strong> tx_enable ;<br /><strong><span style="color: #0000ff;">output</span></strong> tx_out ;<br /><strong><span style="color: #0000ff;">output</span></strong> tx_empty ;<br /><strong><span style="color: #0000ff;">input</span></strong> rxclk ;<br /><strong><span style="color: #0000ff;">input</span></strong> uld_rx_data ;<br /><strong><span style="color: #0000ff;">output</span></strong> [7:0] rx_data ;<br /><strong><span style="color: #0000ff;">input</span></strong> rx_enable ;<br /><strong><span style="color: #0000ff;">input</span></strong> rx_in ;<br /><strong><span style="color: #0000ff;">output</span></strong> rx_empty ;<br /><span style="color: #008000;">// Внутренние переменные</span><br /><strong><span style="color: #0000ff;">reg</span></strong> [7:0] tx_reg ;<br /><strong><span style="color: #0000ff;">reg</span></strong> tx_empty ;<br /><strong><span style="color: #0000ff;">reg</span></strong> tx_over_run ;<br /><strong><span style="color: #0000ff;">reg</span></strong> [3:0] tx_cnt ;<br /><strong><span style="color: #0000ff;">reg</span></strong> tx_out ;<br /><strong><span style="color: #0000ff;">reg</span></strong> [7:0] rx_reg ;<br /><strong><span style="color: #0000ff;">reg</span></strong> [7:0] rx_data ;<br /><strong><span style="color: #0000ff;">reg</span></strong> [3:0] rx_sample_cnt ;<br /><strong><span style="color: #0000ff;">reg</span></strong> [3:0] rx_cnt ;<br /><strong><span style="color: #0000ff;">reg</span></strong> rx_frame_err ;<br /><strong><span style="color: #0000ff;">reg</span></strong> rx_over_run ;<br /><strong><span style="color: #0000ff;">reg</span></strong> rx_empty ;<br /><strong><span style="color: #0000ff;">reg</span></strong> rx_d1 ;<br /><strong><span style="color: #0000ff;">reg</span></strong> rx_d2 ;<br /><strong><span style="color: #0000ff;">reg</span></strong> rx_busy ;<br /><span style="color: #008000;">// Логика UART приема</span><br /><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> rxclk <strong><span style="color: #0000ff;">or posedge</span></strong> reset)<br /><strong><span style="color: #0000ff;">if</span> </strong>(reset) <strong><span style="color: #0000ff;">begin</span></strong><br />rx_reg <= 0;<br />rx_data <= 0;<br />rx_sample_cnt <= 0;<br />rx_cnt <= 0;<br />rx_frame_err <= 0;<br />rx_over_run <= 0;<br />rx_empty <= 1;<br />rx_d1 <= 1;<br />rx_d2 <= 1;<br />rx_busy <= 0;<br /><strong><span style="color: #0000ff;">end else begin</span></strong><br /><span style="color: #008000;">// Синхронный и асинхронный сигнал</span><br />rx_d1 <= rx_in;<br />rx_d2 <= rx_d1;<br /><span style="color: #008000;">// Загрузка принятых данных</span><br /><strong><span style="color: #0000ff;">if</span></strong> (uld_rx_data) <strong><span style="color: #0000ff;">begin</span></strong><br />rx_data <= rx_reg;<br />rx_empty <= 1;<br /><strong><span style="color: #0000ff;">end</span></strong><br /><span style="color: #008000;">// Приём данных только тогда, когда разрешен приём</span><br /><strong><span style="color: #0000ff;">if</span></strong> (rx_enable) <strong><span style="color: #0000ff;">begin</span></strong><br /><span style="color: #008000;">// Проверка того, что получено начало кадра</span><br /><strong><span style="color: #0000ff;">if</span></strong> (!rx_busy && !rx_d2) <strong><span style="color: #0000ff;">begin</span></strong><br /> rx_busy <= 1;<br /> rx_sample_cnt <= 1;<br /> rx_cnt <= 0;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><span style="color: #008000;">// Начало кадра обнаружено, переходим к остальным данным</span><br /><strong><span style="color: #0000ff;">if</span></strong> (rx_busy) <strong><span style="color: #0000ff;">begin</span></strong><br /> rx_sample_cnt <= rx_sample_cnt + 1;<br /> <strong><span style="color: #0000ff;">if</span></strong> (rx_sample_cnt == 7) <strong><span style="color: #0000ff;">begin</span></strong><br /> <strong><span style="color: #0000ff;">if</span> </strong>((rx_d2 == 1) && (rx_cnt == 0)) <strong><span style="color: #0000ff;">begin</span></strong><br /> rx_busy <= 0;<br /> <strong><span style="color: #0000ff;">end else begin</span></strong><br /> rx_cnt <= rx_cnt + 1;<br /><span style="color: #008000;">// Начало сохранения данных приёма</span><br /><strong><span style="color: #0000ff;">if</span></strong> (rx_cnt > 0 && rx_cnt < 9) <strong><span style="color: #0000ff;">begin</span></strong><br /> rx_reg[rx_cnt - 1] <= rx_d2;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">if</span></strong> (rx_cnt == 9) <strong><span style="color: #0000ff;">begin</span></strong><br /> rx_busy <= 0;<br /><span style="color: #008000;">// Проверка конца кадра, т.е. кадр принят корректно</span><br /><strong><span style="color: #0000ff;">if</span></strong> (rx_d2 == 0) <strong><span style="color: #0000ff;">begin</span></strong><br /> rx_frame_err <= 1;<br /><strong><span style="color: #0000ff;"> end else begin</span></strong><br /> rx_empty <= 0;<br /> rx_frame_err <= 0;<br /> rx_over_run <= (rx_empty) ? 0 : 1;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">if</span></strong> (!rx_enable) <strong><span style="color: #0000ff;">begin</span></strong><br /> rx_busy <= 0;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><span style="color: #008000;">// UART передатчик</span><br /><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> txclk <strong><span style="color: #0000ff;">or posedge</span></strong> reset)<br /><strong><span style="color: #0000ff;">if</span></strong> (reset) <strong><span style="color: #0000ff;">begin</span></strong><br /> tx_reg <= 0;<br /> tx_empty <= 1;<br /> tx_over_run <= 0;<br /> tx_out <= 1;<br /> tx_cnt <= 0;<br /><strong><span style="color: #0000ff;"> end else begin</span></strong><br /><strong><span style="color: #0000ff;"> if</span></strong> (ld_tx_data) <strong><span style="color: #0000ff;">begin</span></strong><br /><strong><span style="color: #0000ff;"><strong><span style="color: #0000ff;"> </span></strong><strong><span style="color: #0000ff;"> </span></strong>if</span> </strong>(!tx_empty) <strong><span style="color: #0000ff;">begin</span></strong><br /> tx_over_run <= 0;<br /><strong><span style="color: #0000ff;"> end else begin</span></strong><br /> tx_reg <= tx_data;<br /> tx_empty <= 0;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">if</span> </strong>(tx_enable && !tx_empty)<strong><span style="color: #0000ff;"> begin</span></strong><br /> tx_cnt <= tx_cnt + 1;<br /><strong><span style="color: #0000ff;"> if</span></strong> (tx_cnt == 0)<strong><span style="color: #0000ff;"> begin</span></strong><br /> tx_out <= 0;<br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">if</span></strong> (tx_cnt > 0 && tx_cnt < 9) <strong><span style="color: #0000ff;">begin</span></strong><br /> tx_out <= tx_reg[tx_cnt -1];<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">if</span></strong> (tx_cnt == 9) <strong><span style="color: #0000ff;">begin</span></strong><br /> tx_out <= 1;<br /> tx_cnt <= 0;<br /> tx_empty <= 1;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">if</span></strong> (!tx_enable) <strong><span style="color: #0000ff;">begin</span></strong><br /> tx_cnt <= 0;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">endmodule</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><span style="color: #ff0000;">{phocadownload view=file|id=5|text=СКАЧАТЬ ПРИМЕР|target=s}</span></p> <p><strong><span style="color: #0000ff;"> </span></strong></p></div>
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : uart</span><br /><span style="color: #008000;">// Имя файла : uart.v</span><br /><span style="color: #008000;">// Функц. назначение : Простой UART</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><strong><span style="color: #0000ff;">module</span></strong> uart (<br />reset ,<br />txclk ,<br />ld_tx_data ,<br />tx_data ,<br />tx_enable ,<br />tx_out ,<br />tx_empty ,<br />rxclk ,<br />uld_rx_data ,<br />rx_data ,<br />rx_enable ,<br />rx_in ,<br />rx_empty<br />);<br /><span style="color: #008000;">// Объявление портов</span><br /><strong><span style="color: #0000ff;">input</span></strong> reset ;<br /><strong><span style="color: #0000ff;">input</span></strong> txclk ;<br /><strong><span style="color: #0000ff;">input</span></strong> ld_tx_data ;<br /><strong><span style="color: #0000ff;">input</span></strong> [7:0] tx_data ;<br /><strong><span style="color: #0000ff;">input</span></strong> tx_enable ;<br /><strong><span style="color: #0000ff;">output</span></strong> tx_out ;<br /><strong><span style="color: #0000ff;">output</span></strong> tx_empty ;<br /><strong><span style="color: #0000ff;">input</span></strong> rxclk ;<br /><strong><span style="color: #0000ff;">input</span></strong> uld_rx_data ;<br /><strong><span style="color: #0000ff;">output</span></strong> [7:0] rx_data ;<br /><strong><span style="color: #0000ff;">input</span></strong> rx_enable ;<br /><strong><span style="color: #0000ff;">input</span></strong> rx_in ;<br /><strong><span style="color: #0000ff;">output</span></strong> rx_empty ;<br /><span style="color: #008000;">// Внутренние переменные</span><br /><strong><span style="color: #0000ff;">reg</span></strong> [7:0] tx_reg ;<br /><strong><span style="color: #0000ff;">reg</span></strong> tx_empty ;<br /><strong><span style="color: #0000ff;">reg</span></strong> tx_over_run ;<br /><strong><span style="color: #0000ff;">reg</span></strong> [3:0] tx_cnt ;<br /><strong><span style="color: #0000ff;">reg</span></strong> tx_out ;<br /><strong><span style="color: #0000ff;">reg</span></strong> [7:0] rx_reg ;<br /><strong><span style="color: #0000ff;">reg</span></strong> [7:0] rx_data ;<br /><strong><span style="color: #0000ff;">reg</span></strong> [3:0] rx_sample_cnt ;<br /><strong><span style="color: #0000ff;">reg</span></strong> [3:0] rx_cnt ;<br /><strong><span style="color: #0000ff;">reg</span></strong> rx_frame_err ;<br /><strong><span style="color: #0000ff;">reg</span></strong> rx_over_run ;<br /><strong><span style="color: #0000ff;">reg</span></strong> rx_empty ;<br /><strong><span style="color: #0000ff;">reg</span></strong> rx_d1 ;<br /><strong><span style="color: #0000ff;">reg</span></strong> rx_d2 ;<br /><strong><span style="color: #0000ff;">reg</span></strong> rx_busy ;<br /><span style="color: #008000;">// Логика UART приема</span><br /><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> rxclk <strong><span style="color: #0000ff;">or posedge</span></strong> reset)<br /><strong><span style="color: #0000ff;">if</span> </strong>(reset) <strong><span style="color: #0000ff;">begin</span></strong><br />rx_reg <= 0;<br />rx_data <= 0;<br />rx_sample_cnt <= 0;<br />rx_cnt <= 0;<br />rx_frame_err <= 0;<br />rx_over_run <= 0;<br />rx_empty <= 1;<br />rx_d1 <= 1;<br />rx_d2 <= 1;<br />rx_busy <= 0;<br /><strong><span style="color: #0000ff;">end else begin</span></strong><br /><span style="color: #008000;">// Синхронный и асинхронный сигнал</span><br />rx_d1 <= rx_in;<br />rx_d2 <= rx_d1;<br /><span style="color: #008000;">// Загрузка принятых данных</span><br /><strong><span style="color: #0000ff;">if</span></strong> (uld_rx_data) <strong><span style="color: #0000ff;">begin</span></strong><br />rx_data <= rx_reg;<br />rx_empty <= 1;<br /><strong><span style="color: #0000ff;">end</span></strong><br /><span style="color: #008000;">// Приём данных только тогда, когда разрешен приём</span><br /><strong><span style="color: #0000ff;">if</span></strong> (rx_enable) <strong><span style="color: #0000ff;">begin</span></strong><br /><span style="color: #008000;">// Проверка того, что получено начало кадра</span><br /><strong><span style="color: #0000ff;">if</span></strong> (!rx_busy && !rx_d2) <strong><span style="color: #0000ff;">begin</span></strong><br /> rx_busy <= 1;<br /> rx_sample_cnt <= 1;<br /> rx_cnt <= 0;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><span style="color: #008000;">// Начало кадра обнаружено, переходим к остальным данным</span><br /><strong><span style="color: #0000ff;">if</span></strong> (rx_busy) <strong><span style="color: #0000ff;">begin</span></strong><br /> rx_sample_cnt <= rx_sample_cnt + 1;<br /> <strong><span style="color: #0000ff;">if</span></strong> (rx_sample_cnt == 7) <strong><span style="color: #0000ff;">begin</span></strong><br /> <strong><span style="color: #0000ff;">if</span> </strong>((rx_d2 == 1) && (rx_cnt == 0)) <strong><span style="color: #0000ff;">begin</span></strong><br /> rx_busy <= 0;<br /> <strong><span style="color: #0000ff;">end else begin</span></strong><br /> rx_cnt <= rx_cnt + 1;<br /><span style="color: #008000;">// Начало сохранения данных приёма</span><br /><strong><span style="color: #0000ff;">if</span></strong> (rx_cnt > 0 && rx_cnt < 9) <strong><span style="color: #0000ff;">begin</span></strong><br /> rx_reg[rx_cnt - 1] <= rx_d2;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">if</span></strong> (rx_cnt == 9) <strong><span style="color: #0000ff;">begin</span></strong><br /> rx_busy <= 0;<br /><span style="color: #008000;">// Проверка конца кадра, т.е. кадр принят корректно</span><br /><strong><span style="color: #0000ff;">if</span></strong> (rx_d2 == 0) <strong><span style="color: #0000ff;">begin</span></strong><br /> rx_frame_err <= 1;<br /><strong><span style="color: #0000ff;"> end else begin</span></strong><br /> rx_empty <= 0;<br /> rx_frame_err <= 0;<br /> rx_over_run <= (rx_empty) ? 0 : 1;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">if</span></strong> (!rx_enable) <strong><span style="color: #0000ff;">begin</span></strong><br /> rx_busy <= 0;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><span style="color: #008000;">// UART передатчик</span><br /><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> txclk <strong><span style="color: #0000ff;">or posedge</span></strong> reset)<br /><strong><span style="color: #0000ff;">if</span></strong> (reset) <strong><span style="color: #0000ff;">begin</span></strong><br /> tx_reg <= 0;<br /> tx_empty <= 1;<br /> tx_over_run <= 0;<br /> tx_out <= 1;<br /> tx_cnt <= 0;<br /><strong><span style="color: #0000ff;"> end else begin</span></strong><br /><strong><span style="color: #0000ff;"> if</span></strong> (ld_tx_data) <strong><span style="color: #0000ff;">begin</span></strong><br /><strong><span style="color: #0000ff;"><strong><span style="color: #0000ff;"> </span></strong><strong><span style="color: #0000ff;"> </span></strong>if</span> </strong>(!tx_empty) <strong><span style="color: #0000ff;">begin</span></strong><br /> tx_over_run <= 0;<br /><strong><span style="color: #0000ff;"> end else begin</span></strong><br /> tx_reg <= tx_data;<br /> tx_empty <= 0;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">if</span> </strong>(tx_enable && !tx_empty)<strong><span style="color: #0000ff;"> begin</span></strong><br /> tx_cnt <= tx_cnt + 1;<br /><strong><span style="color: #0000ff;"> if</span></strong> (tx_cnt == 0)<strong><span style="color: #0000ff;"> begin</span></strong><br /> tx_out <= 0;<br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">if</span></strong> (tx_cnt > 0 && tx_cnt < 9) <strong><span style="color: #0000ff;">begin</span></strong><br /> tx_out <= tx_reg[tx_cnt -1];<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">if</span></strong> (tx_cnt == 9) <strong><span style="color: #0000ff;">begin</span></strong><br /> tx_out <= 1;<br /> tx_cnt <= 0;<br /> tx_empty <= 1;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">if</span></strong> (!tx_enable) <strong><span style="color: #0000ff;">begin</span></strong><br /> tx_cnt <= 0;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">endmodule</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><span style="color: #ff0000;">{phocadownload view=file|id=5|text=СКАЧАТЬ ПРИМЕР|target=s}</span></p> <p><strong><span style="color: #0000ff;"> </span></strong></p></div>
Моделирование с использованием примитивов. Реализация полного сумматора.
2013-10-08T02:21:12+00:00 2013-10-08T02:21:12+00:00 http://portal-ed.ru/index.php/primery-verilog/161-modelirovanie-s-ispolzovaniem-primitivov-realizatsiya-polnogo-summatora EngineerDeveloper® [email protected]
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : full_adder_gates</span><br /><span style="color: #008000;">// Имя файла : full_adder_gates.v</span><br /><span style="color: #008000;">// Функц. назначение : Полный сумматор, используя приметивы</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><strong><span style="color: #0000ff;">module</span></strong> full_adder_gates(x,y,z,sum,carry);<br /><strong><span style="color: #0000ff;">input</span></strong> x,y,z;<br /><strong><span style="color: #0000ff;">output</span></strong> sum,carry;<br /><strong><span style="color: #0000ff;">wire</span></strong> and1,and2,and3,sum1;<br /><strong><span style="color: #0000ff;">and</span></strong> U_and1 (and1,x,y),<br />U_and2 (and2,x,z),<br />U_and3 (and3,y,z);<br /><strong><span style="color: #0000ff;">or</span></strong> U_or (carry,and1,and2,and3);<br /><strong><span style="color: #0000ff;">xor</span> </strong>U_sum (sum,x,y,z);<br /><strong><span style="color: #0000ff;">endmodule</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;"><span style="color: #000000;"> {phocadownload view=file|id=19|text=СКАЧАТЬ ПРИМЕР|target=s}</span><br /></span></strong></p></div>
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : full_adder_gates</span><br /><span style="color: #008000;">// Имя файла : full_adder_gates.v</span><br /><span style="color: #008000;">// Функц. назначение : Полный сумматор, используя приметивы</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><strong><span style="color: #0000ff;">module</span></strong> full_adder_gates(x,y,z,sum,carry);<br /><strong><span style="color: #0000ff;">input</span></strong> x,y,z;<br /><strong><span style="color: #0000ff;">output</span></strong> sum,carry;<br /><strong><span style="color: #0000ff;">wire</span></strong> and1,and2,and3,sum1;<br /><strong><span style="color: #0000ff;">and</span></strong> U_and1 (and1,x,y),<br />U_and2 (and2,x,z),<br />U_and3 (and3,y,z);<br /><strong><span style="color: #0000ff;">or</span></strong> U_or (carry,and1,and2,and3);<br /><strong><span style="color: #0000ff;">xor</span> </strong>U_sum (sum,x,y,z);<br /><strong><span style="color: #0000ff;">endmodule</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;"><span style="color: #000000;"> {phocadownload view=file|id=19|text=СКАЧАТЬ ПРИМЕР|target=s}</span><br /></span></strong></p></div>
Моделирование с использованием примитивов. Реализация битового сумматора
2013-10-08T02:20:03+00:00 2013-10-08T02:20:03+00:00 http://portal-ed.ru/index.php/primery-verilog/160-modelirovanie-s-ispolzovaniem-primitivov-realizatsiya-bitovogo-summatora EngineerDeveloper® [email protected]
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : half_adder_gates</span><br /><span style="color: #008000;">// Имя файла : half_adder_gates.v</span><br /><span style="color: #008000;">// Функц. назначение : Последовательное CRC CCITT</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><strong><span style="color: #0000ff;">module</span></strong> half_adder_gates(x,y,sum,carry);<br /><strong><span style="color: #0000ff;">input</span></strong> x,y;<br /><strong><span style="color: #0000ff;">output</span></strong> sum,carry;<br /><strong><span style="color: #0000ff;">and</span></strong> U_carry (carry,x,y);<br /><strong><span style="color: #0000ff;">xor</span></strong> U_sum (sum,x,y);<br /><strong><span style="color: #0000ff;">endmodule</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;">{phocadownload view=file|id=21|text=СКАЧАТЬ ПРИМЕР|target=s}</span></strong></p></div>
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : half_adder_gates</span><br /><span style="color: #008000;">// Имя файла : half_adder_gates.v</span><br /><span style="color: #008000;">// Функц. назначение : Последовательное CRC CCITT</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><strong><span style="color: #0000ff;">module</span></strong> half_adder_gates(x,y,sum,carry);<br /><strong><span style="color: #0000ff;">input</span></strong> x,y;<br /><strong><span style="color: #0000ff;">output</span></strong> sum,carry;<br /><strong><span style="color: #0000ff;">and</span></strong> U_carry (carry,x,y);<br /><strong><span style="color: #0000ff;">xor</span></strong> U_sum (sum,x,y);<br /><strong><span style="color: #0000ff;">endmodule</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;">{phocadownload view=file|id=21|text=СКАЧАТЬ ПРИМЕР|target=s}</span></strong></p></div>
Асинхронный FIFO
2013-10-08T02:18:35+00:00 2013-10-08T02:18:35+00:00 http://portal-ed.ru/index.php/primery-verilog/159-asinkhronnyj-fifo EngineerDeveloper® [email protected]
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : aFifo</span><br /><span style="color: #008000;">// Имя файла : aFifo.v</span><br /><span style="color: #008000;">// Функц. назначение : Асинхронный (однотактовый) FIFO</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #000000;"><span style="color: #0000ff;"><strong>module</strong></span> aFifo</span><br /><span style="color: #000000;">#(<strong><span style="color: #0000ff;">parameter</span></strong> DATA_WIDTH = 8,</span><br /><span style="color: #000000;">ADDRESS_WIDTH = 4,</span><br /><span style="color: #000000;">FIFO_DEPTH = (1 << ADDRESS_WIDTH))</span><br /><span style="color: #008000;">//Чтение порта</span><br /><span style="color: #000000;">(<strong><span style="color: #0000ff;">output reg</span></strong> [DATA_WIDTH-1:0] Data_out,</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">output reg</span></strong> Empty_out,</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input wire</span></strong> ReadEn_in,</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input wire</span></strong> RClk,</span><br /><span style="color: #008000;">//Запись в порт</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input wire</span></strong> [DATA_WIDTH-1:0] Data_in,</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">output reg</span></strong> Full_out,</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input wire</span></strong> WriteEn_in,</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input wire</span></strong> WClk,</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input wire</span></strong> Clear_in);</span><br /><span style="color: #008000;">/////Внутренние связи и переменные//////</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">reg</span> </strong>[DATA_WIDTH-1:0] Mem [FIFO_DEPTH-1:0];</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">wire</span></strong> [ADDRESS_WIDTH-1:0] pNextWordToWrite, pNextWordToRead;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">wire</span></strong> EqualAddresses;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">wire</span></strong> NextWriteAddressEn, NextReadAddressEn;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">wire</span></strong> Set_Status, Rst_Status;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">reg</span></strong> Status;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">wire</span></strong> PresetFull, PresetEmpty;</span><br /><span style="color: #008000;">//////////////Начало кода///////////////</span><br /><span style="color: #008000;">//Логические порты данных:</span><br /><span style="color: #008000;">//(Использование двойной RAM).</span><br /><span style="color: #008000;">//'Data_out:</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> RClk)</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> if</span></strong> (ReadEn_in & !Empty_out)</span><br /><span style="color: #000000;"> Data_out <= Mem[pNextWordToRead];</span><br /><span style="color: #008000;">//'Data_in’:</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> WClk)</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> if</span></strong> (WriteEn_in & !Full_out)</span><br /><span style="color: #000000;"> Mem[pNextWordToWrite] <= Data_in;</span><br /><span style="color: #008000;">//Логическая поддержка Fifo:</span><br /><span style="color: #008000;">//'Next Addresses' логическое разрешение:</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> NextWriteAddressEn = WriteEn_in & ~Full_out;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> NextReadAddressEn = ReadEn_in & ~Empty_out;</span><br /><span style="color: #008000;">//Addreses (Счетчик Грэя):</span><br /><span style="color: #000000;">GrayCounter GrayCounter_pWr</span><br /><span style="color: #000000;">(.GrayCount_out(pNextWordToWrite),</span><br /><span style="color: #000000;">.Enable_in(NextWriteAddressEn),</span><br /><span style="color: #000000;">.Clear_in(Clear_in),</span><br /><span style="color: #000000;">.Clk(WClk)</span><br /><span style="color: #000000;">);</span><br /><span style="color: #000000;">GrayCounter GrayCounter_pRd</span><br /><span style="color: #000000;">(.GrayCount_out(pNextWordToRead),</span><br /><span style="color: #000000;">.Enable_in(NextReadAddressEn),</span><br /><span style="color: #000000;">.Clear_in(Clear_in),</span><br /><span style="color: #000000;">.Clk(RClk)</span><br /><span style="color: #000000;">);</span><br /><span style="color: #008000;">//'EqualAddresses':</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> EqualAddresses = (pNextWordToWrite == pNextWordToRead);</span><br /><span style="color: #008000;">//'Quadrant selectors’:</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> Set_Status = (pNextWordToWrite[ADDRESS_WIDTH-2] ~^ pNextWordToRead[ADDRESS_WIDTH-1]) &</span><br /><span style="color: #000000;">(pNextWordToWrite[ADDRESS_WIDTH-1] ^ pNextWordToRead[ADDRESS_WIDTH-2]);</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> Rst_Status = (pNextWordToWrite[ADDRESS_WIDTH-2] ^ pNextWordToRead[ADDRESS_WIDTH-1]) &</span><br /><span style="color: #000000;">(pNextWordToWrite[ADDRESS_WIDTH-1] ~^ pNextWordToRead[ADDRESS_WIDTH-2]);</span><br /><span style="color: #008000;">//'Status' защелка:</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">always</span></strong> @ (Set_Status, Rst_Status, Clear_in) //D Latch w/ Asynchronous Clear & Preset.</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> if</span></strong> (Rst_Status | Clear_in)</span><br /><span style="color: #000000;"> Status = 0; <span style="color: #008000;">//Going 'Empty'.</span></span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> else if</span> </strong>(Set_Status)</span><br /><span style="color: #000000;"> Status = 1; <span style="color: #008000;">//Going 'Full'.</span></span><br /><span style="color: #008000;">//'Full_out' запись в порт:</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> PresetFull = Status & EqualAddresses; <span style="color: #008000;">//'Полный' Fifo.</span></span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> WClk, <strong><span style="color: #0000ff;">posedge</span></strong> PresetFull) <span style="color: #008000;">//D-триггер с</span></span><br /><span style="color: #008000;">// асинхронной предустановкой</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">if</span> </strong>(PresetFull)</span><br /><span style="color: #000000;"> Full_out <= 1;</span><br /><strong><span style="color: #0000ff;"> else</span></strong><br /><span style="color: #000000;"> Full_out <= 0;</span><br /><span style="color: #008000;">//'Empty_out' чтение из порта:</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> PresetEmpty = ~Status & EqualAddresses; <span style="color: #008000;">//'Пустой' Fifo.</span></span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> RClk, <strong><span style="color: #0000ff;">posedge</span></strong> PresetEmpty) <span style="color: #008000;">// D-триггер с</span></span><br /><span style="color: #008000;">// асинхронной предустановкой</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">if</span></strong> (PresetEmpty)</span><br /><span style="color: #000000;"> Empty_out <= 1;</span><br /><strong><span style="color: #0000ff;"> else</span></strong><br /><span style="color: #000000;"> Empty_out <= 0;</span><br /><strong><span style="color: #0000ff;">endmodule</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;">{phocadownload view=file|id=6|text=СКАЧАТЬ ПРИМЕР|target=s}</span></strong></p></div>
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : aFifo</span><br /><span style="color: #008000;">// Имя файла : aFifo.v</span><br /><span style="color: #008000;">// Функц. назначение : Асинхронный (однотактовый) FIFO</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #000000;"><span style="color: #0000ff;"><strong>module</strong></span> aFifo</span><br /><span style="color: #000000;">#(<strong><span style="color: #0000ff;">parameter</span></strong> DATA_WIDTH = 8,</span><br /><span style="color: #000000;">ADDRESS_WIDTH = 4,</span><br /><span style="color: #000000;">FIFO_DEPTH = (1 << ADDRESS_WIDTH))</span><br /><span style="color: #008000;">//Чтение порта</span><br /><span style="color: #000000;">(<strong><span style="color: #0000ff;">output reg</span></strong> [DATA_WIDTH-1:0] Data_out,</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">output reg</span></strong> Empty_out,</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input wire</span></strong> ReadEn_in,</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input wire</span></strong> RClk,</span><br /><span style="color: #008000;">//Запись в порт</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input wire</span></strong> [DATA_WIDTH-1:0] Data_in,</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">output reg</span></strong> Full_out,</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input wire</span></strong> WriteEn_in,</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input wire</span></strong> WClk,</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input wire</span></strong> Clear_in);</span><br /><span style="color: #008000;">/////Внутренние связи и переменные//////</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">reg</span> </strong>[DATA_WIDTH-1:0] Mem [FIFO_DEPTH-1:0];</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">wire</span></strong> [ADDRESS_WIDTH-1:0] pNextWordToWrite, pNextWordToRead;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">wire</span></strong> EqualAddresses;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">wire</span></strong> NextWriteAddressEn, NextReadAddressEn;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">wire</span></strong> Set_Status, Rst_Status;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">reg</span></strong> Status;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">wire</span></strong> PresetFull, PresetEmpty;</span><br /><span style="color: #008000;">//////////////Начало кода///////////////</span><br /><span style="color: #008000;">//Логические порты данных:</span><br /><span style="color: #008000;">//(Использование двойной RAM).</span><br /><span style="color: #008000;">//'Data_out:</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> RClk)</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> if</span></strong> (ReadEn_in & !Empty_out)</span><br /><span style="color: #000000;"> Data_out <= Mem[pNextWordToRead];</span><br /><span style="color: #008000;">//'Data_in’:</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> WClk)</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> if</span></strong> (WriteEn_in & !Full_out)</span><br /><span style="color: #000000;"> Mem[pNextWordToWrite] <= Data_in;</span><br /><span style="color: #008000;">//Логическая поддержка Fifo:</span><br /><span style="color: #008000;">//'Next Addresses' логическое разрешение:</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> NextWriteAddressEn = WriteEn_in & ~Full_out;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> NextReadAddressEn = ReadEn_in & ~Empty_out;</span><br /><span style="color: #008000;">//Addreses (Счетчик Грэя):</span><br /><span style="color: #000000;">GrayCounter GrayCounter_pWr</span><br /><span style="color: #000000;">(.GrayCount_out(pNextWordToWrite),</span><br /><span style="color: #000000;">.Enable_in(NextWriteAddressEn),</span><br /><span style="color: #000000;">.Clear_in(Clear_in),</span><br /><span style="color: #000000;">.Clk(WClk)</span><br /><span style="color: #000000;">);</span><br /><span style="color: #000000;">GrayCounter GrayCounter_pRd</span><br /><span style="color: #000000;">(.GrayCount_out(pNextWordToRead),</span><br /><span style="color: #000000;">.Enable_in(NextReadAddressEn),</span><br /><span style="color: #000000;">.Clear_in(Clear_in),</span><br /><span style="color: #000000;">.Clk(RClk)</span><br /><span style="color: #000000;">);</span><br /><span style="color: #008000;">//'EqualAddresses':</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> EqualAddresses = (pNextWordToWrite == pNextWordToRead);</span><br /><span style="color: #008000;">//'Quadrant selectors’:</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> Set_Status = (pNextWordToWrite[ADDRESS_WIDTH-2] ~^ pNextWordToRead[ADDRESS_WIDTH-1]) &</span><br /><span style="color: #000000;">(pNextWordToWrite[ADDRESS_WIDTH-1] ^ pNextWordToRead[ADDRESS_WIDTH-2]);</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> Rst_Status = (pNextWordToWrite[ADDRESS_WIDTH-2] ^ pNextWordToRead[ADDRESS_WIDTH-1]) &</span><br /><span style="color: #000000;">(pNextWordToWrite[ADDRESS_WIDTH-1] ~^ pNextWordToRead[ADDRESS_WIDTH-2]);</span><br /><span style="color: #008000;">//'Status' защелка:</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">always</span></strong> @ (Set_Status, Rst_Status, Clear_in) //D Latch w/ Asynchronous Clear & Preset.</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> if</span></strong> (Rst_Status | Clear_in)</span><br /><span style="color: #000000;"> Status = 0; <span style="color: #008000;">//Going 'Empty'.</span></span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> else if</span> </strong>(Set_Status)</span><br /><span style="color: #000000;"> Status = 1; <span style="color: #008000;">//Going 'Full'.</span></span><br /><span style="color: #008000;">//'Full_out' запись в порт:</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> PresetFull = Status & EqualAddresses; <span style="color: #008000;">//'Полный' Fifo.</span></span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> WClk, <strong><span style="color: #0000ff;">posedge</span></strong> PresetFull) <span style="color: #008000;">//D-триггер с</span></span><br /><span style="color: #008000;">// асинхронной предустановкой</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">if</span> </strong>(PresetFull)</span><br /><span style="color: #000000;"> Full_out <= 1;</span><br /><strong><span style="color: #0000ff;"> else</span></strong><br /><span style="color: #000000;"> Full_out <= 0;</span><br /><span style="color: #008000;">//'Empty_out' чтение из порта:</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> PresetEmpty = ~Status & EqualAddresses; <span style="color: #008000;">//'Пустой' Fifo.</span></span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> RClk, <strong><span style="color: #0000ff;">posedge</span></strong> PresetEmpty) <span style="color: #008000;">// D-триггер с</span></span><br /><span style="color: #008000;">// асинхронной предустановкой</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">if</span></strong> (PresetEmpty)</span><br /><span style="color: #000000;"> Empty_out <= 1;</span><br /><strong><span style="color: #0000ff;"> else</span></strong><br /><span style="color: #000000;"> Empty_out <= 0;</span><br /><strong><span style="color: #0000ff;">endmodule</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;">{phocadownload view=file|id=6|text=СКАЧАТЬ ПРИМЕР|target=s}</span></strong></p></div>
Синхронный FIFO
2013-10-08T02:17:37+00:00 2013-10-08T02:17:37+00:00 http://portal-ed.ru/index.php/primery-verilog/158-sinkhronnyj-fifo EngineerDeveloper® [email protected]
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : syn_fifo</span><br /><span style="color: #008000;">// Имя файла : syn_fifo.v</span><br /><span style="color: #008000;">// Функц. назначение : Синхронный (однотактовый) FIFO</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><strong><span style="color: #0000ff;">module</span></strong> syn_fifo (<br />clk , <span style="color: #008000;">// Тактовый вход</span><br />rst , <span style="color: #008000;">// Высокий уровень - сброс</span><br />wr_cs , <span style="color: #008000;">// Запись, выбор блока</span><br />rd_cs , <span style="color: #008000;">// Чтение, выбор блока</span><br />data_in ,<span style="color: #008000;"> // Входные данные</span><br />rd_en , <span style="color: #008000;">// Разрешение чтения</span><br />wr_en , <span style="color: #008000;">// Разрешение записи</span><br />data_out , <span style="color: #008000;">// Выходные данные</span><br />empty ,<span style="color: #008000;"> // FIFO пустой</span><br />full <span style="color: #008000;">// FIFO полный</span><br />);<br /><span style="color: #008000;">// Константы FIFO</span><br /><strong><span style="color: #0000ff;">parameter</span></strong> DATA_WIDTH = 8;<br /><strong><span style="color: #0000ff;">parameter</span></strong> ADDR_WIDTH = 8;<br /><strong><span style="color: #0000ff;">parameter</span></strong> RAM_DEPTH = (1 << ADDR_WIDTH);<br /><span style="color: #008000;">// Объявление портов</span><br /><strong><span style="color: #0000ff;">input</span></strong> clk ;<br /><strong><span style="color: #0000ff;">input</span></strong> rst ;<br /><strong><span style="color: #0000ff;">input</span></strong> wr_cs ;<br /><strong><span style="color: #0000ff;">input</span></strong> rd_cs ;<br /><strong><span style="color: #0000ff;">input</span></strong> rd_en ;<br /><strong><span style="color: #0000ff;">input</span></strong> wr_en ;<br /><strong><span style="color: #0000ff;">input</span></strong> [DATA_WIDTH-1:0] data_in ;<br /><strong><span style="color: #0000ff;">output</span></strong> full ;<br /><strong><span style="color: #0000ff;">output</span></strong> empty ;<br /><strong><span style="color: #0000ff;">output</span></strong>[DATA_WIDTH-1:0] data_out ;<br /><span style="color: #008000;">//-----------Внутренние переменные-------------------</span><br /><strong><span style="color: #0000ff;">reg</span></strong> [ADDR_WIDTH-1:0] wr_pointer;<br /><strong><span style="color: #0000ff;">reg</span></strong> [ADDR_WIDTH-1:0] rd_pointer;<br /><strong><span style="color: #0000ff;">reg</span></strong> [ADDR_WIDTH :0] status_cnt;<br /><strong><span style="color: #0000ff;">reg</span></strong> [DATA_WIDTH-1:0] data_out ;<br /><strong><span style="color: #0000ff;">wire</span> </strong>[DATA_WIDTH-1:0] data_ram ;<br /><span style="color: #008000;">//-----------Заданные переменные---------------</span><br /><strong><span style="color: #0000ff;">assign</span></strong> full = (status_cnt == (RAM_DEPTH-1));<br /><strong><span style="color: #0000ff;">assign</span></strong> empty = (status_cnt == 0);<br /><span style="color: #008000;">//-----------Начало кода---------------------------</span><br /><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> clk <strong><span style="color: #0000ff;">or posedge</span></strong> rst)<br /><strong><span style="color: #0000ff;">begin</span></strong> : WRITE_POINTER<br /><strong><span style="color: #0000ff;"> if</span></strong> (rst) <strong><span style="color: #0000ff;">begin</span></strong><br /> wr_pointer <= 0;<br /><strong><span style="color: #0000ff;"> end else if</span> </strong>(wr_cs && wr_en ) <strong><span style="color: #0000ff;">begin</span></strong><br /> wr_pointer <= wr_pointer + 1;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> clk <strong><span style="color: #0000ff;">or posedge</span></strong> rst)<br /><strong><span style="color: #0000ff;">begin</span></strong> : READ_POINTER<br /><strong><span style="color: #0000ff;"> if</span> </strong>(rst) <strong><span style="color: #0000ff;">begin</span></strong><br /> rd_pointer <= 0;<br /><strong><span style="color: #0000ff;"> end else if</span></strong> (rd_cs && rd_en )<strong><span style="color: #0000ff;"> begin</span></strong><br /> rd_pointer <= rd_pointer + 1;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">always</span></strong> @ <strong><span style="color: #0000ff;">(posedge</span></strong> clk <strong><span style="color: #0000ff;">or posedge</span></strong> rst)<br /><strong><span style="color: #0000ff;">begin</span></strong> : READ_DATA<br /><strong><span style="color: #0000ff;"> if</span></strong> (rst) <strong><span style="color: #0000ff;">begin</span></strong><br /> data_out <= 0;<br /><strong><span style="color: #0000ff;"> end else if</span></strong> (rd_cs && rd_en )<strong><span style="color: #0000ff;"> begin</span></strong><br /> data_out <= data_ram;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">always</span> </strong>@ (<strong><span style="color: #0000ff;">posedge</span></strong> clk <strong><span style="color: #0000ff;">or posedge</span></strong> rst)<br /><strong><span style="color: #0000ff;">begin</span></strong> : STATUS_COUNTER<br /><strong><span style="color: #0000ff;"> if</span></strong> (rst) <strong><span style="color: #0000ff;">begin</span></strong><br /> status_cnt <= 0;<br /><span style="color: #008000;"> // Чтение, но не запись</span><br /><strong><span style="color: #0000ff;"> end else if</span> </strong>((rd_cs && rd_en) && !(wr_cs && wr_en)<br /> && (status_cnt != 0)) <strong><span style="color: #0000ff;">begin</span></strong><br /> status_cnt <= status_cnt - 1;<br /><span style="color: #008000;"> // Запись, но не чтение</span><br /><strong><span style="color: #0000ff;"> end else if</span></strong> ((wr_cs && wr_en) && !(rd_cs && rd_en)<br /> && (status_cnt != RAM_DEPTH)) <strong><span style="color: #0000ff;">begin</span></strong><br /> status_cnt <= status_cnt + 1;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br />ram_dp_ar_aw #(DATA_WIDTH,ADDR_WIDTH)DP_RAM (<br />.address_0 (wr_pointer) , <span style="color: #008000;">// Вход address_0</span><br />.data_0 (data_in) , <span style="color: #008000;">// Двунаправленный порт data_0</span><br />.cs_0 (wr_cs) , <span style="color: #008000;">// Выбор блока</span><br />.we_0 (wr_en) ,<span style="color: #008000;"> // Разрешение записи</span><br />.oe_0 (1'b0) , <span style="color: #008000;">// Разрешение выхода</span><br />.address_1 (rd_pointer) ,<span style="color: #008000;"> // Вход address_q</span><br />.data_1 (data_ram) ,<span style="color: #008000;"> // Двунаправленный порт data_1</span><br />.cs_1 (rd_cs) , <span style="color: #008000;">// Выбор блока</span><br />.we_1 (1'b0) , <span style="color: #008000;">// Разрешение чтения</span><br />.oe_1 (rd_en) <span style="color: #008000;">// Разрешение выхода</span><br />);<br /><strong><span style="color: #0000ff;">endmodule</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;">{phocadownload view=file|id=37|text=СКАЧАТЬ ПРИМЕР|target=s}</span></strong></p></div>
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : syn_fifo</span><br /><span style="color: #008000;">// Имя файла : syn_fifo.v</span><br /><span style="color: #008000;">// Функц. назначение : Синхронный (однотактовый) FIFO</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><strong><span style="color: #0000ff;">module</span></strong> syn_fifo (<br />clk , <span style="color: #008000;">// Тактовый вход</span><br />rst , <span style="color: #008000;">// Высокий уровень - сброс</span><br />wr_cs , <span style="color: #008000;">// Запись, выбор блока</span><br />rd_cs , <span style="color: #008000;">// Чтение, выбор блока</span><br />data_in ,<span style="color: #008000;"> // Входные данные</span><br />rd_en , <span style="color: #008000;">// Разрешение чтения</span><br />wr_en , <span style="color: #008000;">// Разрешение записи</span><br />data_out , <span style="color: #008000;">// Выходные данные</span><br />empty ,<span style="color: #008000;"> // FIFO пустой</span><br />full <span style="color: #008000;">// FIFO полный</span><br />);<br /><span style="color: #008000;">// Константы FIFO</span><br /><strong><span style="color: #0000ff;">parameter</span></strong> DATA_WIDTH = 8;<br /><strong><span style="color: #0000ff;">parameter</span></strong> ADDR_WIDTH = 8;<br /><strong><span style="color: #0000ff;">parameter</span></strong> RAM_DEPTH = (1 << ADDR_WIDTH);<br /><span style="color: #008000;">// Объявление портов</span><br /><strong><span style="color: #0000ff;">input</span></strong> clk ;<br /><strong><span style="color: #0000ff;">input</span></strong> rst ;<br /><strong><span style="color: #0000ff;">input</span></strong> wr_cs ;<br /><strong><span style="color: #0000ff;">input</span></strong> rd_cs ;<br /><strong><span style="color: #0000ff;">input</span></strong> rd_en ;<br /><strong><span style="color: #0000ff;">input</span></strong> wr_en ;<br /><strong><span style="color: #0000ff;">input</span></strong> [DATA_WIDTH-1:0] data_in ;<br /><strong><span style="color: #0000ff;">output</span></strong> full ;<br /><strong><span style="color: #0000ff;">output</span></strong> empty ;<br /><strong><span style="color: #0000ff;">output</span></strong>[DATA_WIDTH-1:0] data_out ;<br /><span style="color: #008000;">//-----------Внутренние переменные-------------------</span><br /><strong><span style="color: #0000ff;">reg</span></strong> [ADDR_WIDTH-1:0] wr_pointer;<br /><strong><span style="color: #0000ff;">reg</span></strong> [ADDR_WIDTH-1:0] rd_pointer;<br /><strong><span style="color: #0000ff;">reg</span></strong> [ADDR_WIDTH :0] status_cnt;<br /><strong><span style="color: #0000ff;">reg</span></strong> [DATA_WIDTH-1:0] data_out ;<br /><strong><span style="color: #0000ff;">wire</span> </strong>[DATA_WIDTH-1:0] data_ram ;<br /><span style="color: #008000;">//-----------Заданные переменные---------------</span><br /><strong><span style="color: #0000ff;">assign</span></strong> full = (status_cnt == (RAM_DEPTH-1));<br /><strong><span style="color: #0000ff;">assign</span></strong> empty = (status_cnt == 0);<br /><span style="color: #008000;">//-----------Начало кода---------------------------</span><br /><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> clk <strong><span style="color: #0000ff;">or posedge</span></strong> rst)<br /><strong><span style="color: #0000ff;">begin</span></strong> : WRITE_POINTER<br /><strong><span style="color: #0000ff;"> if</span></strong> (rst) <strong><span style="color: #0000ff;">begin</span></strong><br /> wr_pointer <= 0;<br /><strong><span style="color: #0000ff;"> end else if</span> </strong>(wr_cs && wr_en ) <strong><span style="color: #0000ff;">begin</span></strong><br /> wr_pointer <= wr_pointer + 1;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> clk <strong><span style="color: #0000ff;">or posedge</span></strong> rst)<br /><strong><span style="color: #0000ff;">begin</span></strong> : READ_POINTER<br /><strong><span style="color: #0000ff;"> if</span> </strong>(rst) <strong><span style="color: #0000ff;">begin</span></strong><br /> rd_pointer <= 0;<br /><strong><span style="color: #0000ff;"> end else if</span></strong> (rd_cs && rd_en )<strong><span style="color: #0000ff;"> begin</span></strong><br /> rd_pointer <= rd_pointer + 1;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">always</span></strong> @ <strong><span style="color: #0000ff;">(posedge</span></strong> clk <strong><span style="color: #0000ff;">or posedge</span></strong> rst)<br /><strong><span style="color: #0000ff;">begin</span></strong> : READ_DATA<br /><strong><span style="color: #0000ff;"> if</span></strong> (rst) <strong><span style="color: #0000ff;">begin</span></strong><br /> data_out <= 0;<br /><strong><span style="color: #0000ff;"> end else if</span></strong> (rd_cs && rd_en )<strong><span style="color: #0000ff;"> begin</span></strong><br /> data_out <= data_ram;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">always</span> </strong>@ (<strong><span style="color: #0000ff;">posedge</span></strong> clk <strong><span style="color: #0000ff;">or posedge</span></strong> rst)<br /><strong><span style="color: #0000ff;">begin</span></strong> : STATUS_COUNTER<br /><strong><span style="color: #0000ff;"> if</span></strong> (rst) <strong><span style="color: #0000ff;">begin</span></strong><br /> status_cnt <= 0;<br /><span style="color: #008000;"> // Чтение, но не запись</span><br /><strong><span style="color: #0000ff;"> end else if</span> </strong>((rd_cs && rd_en) && !(wr_cs && wr_en)<br /> && (status_cnt != 0)) <strong><span style="color: #0000ff;">begin</span></strong><br /> status_cnt <= status_cnt - 1;<br /><span style="color: #008000;"> // Запись, но не чтение</span><br /><strong><span style="color: #0000ff;"> end else if</span></strong> ((wr_cs && wr_en) && !(rd_cs && rd_en)<br /> && (status_cnt != RAM_DEPTH)) <strong><span style="color: #0000ff;">begin</span></strong><br /> status_cnt <= status_cnt + 1;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br />ram_dp_ar_aw #(DATA_WIDTH,ADDR_WIDTH)DP_RAM (<br />.address_0 (wr_pointer) , <span style="color: #008000;">// Вход address_0</span><br />.data_0 (data_in) , <span style="color: #008000;">// Двунаправленный порт data_0</span><br />.cs_0 (wr_cs) , <span style="color: #008000;">// Выбор блока</span><br />.we_0 (wr_en) ,<span style="color: #008000;"> // Разрешение записи</span><br />.oe_0 (1'b0) , <span style="color: #008000;">// Разрешение выхода</span><br />.address_1 (rd_pointer) ,<span style="color: #008000;"> // Вход address_q</span><br />.data_1 (data_ram) ,<span style="color: #008000;"> // Двунаправленный порт data_1</span><br />.cs_1 (rd_cs) , <span style="color: #008000;">// Выбор блока</span><br />.we_1 (1'b0) , <span style="color: #008000;">// Разрешение чтения</span><br />.oe_1 (rd_en) <span style="color: #008000;">// Разрешение выхода</span><br />);<br /><strong><span style="color: #0000ff;">endmodule</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;">{phocadownload view=file|id=37|text=СКАЧАТЬ ПРИМЕР|target=s}</span></strong></p></div>
Инициализация ROM, EPROM, EEPROM с использованием case
2013-10-08T02:16:41+00:00 2013-10-08T02:16:41+00:00 http://portal-ed.ru/index.php/primery-verilog/157-initsializatsiya-rom-eprom-eeprom-s-ispolzovaniem-case EngineerDeveloper® [email protected]
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : rom_using_case</span><br /><span style="color: #008000;">// Имя файла : rom_using_case.v</span><br /><span style="color: #008000;">// Функц. назначение : Инициализация ROM используя case</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><strong><span style="color: #0000ff;">module</span></strong> rom_using_case (<br />address , <span style="color: #008000;">// Вход адреса</span><br />data , <span style="color: #008000;">// Выход данных</span><br />read_en , <span style="color: #008000;">// Разрешение чтения</span><br />ce <span style="color: #008000;">// Выбор блока</span><br />);<br /><strong><span style="color: #0000ff;">input</span></strong> [3:0] address;<br /><strong><span style="color: #0000ff;">output</span></strong> [7:0] data;<br /><strong><span style="color: #0000ff;">input</span></strong> read_en;<br /><strong><span style="color: #0000ff;">input</span></strong> ce;<br /><strong><span style="color: #0000ff;">reg</span></strong> [7:0] data ;<br /><strong><span style="color: #0000ff;">always</span></strong> @ (ce <strong><span style="color: #0000ff;">or</span></strong> read_en <strong><span style="color: #0000ff;">or</span></strong> address)<br /><strong><span style="color: #0000ff;">begin</span></strong><br /><strong><span style="color: #0000ff;">case</span></strong> (address)<br />0 : data = 10;<br />1 : data = 55;<br />2 : data = 244;<br />3 : data = 0;<br />4 : data = 1;<br />5 : data = 8'hff;<br />6 : data = 8'h11;<br />7 : data = 8'h1;<br />8 : data = 8'h10;<br />9 : data = 8'h0;<br />10 : data = 8'h10;<br />11 : data = 8'h15;<br />12 : data = 8'h60;<br />13 : data = 8'h90;<br />14 : data = 8'h70;<br />15 : data = 8'h90;<br /><strong><span style="color: #0000ff;">endcase</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">endmodule</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;">{phocadownload view=file|id=35|text=СКАЧАТЬ ПРИМЕР|target=s}</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><a href="index.php/osnovy-tsifrovoj-tekhniki/186-printsip-raboty-rom" target="_blank"><span style="color: #0000ff;"><span style="color: #0000ff;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #000000;"><span style="background-color: #00ff00;"><span style="font-size: large; background-color: #00ff00;">ВСПОМНИТЬ КАК</span></span></span></span></span></span></span></span></span></span></span></span></span><span style="color: #0000ff;"><span style="color: #0000ff;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #000000;"><span style="background-color: #00ff00;"><span style="font-size: large; background-color: #00ff00;"> РАБОТАЕТ>>></span></span></span></span></span></span></span></span></span></span></span></span></span></a></p></div>
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : rom_using_case</span><br /><span style="color: #008000;">// Имя файла : rom_using_case.v</span><br /><span style="color: #008000;">// Функц. назначение : Инициализация ROM используя case</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><strong><span style="color: #0000ff;">module</span></strong> rom_using_case (<br />address , <span style="color: #008000;">// Вход адреса</span><br />data , <span style="color: #008000;">// Выход данных</span><br />read_en , <span style="color: #008000;">// Разрешение чтения</span><br />ce <span style="color: #008000;">// Выбор блока</span><br />);<br /><strong><span style="color: #0000ff;">input</span></strong> [3:0] address;<br /><strong><span style="color: #0000ff;">output</span></strong> [7:0] data;<br /><strong><span style="color: #0000ff;">input</span></strong> read_en;<br /><strong><span style="color: #0000ff;">input</span></strong> ce;<br /><strong><span style="color: #0000ff;">reg</span></strong> [7:0] data ;<br /><strong><span style="color: #0000ff;">always</span></strong> @ (ce <strong><span style="color: #0000ff;">or</span></strong> read_en <strong><span style="color: #0000ff;">or</span></strong> address)<br /><strong><span style="color: #0000ff;">begin</span></strong><br /><strong><span style="color: #0000ff;">case</span></strong> (address)<br />0 : data = 10;<br />1 : data = 55;<br />2 : data = 244;<br />3 : data = 0;<br />4 : data = 1;<br />5 : data = 8'hff;<br />6 : data = 8'h11;<br />7 : data = 8'h1;<br />8 : data = 8'h10;<br />9 : data = 8'h0;<br />10 : data = 8'h10;<br />11 : data = 8'h15;<br />12 : data = 8'h60;<br />13 : data = 8'h90;<br />14 : data = 8'h70;<br />15 : data = 8'h90;<br /><strong><span style="color: #0000ff;">endcase</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">endmodule</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;">{phocadownload view=file|id=35|text=СКАЧАТЬ ПРИМЕР|target=s}</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><a href="index.php/osnovy-tsifrovoj-tekhniki/186-printsip-raboty-rom" target="_blank"><span style="color: #0000ff;"><span style="color: #0000ff;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #000000;"><span style="background-color: #00ff00;"><span style="font-size: large; background-color: #00ff00;">ВСПОМНИТЬ КАК</span></span></span></span></span></span></span></span></span></span></span></span></span><span style="color: #0000ff;"><span style="color: #0000ff;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #000000;"><span style="background-color: #00ff00;"><span style="font-size: large; background-color: #00ff00;"> РАБОТАЕТ>>></span></span></span></span></span></span></span></span></span></span></span></span></span></a></p></div>
Инициализация ROM, EPROM, EEPROM из файла
2013-10-08T02:15:47+00:00 2013-10-08T02:15:47+00:00 http://portal-ed.ru/index.php/primery-verilog/156-initsializatsiya-rom-eprom-eeprom-iz-fajla EngineerDeveloper® [email protected]
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : rom_using_case</span><br /><span style="color: #008000;">// Имя файла : rom_using_case.v</span><br /><span style="color: #008000;">// Функц. назначение : Инициализация ROM из файла "memory.list"</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><strong><span style="color: #0000ff;">module</span></strong> rom_using_file (<br />address , <span style="color: #008000;">// Адресный вход</span><br />data , <span style="color: #008000;">// Выход данных</span><br />read_en , <span style="color: #008000;">// Разрешение чтения</span><br />ce<span style="color: #008000;"> // Выбор блока</span><br />);<br /><strong><span style="color: #0000ff;">input</span></strong> [7:0] address;<br /><strong><span style="color: #0000ff;">output</span></strong> [7:0] data;<br /><strong><span style="color: #0000ff;">input</span></strong> read_en;<br /><strong><span style="color: #0000ff;">input</span></strong> ce;<br /><strong><span style="color: #0000ff;">reg</span> </strong>[7:0] mem [0:255] ;<br /><strong><span style="color: #0000ff;">assign</span></strong> data = (ce && read_en) ? mem[address] : 8'b0;<br /><strong><span style="color: #0000ff;">initial begin</span></strong><br /><span style="color: #ff6600;">$readmemb</span>(<span style="color: #808080;">"memory.list"</span>, mem); <span style="color: #008000;">// memory_list – это файл с содержимым // ROM</span><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">endmodule</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;">{phocadownload view=file|id=36|text=СКАЧАТЬ ПРИМЕР|target=s}</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><a href="index.php/osnovy-tsifrovoj-tekhniki/186-printsip-raboty-rom" target="_blank"><span style="color: #0000ff;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #000000;"><span style="background-color: #00ff00;"><span style="font-size: large; background-color: #00ff00;">ВСПОМНИТЬ КАК РАБОТАЕТ>>></span></span></span></span></span></span></span></span></span></span></span></span></a></p></div>
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : rom_using_case</span><br /><span style="color: #008000;">// Имя файла : rom_using_case.v</span><br /><span style="color: #008000;">// Функц. назначение : Инициализация ROM из файла "memory.list"</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><strong><span style="color: #0000ff;">module</span></strong> rom_using_file (<br />address , <span style="color: #008000;">// Адресный вход</span><br />data , <span style="color: #008000;">// Выход данных</span><br />read_en , <span style="color: #008000;">// Разрешение чтения</span><br />ce<span style="color: #008000;"> // Выбор блока</span><br />);<br /><strong><span style="color: #0000ff;">input</span></strong> [7:0] address;<br /><strong><span style="color: #0000ff;">output</span></strong> [7:0] data;<br /><strong><span style="color: #0000ff;">input</span></strong> read_en;<br /><strong><span style="color: #0000ff;">input</span></strong> ce;<br /><strong><span style="color: #0000ff;">reg</span> </strong>[7:0] mem [0:255] ;<br /><strong><span style="color: #0000ff;">assign</span></strong> data = (ce && read_en) ? mem[address] : 8'b0;<br /><strong><span style="color: #0000ff;">initial begin</span></strong><br /><span style="color: #ff6600;">$readmemb</span>(<span style="color: #808080;">"memory.list"</span>, mem); <span style="color: #008000;">// memory_list – это файл с содержимым // ROM</span><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">endmodule</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><strong><span style="color: #0000ff;">{phocadownload view=file|id=36|text=СКАЧАТЬ ПРИМЕР|target=s}</span></strong></p> <p><strong><span style="color: #0000ff;"> </span></strong></p> <p><a href="index.php/osnovy-tsifrovoj-tekhniki/186-printsip-raboty-rom" target="_blank"><span style="color: #0000ff;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #000000;"><span style="background-color: #00ff00;"><span style="font-size: large; background-color: #00ff00;">ВСПОМНИТЬ КАК РАБОТАЕТ>>></span></span></span></span></span></span></span></span></span></span></span></span></a></p></div>
Двойной порт RAM c асинхронным режимом записи/чтения
2013-10-08T02:14:53+00:00 2013-10-08T02:14:53+00:00 http://portal-ed.ru/index.php/primery-verilog/155-dvojnoj-port-ram-c-asinkhronnym-rezhimom-zapisi-chteniya EngineerDeveloper® [email protected]
<div class="feed-description"><p><span style="color: #000000;"><span style="color: #008000;">//-----------------------------------------------------</span></span><br /><span style="color: #008000;">// Имя модуля : ram_dp_ar_aw</span><br /><span style="color: #008000;">// Имя файла : ram_dp_ar_aw.v</span><br /><span style="color: #008000;">// Функц. назначение : Асинхронный блок для записи/чтения RAM</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">module</span></strong> ram_dp_ar_aw (</span><br /><span style="color: #000000;">address_0 , <span style="color: #008000;">// Вход address_0</span></span><br /><span style="color: #000000;">data_0 , <span style="color: #008000;">// Двунаправленный порт data_0</span></span><br /><span style="color: #000000;">cs_0 , <span style="color: #008000;">// Выбор блока</span></span><br /><span style="color: #000000;">we_0 , <span style="color: #008000;">// Разрешение записи/Разрешение чтения</span></span><br /><span style="color: #000000;">oe_0 , <span style="color: #008000;">// Разрешение выхода</span></span><br /><span style="color: #000000;">address_1 , <span style="color: #008000;">// Вход address_1</span></span><br /><span style="color: #000000;">data_1 , <span style="color: #008000;">// Двунаправленный порт data_1</span></span><br /><span style="color: #000000;">cs_1 ,<span style="color: #008000;"> // Выбор блока</span></span><br /><span style="color: #000000;">we_1 ,<span style="color: #008000;"> // Разрешение записи/Разрешение чтения</span></span><br /><span style="color: #000000;">oe_1 <span style="color: #008000;">// Разрешение выхода</span></span><br /><span style="color: #000000;">);</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">parameter</span></strong> DATA_WIDTH = 8 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">parameter</span></strong> ADDR_WIDTH = 8 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">parameter</span></strong> RAM_DEPTH = 1 << ADDR_WIDTH;</span><br /><span style="color: #008000;">//--------------Входные порты-----------------------</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input</span></strong> [ADDR_WIDTH-1:0] address_0 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input</span></strong> cs_0 ;</span><br /><span style="color: #000000;"><span style="color: #0000ff;"><strong>input</strong></span> we_0 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input</span></strong> oe_0 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input</span></strong> [ADDR_WIDTH-1:0] address_1 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input</span></strong> cs_1 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input</span></strong> we_1 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input</span></strong> oe_1 ;</span><br /><span style="color: #008000;">//--------------Двунаправленные порты-----------------------</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">inout</span></strong> [DATA_WIDTH-1:0] data_0 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">inout</span></strong> [DATA_WIDTH-1:0] data_1 ;</span><br /><span style="color: #008000;">//--------------Внутренние переменные----------------</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">reg</span></strong> [DATA_WIDTH-1:0] data_0_out ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">reg</span></strong> [DATA_WIDTH-1:0] data_1_out ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">reg</span></strong> [DATA_WIDTH-1:0] mem [0:RAM_DEPTH-1];</span><br /><span style="color: #008000;">//--------------Начало кода------------------</span><br /><span style="color: #008000;">// Блок записи памяти</span><br /><span style="color: #008000;">// Write Operation : When we_0 = 1, cs_0 = 1</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">always</span></strong> @ (address_0 <strong><span style="color: #0000ff;">or</span></strong> cs_0 <strong><span style="color: #0000ff;">or</span></strong> we_0 <strong><span style="color: #0000ff;">or</span></strong> data_0</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">or</span></strong> address_1 <strong><span style="color: #0000ff;">or</span></strong> cs_1 <strong><span style="color: #0000ff;">or</span></strong> we_1 <strong><span style="color: #0000ff;">or</span></strong> data_1)</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> begin</span></strong> : MEM_WRITE</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> if</span></strong> ( cs_0 && we_0 ) <strong><span style="color: #0000ff;">begin</span></strong></span><br /><span style="color: #000000;"> mem[address_0] <= data_0;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> end else if</span></strong> (cs_1 && we_1)<strong><span style="color: #0000ff;"> begin</span></strong></span><br /><span style="color: #000000;"> mem[address_1] <= data_1;</span><br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;"> end</span></strong><br /><span style="color: #008000;">// Управление тристабильным буфером</span><br /><span style="color: #008000;">// output : When we_0 = 0, oe_0 = 1, cs_0 = 1</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> data_0 = (cs_0 && oe_0 && !we_0) ? data_0_out : 8'bz;</span><br /><span style="color: #008000;">// Блок чтения памяти</span><br /><span style="color: #008000;">// Read Operation : When we_0 = 0, oe_0 = 1, cs_0 = 1</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">always</span></strong> @ (address_0 <strong><span style="color: #0000ff;">or</span></strong> cs_0<strong><span style="color: #0000ff;"> or</span></strong> we_1 <strong><span style="color: #0000ff;">or</span></strong> oe_0)</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> begin</span></strong> : MEM_READ_0</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> if</span></strong> (cs_0 && !we_0 && oe_0) <strong><span style="color: #0000ff;">begin</span></strong></span><br /><span style="color: #000000;"> data_0_out <= mem[address_0];</span><br /><strong><span style="color: #0000ff;"> end else begin</span></strong><br /><span style="color: #000000;"> data_0_out <= 0;</span><br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;"> end</span></strong><br /><span style="color: #008000;">//Второй блок RAM</span><br /><span style="color: #008000;">// Управление тристабильным буфером</span><br /><span style="color: #008000;">// output : When we_0 = 0, oe_0 = 1, cs_0 = 1</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> data_1 = (cs_1 && oe_1 && !we_1) ? data_1_out : 8'bz;</span><br /><span style="color: #008000;">// Memory Read Block 1</span><br /><span style="color: #008000;">// Read Operation : When we_1 = 0, oe_1 = 1, cs_1 = 1</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">always</span></strong> @ (address_1 <strong><span style="color: #0000ff;">or</span></strong> cs_1<strong><span style="color: #0000ff;"> or</span></strong> we_1 <strong><span style="color: #0000ff;">or</span></strong> oe_1)</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> begin</span></strong> : MEM_READ_1</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> if</span></strong> (cs_1 && !we_1 && oe_1) <strong><span style="color: #0000ff;">begin</span></strong></span><br /><span style="color: #000000;"> data_1_out <= mem[address_1];</span><br /><strong><span style="color: #0000ff;"> end else begin</span></strong><br /><span style="color: #000000;"> data_1_out <= 0;</span><br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;"> end</span></strong><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">endmodule</span></strong><span style="color: #008000;"> // Конец модуля ram_dp_ar_aw</span></span></p> <p><span style="color: #000000;"><span style="color: #008000;"> </span></span></p> <p><span style="color: #000000;"><span style="color: #008000;">{phocadownload view=file|id=30|text=СКАЧАТЬ ПРИМЕР|target=s}</span></span></p> <p><span style="color: #000000;"><span style="color: #008000;"> </span></span></p> <p><span style="color: #000000;"><span style="color: #008000;"><a href="index.php/osnovy-tsifrovoj-tekhniki/185-printsip-funktsionirovaniya-ram" target="_blank"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #000000;"><span style="background-color: #00ff00;"><span style="font-size: large; background-color: #00ff00;">ВСПОМНИТЬ КАК РАБОТАЕТ>>></span></span></span></span></span></span></span></span></span></a></span></span></p></div>
<div class="feed-description"><p><span style="color: #000000;"><span style="color: #008000;">//-----------------------------------------------------</span></span><br /><span style="color: #008000;">// Имя модуля : ram_dp_ar_aw</span><br /><span style="color: #008000;">// Имя файла : ram_dp_ar_aw.v</span><br /><span style="color: #008000;">// Функц. назначение : Асинхронный блок для записи/чтения RAM</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">module</span></strong> ram_dp_ar_aw (</span><br /><span style="color: #000000;">address_0 , <span style="color: #008000;">// Вход address_0</span></span><br /><span style="color: #000000;">data_0 , <span style="color: #008000;">// Двунаправленный порт data_0</span></span><br /><span style="color: #000000;">cs_0 , <span style="color: #008000;">// Выбор блока</span></span><br /><span style="color: #000000;">we_0 , <span style="color: #008000;">// Разрешение записи/Разрешение чтения</span></span><br /><span style="color: #000000;">oe_0 , <span style="color: #008000;">// Разрешение выхода</span></span><br /><span style="color: #000000;">address_1 , <span style="color: #008000;">// Вход address_1</span></span><br /><span style="color: #000000;">data_1 , <span style="color: #008000;">// Двунаправленный порт data_1</span></span><br /><span style="color: #000000;">cs_1 ,<span style="color: #008000;"> // Выбор блока</span></span><br /><span style="color: #000000;">we_1 ,<span style="color: #008000;"> // Разрешение записи/Разрешение чтения</span></span><br /><span style="color: #000000;">oe_1 <span style="color: #008000;">// Разрешение выхода</span></span><br /><span style="color: #000000;">);</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">parameter</span></strong> DATA_WIDTH = 8 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">parameter</span></strong> ADDR_WIDTH = 8 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">parameter</span></strong> RAM_DEPTH = 1 << ADDR_WIDTH;</span><br /><span style="color: #008000;">//--------------Входные порты-----------------------</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input</span></strong> [ADDR_WIDTH-1:0] address_0 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input</span></strong> cs_0 ;</span><br /><span style="color: #000000;"><span style="color: #0000ff;"><strong>input</strong></span> we_0 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input</span></strong> oe_0 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input</span></strong> [ADDR_WIDTH-1:0] address_1 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input</span></strong> cs_1 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input</span></strong> we_1 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">input</span></strong> oe_1 ;</span><br /><span style="color: #008000;">//--------------Двунаправленные порты-----------------------</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">inout</span></strong> [DATA_WIDTH-1:0] data_0 ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">inout</span></strong> [DATA_WIDTH-1:0] data_1 ;</span><br /><span style="color: #008000;">//--------------Внутренние переменные----------------</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">reg</span></strong> [DATA_WIDTH-1:0] data_0_out ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">reg</span></strong> [DATA_WIDTH-1:0] data_1_out ;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">reg</span></strong> [DATA_WIDTH-1:0] mem [0:RAM_DEPTH-1];</span><br /><span style="color: #008000;">//--------------Начало кода------------------</span><br /><span style="color: #008000;">// Блок записи памяти</span><br /><span style="color: #008000;">// Write Operation : When we_0 = 1, cs_0 = 1</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">always</span></strong> @ (address_0 <strong><span style="color: #0000ff;">or</span></strong> cs_0 <strong><span style="color: #0000ff;">or</span></strong> we_0 <strong><span style="color: #0000ff;">or</span></strong> data_0</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">or</span></strong> address_1 <strong><span style="color: #0000ff;">or</span></strong> cs_1 <strong><span style="color: #0000ff;">or</span></strong> we_1 <strong><span style="color: #0000ff;">or</span></strong> data_1)</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> begin</span></strong> : MEM_WRITE</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> if</span></strong> ( cs_0 && we_0 ) <strong><span style="color: #0000ff;">begin</span></strong></span><br /><span style="color: #000000;"> mem[address_0] <= data_0;</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> end else if</span></strong> (cs_1 && we_1)<strong><span style="color: #0000ff;"> begin</span></strong></span><br /><span style="color: #000000;"> mem[address_1] <= data_1;</span><br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;"> end</span></strong><br /><span style="color: #008000;">// Управление тристабильным буфером</span><br /><span style="color: #008000;">// output : When we_0 = 0, oe_0 = 1, cs_0 = 1</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> data_0 = (cs_0 && oe_0 && !we_0) ? data_0_out : 8'bz;</span><br /><span style="color: #008000;">// Блок чтения памяти</span><br /><span style="color: #008000;">// Read Operation : When we_0 = 0, oe_0 = 1, cs_0 = 1</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">always</span></strong> @ (address_0 <strong><span style="color: #0000ff;">or</span></strong> cs_0<strong><span style="color: #0000ff;"> or</span></strong> we_1 <strong><span style="color: #0000ff;">or</span></strong> oe_0)</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> begin</span></strong> : MEM_READ_0</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> if</span></strong> (cs_0 && !we_0 && oe_0) <strong><span style="color: #0000ff;">begin</span></strong></span><br /><span style="color: #000000;"> data_0_out <= mem[address_0];</span><br /><strong><span style="color: #0000ff;"> end else begin</span></strong><br /><span style="color: #000000;"> data_0_out <= 0;</span><br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;"> end</span></strong><br /><span style="color: #008000;">//Второй блок RAM</span><br /><span style="color: #008000;">// Управление тристабильным буфером</span><br /><span style="color: #008000;">// output : When we_0 = 0, oe_0 = 1, cs_0 = 1</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">assign</span></strong> data_1 = (cs_1 && oe_1 && !we_1) ? data_1_out : 8'bz;</span><br /><span style="color: #008000;">// Memory Read Block 1</span><br /><span style="color: #008000;">// Read Operation : When we_1 = 0, oe_1 = 1, cs_1 = 1</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">always</span></strong> @ (address_1 <strong><span style="color: #0000ff;">or</span></strong> cs_1<strong><span style="color: #0000ff;"> or</span></strong> we_1 <strong><span style="color: #0000ff;">or</span></strong> oe_1)</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> begin</span></strong> : MEM_READ_1</span><br /><span style="color: #000000;"><strong><span style="color: #0000ff;"> if</span></strong> (cs_1 && !we_1 && oe_1) <strong><span style="color: #0000ff;">begin</span></strong></span><br /><span style="color: #000000;"> data_1_out <= mem[address_1];</span><br /><strong><span style="color: #0000ff;"> end else begin</span></strong><br /><span style="color: #000000;"> data_1_out <= 0;</span><br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;"> end</span></strong><br /><span style="color: #000000;"><strong><span style="color: #0000ff;">endmodule</span></strong><span style="color: #008000;"> // Конец модуля ram_dp_ar_aw</span></span></p> <p><span style="color: #000000;"><span style="color: #008000;"> </span></span></p> <p><span style="color: #000000;"><span style="color: #008000;">{phocadownload view=file|id=30|text=СКАЧАТЬ ПРИМЕР|target=s}</span></span></p> <p><span style="color: #000000;"><span style="color: #008000;"> </span></span></p> <p><span style="color: #000000;"><span style="color: #008000;"><a href="index.php/osnovy-tsifrovoj-tekhniki/185-printsip-funktsionirovaniya-ram" target="_blank"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #000000;"><span style="background-color: #00ff00;"><span style="font-size: large; background-color: #00ff00;">ВСПОМНИТЬ КАК РАБОТАЕТ>>></span></span></span></span></span></span></span></span></span></a></span></span></p></div>
Двойной порт RAM c синхронным режимом записи/чтения
2013-10-08T02:13:49+00:00 2013-10-08T02:13:49+00:00 http://portal-ed.ru/index.php/primery-verilog/154-dvojnoj-port-ram-c-sinkhronnym-rezhimom-zapisi-chteniya EngineerDeveloper® [email protected]
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : ram_dp_sr_sw</span><br /><span style="color: #008000;">// Имя файла : ram_dp_sr_sw.v</span><br /><span style="color: #008000;">// Функц. назначение : Синхронный блок для записи/чтения RAM</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><strong><span style="color: #0000ff;">module</span></strong> ram_dp_sr_sw (<br />clk , <span style="color: #008000;">// Тактовый вход</span><br />address_0 , <span style="color: #008000;">// Вход address_0</span><br />data_0 , <span style="color: #008000;">// Двунаправленный порт data_0</span><br />cs_0 ,<span style="color: #008000;"> // Выбор блока</span><br />we_0 , <span style="color: #008000;">// Разрешение записи/Разрешение чтения</span><br />oe_0 , <span style="color: #008000;">// Разрешение выхода</span><br />address_1 ,<span style="color: #008000;"> // Вход address_1</span><br />data_1 ,<span style="color: #008000;"> // Двунаправленный порт data_1</span><br />cs_1 , <span style="color: #008000;">// Выбор блока</span><br />we_1 ,<span style="color: #008000;"> // Разрешение записи/Разрешение чтения</span><br />oe_1 <span style="color: #008000;">// Разрешение выхода</span><br />);<br /><strong><span style="color: #0000ff;">parameter</span></strong> data_0_WIDTH = 8 ;<br /><strong><span style="color: #0000ff;">parameter</span></strong> ADDR_WIDTH = 8 ;<br /><strong><span style="color: #0000ff;">parameter</span></strong> RAM_DEPTH = 1 << ADDR_WIDTH;<br /><span style="color: #008000;">//--------------Входные порты-----------------------</span><br /><strong><span style="color: #0000ff;">input</span></strong> [ADDR_WIDTH-1:0] address_0 ;<br /><strong><span style="color: #0000ff;">input</span></strong> cs_0 ;<br /><strong><span style="color: #0000ff;">input</span></strong> we_0 ;<br /><strong><span style="color: #0000ff;">input</span></strong> oe_0 ;<br /><strong><span style="color: #0000ff;">input</span></strong> [ADDR_WIDTH-1:0] address_1 ;<br /><strong><span style="color: #0000ff;">input</span></strong> cs_1 ;<br /><strong><span style="color: #0000ff;">input</span></strong> we_1 ;<br /><strong><span style="color: #0000ff;">input</span></strong> oe_1 ;<br /><span style="color: #008000;">//--------------Двунаправленные порты-------------------</span><br /><strong><span style="color: #0000ff;">inout</span></strong> [data_0_WIDTH-1:0] data_0 ;<br /><strong><span style="color: #0000ff;">inout</span></strong> [data_0_WIDTH-1:0] data_1 ;<br /><span style="color: #008000;">//--------------Внутренние переменные----------------</span><br /><strong><span style="color: #0000ff;">reg</span></strong> [data_0_WIDTH-1:0] data_0_out ;<br /><strong><span style="color: #0000ff;">reg</span></strong> [data_0_WIDTH-1:0] data_1_out ;<br /><strong><span style="color: #0000ff;">reg</span></strong> [data_0_WIDTH-1:0] mem [0:RAM_DEPTH-1];<br /><span style="color: #008000;">//--------------Начало кода------------------</span><br /><span style="color: #008000;">// Запись блока памяти</span><br /><span style="color: #008000;">// Write Operation : When we_0 = 1, cs_0 = 1</span><br /><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> clk)<br /><strong><span style="color: #0000ff;">begin</span></strong> : MEM_WRITE<br /><strong><span style="color: #0000ff;"> if</span></strong> ( cs_0 && we_0 ) <strong><span style="color: #0000ff;">begin</span></strong><br /> mem[address_0] <= data_0;<br /> <strong><span style="color: #0000ff;">end else if</span> </strong>(cs_1 && we_1)<strong><span style="color: #0000ff;"> begin</span></strong><br /> mem[address_1] <= data_1;<br /> <strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><span style="color: #008000;">// Управление тристабильным буфером</span><br /><span style="color: #008000;">// output : When we_0 = 0, oe_0 = 1, cs_0 = 1</span><br /><strong><span style="color: #0000ff;">assign</span></strong> data_0 = (cs_0 && oe_0 && !we_0) ? data_0_out : 8'bz;<br /><span style="color: #008000;">// Чтение блока памяти</span><br /><span style="color: #008000;">// Read Operation : When we_0 = 0, oe_0 = 1, cs_0 = 1</span><br /><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> clk)<br /><strong><span style="color: #0000ff;">begin</span></strong> : MEM_READ_0<br /><strong><span style="color: #0000ff;"> if</span> </strong>(cs_0 && !we_0 && oe_0) <strong><span style="color: #0000ff;">begin</span></strong><br /> data_0_out <= mem[address_0];<br /> <strong><span style="color: #0000ff;">end else begin</span></strong><br /> data_0_out <= 0;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><span style="color: #008000;">//Второй блок RAM</span><br /><span style="color: #008000;">// Управление тристабильным буфером</span><br /><span style="color: #008000;">// output : When we_0 = 0, oe_0 = 1, cs_0 = 1</span><br /><strong><span style="color: #0000ff;">assign</span></strong> data_1 = (cs_1 && oe_1 && !we_1) ? data_1_out : 8'bz;<br /><span style="color: #008000;">// Чтение блока памяти 1</span><br /><span style="color: #008000;">// Read Operation : When we_1 = 0, oe_1 = 1, cs_1 = 1</span><br /><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> clk)<br /><strong><span style="color: #0000ff;">begin</span></strong> : MEM_READ_1<br /><strong><span style="color: #0000ff;"> if</span></strong> (cs_1 && !we_1 && oe_1) <strong><span style="color: #0000ff;">begin</span></strong><br /> data_1_out <= mem[address_1];<br /><strong><span style="color: #0000ff;"> end else begin</span></strong><br /> data_1_out <= 0;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">endmodule</span></strong> <span style="color: #008000;">// Конец блока ram_dp_sr_sw</span></p> <p><span style="color: #008000;"> </span></p> <p><span style="color: #008000;">{phocadownload view=file|id=31|text=СКАЧАТЬ ПРИМЕР|target=s}</span></p> <p><span style="color: #008000;"> </span></p> <p><span style="color: #008000;"><a href="index.php/osnovy-tsifrovoj-tekhniki/185-printsip-funktsionirovaniya-ram" target="_blank"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #000000;"><span style="background-color: #00ff00;"><span style="font-size: large; background-color: #00ff00;">ВСПОМНИТЬ КАК РАБОТАЕТ>>></span></span></span></span></span></span></span></span></span></a></span></p></div>
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : ram_dp_sr_sw</span><br /><span style="color: #008000;">// Имя файла : ram_dp_sr_sw.v</span><br /><span style="color: #008000;">// Функц. назначение : Синхронный блок для записи/чтения RAM</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><strong><span style="color: #0000ff;">module</span></strong> ram_dp_sr_sw (<br />clk , <span style="color: #008000;">// Тактовый вход</span><br />address_0 , <span style="color: #008000;">// Вход address_0</span><br />data_0 , <span style="color: #008000;">// Двунаправленный порт data_0</span><br />cs_0 ,<span style="color: #008000;"> // Выбор блока</span><br />we_0 , <span style="color: #008000;">// Разрешение записи/Разрешение чтения</span><br />oe_0 , <span style="color: #008000;">// Разрешение выхода</span><br />address_1 ,<span style="color: #008000;"> // Вход address_1</span><br />data_1 ,<span style="color: #008000;"> // Двунаправленный порт data_1</span><br />cs_1 , <span style="color: #008000;">// Выбор блока</span><br />we_1 ,<span style="color: #008000;"> // Разрешение записи/Разрешение чтения</span><br />oe_1 <span style="color: #008000;">// Разрешение выхода</span><br />);<br /><strong><span style="color: #0000ff;">parameter</span></strong> data_0_WIDTH = 8 ;<br /><strong><span style="color: #0000ff;">parameter</span></strong> ADDR_WIDTH = 8 ;<br /><strong><span style="color: #0000ff;">parameter</span></strong> RAM_DEPTH = 1 << ADDR_WIDTH;<br /><span style="color: #008000;">//--------------Входные порты-----------------------</span><br /><strong><span style="color: #0000ff;">input</span></strong> [ADDR_WIDTH-1:0] address_0 ;<br /><strong><span style="color: #0000ff;">input</span></strong> cs_0 ;<br /><strong><span style="color: #0000ff;">input</span></strong> we_0 ;<br /><strong><span style="color: #0000ff;">input</span></strong> oe_0 ;<br /><strong><span style="color: #0000ff;">input</span></strong> [ADDR_WIDTH-1:0] address_1 ;<br /><strong><span style="color: #0000ff;">input</span></strong> cs_1 ;<br /><strong><span style="color: #0000ff;">input</span></strong> we_1 ;<br /><strong><span style="color: #0000ff;">input</span></strong> oe_1 ;<br /><span style="color: #008000;">//--------------Двунаправленные порты-------------------</span><br /><strong><span style="color: #0000ff;">inout</span></strong> [data_0_WIDTH-1:0] data_0 ;<br /><strong><span style="color: #0000ff;">inout</span></strong> [data_0_WIDTH-1:0] data_1 ;<br /><span style="color: #008000;">//--------------Внутренние переменные----------------</span><br /><strong><span style="color: #0000ff;">reg</span></strong> [data_0_WIDTH-1:0] data_0_out ;<br /><strong><span style="color: #0000ff;">reg</span></strong> [data_0_WIDTH-1:0] data_1_out ;<br /><strong><span style="color: #0000ff;">reg</span></strong> [data_0_WIDTH-1:0] mem [0:RAM_DEPTH-1];<br /><span style="color: #008000;">//--------------Начало кода------------------</span><br /><span style="color: #008000;">// Запись блока памяти</span><br /><span style="color: #008000;">// Write Operation : When we_0 = 1, cs_0 = 1</span><br /><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> clk)<br /><strong><span style="color: #0000ff;">begin</span></strong> : MEM_WRITE<br /><strong><span style="color: #0000ff;"> if</span></strong> ( cs_0 && we_0 ) <strong><span style="color: #0000ff;">begin</span></strong><br /> mem[address_0] <= data_0;<br /> <strong><span style="color: #0000ff;">end else if</span> </strong>(cs_1 && we_1)<strong><span style="color: #0000ff;"> begin</span></strong><br /> mem[address_1] <= data_1;<br /> <strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><span style="color: #008000;">// Управление тристабильным буфером</span><br /><span style="color: #008000;">// output : When we_0 = 0, oe_0 = 1, cs_0 = 1</span><br /><strong><span style="color: #0000ff;">assign</span></strong> data_0 = (cs_0 && oe_0 && !we_0) ? data_0_out : 8'bz;<br /><span style="color: #008000;">// Чтение блока памяти</span><br /><span style="color: #008000;">// Read Operation : When we_0 = 0, oe_0 = 1, cs_0 = 1</span><br /><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> clk)<br /><strong><span style="color: #0000ff;">begin</span></strong> : MEM_READ_0<br /><strong><span style="color: #0000ff;"> if</span> </strong>(cs_0 && !we_0 && oe_0) <strong><span style="color: #0000ff;">begin</span></strong><br /> data_0_out <= mem[address_0];<br /> <strong><span style="color: #0000ff;">end else begin</span></strong><br /> data_0_out <= 0;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><span style="color: #008000;">//Второй блок RAM</span><br /><span style="color: #008000;">// Управление тристабильным буфером</span><br /><span style="color: #008000;">// output : When we_0 = 0, oe_0 = 1, cs_0 = 1</span><br /><strong><span style="color: #0000ff;">assign</span></strong> data_1 = (cs_1 && oe_1 && !we_1) ? data_1_out : 8'bz;<br /><span style="color: #008000;">// Чтение блока памяти 1</span><br /><span style="color: #008000;">// Read Operation : When we_1 = 0, oe_1 = 1, cs_1 = 1</span><br /><strong><span style="color: #0000ff;">always</span></strong> @ (<strong><span style="color: #0000ff;">posedge</span></strong> clk)<br /><strong><span style="color: #0000ff;">begin</span></strong> : MEM_READ_1<br /><strong><span style="color: #0000ff;"> if</span></strong> (cs_1 && !we_1 && oe_1) <strong><span style="color: #0000ff;">begin</span></strong><br /> data_1_out <= mem[address_1];<br /><strong><span style="color: #0000ff;"> end else begin</span></strong><br /> data_1_out <= 0;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">endmodule</span></strong> <span style="color: #008000;">// Конец блока ram_dp_sr_sw</span></p> <p><span style="color: #008000;"> </span></p> <p><span style="color: #008000;">{phocadownload view=file|id=31|text=СКАЧАТЬ ПРИМЕР|target=s}</span></p> <p><span style="color: #008000;"> </span></p> <p><span style="color: #008000;"><a href="index.php/osnovy-tsifrovoj-tekhniki/185-printsip-funktsionirovaniya-ram" target="_blank"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #000000;"><span style="background-color: #00ff00;"><span style="font-size: large; background-color: #00ff00;">ВСПОМНИТЬ КАК РАБОТАЕТ>>></span></span></span></span></span></span></span></span></span></a></span></p></div>
Одиночный порт RAM с асинхронной записью и чтением
2013-10-08T02:12:52+00:00 2013-10-08T02:12:52+00:00 http://portal-ed.ru/index.php/primery-verilog/153-odinochnyj-port-ram-s-asinkhronnoj-zapisyu-i-chteniem EngineerDeveloper® [email protected]
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : ram_sp_ar_aw</span><br /><span style="color: #008000;">// Имя файла : ram_sp_ar_aw.v</span><br /><span style="color: #008000;">// Функц. назначение : Аинхронная запись/чтение RAM</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><strong><span style="color: #0000ff;">module</span></strong> ram_sp_ar_aw (<br />address , <span style="color: #008000;">// Адресный вход</span><br />data , <span style="color: #008000;">// Двунаправленный порт данных</span><br />cs ,<span style="color: #008000;"> // Выбор блока</span><br />we , <span style="color: #008000;">// Разрешение записи/Разрешение чтения</span><br />oe <span style="color: #008000;">// Разрешение выхода</span><br />);<br /><strong><span style="color: #0000ff;">parameter</span></strong> DATA_WIDTH = 8 ;<br /><strong><span style="color: #0000ff;">parameter</span></strong> ADDR_WIDTH = 8 ;<br /><strong><span style="color: #0000ff;">parameter</span></strong> RAM_DEPTH = 1 << ADDR_WIDTH;<br /><span style="color: #008000;">//--------------Входные порты-----------------------</span><br /><strong><span style="color: #0000ff;">input</span></strong> [ADDR_WIDTH-1:0] address ;<br /><strong><span style="color: #0000ff;">input</span></strong> cs ;<br /><strong><span style="color: #0000ff;">input</span></strong> we ;<br /><strong><span style="color: #0000ff;">input</span></strong> oe ;<br /><span style="color: #008000;">//--------------Двунаправленные порты------------------</span><br /><strong><span style="color: #0000ff;">inout</span></strong> [DATA_WIDTH-1:0] data ;<br /><span style="color: #008000;">//--------------Внутренние переменные----------------</span><br /><strong><span style="color: #0000ff;">reg</span></strong> [DATA_WIDTH-1:0] data_out ;<br /><strong><span style="color: #0000ff;">reg</span></strong> [DATA_WIDTH-1:0] mem [0:RAM_DEPTH-1];<br /><span style="color: #008000;">//--------------Начало кода------------------</span><br /><span style="color: #008000;">// Управление тристабильным буфером</span><br /><span style="color: #008000;">// output : When we = 0, oe = 1, cs = 1</span><br /><strong><span style="color: #0000ff;">assign</span></strong> data = (cs && oe && !we) ? data_out : 8'bz;<br /><span style="color: #008000;">// Запись блока памяти</span><br /><span style="color: #008000;">// Write Operation : When we = 1, cs = 1</span><br /><strong><span style="color: #0000ff;">always</span></strong> @ (address <strong><span style="color: #0000ff;">or</span></strong> data <strong><span style="color: #0000ff;">or</span></strong> cs <strong><span style="color: #0000ff;">or</span> </strong>we)<br /><strong><span style="color: #0000ff;">begin</span></strong> : MEM_WRITE<br /><strong><span style="color: #0000ff;"> if</span></strong> ( cs && we ) <strong><span style="color: #0000ff;">begin</span></strong><br /> mem[address] = data;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><span style="color: #008000;">// Чтение блока памяти</span><br /><span style="color: #008000;">// Read Operation : When we = 0, oe = 1, cs = 1</span><br /><strong><span style="color: #0000ff;">always</span></strong> @ (address <strong><span style="color: #0000ff;">or</span></strong> cs <strong><span style="color: #0000ff;">or</span></strong> we<strong><span style="color: #0000ff;"> or</span></strong> oe)<br /><strong><span style="color: #0000ff;">begin</span></strong> : MEM_READ<br /><strong><span style="color: #0000ff;"> if</span></strong> (cs && !we && oe) <strong><span style="color: #0000ff;">begin</span></strong><br /> data_out = mem[address];<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">endmodule</span></strong> <span style="color: #008000;">// Конец модуля ram_sp_ar_aw</span></p> <p><span style="color: #008000;"> </span></p> <p><span style="color: #008000;">{phocadownload view=file|id=32|text=СКАЧАТЬ ПРИМЕР|target=s}</span></p> <p><span style="color: #008000;"> </span></p> <p><span style="color: #008000;"><a href="index.php/osnovy-tsifrovoj-tekhniki/185-printsip-funktsionirovaniya-ram" target="_blank"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #000000;"><span style="background-color: #00ff00;"><span style="font-size: large; background-color: #00ff00;">ВСПОМНИТЬ КАК РАБОТАЕТ>>></span></span></span></span></span></span></span></span></span></a></span></p></div>
<div class="feed-description"><p><span style="color: #008000;">//-----------------------------------------------------</span><br /><span style="color: #008000;">// Имя модуля : ram_sp_ar_aw</span><br /><span style="color: #008000;">// Имя файла : ram_sp_ar_aw.v</span><br /><span style="color: #008000;">// Функц. назначение : Аинхронная запись/чтение RAM</span><br /><span style="color: #008000;">// Программист : portal-ed.ru/</span><br /><span style="color: #008000;">//-----------------------------------------------------</span><br /><strong><span style="color: #0000ff;">module</span></strong> ram_sp_ar_aw (<br />address , <span style="color: #008000;">// Адресный вход</span><br />data , <span style="color: #008000;">// Двунаправленный порт данных</span><br />cs ,<span style="color: #008000;"> // Выбор блока</span><br />we , <span style="color: #008000;">// Разрешение записи/Разрешение чтения</span><br />oe <span style="color: #008000;">// Разрешение выхода</span><br />);<br /><strong><span style="color: #0000ff;">parameter</span></strong> DATA_WIDTH = 8 ;<br /><strong><span style="color: #0000ff;">parameter</span></strong> ADDR_WIDTH = 8 ;<br /><strong><span style="color: #0000ff;">parameter</span></strong> RAM_DEPTH = 1 << ADDR_WIDTH;<br /><span style="color: #008000;">//--------------Входные порты-----------------------</span><br /><strong><span style="color: #0000ff;">input</span></strong> [ADDR_WIDTH-1:0] address ;<br /><strong><span style="color: #0000ff;">input</span></strong> cs ;<br /><strong><span style="color: #0000ff;">input</span></strong> we ;<br /><strong><span style="color: #0000ff;">input</span></strong> oe ;<br /><span style="color: #008000;">//--------------Двунаправленные порты------------------</span><br /><strong><span style="color: #0000ff;">inout</span></strong> [DATA_WIDTH-1:0] data ;<br /><span style="color: #008000;">//--------------Внутренние переменные----------------</span><br /><strong><span style="color: #0000ff;">reg</span></strong> [DATA_WIDTH-1:0] data_out ;<br /><strong><span style="color: #0000ff;">reg</span></strong> [DATA_WIDTH-1:0] mem [0:RAM_DEPTH-1];<br /><span style="color: #008000;">//--------------Начало кода------------------</span><br /><span style="color: #008000;">// Управление тристабильным буфером</span><br /><span style="color: #008000;">// output : When we = 0, oe = 1, cs = 1</span><br /><strong><span style="color: #0000ff;">assign</span></strong> data = (cs && oe && !we) ? data_out : 8'bz;<br /><span style="color: #008000;">// Запись блока памяти</span><br /><span style="color: #008000;">// Write Operation : When we = 1, cs = 1</span><br /><strong><span style="color: #0000ff;">always</span></strong> @ (address <strong><span style="color: #0000ff;">or</span></strong> data <strong><span style="color: #0000ff;">or</span></strong> cs <strong><span style="color: #0000ff;">or</span> </strong>we)<br /><strong><span style="color: #0000ff;">begin</span></strong> : MEM_WRITE<br /><strong><span style="color: #0000ff;"> if</span></strong> ( cs && we ) <strong><span style="color: #0000ff;">begin</span></strong><br /> mem[address] = data;<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><span style="color: #008000;">// Чтение блока памяти</span><br /><span style="color: #008000;">// Read Operation : When we = 0, oe = 1, cs = 1</span><br /><strong><span style="color: #0000ff;">always</span></strong> @ (address <strong><span style="color: #0000ff;">or</span></strong> cs <strong><span style="color: #0000ff;">or</span></strong> we<strong><span style="color: #0000ff;"> or</span></strong> oe)<br /><strong><span style="color: #0000ff;">begin</span></strong> : MEM_READ<br /><strong><span style="color: #0000ff;"> if</span></strong> (cs && !we && oe) <strong><span style="color: #0000ff;">begin</span></strong><br /> data_out = mem[address];<br /><strong><span style="color: #0000ff;"> end</span></strong><br /><strong><span style="color: #0000ff;">end</span></strong><br /><strong><span style="color: #0000ff;">endmodule</span></strong> <span style="color: #008000;">// Конец модуля ram_sp_ar_aw</span></p> <p><span style="color: #008000;"> </span></p> <p><span style="color: #008000;">{phocadownload view=file|id=32|text=СКАЧАТЬ ПРИМЕР|target=s}</span></p> <p><span style="color: #008000;"> </span></p> <p><span style="color: #008000;"><a href="index.php/osnovy-tsifrovoj-tekhniki/185-printsip-funktsionirovaniya-ram" target="_blank"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #008000;"><span style="color: #000000;"><span style="color: #008000;"><span style="color: #000000;"><span style="background-color: #00ff00;"><span style="font-size: large; background-color: #00ff00;">ВСПОМНИТЬ КАК РАБОТАЕТ>>></span></span></span></span></span></span></span></span></span></a></span></p></div>