资源简介
讲述了SPI总线原理,提供主从设备Verilog源码及仿真波形,对初学者有帮助
淘宝店铺:小月电子 QQ:3181961725 lways@ (posedge sysclkspi clk r<= spi clk ∥/从机读取数据,MSO串转并 always@(posedge sysclk or negedge rst n begin (!rst_ n) egin nt data in<= 4do shift reg<= 8'dz data bus <=8dz Vi <=1"b0; else if (cnt data in ==8) be cnt data in <=0 data b 1b1; else if( spi clk_neg∥/下降沿读取数据 egir va|<=1"b0 data bus <=8d cnt data in<= cnt data in+1 b1 hift_reg<=Shift reg[6: 0], misoF end els /向从机写数据,并转串MOS,高位在前 always@(posedge sysclk or negedge rst n begin if (rst n begin cnt data send 4′d0 shift send 8'h else if( cnt data send==8) begin cnt data send <= 4d0 shift send <=8 haa: end else if(spi_ck_pos)/上升沿发送数据 gIn mosi < shift send[7]: 淘宝店铺:小月电子 Qa:3181961725 淘宝店铺:小月电子 QQ:3181961725 shift send <=(shift send[6: 0], b01 nt data send cnt data send +1b1 eIst end module sP从设备 Verilog源码 module spi slave( input sysc nput n put outpu eg mIso input lk output reg 7: 0] data inout g spi clk ri reg [3: 0] cnt send g[7: 0 data send g [3: 0 cnt rece reg [7: 0 receive reg lways @ posedge sysclk spi clk r <=spi clk sign pos spi clk =(spi clk r& spi_clk ) assign neg_ spi clk =(spi clk spi clk r) always@(posedge sysclk or negedge rst n) begin if(!rst_n egIn cnt send <=4'd0 data send 8d170; nd Ise if(cnt send ==8 egIn cnt send data send <=8hba end else if(pos spi clk egIn cnt send < cnt send +1b1 d[刀 data send <=data send[6: 0],1'b0J: else 淘宝店铺:小月电子 Qa:3181961725 淘宝店铺:小月电子 QQ:3181961725 end always@(posedge sysclk or negedge rst n) begin if(!rst n) begin cnt receive < 4'd0 receive reg <=do data inout <=8'dz end else if (cnt receive ==8 egIn data inout < receive regi else if(neg spi clk&&Cs==o) begil cnt receive < cnt receive +1 b1 receive reg <=receive_ reg[6: 0], mosi] data inout<='dz end else endmodule 仿真波形图: 主设备向从设备发送0xaa,从设备向主设备发送0xab 1 U. ILIUL LILTIILULm. T uL UIUU MI MIILLULLLLLOLIL LILmm uTuu MU ILLIL LuLILLIL umU uunuMLULILIO MIUI ≌ achive rec I':0 淘宝店铺:小月电子 Qa:3181961725
代码片段和文件信息
相关资源
- PRML最全资料集合.zip
- 数据可视化驾驶舱.zip
- 李晓峰通信原理.zip
- 图解西门子S71200PLC入门到实践(清晰
- AI拓客商家联盟V2.1.3前端+后端.rar
- echarts大数据领导仓demo.rar
- [C51单片机开发工具Keil.UV4].Keil.C51.V9
- Deep_Learning_2016.pdf
- zw_Classification1.zip
- Griffiths-IntroductiontoElectrodynamics4thEdit
- ParaViewTutorial.pdf
- xyisv_10236804.zip
- 计算机图形学第4版高清电子书.pdf
- 《多粒度知识获取与不确定性度量》
- 华成英模电课件.zip
- 70d0cd041f738f12db575d3b46e97582.pdf
- OfficeTabEnterprise13.1.zip
- wxu998.rar
- PowerDesigner16.5汉化文件.rar
- jsgis.zip
- PinyinIME(关键代码写了注释).zip
- 锁相环设计、仿真与应用第5版中.pd
- novelOnLine.zip
- SingleSensorImagingMethodsandApplicationsforDi
- ControlSystemsEngineering7th(NormanS.Nise)
- ModernControlSystems13th(RichardC.Dorf).ra
- VectorMagic_1.15pojie.rar
- complexityoflattice__problems.pdf
- xnby_883749.zip
- TOGAF培训讲义-周金根.pdf
评论
共有 条评论