第一范文网 - 专业文章范例文档资料分享平台

Verilog仿真文件testbench编写样例

来源:用户分享 时间:2025/11/4 2:56:02 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

Verilog 仿真文件testbench编写样例

`timescale 1ns/100ps module testbench;

localparam DATA_WIDTH = 32; localparam CLK_100_PERIOD = 5; localparam CLK_200_PERIOD = 2.5; localparam SIM_TIME = 150000; localparam ; localparam ;

reg clk_100, clk_200; wire clk;

assign clk = clk_100; always begin clk_100 = 0;

forever #CLK_100_PERIOD clk_100 = ~clk_100; end always begin clk_200 = 0;

forever #CLK_200_PERIOD clk_200 = ~clk_200;

end reg rstn;

integer fp_testin; integer fp_matlab_out; integer fp_sim_out; integer fp_outdiff;

reg signed [DATA_WIDTH/2-1:0] matlab_in_re, matlab_in_im;

reg signed [DATA_WIDTH/2-1:0] matlab_out_re, matlab_out_im;

reg signed [DATA_WIDTH/2-1:0] matlab_diff_re, matlab_diff_im;

reg signed [DATA_WIDTH/2-1:0] matlab_diff_re2, matlab_diff_im2;

reg signed [DATA_WIDTH/2-1:0] max_diff_re, max_diff_im; initial begin max_diff_re = 0; max_diff_im = 0; rstn = 0; #500 rstn = 1;

#SIM_TIME sim_finish(); $stop(); end

task sim_finish; begin

if(fp_testin!=0) $fclose(fp_testin); if(fp_matlab_out!=0) $fclose(fp_matlab_out); if(fp_sim_out) $fclose(fp_sim_out); if(fp_outdiff!=0) $fclose(fp_outdiff); end endtask initial begin

fp_testin = 0; fp_testin=

$fopen("txt_file/input_data.txt","r");

if(fp_testin==0) begin

$display("input_data.txt open failed!"); sim_finish(); $stop(); end else begin

$fscanf(fp_testin,

"%d, %d\\n",matlab_in_re,matlab_in_im); end

fp_matlab_out = 0; fp_matlab_out =

$fopen("txt_file/matlab_out.txt","r");

if(fp_matlab_out==0) begin

$display("fp_matlab_out.txt open failed!"); sim_finish(); $stop(); end else begin

搜索更多关于: Verilog仿真文件testbench编写样例 的文档
Verilog仿真文件testbench编写样例.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c3odou62rx1797950lpza3sk4u09qt500fla_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top