问答

汇集网友智慧,解决技术难题

21ic问答首页 - TAG - FPGA
  • modelsim仿真问题 赏800家园币

    [i=s] 本帖最后由 awbl 于 2023-8-27 13:33 编辑 [/i] 在学习FIR的过程中遇到了仿真问题,大家帮忙看一下。1、modelsim版本:modelsim-Altera 10.3d 2、quartus版本 :Quartus II 15.0 (64-bit) 3、主程序fir.v:[list=1] [*] module fir( [*] clk , [*] rst_n , [*] key , [*] dac_mode , [*] dac_sleep , [*] dac_clka , [*] dac_dat_a , [*] dac_wra , [*] dac_clkb , [*] dac_dat_b , [*] dac_wrb [*]); [*] [*]input clk ; [*]input rst_n ; [*]input [7:0] key ; [*]output dac_mode ; [*]output dac_sleep ; [*]output dac_clka ; [*]output [7:0] dac_dat_a ; [*]output dac_wra ; [*]output dac_clkb ; [*]output [7:0] dac_dat_b ; [*]output dac_wrb ; [*] [*]//信号类型定义。 [*]reg [7:0] sin_data ; [*]reg [31:0] cnt1 ; [*]wire add_cnt1 ; [*]wire end_cnt1 ; [*]wire [16:0] addr_temp ; [*]wire [6:0] addr ; [*]reg [12:0] x ; [*]reg [7:0] dac_dat_a ; [*]wire dac_sleep ; [*]wire dac_mode ; [*]wire dac_clka ; [*]reg [1:0] cnt0 ; [*]wire add_cnt0 ; [*]wire end_cnt0 ; [*]wire [7:0] fir_dout ; [*]wire fir_dout_vld; [*]reg [7:0] dac_dat_b ; [*]wire dac_clkb ; [*]wire dac_wrb ; [*]wire [7:0] fir_din ; [*]wire [7:0] fir_dout2 ; [*]//设计正弦信号。 [*]always @(*) begin [*] case(addr) [*]0: sin_data = 8'h7F; [*]1: sin_data = 8'h85; [*]2: sin_data = 8'h8C; [*]3: sin_data = 8'h92; [*]4: sin_data = 8'h98; [*]5: sin_data = 8'h9E; [*]6: sin_data = 8'hA4; [*]7: sin_data = 8'hAA; [*]8: sin_data = 8'hB0; [*]9: sin_data = 8'hB6; [*]10: sin_data = 8'hBC; [*]11: sin_data = 8'hC1; [*]12: sin_data = 8'hC6; [*]13: sin_data = 8'hCB; [*]14: sin_data = 8'hD0; [*]15: sin_data = 8'hD5; [*]16: sin_data = 8'hDA; [*]17: sin_data = 8'hDE; [*]18: sin_data = 8'hE2; [*]19: sin_data = 8'hE6; [*]20: sin_data = 8'hEA; [*]21: sin_data = 8'hED; [*]22: sin_data = 8'hF0; [*]23: sin_data = 8'hF3; [*]24: sin_data = 8'hF5; [*]25: sin_data = 8'hF7; [*]26: sin_data = 8'hF9; [*]27: sin_data = 8'hFB; [*]28: sin_data = 8'hFC; [*]29: sin_data = 8'hFD; [*]30: sin_data = 8'hFE; [*]31: sin_data = 8'hFE; [*]32: sin_data = 8'hFE; [*]33: sin_data = 8'hFE; [*]34: sin_data = 8'hFE; [*]35: sin_data = 8'hFD; [*]36: sin_data = 8'hFC; [*]37: sin_data = 8'hFA; [*]38: sin_data = 8'hF8; [*]39: sin_data = 8'hF6; [*]40: sin_data = 8'hF4; [*]41: sin_data = 8'hF1; [*]42: sin_data = 8'hEF; [*]43: sin_data = 8'hEB; [*]44: sin_data = 8'hE8; [*]45: sin_data = 8'hE4; [*]46: sin_data = 8'hE0; [*]47: sin_data = 8'hDC; [*]48: sin_data = 8'hD8; [*]49: sin_data = 8'hD3; [*]50: sin_data = 8'hCE; [*]51: sin_data = 8'hC9; [*]52: sin_data = 8'hC4; [*]53: sin_data = 8'hBE; [*]54: sin_data = 8'hB9; [*]55: sin_data = 8'hB3; [*]56: sin_data = 8'hAD; [*]57: sin_data = 8'hA7; [*]58: sin_data = 8'hA1; [*]59: sin_data = 8'h9B; [*]60: sin_data = 8'h95; [*]61: sin_data = 8'h8F; [*]62: sin_data = 8'h89; [*]63: sin_data = 8'h82; [*]64: sin_data = 8'h7D; [*]65: sin_data = 8'h77; [*]66: sin_data = 8'h70; [*]67: sin_data = 8'h6A; [*]68: sin_data = 8'h64; [*]69: sin_data = 8'h5E; [*]70: sin_data = 8'h58; [*]71: sin_data = 8'h52; [*]72: sin_data = 8'h4C; [*]73: sin_data = 8'h46; [*]74: sin_data = 8'h41; [*]75: sin_data = 8'h3C; [*]76: sin_data = 8'h36; [*]77: sin_data = 8'h31; [*]78: sin_data = 8'h2C; [*]79: sin_data = 8'h28; [*]80: sin_data = 8'h23; [*]81: sin_data = 8'h1F; [*]82: sin_data = 8'h1B; [*]83: sin_data = 8'h17; [*]84: sin_data = 8'h14; [*]85: sin_data = 8'h11; [*]86: sin_data = 8'hE ; [*]87: sin_data = 8'hB ; [*]88: sin_data = 8'h9 ; [*]89: sin_data = 8'h7 ; [*]90: sin_data = 8'h5 ; [*]91: sin_data = 8'h3 ; [*]92: sin_data = 8'h2 ; [*]93: sin_data = 8'h1 ; [*]94: sin_data = 8'h1 ; [*]95: sin_data = 8'h1 ; [*]96: sin_data = 8'h1 ; [*]97: sin_data = 8'h1 ; [*]98: sin_data = 8'h2 ; [*]99: sin_data = 8'h3 ; [*]100: sin_data = 8'h4 ; [*]101: sin_data = 8'h6 ; [*]102: sin_data = 8'h7 ; [*]103: sin_data = 8'hA ; [*]104: sin_data = 8'hC ; [*]105: sin_data = 8'hF ; [*]106: sin_data = 8'h12; [*]107: sin_data = 8'h15; [*]108: sin_data = 8'h19; [*]109: sin_data = 8'h1D; [*]110: sin_data = 8'h21; [*]111: sin_data = 8'h25; [*]112: sin_data = 8'h2A; [*]113: sin_data = 8'h2E; [*]114: sin_data = 8'h33; [*]115: sin_data = 8'h38; [*]116: sin_data = 8'h3E; [*]117: sin_data = 8'h43; [*]118: sin_data = 8'h49; [*]119: sin_data = 8'h4E; [*]120: sin_data = 8'h54; [*]121: sin_data = 8'h5A; [*]122: sin_data = 8'h60; [*]123: sin_data = 8'h67; [*]124: sin_data = 8'h6D; [*]125: sin_data = 8'h73; [*]126: sin_data = 8'h79; [*]127: sin_data = 8'h7F; [*] endcase [*]end [*] [*]always @(posedge clk or negedge rst_n)begin [*] if(!rst_n)begin [*] cnt1 <= 0; [*] end [*] else if(add_cnt1)begin [*] if(end_cnt1) [*] cnt1 <= 0; [*] else [*] cnt1 <= cnt1 + 1; [*] end [*]end [*] [*]assign add_cnt1 = 1 ; [*]assign end_cnt1 = 0 ; [*] [*] [*]always @(*) begin [*] if(key == 0)begin [*] x = 262 ; [*] end [*] else if(key == 1)begin [*] x = 524 ; [*] end [*] else if(key == 2)begin [*] x = 786 ; [*] end [*] else if(key == 3)begin [*] x = 1029 ; [*] end [*] else if(key == 4)begin [*] x = 1311 ; [*] end [*] else if(key == 5)begin [*] x = 1573 ; [*] end [*] else if(key == 6)begin [*] x = 1835 ; [*] end [*] else begin [*] x = 2097 ; [*] end [*]end [*]assign addr_temp = cnt1 * x ; [*]assign addr = addr_temp >> 10 ; [*] [*] [*]//A通道输出。 [*]always @(posedge clk or negedge rst_n)begin [*] if(rst_n==1'b0)begin [*] dac_dat_a <= 0 ; [*] end [*] else begin [*] dac_dat_a <= 255 - sin_data ; [*] end [*]end [*] [*]assign dac_sleep = 0 ; [*]assign dac_mode = 1 ; [*]assign dac_wra = dac_clka ; [*]assign dac_clka = ~clk ; [*] [*]//设计滤波器。 [*]always @(posedge clk or negedge rst_n)begin [*] if(!rst_n)begin [*] cnt0 <= 0; [*] end [*] else if(add_cnt0)begin [*] if(end_cnt0) [*] cnt0 <= 0; [*] else [*] cnt0 <= cnt0 + 1; [*] end [*]end [*] [*]assign add_cnt0 = 1 ; [*]assign end_cnt0 = add_cnt0 && cnt0== 4 - 1 ; [*]assign fir_din = sin_data - 128 ; [*]ip_fir_1 module_2( [*] .clk (clk ), [*] .reset_n (rst_n ), [*] .ast_sink_data (fir_din ), [*] .ast_sink_valid (end_cnt0 ), [*] .ast_sink_error (2'b00 ), [*] .ast_source_data (fir_dout ), [*] .ast_source_valid (fir_dout_vld ), [*] .ast_source_error ( ) [*] ); [*]assign fir_dout2 = fir_dout + 128 ; [*]always @(posedge clk or negedge rst_n)begin [*] if(rst_n==1'b0)begin [*] dac_dat_b <= 0 ; [*] end [*] else if(fir_dout_vld) begin [*] dac_dat_b <= 255 - fir_dout2 ; [*] end [*]end [*] [*]assign dac_wrb = dac_clkb ; [*]assign dac_clkb = ~clk ; [*]endmodule [/list] 4、IP核文件 ip_fir_1.v : [list=1] [*]`timescale 1 ps / 1 ps [*]module ip_fir_1 ( [*] input wire clk, // clk.clk [*] input wire reset_n, // rst.reset_n [*] input wire [7:0] ast_sink_data, // avalon_streaming_sink.data [*] input wire ast_sink_valid, // .valid [*] input wire [1:0] ast_sink_error, // .error [*] output wire [7:0] ast_source_data, // avalon_streaming_source.data [*] output wire ast_source_valid, // .valid [*] output wire [1:0] ast_source_error // .error [*] ); [*] [*] ip_fir_1_0002 ip_fir_1_inst ( [*] .clk (clk), // clk.clk [*] .reset_n (reset_n), // rst.reset_n [*] .ast_sink_data (ast_sink_data), // avalon_streaming_sink.data [*] .ast_sink_valid (ast_sink_valid), // .valid [*] .ast_sink_error (ast_sink_error), // .error [*] .ast_source_data (ast_source_data), // avalon_streaming_source.data [*] .ast_source_valid (ast_source_valid), // .valid [*] .ast_source_error (ast_source_error) // .error [*] ); [*] [*]endmodule [/list] 5、测试文件 test_fir.v : [list=1] [*]`timescale 1 ns/1 ns [*] [*]module test_fir(); [*] [*]//时钟和复位 [*]reg clk ; [*]reg rst_n; [*] [*]//uut的输入信号 [*]reg[7:0] key ; [*] [*]//uut的输出信号 [*]wire dac_mode ; [*]wire dac_sleep ; [*]wire dac_clka ; [*]wire [7:0] dac_dat_a ; [*]wire dac_wra ; [*]wire dac_clkb ; [*]wire [7:0] dac_dat_b ; [*]wire dac_wrb ; [*] [*] [*]//时钟周期,单位为ns,可在此修改时钟周期。 [*]parameter CYCLE = 200; [*] [*]//复位时间,此时表示复位3个时钟周期的时间。 [*]parameter RST_TIME = 3 ; [*] [*]//待测试的模块例化 [*]fir uut( [*] .clk (clk ), [*] .rst_n (rst_n ), [*] .key (key ), [*] .dac_mode (dac_mode ), [*] .dac_sleep (dac_sleep ), [*] .dac_clka (dac_clka ), [*] .dac_dat_a (dac_dat_a ), [*] .dac_wra (dac_wra ), [*] .dac_clkb (dac_clkb ), [*] .dac_dat_b (dac_dat_b ), [*] .dac_wrb (dac_wrb ) [*] [*]); [*] [*] [*]//生成本地时钟50M [*]initial begin [*] clk = 0; [*] forever [*] #(CYCLE/2) [*] clk=~clk; [*]end [*] [*]//产生复位信号 [*]initial begin [*] rst_n = 1; [*] #2; [*] rst_n = 0; [*] #(CYCLE*RST_TIME); [*] rst_n = 1; [*]end [*] [*]//输入信号key赋值方式 [*]initial begin [*] forever begin [*] #(10000*CYCLE); [*] //赋初值 [*] key = 0; [*] #(10000*CYCLE); [*] key = 1; [*] #(10000*CYCLE); [*] key = 2; [*] #(10000*CYCLE); [*] key = 3; [*] #(10000*CYCLE); [*] key = 4; [*] #(10000*CYCLE); [*] key = 5; [*] #(10000*CYCLE); [*] key = 6; [*] #(10000*CYCLE); [*] key = 7; [*]end [*]end [*]endmodule [/list] 6、quartus和modelsim联合仿真报错如下图: [attach]2152750[/attach] [attach]2152748[/attach] 恳请各位指正!!

    DAC DA 仿真 modelsim FPGA

    25036浏览量 7回复量 关注量
  • 关于modelsim的仿真问题。 sos

    [i=s] 本帖最后由 awbl 于 2023-8-26 17:40 编辑 [/i] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "]在跟着B站视频学习到FIR时,仿真遇到问题。[/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "]1、quartus版本:Quartus (Quartus Prime 18.1) Lite Edition[/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "]2、modelsim是从altera官网下载的pro 18.1 ,已经解锁。[/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "]3、联合仿真时出现以下错误: [/font][/backcolor][/color][img=600,0]http://www.fpgabbs.cn/data/attachment/forum/202308/25/171117k153sus5p2i5js3l.png[/img] [align=left][font=Arial][float=right] [/float][/font][/align][color=#444444][backcolor=rgb(255, 255, 255)][/backcolor][/color][img=598,0]http://www.fpgabbs.cn/data/attachment/forum/202308/25/171117z64f68j1o6tf0jz6.png[/img][color=#444444][backcolor=rgb(255, 255, 255)][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "]4、单独仿真时出现以下错误: [/font][/backcolor][/color][img=600,0]http://www.fpgabbs.cn/data/attachment/forum/202308/25/171142uglnnhinm9ph5mnm.png[/img] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "]诸位大佬指点迷经,感激不尽[/font][/backcolor][/color]{:cry:}

    UART Quartus 仿真 modelsim FPGA

    3479浏览量 0回复量 关注量
  • 现在有哪些型号的FPGA需求量大,但是国内没有能替代的? sos

    另外一个问题,瓶颈主要在哪些feature 或者性能指标上?

    国产芯片 FPGA

    1462浏览量 0回复量 关注量
  • C6678与FPGA之间通信 sos

    C6678与FPGA之间通信用什么通信较好 有没有案例 最好有代码,本人小白需要代码看看

    FPGA PGA 通信 代码

    1145浏览量 0回复量 关注量
  • 请问可以发FPGA的招聘信息吗

    请问可以发FPGA的招聘信息吗

    FPGA PGA

    750浏览量 2回复量 关注量
  • FPGA程序,不能正确输出,各位帮忙看下

    我编写了两个文件,配置了输出口,,LASER_PWM 始终输出不了波形,请问下,这个是什么原因呀?modesiem仿真是有波形输出的//////////////-------PWM.V 文件 `timescale 1 ns / 1 ps module pwm( input rsn, input clk, input [15:0]pwm_counter, input [15:0]pwm_duty, output pwm_out ); //reg[15:0]pwm_counter; //reg [15:0]pwm_duty; reg [15:0]counter=16'd0; reg pwm_out_r; always@(posedge clk or negedge rsn) //begin if(!rsn) begin counter <= 16'd0; end else begin if(counter >= pwm_counter)counter <= 16'd0; else counter <= counter + 1'd1; end // end always@(posedge clk or negedge rsn) if(!rsn) begin pwm_out_r <= 1'd0; end else if(counter>=pwm_duty) pwm_out_r<=1'b0; else pwm_out_r<=1'b1; //wire pwm_out; assign pwm_out = pwm_out_r;//((counter > pwm_duty) ? 1'd0 : 1'd1); endmodule ////// top_indepen.v 文件 //-------------------------Timescale----------------------------// `timescale 1 ns / 1 ps //--------------------FSMC_SIG---------------------// module FSMC_INDEP( FPGA_CLK, //鏉堟挸鍙嗛弶鑳祰閺呰埖灏烥PGA_CLK,25M FPGA_LEDR, FPGA_LEDG, FPGA_LEDB, WR, //FSMC閸愭瑤淇婇崣 RD, //FSMC鐠囪淇婇崣 CS0, //FSMC閻楀洭鈧 A, //FSMC閸︽澘**冮幀鑽ゅ殠 DB, //FSMC閺佺増宓侀幀鑽ゅ殠 NADV, //FSMC閻ㄥ嚞ADV //LASER PWM LASER_PWM, //interpn_exti Interp_ex, testclk, testclk_100, testclk_50, FPGA_KEY ); input FPGA_KEY; input FPGA_CLK,NADV; input WR,RD,CS0; inout [15:0]DB; input [24:16]A; output FPGA_LEDB,FPGA_LEDG,FPGA_LEDR; assign FPGA_LEDR = 1'd1; assign FPGA_LEDG = 1'd0; assign FPGA_LEDB = 1'd1; output LASER_PWM; output Interp_ex,testclk,testclk_100,testclk_50; //-------------------------MY_PLL-------------------------------// wire PLL_100M; wire PLL_8M; wire PLL_50M; wire PLL_12_5M; reg LaserCtrl1; reg [15:0] dbPower1;//閸旂喓宸 閸楃姷鈹栧В reg [15:0]dbQFreq1;//妫版垹宸 reg [15:0]counter; initial begin dbQFreq1 <= 16'd106; dbPower1 <= 16'd53; LaserCtrl1 <= 1'd1; end MY_PLL U1( .inclk0(FPGA_CLK), .c0(PLL_100M), .c1(PLL_50M), .c2(PLL_8M), .c3(PLL_12_5M) );// //------------------------RST_Ctrl-----------------------------// wire RST_n; RST_Ctrl U2( .FPGA_CLK(FPGA_CLK), .RST_n(RST_n) ); //娓氬瀵睷ST_Ctrl濡€虫健,鏉堟挸鍤崗銊ョ湰婢跺秳缍呮穱鈥冲娇RST_n pwm U5( .rsn(RST_n), .clk(PLL_8M), .pwm_counter(dbQFreq1), .pwm_duty(dbPower1),//閸旂喓宸 .pwm_out(LASER_PWM) ); endmodule

    FPGA PWM counter TE npu

    673浏览量 2回复量 关注量
  • 什么是FPGA

    什么是FPGA

    FPGA PGA

    577浏览量 1回复量 关注量
  • FPGA在汽车电子中的应用有哪些

    FPGA在汽车电子中的应用有哪些

    FPGA PGA 汽车 汽车电子 电子

    1130浏览量 1回复量 关注量
  • 在SOC设计中和FPGA使用verilog有什么区别?

    在SOC设计中使用verilog,和FPGA为对象使用verilog,有什么区别?

    FPGA verilog SoC设计

    3747浏览量 1回复量 关注量
  • FPGA设计的功耗都有什么

    FPGA设计的功耗都有什么

    FPGA FPGA设计 PGA pga设计

    797浏览量 1回复量 关注量
  • FPGA读取SD卡信息,为什么返回没有数据?

    FPGA读取SD卡信息,SD卡初始化成功,可以相应读指令返回0x00,但是为什么没有数据?miso引脚返回0x00后,一直是高电平,没有0xFE令牌,也没有数据。请问是怎么回事?可以有偿,可加我QQ交流。

    FPGA SD卡 ISO 引脚 指令

    3735浏览量 2回复量 关注量
  • 有没有给介绍一下FPGA芯片结构的啊

    有没有给介绍一下FPGA芯片结构的啊

    FPGA FPGA芯片 PGA 芯片

    590浏览量 2回复量 关注量
  • FPGA、DSP、ASIC的区别是什么

    FPGA、DSP、ASIC的区别是什么

    ASIC DSP FPGA

    894浏览量 3回复量 关注量
  • FPGA为什么可以帮助CPU加速

    FPGA为什么可以帮助CPU加速

    CPU FPGA PGA

    849浏览量 7回复量 关注量
  • FPGA与单片机的区别是啥

    FPGA与单片机的区别是啥

    FPGA PGA 单片机

    668浏览量 1回复量 关注量
123下一页