初级会员
积分 65
金钱 65
注册时间 2018-11-23
在线时间 17 小时
1 金钱
zynq 7020 采集2块ad7606,16通道数据,仿真出现信号都是高阻态
由于对verlog不熟悉,然后对vivado也不熟悉,程序也是参考网上的程序,网上的都为1个ad7606 8通道
我修改了一下,但是写好,然后通过ila 仿真观察,信号都呈现高阻态,帮忙看一下是什么原因,分析一下程序这样写对吗
//这个是管脚约束
create_clock -period 20.000 -name sys_clk [get_ports sys_clk]
set_property -dict {PACKAGE_PIN U18 IOSTANDARD LVCMOS33} [get_ports sys_clk]
#系统复位按键,低电平有效
set_property -dict {PACKAGE_PIN N16 IOSTANDARD LVCMOS33} [get_ports sys_rst_n]
#画的板子没有将这个引脚引到按键上? 这个怎么弄
#ad_b_data_pin
set_property -dict {PACKAGE_PIN Y11 IOSTANDARD LVCMOS33} [get_ports ad_a_convstab]
set_property -dict {PACKAGE_PIN W11 IOSTANDARD LVCMOS33} [get_ports ad_a_rst]
set_property -dict {PACKAGE_PIN Y13 IOSTANDARD LVCMOS33} [get_ports ad_a_rd_n]
set_property -dict {PACKAGE_PIN Y12 IOSTANDARD LVCMOS33} [get_ports ad_a_cs_n]
set_property -dict {PACKAGE_PIN V11 IOSTANDARD LVCMOS33} [get_ports ad_a_busy]
set_property -dict {PACKAGE_PIN V10 IOSTANDARD LVCMOS33} [get_ports ad_a_first_data]
set_property -dict {PACKAGE_PIN W10 IOSTANDARD LVCMOS33} [get_ports {ad_a_data[0]}]
set_property -dict {PACKAGE_PIN W9 IOSTANDARD LVCMOS33} [get_ports {ad_a_data[1]}]
set_property -dict {PACKAGE_PIN Y9 IOSTANDARD LVCMOS33} [get_ports {ad_a_data[2]}]
set_property -dict {PACKAGE_PIN Y8 IOSTANDARD LVCMOS33} [get_ports {ad_a_data[3]}]
set_property -dict {PACKAGE_PIN Y7 IOSTANDARD LVCMOS33} [get_ports {ad_a_data[4]}]
set_property -dict {PACKAGE_PIN Y6 IOSTANDARD LVCMOS33} [get_ports {ad_a_data[5]}]
set_property -dict {PACKAGE_PIN W6 IOSTANDARD LVCMOS33} [get_ports {ad_a_data[6]}]
set_property -dict {PACKAGE_PIN V6 IOSTANDARD LVCMOS33} [get_ports {ad_a_data[7]}]
set_property -dict {PACKAGE_PIN V5 IOSTANDARD LVCMOS33} [get_ports {ad_a_data[8]}]
set_property -dict {PACKAGE_PIN U8 IOSTANDARD LVCMOS33} [get_ports {ad_a_data[9]}]
set_property -dict {PACKAGE_PIN W8 IOSTANDARD LVCMOS33} [get_ports {ad_a_data[10]}]
set_property -dict {PACKAGE_PIN V8 IOSTANDARD LVCMOS33} [get_ports {ad_a_data[11]}]
set_property -dict {PACKAGE_PIN V7 IOSTANDARD LVCMOS33} [get_ports {ad_a_data[12]}]
set_property -dict {PACKAGE_PIN U7 IOSTANDARD LVCMOS33} [get_ports {ad_a_data[13]}]
set_property -dict {PACKAGE_PIN U5 IOSTANDARD LVCMOS33} [get_ports {ad_a_data[14]}]
set_property -dict {PACKAGE_PIN T5 IOSTANDARD LVCMOS33} [get_ports {ad_a_data[15]}]
#ad_b_data_pin
set_property -dict {PACKAGE_PIN U20 IOSTANDARD LVCMOS33} [get_ports ad_b_convstab]
set_property -dict {PACKAGE_PIN T20 IOSTANDARD LVCMOS33} [get_ports ad_b_rst]
set_property -dict {PACKAGE_PIN T19 IOSTANDARD LVCMOS33} [get_ports ad_b_rd_n]
set_property -dict {PACKAGE_PIN U19 IOSTANDARD LVCMOS33} [get_ports ad_b_cs_n]
set_property -dict {PACKAGE_PIN V20 IOSTANDARD LVCMOS33} [get_ports ad_b_busy]
set_property -dict {PACKAGE_PIN W20 IOSTANDARD LVCMOS33} [get_ports ad_b_first_data]
set_property -dict {PACKAGE_PIN W19 IOSTANDARD LVCMOS33} [get_ports {ad_b_data[0]}]
set_property -dict {PACKAGE_PIN W18 IOSTANDARD LVCMOS33} [get_ports {ad_b_data[1]}]
set_property -dict {PACKAGE_PIN Y19 IOSTANDARD LVCMOS33} [get_ports {ad_b_data[2]}]
set_property -dict {PACKAGE_PIN Y18 IOSTANDARD LVCMOS33} [get_ports {ad_b_data[3]}]
set_property -dict {PACKAGE_PIN V18 IOSTANDARD LVCMOS33} [get_ports {ad_b_data[4]}]
set_property -dict {PACKAGE_PIN V17 IOSTANDARD LVCMOS33} [get_ports {ad_b_data[5]}]
set_property -dict {PACKAGE_PIN Y16 IOSTANDARD LVCMOS33} [get_ports {ad_b_data[6]}]
set_property -dict {PACKAGE_PIN Y17 IOSTANDARD LVCMOS33} [get_ports {ad_b_data[7]}]
set_property -dict {PACKAGE_PIN W16 IOSTANDARD LVCMOS33} [get_ports {ad_b_data[8]}]
set_property -dict {PACKAGE_PIN V16 IOSTANDARD LVCMOS33} [get_ports {ad_b_data[9]}]
set_property -dict {PACKAGE_PIN W15 IOSTANDARD LVCMOS33} [get_ports {ad_b_data[10]}]
set_property -dict {PACKAGE_PIN V15 IOSTANDARD LVCMOS33} [get_ports {ad_b_data[11]}]
set_property -dict {PACKAGE_PIN Y14 IOSTANDARD LVCMOS33} [get_ports {ad_b_data[12]}]
set_property -dict {PACKAGE_PIN W14 IOSTANDARD LVCMOS33} [get_ports {ad_b_data[13]}]
set_property -dict {PACKAGE_PIN W13 IOSTANDARD LVCMOS33} [get_ports {ad_b_data[14]}]
set_property -dict {PACKAGE_PIN V12 IOSTANDARD LVCMOS33} [get_ports {ad_b_data[15]}]
////////////////////////////////////////////////////////////////////////////////////////////////////////////
这个是程序
//`timescale 1ns / 1ps
module ad7606_double(
input sys_clk,
input sys_rst_n,
//=================dev_a====================//
input [15:0] ad_a_data,
input ad_a_busy,
input ad_a_first_data,
//input ad_a_data_valid_to_fpga,
//output reg[2:0] ad_a_os,
output reg ad_a_cs_n,
output reg ad_a_rd_n,
output reg ad_a_rst,
output reg ad_a_convstab,
//output ad_a_data_valid_to_pc,
/*
output reg[15:0] ad_a_ch1,
output reg[15:0] ad_a_ch2,
output reg[15:0] ad_a_ch3,
output reg[15:0] ad_a_ch4,
output reg[15:0] ad_a_ch5,
output reg[15:0] ad_a_ch6,
output reg[15:0] ad_a_ch7,
output reg[15:0] ad_a_ch8,
*/
//=================dev_b====================//
input [15:0] ad_b_data,
input ad_b_busy,
input ad_b_first_data,
//input ad_b_data_valid_to_fpga,
//output reg[2:0] ad_b_os,
output reg ad_b_cs_n,
output reg ad_b_rd_n,
output reg ad_b_rst,
output reg ad_b_convstab
//output ad_b_data_valid_to_pc
/*
output reg[15:0] ad_b_ch1,
output reg[15:0] ad_b_ch2,
output reg[15:0] ad_b_ch3,
output reg[15:0] ad_b_ch4,
output reg[15:0] ad_b_ch5,
output reg[15:0] ad_b_ch6,
output reg[15:0] ad_b_ch7,
output reg[15:0] ad_b_ch8
*/
//=================dev_a and dev_b====================//
//output reg ad_a_b_rst //让ad器件复位
);
reg[15:0] ad_a_ch1;
reg[15:0] ad_a_ch2;
reg[15:0] ad_a_ch3;
reg[15:0] ad_a_ch4;
reg[15:0] ad_a_ch5;
reg[15:0] ad_a_ch6;
reg[15:0] ad_a_ch7;
reg[15:0] ad_a_ch8;
reg[15:0] ad_b_ch1;
reg[15:0] ad_b_ch2;
reg[15:0] ad_b_ch3;
reg[15:0] ad_b_ch4;
reg[15:0] ad_b_ch5;
reg[15:0] ad_b_ch6;
reg[15:0] ad_b_ch7;
reg[15:0] ad_b_ch8;
reg [15:0] rst_cnt;
reg [5:0] delay_cnt;
reg [3:0] ad7606_state;
wire ad_a_data_valid_to_pc; //这两个变量在output型中但是没有进行管脚绑定,结果报错,只能拿出来
wire ad_b_data_valid_to_pc;
parameter IDLE = 4'd0;
parameter AD_CONV = 4'd1;
parameter WAIT_1 = 4'd2;
parameter WAIT_BUSY = 4'd3;
parameter READ_CH1 = 4'd4;
parameter READ_CH2 = 4'd5;
parameter READ_CH3 = 4'd6;
parameter READ_CH4 = 4'd7;
parameter READ_CH5 = 4'd8;
parameter READ_CH6 = 4'd9;
parameter READ_CH7 = 4'd10;
parameter READ_CH8 = 4'd11;
parameter READ_DONE = 4'd12;
//assign ad_os = 3'b000;
assign ad_a_data_valid_to_pc =(ad7606_state==READ_DONE) ? 1'b1:1'b0;
assign ad_a_data_valid_to_pc =(ad7606_state==READ_DONE) ? 1'b1:1'b0;
//assign #10 sys_rst_n =1'b0; //输入不能赋值? sys_rst_n引脚没有引出
//===========================================================================
always @(posedge sys_clk or negedge sys_rst_n) begin
if(!sys_rst_n) begin
rst_cnt <= 16'b0;
ad_a_rst <= 1'b0;
ad_b_rst <= 1'b0;
end
else if(rst_cnt < 16'hffff) begin //65535次,每次20ns
rst_cnt <= rst_cnt+16'd1;
ad_a_rst <= 1'b1;
ad_b_rst <= 1'b1;
end
else //计满16'hffff个周期,将2个器件复位
ad_a_rst <= 1'b0;
ad_b_rst <= 1'b0;
end
//===========================================================================
always @(posedge sys_clk) begin
if((ad_a_rst==1'b1)&&(ad_b_rst==1'b1)) begin //ad7606处于工作情况
ad7606_state <= IDLE;
ad_a_ch1 <= 0;
ad_a_ch2 <= 0;
ad_a_ch3 <= 0;
ad_a_ch4 <= 0;
ad_a_ch5 <= 0;
ad_a_ch6 <= 0;
ad_a_ch7 <= 0;
ad_a_ch8 <= 0;
ad_a_cs_n <= 1;
ad_a_rd_n <= 1;
ad_a_convstab <= 1; //下一个时钟开始转换
ad_b_ch1 <= 0;
ad_b_ch2 <= 0;
ad_b_ch3 <= 0;
ad_b_ch4 <= 0;
ad_b_ch5 <= 0;
ad_b_ch6 <= 0;
ad_b_ch7 <= 0;
ad_b_ch8 <= 0;
ad_b_cs_n <= 1;
ad_b_rd_n <= 1;
ad_b_convstab <= 1; //下一个时钟开始转换
end
else begin
case(ad7606_state)
IDLE : begin
ad_a_cs_n <= 1;
ad_a_rd_n <= 1;
ad_a_convstab <= 1;
ad_b_cs_n <= 1;
ad_b_rd_n <= 1;
ad_b_convstab <= 1;
if(delay_cnt==20) begin
delay_cnt <= 6'd0;
ad7606_state <= AD_CONV;
end
else
delay_cnt <= delay_cnt+6'd1;
end
AD_CONV:begin
if(delay_cnt==2) begin
delay_cnt <= 6'd0;
ad7606_state <= WAIT_1;
ad_a_convstab <= 1'b1;
ad_b_convstab <= 1'b1;
end
else begin
delay_cnt <= delay_cnt+6'd1;
ad_a_convstab <= 1'b0;
ad_b_convstab <= 1'b0;
end
end
WAIT_1:begin
if(delay_cnt==5) begin
delay_cnt <= 6'd0;
ad7606_state <= WAIT_BUSY;
end
else begin
delay_cnt <= delay_cnt+6'd1;
end
end
WAIT_BUSY:begin
if((ad_a_busy==1'b0)&&(ad_b_busy==1'b0)) begin //等待2个器件数据都可用,如果2个都没来或者有1个没有来就死等?
delay_cnt <= 6'd0;
ad7606_state <= READ_CH1;
end
/*
else begin
ad7606_state <= WAIT_BUSY;
end
*/
else begin
ad7606_state <= WAIT_BUSY;
end
/*可不可以手动延迟一段时间呢*/
end
READ_CH1:begin
ad_a_cs_n <= 1'b0;
ad_b_cs_n <= 1'b0;
if(delay_cnt==3) begin
ad_a_rd_n <= 1'b1; //为什么是1? //读取下一个数据按照手册需要拉高ad的读信号
ad_b_rd_n <= 1'b1; //为什么是1? //读取下一个数据按照手册需要拉高ad的读信号
delay_cnt <= 6'd0;
ad_a_ch1 <= ad_a_data; //延迟3个时钟才真正将数据给相应的通道
ad_b_ch1 <= ad_b_data; //延迟3个时钟才真正将数据给相应的通道
ad7606_state <= READ_CH2;
end
else begin
ad_a_rd_n <= 1'b0; //所以这个是拉低读取
ad_b_rd_n <= 1'b0; //所以这个是拉低读取
delay_cnt <= delay_cnt+6'd1;
end
end
READ_CH2:begin
if(delay_cnt==3) begin
ad_a_rd_n <= 1'b1;
ad_b_rd_n <= 1'b1;
delay_cnt <= 6'd0;
ad_a_ch2 <= ad_a_data;
ad_b_ch2 <= ad_b_data;
ad7606_state <= READ_CH3;
end
else begin
ad_a_rd_n <= 1'b0;
ad_b_rd_n <= 1'b0;
delay_cnt <= delay_cnt+6'd1;
end
end
READ_CH3:begin
if(delay_cnt==3) begin
ad_a_rd_n <= 1'b1;
ad_b_rd_n <= 1'b1;
delay_cnt <= 6'd0;
ad_a_ch3 <= ad_a_data;
ad_b_ch3 <= ad_b_data;
ad7606_state <= READ_CH4;
end
else begin
ad_a_rd_n <= 1'b0;
ad_b_rd_n <= 1'b0;
delay_cnt <= delay_cnt+6'd1;
end
end
READ_CH4:begin
if(delay_cnt==3) begin
ad_a_rd_n <= 1'b1;
ad_b_rd_n <= 1'b1;
delay_cnt <= 6'd0;
ad_a_ch4 <= ad_a_data;
ad_b_ch4 <= ad_b_data;
ad7606_state <= READ_CH5;
end
else begin
ad_a_rd_n <= 1'b0;
ad_b_rd_n <= 1'b0;
delay_cnt <= delay_cnt+6'd1;
end
end
READ_CH5:begin
if(delay_cnt==3) begin
ad_a_rd_n <= 1'b1;
ad_b_rd_n <= 1'b1;
delay_cnt <= 6'd0;
ad_a_ch5 <= ad_a_data;
ad_b_ch5 <= ad_b_data;
ad7606_state <= READ_CH6;
end
else begin
ad_a_rd_n <= 1'b0;
ad_b_rd_n <= 1'b0;
delay_cnt <= delay_cnt+6'd1;
end
end
READ_CH6:begin
if(delay_cnt==3) begin
ad_a_rd_n <= 1'b1;
ad_b_rd_n <= 1'b1;
delay_cnt <= 6'd0;
ad_a_ch6 <= ad_a_data;
ad_b_ch6 <= ad_b_data;
ad7606_state <= READ_CH7;
end
else begin
ad_a_rd_n <= 1'b0;
ad_b_rd_n <= 1'b0;
delay_cnt <= delay_cnt+6'd1;
end
end
READ_CH7:begin
if(delay_cnt==3) begin
ad_a_rd_n <= 1'b1;
ad_b_rd_n <= 1'b1;
delay_cnt <= 6'd0;
ad_a_ch7 <= ad_a_data;
ad_b_ch7 <= ad_b_data;
ad7606_state <= READ_CH8;
end
else begin
ad_a_rd_n <= 1'b0;
ad_b_rd_n <= 1'b0;
delay_cnt <= delay_cnt+6'd1;
end
end
READ_CH8:begin
if(delay_cnt==3) begin
ad_a_rd_n <= 1'b1;
ad_b_rd_n <= 1'b1;
delay_cnt <= 6'd0;
ad_a_ch8 <= ad_a_data;
ad_b_ch8 <= ad_b_data;
ad7606_state <= READ_DONE;
end
else begin
ad_a_rd_n <= 1'b0;
ad_b_rd_n <= 1'b0;
delay_cnt <= delay_cnt+6'd1;
end
end
READ_DONE:begin
ad_a_cs_n <= 1'b1;
ad_b_cs_n <= 1'b1;
ad_a_rd_n <= 1'b1;
ad_b_rd_n <= 1'b1;
ad7606_state <= IDLE;
end
default:
ad7606_state <= IDLE;
endcase
end
end
ila_0 u_ila_0 (
.clk(sys_clk), // input wire clk
.probe0(sys_rst_n), // input wire [0:0] probe0
.probe1(ad_a_data), // input wire [0:0] probe1
.probe2(ad_a_busy), // input wire [15:0] probe2
.probe3(ad_a_first_data), // input wire [0:0] probe3
.probe4(ad_a_cs_n), // input wire [0:0] probe4
.probe5(ad_a_rd_n), // input wire [0:0] probe5
.probe6(ad_a_rst), // input wire [0:0] probe6
.probe7(ad_a_convstab), // input wire [15:0] probe7
.probe8(ad_b_data), // input wire [0:0] probe8
.probe9(ad_b_busy), // input wire [0:0] probe9
.probe10(ad_b_first_data), // input wire [0:0] probe10
.probe11(ad_b_cs_n), // input wire [0:0] probe11
.probe12(ad_b_rd_n), // input wire [0:0] probe12
.probe13(ad_b_rst), // input wire [0:0] probe13
.probe14(ad_b_convstab) // input wire [0:0] probe14
);
endmodule
我来回答