-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.v
executable file
·129 lines (94 loc) · 3.83 KB
/
config.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
`ifndef _my_incl_vh_
`define _my_incl_vh_
/*
For new version
*/
// `define SPARSE
`define GET_2D(regfile, D2, BL, i, j) regfile[((i)*D2 + (j))*BL+BL-1 -: BL]
`define GET_1D(regfile, BL, i) regfile[(i)*BL+BL-1 -: BL]
`define ASSERT(condition, msg) if(condition) begin $display(msg); $finish(1); end
/*
# For RandomGenerator
## Problem
- not fully configurable, number of xor is hard coded
*/
`define R_1 8-1
`define R_2 6-1
`define R_3 5-1
`define R_4 4-1
`define TB_SEED 4
`define TB_RG_DUMPFILE "./dumpFolder/RG.vcd"
`define ReadMem(x,y) $readmemh(x,y)
`define DEFINE_READMEM_VAR integer rm_file, rm_temp
// `define ReadMem(path, mem) \
// rm_file = $fopen(path, "r"); \
// rm_temp = $fread(mem, rm_file); \
// rm_temp = $fclose(rm_file)
/*
Utility
*/
`define PORT_2D(D1,D2,BL) (BL*D1*D2)-1:0
`define PORT_1D(D,BL) (BL*D)-1:0
`define DIM_3D(D1,D2,D3) [0:D1-1][0:D2-1][0:D3-1]
`define DIM_2D(D1,D2) [0:D1-1][0:D2-1]
`define DIM_1D(D1) [0:D1-1]
`define DEFINE_PACK_VAR genvar pk_i,pk_j
`define PACK_2D_ARRAY(D1,D2, BL,src,dst) \
generate \
for(pk_i=1; pk_i<=D1; pk_i=pk_i+1) \
for(pk_j=1; pk_j<=D2; pk_j=pk_j+1) \
assign dst[(((pk_i-1)*D2 + (pk_j-1))*BL)+BL-1 -: BL] = src[pk_i-1][pk_j-1]; \
endgenerate
`define UNPACK_2D_ARRAY(D1,D2, BL,src,dst) \
generate \
for(pk_i=1; pk_i<=D1; pk_i=pk_i+1) \
for(pk_j=1; pk_j<=D2; pk_j=pk_j+1) \
assign dst[pk_i-1][pk_j-1] = src[(((pk_i-1)*D2 + (pk_j-1))*BL)+BL-1 -: BL]; \
endgenerate
`define PACK_1D_ARRAY(D1, BL,src,dst) \
generate \
for(pk_i=1; pk_i<=D1; pk_i=pk_i+1) \
assign dst[((pk_i-1)*BL)+BL-1 -: BL] = src[pk_i-1]; \
endgenerate
`define UNPACK_1D_ARRAY(D1,BL,src,dst) \
generate \
for(pk_i=1; pk_i<=D1; pk_i=pk_i+1) \
assign dst[pk_i-1] = src[((pk_i-1)*BL)+BL-1 -: BL]; \
endgenerate
`define D1_TO_D2_ARRAY(D1, D2, d1array, d2array) \
generate \
for(pk_i=0;pk_i<D1;pk_i=pk_i+1) \
for(pk_j=0;pk_j<D2;pk_j=pk_j+1) \
assign d2array[pk_i][pk_j] = d1array[pk_i*D2+pk_j]; \
endgenerate
// array printing
`define DEFINE_PRINTING_VAR integer pt_i, pt_j
`define DISPLAY_1D_ARRAY(D1,msg, array) \
$display("%s", msg); \
for(pt_i = 0; pt_i < D1; pt_i=pt_i+1) begin \
$display("%0d ", array[pt_i]); \
end \
$display("\n");
`define DISPLAY_2D_ARRAY(D1, D2,msg, array) \
$display("%s", msg); \
for(pt_i = 0; pt_i < D1; pt_i=pt_i+1) begin \
for(pt_j = 0; pt_j < D2; pt_j=pt_j+1) begin \
$display("%0d ", array[pt_i][pt_j]); \
end \
$display("\n===="); \
end \
$display("\n");
`define DISPLAY_1D_BIT_ARRAY(D1, BL, msg, array) \
$display("%s", msg); \
for(pt_i = 1 ;pt_i < D1+1; pt_i=pt_i+1) begin \
$display("%0d ", array[((pt_i-1)*BL)+BL-1 -: BL]); \
end \
$display("\n");
`define DISPLAY_2D_BIT_ARRAY(D1,D2, BL, msg, array) \
$display("%s", msg); \
for(pt_i = 1 ;pt_i <= D1; pt_i=pt_i+1) \
for(pt_j = 1; pt_j <= D2; pt_j=pt_j+1) begin \
$display("%0d ", array[(((pt_i-1)*D2 + (pt_j-1))*BL)+BL-1 -: BL]); \
end \
$display("\n====");
`endif