摸鱼怪得到了新装备,学着用一下
用的是小梅哥的7010和ad9238(配套的,不用自己画板嘿嘿嘿)
【偷偷吐槽一下:IO好少,想加俩按键都很难写T_T】
ADC模-数转换原理与实现_模数转换器如何实现-CSDN博客
之前用的是EDA扩展版上的adc128s102是8通道12位SPI协议
本次使用的AD9238是双核12位高速ADC,(因为本摸鱼怪需要同时采集两路信号
adc_1024_one.v
module adc_1024_one(
input clk ,
input key ,
output adc_clk_0 ,
output adc_clk_1 ,
input [11:0]adc_in_0 ,
input [11:0]adc_in_1 ,
input adc_ovr_0 ,
input adc_ovr_1 ,
output VGA_CLK ,
output VGA_HS , //TFT行同步信号
output VGA_VS , //TFT场同步信号
output VGA_BLK , //VGA 场消隐信号
output [23:0] VGA_RGB ,//TFT数据输出
output TFT_BL //背光
);
assign adc_clk_0 = clk ;
assign adc_clk_1 = clk ;
wire clk_vga ;
assign TFT_BL = 1'b1 ;
reg [23:0]disp_data ;
wire [11:0]hcount ;
wire [11:0]vcount ;
wire Data_Req ;
assign VGA_CLK = clk_vga ;
wire key_flag , key_state ;
reg key_cnt = 1'b0;
reg key_cnt_now = 1'b0;
always@(posedge clk)
key_cnt <= key_cnt_now ;
always@(posedge clk)
if((key_flag)&&(key_state==1))
key_cnt_now <= key_cnt_now + 1'b1 ;
reg [2:0] clk_10M_cnt = 3'b000 ; //10MHz采样
always@(posedge clk)
if(!key_cnt_now)
clk_10M_cnt <= 3'b000 ;
else if(clk_10M_cnt == 3'b100)
clk_10M_cnt <= 3'b000 ;
else
clk_10M_cnt <= clk_10M_cnt + 1'b1 ;
reg ram_adc_w = 1'b0 ;
always@(posedge clk)
if(clk_10M_cnt == 3'b100)
ram_adc_w <= 1'b1 ;
else
ram_adc_w <= 1'b0 ;
reg adc_go = 1'b0 ;
reg adc_ing = 1'b0 ;
reg adc_done = 1'b0 ;
reg [9 : 0] ram_adc_addra = 0 ;
always@(posedge clk)
if( (!key_cnt) && key_cnt_now )
adc_go <= 1'b1 ;
else
adc_go <= 1'b0 ;
always@(posedge clk)
if( adc_go )
adc_ing <= 1'b1 ;
else if( adc_done )
adc_ing <= 1'b0 ;
always@(posedge clk)
if( adc_go )
ram_adc_addra <= 0 ;
else if( adc_ing && (clk_10M_cnt == 3'b011) )
ram_adc_addra <= ram_adc_addra + 1'b1 ;
else
ram_adc_addra <= ram_adc_addra ;
always@(posedge clk)
if( (ram_adc_addra == 10'd1023) && (clk_10M_cnt == 3'b100) && adc_ing)
adc_done <= 1'b1 ;
else
adc_done <= 1'b0 ;
wire [15:0] ram_adc_0_doutb ;
wire [15:0] ram_adc_1_doutb ;
//定义颜色编码
localparam
BLACK = 24'h000000 , //黑色
BLUE = 24'h0000FF , //蓝色
YELLOW = 24'h00FF00 , //绿色
WHITE = 24'hFFFFFF ; //白色
localparam
LINE = BLACK , //线是黑色
BACKGROUND = WHITE , //背景白色
ADC_0 = BLUE ,
ADC_1 = YELLOW ;
wire R_all = vcount >= 0 && vcount < 480 ;
wire C_all = hcount >= 0 && hcount < 800 ;
wire BR = R_all & C_all;//底色全为白色
wire L_mid = vcount == 255 ;//中间黑线
wire adc_dot_0 = (vcount == ram_adc_0_doutb[11:3]) && hcount;
wire adc_dot_1 = (vcount == ram_adc_1_doutb[11:3]) && hcount;
always@(*)
case({ BR , L_mid , adc_dot_0 , adc_dot_1 })
4'b1000: disp_data = BACKGROUND;
4'b1100: disp_data = LINE;
4'b1101: disp_data = LINE;
4'b1110: disp_data = LINE;
4'b1111: disp_data = LINE;
4'b1010: disp_data = ADC_0;
4'b1001: disp_data = ADC_1;
4'b1011: disp_data = ADC_1;
endcase
clk_33 clk_33_(
.clk_out1(clk_vga),
.clk_in1(clk)
);
key_one key_one_(
. clk(clk) ,
. reset_n(1'b1),
. key(key),
. key_flag(key_flag),
. key_state(key_state)
);
ram_adc_0 ram_adc_0_(
.clka(clk) ,
.wea(ram_adc_w ? 2'b11 : 2'b00) ,
.addra( ram_adc_addra) ,
.dina({4'b0000 ,adc_in_0}) ,
.clkb(clk_vga) ,
.addrb(hcount) ,
.doutb(ram_adc_0_doutb)
);
ram_adc_1 ram_adc_1_(
.clka(clk) ,
.wea(ram_adc_w ? 2'b11 : 2'b00) ,
.addra(ram_adc_addra) ,
.dina({4'b0000 ,adc_in_1}) ,
.clkb(clk_vga) ,
.addrb(hcount) ,
.doutb(ram_adc_1_doutb)
);
VGA_CTRL VGA_CTRL(
.clk(clk_vga), //系统输入时钟33MHZ
.reset_n(1'b1),
.data(disp_data), //待显示数据
.data_req(Data_Req),
.H_addr(hcount), //VGA行扫描计数器
.V_addr(vcount), //VGA场扫描计数器
.VGA_HS(VGA_HS), //VGA行同步信号
.VGA_VS(VGA_VS), //VGA场同步信号
.VGA_BLK(VGA_BLK) , //VGA 场消隐信号
.VGA_RGB(VGA_RGB) //VGA数据输出
);
endmodule
adc.xdc
set_property SEVERITY {Warning} [get_drc_checks NSTD-1]
set_property SEVERITY {Warning} [get_drc_checks RTSTAT-1]
set_property SEVERITY {Warning} [get_drc_checks UCIO-1]
set_property IOSTANDARD LVCMOS33 [get_ports {VGA_RGB[15]}]
set_property IOSTANDARD LVCMOS33 [get_ports {VGA_RGB[14]}]
set_property IOSTANDARD LVCMOS33 [get_ports {VGA_RGB[13]}]
set_property IOSTANDARD LVCMOS33 [get_ports {VGA_RGB[12]}]
set_property IOSTANDARD LVCMOS33 [get_ports {VGA_RGB[11]}]
set_property IOSTANDARD LVCMOS33 [get_ports {VGA_RGB[10]}]
set_property IOSTANDARD LVCMOS33 [get_ports {VGA_RGB[9]}]
set_property IOSTANDARD LVCMOS33 [get_ports {VGA_RGB[8]}]
set_property IOSTANDARD LVCMOS33 [get_ports {VGA_RGB[7]}]
set_property IOSTANDARD LVCMOS33 [get_ports {VGA_RGB[6]}]
set_property IOSTANDARD LVCMOS33 [get_ports {VGA_RGB[5]}]
set_property IOSTANDARD LVCMOS33 [get_ports {VGA_RGB[4]}]
set_property IOSTANDARD LVCMOS33 [get_ports {VGA_RGB[3]}]
set_property IOSTANDARD LVCMOS33 [get_ports {VGA_RGB[2]}]
set_property IOSTANDARD LVCMOS33 [get_ports {VGA_RGB[1]}]
set_property IOSTANDARD LVCMOS33 [get_ports {VGA_RGB[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports clk]
set_property IOSTANDARD LVCMOS33 [get_ports VGA_BLK]
set_property IOSTANDARD LVCMOS33 [get_ports TFT_BL]
set_property IOSTANDARD LVCMOS33 [get_ports VGA_CLK]
set_property IOSTANDARD LVCMOS33 [get_ports VGA_HS]
set_property IOSTANDARD LVCMOS33 [get_ports VGA_VS]
set_property PACKAGE_PIN W20 [get_ports {VGA_RGB[15]}]
set_property PACKAGE_PIN W19 [get_ports {VGA_RGB[14]}]
set_property PACKAGE_PIN V17 [get_ports {VGA_RGB[13]}]
set_property PACKAGE_PIN V16 [get_ports {VGA_RGB[12]}]
set_property PACKAGE_PIN T15 [get_ports {VGA_RGB[11]}]
set_property PACKAGE_PIN V20 [get_ports {VGA_RGB[10]}]
set_property PACKAGE_PIN U17 [get_ports {VGA_RGB[9]}]
set_property PACKAGE_PIN V18 [get_ports {VGA_RGB[8]}]
set_property PACKAGE_PIN T16 [get_ports {VGA_RGB[7]}]
set_property PACKAGE_PIN R16 [get_ports {VGA_RGB[6]}]
set_property PACKAGE_PIN U19 [get_ports {VGA_RGB[5]}]
set_property PACKAGE_PIN Y19 [get_ports {VGA_RGB[4]}]
set_property PACKAGE_PIN W18 [get_ports {VGA_RGB[3]}]
set_property PACKAGE_PIN Y18 [get_ports {VGA_RGB[2]}]
set_property PACKAGE_PIN W16 [get_ports {VGA_RGB[1]}]
set_property PACKAGE_PIN Y17 [get_ports {VGA_RGB[0]}]
set_property PACKAGE_PIN W14 [get_ports VGA_VS]
set_property PACKAGE_PIN U14 [get_ports VGA_HS]
set_property PACKAGE_PIN U15 [get_ports VGA_CLK]
set_property PACKAGE_PIN R17 [get_ports TFT_BL]
set_property PACKAGE_PIN U18 [get_ports clk]
set_property PACKAGE_PIN W15 [get_ports VGA_BLK]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_0[11]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_0[10]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_0[9]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_0[8]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_0[7]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_0[6]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_0[5]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_0[4]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_0[3]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_0[2]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_0[1]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_0[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_1[11]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_1[10]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_1[9]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_1[8]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_1[7]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_1[6]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_1[5]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_1[4]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_1[3]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_1[2]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_1[1]}]
set_property IOSTANDARD LVCMOS33 [get_ports {adc_in_1[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports adc_clk_0]
set_property IOSTANDARD LVCMOS33 [get_ports adc_clk_1]
set_property IOSTANDARD LVCMOS33 [get_ports adc_ovr_0]
set_property IOSTANDARD LVCMOS33 [get_ports adc_ovr_1]
set_property IOSTANDARD LVCMOS33 [get_ports key]
set_property PACKAGE_PIN K14 [get_ports adc_clk_0]
set_property PACKAGE_PIN K16 [get_ports adc_clk_1]
set_property PACKAGE_PIN J16 [get_ports adc_ovr_1]
set_property PACKAGE_PIN L15 [get_ports {adc_in_0[0]}]
set_property PACKAGE_PIN G14 [get_ports {adc_in_0[1]}]
set_property PACKAGE_PIN J14 [get_ports {adc_in_0[2]}]
set_property PACKAGE_PIN F16 [get_ports {adc_in_0[3]}]
set_property PACKAGE_PIN D18 [get_ports {adc_in_0[5]}]
set_property PACKAGE_PIN D19 [get_ports {adc_in_0[7]}]
set_property PACKAGE_PIN F17 [get_ports {adc_in_0[9]}]
set_property PACKAGE_PIN G17 [get_ports {adc_in_0[11]}]
set_property PACKAGE_PIN H15 [get_ports {adc_in_0[4]}]
set_property PACKAGE_PIN E17 [get_ports {adc_in_0[6]}]
set_property PACKAGE_PIN E18 [get_ports {adc_in_0[8]}]
set_property PACKAGE_PIN D20 [get_ports {adc_in_0[10]}]
set_property PACKAGE_PIN E19 [get_ports adc_ovr_0]
set_property PACKAGE_PIN G19 [get_ports {adc_in_1[1]}]
set_property PACKAGE_PIN G18 [get_ports {adc_in_1[3]}]
set_property PACKAGE_PIN H16 [get_ports {adc_in_1[5]}]
set_property PACKAGE_PIN J19 [get_ports {adc_in_1[7]}]
set_property PACKAGE_PIN K19 [get_ports {adc_in_1[9]}]
set_property PACKAGE_PIN H17 [get_ports {adc_in_1[11]}]
set_property PACKAGE_PIN G20 [get_ports {adc_in_1[0]}]
set_property PACKAGE_PIN H20 [get_ports {adc_in_1[2]}]
set_property PACKAGE_PIN J20 [get_ports {adc_in_1[4]}]
set_property PACKAGE_PIN H18 [get_ports {adc_in_1[6]}]
set_property PACKAGE_PIN J18 [get_ports {adc_in_1[8]}]
set_property PACKAGE_PIN K18 [get_ports {adc_in_1[10]}]
set_property PACKAGE_PIN F20 [get_ports key]
测试结果
10MHz采样,被测信号100kHz |
![]() |
测的1MHz信号显示前800看起来是一堆点,后面显示大概十个周期,去学习一下划线算法 |
//摸鱼怪貌似停更了好久,我爱摸鱼(◞‸◟ )