1 `timescale 1ns / 1ps
2 //////////////////////////////////////////////////////////////////////////////////
3 // Company:
4 // Engineer:
5 //
6 // Create Date: 2018/10/24 10:33:54
7 // Design Name:
8 // Module Name: logic_write_file
9 // Project Name:
10 // Target Devices:
11 // Tool Versions:
12 // Description:
13 //
14 // Dependencies:
15 //
16 // Revision:
17 // Revision 0.01 - File Created
18 // Additional Comments:
19 //
20 //////////////////////////////////////////////////////////////////////////////////
21
22
23 module logic_write_file();
24
25 //
内部变量
26 integer file ;//
读文件
27 integer wirte_file ;//
写文件
28 integer read_code ;//
读文件变量
29 bit[7:0] file_date[8] ;//
读文件数组
(
读文件
ascii
码
)
30 logic[3:0] ascii_date[8] ;//16
进制数组
(16
进制
)
31 logic[7:0] debug_reg ;//
调试变量
32
33 //
类定义
34
35 //class
36 class write_file_finish;
37 string str = "WRITE FILE FINISH";//
类定义字符串
38 endclass
39
40 //class
41 class error_reminder;
42 string str = "ERROR REMINDER";//
类定义字符串
43 endclass
44
45 //
声明类
write_file_finish
46 write_file_finish wff;
47
48 //
声明类
error_reminder
49 error_reminder er;
50
51 //
读文件操作
52 //initial
53 initial begin
54
55 //
类
error_reminder
分配内存
56 er = new();
57
58 //
读文件数据(文件路径定义清楚)
59 file = $fopen("E:/V7/lacp_top/fpga_src/sim/1.dat", "rb");
60
61 //
文件数据存储到数据(文件中的数据必须为行数据,列数据不支持)
62 read_code = $fread(file_date, file);
63
64 //
文件数据读取完成关闭文件
65 $fclose(file);
66
67 //
打印数组中的数据
68 foreach(file_date[i])begin
69 $display("file_date[%0d] = %h", i, file_date[i]);
70 end
71
72 //
将
ascii
码转换为
16
进制
73 for(int j = 0;j < $size(file_date); j++)begin
评论5