|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
通过$fscanf读取文件,对应的代码在VCS和Modelsim编译运行可以(有警告,说是期望遇到一个任务,但实际遇到一个函数)
在NCELAB时报告了如下错误:
Function name encountered. Expecting a task name. [2.7.4(IEEE Std 1364-2001)].
根据日志出问题的地方在“$fscanf(fp_r,"%h",txt_data);”这个地方
- `timescale 1ns / 1ps
- module tb_gen_data(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;
- initial
- begin
- #10
- clk1x_tmp <= 0;
- clk2x_tmp <= 0;
- rst <=1;
- pre_rst<=1;
- #47 pre_rst <=0;
- #1 rst <=0;
- end
- initial
- begin
- fp_r=$fopen("./base_data_8b10b.txt","r");
-
- if(!fp_r)begin
- $display("Read File Error.");
- $fclose(fp_r);
- end
-
- @(posedge clk1x)
- begin
- while(!($feof(fp_r)))
- begin
- @(posedge clk1x)
- if(!pre_rst)begin
- $fscanf(fp_r,"%h",txt_data);
- $display("%h",txt_data);
- end
- end
- end
- end
- initial begin
- fp_w=$fopen("./result_data_8b10b.txt","w");
- if(!fp_w)begin
- $display("Write File Error.");
- $fclose(fp_w);
- end
-
- @(posedge clk1x)
- begin
- while(!($feof(fp_r)))
- begin
- @(posedge clk1x)
- $fwrite(fp_w, "%h\n", txt_data);
- $display("%h",dtout);
- end
- end
- $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
复制代码 |
|