问一个关于在AMS里定读取文件的问题。
时间:10-02
整理:3721RD
点击:
模型中的数字部分,希望数据来源于txt文件,16位,这些数据被模型直接输出给DAC的数字端;下面是我的代码,结果AMS报告错误很奇怪“|
ncelab: *E,NOTUTX (/home/jircheis/work_oa/sim/tb_gen_dk/functional/verilog.v,54|21): Function name encountered.Expecting a task name. [2.7.4(IEEE Std 1364-2001)].
. Done”
下面是我的代码,根据它标示的出问题的地方是“$fscanf(fp_r,"%h",txt_data);”,我简单查了下VAMS的手册,看它是支持$fscanf的,想问下这个问题该怎么解决?
或者有什么例子保证我能从txt中读取数据。
- `timescale 1ns / 1psmodule tb_gen_8bl0b_dk(txd_data,tklsb,tkmsb,rstn,clk1x,clk2x);output [15:0] txd_data;output tklsb,tkmsb,rstn;output clk1x,clk2x;reg[15:0] din;
- wire [9:0] dtout;reg clk1x_tmp,clk2x_tmp;wire clk1x,clk2x;reg rst,pre_rst;reg [23:0] txt_data;
- integer fp,fp_r,i,fp_w;
- initialbegin#10clk1x_tmp <= 0;clk2x_tmp <= 0;rst <=1;pre_rst<=1;#47 pre_rst <=0;#1 rst <=0;end
- initialbeginfp_r=$fopen("./base_data_8b10b.txt","r");if(!fp_r)begin$display("Read File Error.");$fclose(fp_r);end
- @(posedge clk1x)beginwhile(!($feof(fp_r)))begin@(posedge clk1x)if(!pre_rst)begin$fscanf(fp_r,"%h",txt_data);$display("%h",txt_data);endendendend
- initial beginfp_w=$fopen("./result_data_8b10b.txt","w");if(!fp_w)begin$display("Write File Error.");$fclose(fp_w);end@(posedge clk1x)beginwhile(!($feof(fp_r)))begin@(posedge clk1x)$fwrite(fp_w, "%h\n", txt_data);$display("%h",dtout);endend$fclose(fp_w);$stop;end
- always #5 clk1x_tmp =!clk1x_tmp;
- always #2.5 clk2x_tmp =!clk2x_tmp;
- assign #1 clk2x= clk2x_tmp;
- assign clk1x= clk1x_tmp;
- assign txd_data= txt_data[15:0];assign tklsb=txt_data[16];assign tkmsb=txt_data[17];assign rstn=~rst;
- endmodule
求助帮忙,谢谢