linux cpu占用率如何看
251
2022-10-25
基于SPI串行总线接口的Verilog实现
简 介:
在SOC设计中,利用EDA 工具设计芯片实现系统功能已经成为支撑电子设计的通用平台。并逐步向支持系统级的设计方向发展。而且,在设计过程中,越来越强调模块化设计。
1 SPI总线接口概述
SPI总线具有以下特点:
(1)连线较少,简化电路设计。并行总线扩展方法通常需要8根数据线、8~16根地址线、2~3根控制线。而这种设计,仅需4根数据和控制线即可完成并行扩展所实现的功能。
(2)器件统一编址,并与系统地址无关,操作SPI独立性好。
(3)器件操作遵循统一的规范,使系统软硬件具有良好的通用性。
2 SPI总线接口的设计与实现
该模块是802.1lb无线局域网芯片中的一子模块,其在芯片中的位置如图2所示。
其中base band(基带)为SPI的主控器(master),RF(射频)为SPI的受控器(slave)。SPI interface作为baseband与RF的通讯接口,主要完成以下工作:
(1)将从base band接收到的16位的并行数据,转换为RF所能接收的串行数据,并将该数据根据SPI协议送给RF。
(2)产生RF所需的时钟信号SCLK,使能信号CSB。
(3)接收从RF传回的串行数据,并将其转换为并行数据。
(4)将base band发送的数据,与RF返回的数据进行比较,并把比较结果传给base band。
always@ (posedge clock or negedge reset)
begin
if(!reset)
counter《= 0;
else if(enable)
begin
if(counter《 53)
counter=counter + 1;
end
end
//generate signal “csb”
always@ (posedge clock or negedge reset)
begin
if(!reset)
csb 《=1;
else if(counter》= 1 && counter 《= 50)
csb = 0;
else
csb = 1;
end
//Generate “sclk”
always@ (posedge clock or negedge reset)
begin
case(counter)
6‘d02: sclk = 1;
6’d05: sclk = 1;
6‘d08: sclk = 1;
6’d11: sclk = 1;
6‘d14: sclk = 1;
6’d17: sclk = 1;
6‘d20: sclk = 1;
6’d23: sclk = 1;
6‘d26: sclk = 1;
6’d29: sclk = 1;
6‘d32: sclk = 1;
6’d35: sclk = 1;
6‘d38: sclk = 1;
6’d41: sclk = 1;
6‘d44: sclk = 1;
6’d47: sclk = 1;
default sclk = 0;
end
always@ (counter or csb)
begin
if(csb == 0)
case(counter)
6‘h00,
6’h01,
6‘h02,
6’h03:mosi_index = 5‘h00;
6’h04,
6‘h05,
6’h06:mosi_index = 5‘h01;
6’h07,
6‘h08,
6’h09:mosi_index = 5‘h02;
6’h0A,
6‘h0B,
6’h0C:mosi_index = 5‘h03;
6’h0D,
6‘h0E,
6’h0F:mosi_index = 5‘h04;
6’h10,
6‘h11,
6’h12:mosi_index = 5‘h05;
6’h13,
6‘h14,
6’h15:mosi_index = 5‘h06;
6’h16,
6‘h17,
6’h18:mosi_index = 5‘h07;
6’h19,
6‘h1A,
6’h1B:mosi_index = 5‘h08;
6’h1C,
6‘h1D,
6’hlE:mosi_index = 5‘h09;
6’h1F,
6‘h20,
6’h21:mosi_index = 5‘h0A ;
6’h22,
6‘h23,
6’h24:mosi_index = 5‘h0B;
6’h25,
6‘h26,
6’h27:mosi_index = 5‘h0C ;
6’h28,
6‘h29,
6’h2A:mosi_index = 5‘h0D ;
6’h2B,
6‘h2C,
6’h2D:mosi_index = 5‘h0E;
6’h2E,
6‘h2F,
6’h30:mosi_index = 5‘h0F;
default:mosi_index = 5’h00;
endcase
else
mosi_index = 5‘h00:
end
assign mosi=spi_data[mosi_index3];
用Verilog HDL实现的SPI总线接口模块,在ModelSim 中编译、调试,并做了前仿真。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~