




版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、明德?lián)P科技教育SPI 進階 3 之 READ 功能練習參考代碼官網(wǎng):淘寶:群1目錄at93c46_read 模塊3test_at93c46_read 模塊72明德?lián)P科技公司主要是以 FPGA 為,專業(yè)從事 FPGA 配套開發(fā)板、FPGA培訓班或其他培訓、研發(fā) FPGA 技術開發(fā)、承接 FPGA 項目開發(fā)。歡迎加入明德?lián)P FPGA和 ASIC97925396。明德?lián)P以PDF 格式提供源代碼,是為了鼓勵大家多思考,不要拿來就用,否則是學不好 FPGA 的。本代碼對應的設計思路,請參考明德?lián)P課程。at93c46_read 模塊module at93c46_read(clk rst_n addr rd
2、 rdatardata_vld rdydo di cs sk);,/參數(shù)定義 parameterDATA_W =8;/輸入信號定義 inputinput input 6:0 inputinputclk rst_naddr;rddo;/輸出信號定義 outputDATA_W-1:0 outputoutputrdatardata_vld; rdy;3output outputoutputdi cssk;/輸出信號 reg 定義reg reg reg reg regregDATA_W-1:0rdata rdata_vld; rdydi cssk;reg 9:0reg 4:0reg 6:0reg 1:
3、0doutcnt_sclk ;cnt_1us;work_flag;always(edge clk or negedge rst_n)beginif(rst_n=1b0)begin cnt_1us = 0;endelse if(work_flag!=2b0)begin if(cnt_1us=99)begincnt_1us = 0;endelse begincnt_1us = cnt_1us + 1;endendelse begincnt_1us = 0;endendt_sclkalways(edge clk or negedge rst_n)beginif(rst_n=1b0)begin cnt
4、_sclk = 0;endelse if(work_flag=2b01) begin if(cnt_1us=99 & cnt_sclk=17)begincnt_sclk = 0;end4else if(cnt_1us=99) begin cnt_sclk = cnt_sclk + 1;endendelse begincnt_sclk = 0;endendalways(edge clk or negedge rst_n)beginif(rst_n=1b0)begin dout = 0;endelse if(work_flag=2b0 & rd)begin dout = 3b110,addr;en
5、dendalways(edge clk or negedge rst_n)beginif(rst_n=1b0)begin work_flag = 2b00;endelse if(work_flag=2b0 & rd)begin work_flag = 2b01;endelse if(work_flag=2b01 & cnt_1us=99 & cnt_sclk=17)begin work_flag = 2b10;endelse if(work_flag=2b10 & cnt_1us=99)begin work_flag = 2b00;endendalways(edge clk or negedg
6、e rst_n)beginif(rst_n=1b0)begin sk = 1b0;endelse if(work_flag=2b01) begin if(cnt_1us=49)sk = 1b1;else if(cnt_1us=99)5sk = 1b0;endelse beginsk = 1b0;endendalways(edge clk or negedge rst_n)beginif(rst_n=1b0)begin di = 1b0;endelse if(work_flag=2b00 & rd)begin di = 1b1;endelse if(work_flag=2b01 & cnt_1u
7、s=99)begin if(cnt_sclk=9)di = 1b0;else if(cnt_sclk 9)di = doutt_sclk-1;endendalways(edge clk or negedge rst_n)beginif(rst_n=1b0)begin cs = 1b0;endelse if(work_flag=2b00 & rd)begin cs = 1b1;endelse if(work_flag=2b01 & cnt_1us=99 & cnt_sclk=17)begin cs = 1b0;endendalways(*)begin if(rd)rdy = 1b0; else
8、if(|work_flag)rdy = 1b0;elserdy = 1b1;endalways(edge clk or negedge rst_n)begin6if(rst_n=1b0)begin rdata 9) begin rdata = rdata6:0,do;endendalways(edge clk or negedge rst_n)beginif(rst_n=1b0)begin rdata_vld = 1b0;endelse if(work_flag=2b10 & cnt_1us=99) begin rdata_vld = 1b1;endelse beginrdata_vld =
9、1b0;endendendmoduletest_at93c46_read 模塊timescale 1 ns/1 nsmodule test_at93c46_read();parameterDATA_W =8;/輸入信號定義 regregclk rst_naddr;regreg reg6:0rddo;/輸出信號定義wireDATA_W-1:0rdata;7wire wire wire wirewirerdata_vld; rdydi cssk;/時鐘周期, parameter CYCLE為 ns,可在此修改時鐘周期。= 10;/復位時間,此時表示復位 3 個時鐘周期的時間。parameter R
10、ST_TIME = 3 ;/待測試的模塊例化 at93c46_readuut(.clk.rst_n.addr.rd.rdata.rdata_vld.rdy.do.di.cs.sk);(clk (rst_n (addr)(rdata),),),(rd,),)(rdata_vld) (rdy(do(di(cs(sk,/生成本地時鐘 50M initial beginclk = 0; forever #(CYCLE/2)clk=clk;end/產(chǎn)生復位信號 initial beginrst_n = 1;#2;rst_n = 0; #(CYCLE*RST_TIME);rst_n = 1;end8/輸入信號 din0 賦值方式initial begin #1;/賦初值 rd = 0
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- T-ZRIA 002-2024 工業(yè)巡檢四足機器人通.用技術條件
- T-ZSM 0058-2024“領跑者”評價技術要求 飾面木質墻板
- 二零二五年度林業(yè)林地經(jīng)營權買賣合同
- T-ZJATA 0022-2024 土壤中揮發(fā)性有機物測定用便攜式氣相色譜-質譜聯(lián)用儀
- T-ZJZYC 022-2024 靈芝工廠化生產(chǎn)技術規(guī)程
- 二零二五年度簽約主播與汽車廠商合作直播試駕體驗協(xié)議
- 二零二五年度會展中心物業(yè)管理服務托管協(xié)議
- 二零二五年度新能源項目投資對賭協(xié)議
- 二零二五年度股東清算與清算資產(chǎn)評估及拍賣協(xié)議
- 二零二五年度創(chuàng)新創(chuàng)業(yè)團隊員工合作協(xié)議書
- 畢業(yè)設計外文文獻-Spring Boot
- 六年級下冊《生命.生態(tài).安全》全冊教案(表格式)
- 采購入庫單模板
- GB 14930.1-2022食品安全國家標準洗滌劑
- GB/T 15566.6-2007公共信息導向系統(tǒng)設置原則與要求第6部分:醫(yī)療場所
- 中國電信教育基地市級“三通兩平臺”建設方案(教育機構)
- 火力發(fā)電廠節(jié)能技術經(jīng)濟指標釋義
- 智能制造知識課件
- 雙方責任及工程分工界面
- 2017醫(yī)學倫理知情同意書
- 中醫(yī)學-導論課件
評論
0/150
提交評論