打印
[verilog]

FPGA与ADC通过SPI通信的代码问题

[复制链接]
1870|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
zpccx|  楼主 | 2017-4-10 17:31 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
/////////////////sdi数据输出控制//////////////////////////////

always [url=home.php?mod=space&uid=72445]@[/url] (negedge clk_ad  or negedge cnv_reg or negedge rst_n )        //由于ADC是在SCK时钟的上升沿锁存数据,所以需要在SCK的下降沿将数据输出,以满足一定的建立时间
begin                      //而且第一个SDI上的数据是由CNV的下降沿触发

        if(!rst_n)
    sdi_reg<=1'b1;    //如果复位,则使SDI输出为高
        else
    if(wr_done)
        begin
           if(sdi_en)
               sdi_reg<=1'b0;
           else
              sdi_reg<=1'b1;
          end
                       
   else
       begin
          if(sdi_en)
              sdi_reg<=cmd[Data_length-cnt1];
          else
              sdi_reg<=1'b1;
                                       
      end
end

/////////////////////////////////////////////////////////////
以上仅是一段代码,ADC芯片为AD4000,SPI通信,4线TURBO模式。
clk_ad是向ADC输出的时钟即SCK,cmd是要写的指令,用于设定ADC为TURBO模式,wr_done是写数据是否完成的标志。向ADC写数据的时序如下图所示




编译之后总是显示    if(wr_done)  这一行有错误,
错误为:
Error (10200): Verilog HDL Conditional Statement error at AD4000_Interface.v(305): cannot match operand(s) in the condition to the corresponding edges in the enclosing event control of the always construct


求大神指点





相关帖子

沙发
lausdeo| | 2017-5-31 15:58 | 只看该作者
第一个else之后加begin,最后多加一个end

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

10

主题

18

帖子

1

粉丝