DWC_mipi_csi2_host_phy_adapter.v - luoxiafeng/MIPI_CSI GitHub Wiki

# 1作用

这个模块的作用就是负责与外部的D-PHY进行对接.我们可以看到APB总线是个标准的接口,在mipi-csi2模块中将apb总线进行例化来访问其中的寄存器. 同样的,如果外部的D-PHY给mipi-csi2的core提供时钟,则也需要实例化一个类似apb的模块.而我们的adapter就是这样的一个模块.其中的时钟rxbyteclkhs就类似apb总线中的pclk.

# 2模块的定义

module DWC_mipi_csi2_host_phy_adapter(

input    wire                       rxbyteclkhs,                 
input    wire                       rstz,
input    wire [(`LANES*8-1): 0]     rxdatahs,
input    wire [`LANES-1    : 0]     rxvalidhs,
input    wire [`LANES-1    : 0]     errsotsynchs,
input    wire [`LANES-1    : 0]     stopstatedata,
output   reg[(`LANES*8-1)  : 0]     lanedata,
output   wire [`LANES-1    : 0]     laneenable,

) reg [2:0] stopstatedatad; reg fstopstatedata; reg [‘LANES-1:0] r_errsotsynchs; 从这个模块的信号来看,也就是说,mipi-csi的adapter适配器就是用来判断lane是否使能,如果使能则返回有效数据。如果没有使能,则返回的有限数据全部是0.很明显,一个lane的数据是8bit。

3. 模块内部逻辑

3.1 通过D-PHY传递过来的信号,stopstatedata来判断有没有错误。

在rxbyteclkhs的每个上升沿或者复位的时候,都做如下重复的动作:

(1) 给变量stopstatedatad赋值,而且复制的时候会根据输入信号stopstatedata来移位赋值。

stopstatedatad = { stopstatedatad[1:0] , stopstatedata//输入信号来自D-PHY};

(2) 给变量fstopstatedata赋值。这个变量的值只有两种情形,要么就是0,要么就是1.

通过判断stopstatedatad 的高两个bit的值是否是2’b10,是就赋值为1,不是就赋值为0.这样,就可以获取D-PHY的错误信息了。

(3) 循环遍历所有的LANE,循环变量为i。注意,这里是在每一个rxbyteclkhs的上升沿,该循环都遍历一次。

(3.1)如果fstopstatedata为1,则表示D-PHY数据有错误,则我们要把错误信息保存在寄存器中。
       for( i = 0 ; i < LANES; i ++ ){
           if( fstopstatedata )
              r_errsotsynchs[i] = 0; //表示没有错误哦
           else if( errsotsynchs[i] )//通过D-PHY自己给的信号来判断
              r_errsotsynchs[i] = 1; //表示有错误哦。
       }
(3.2)返回最重要的两个信息:lanedata和laneenable状态。
      如果rxvalid[i]为有效,切当前编号为i的lane没有错误,则返回数据。
          lanedata[ (i+1)*8-1: i*8 ] = rxdatahs[(i+1)*8-1: i*8 ];
          laneenable[i] = 1;
      否则:
          lanedata[ (i+1)*8-1: i*8 ] = 0;
          laneenable[i] = 0;
⚠️ **GitHub.com Fallback** ⚠️