|
| 1 | +#ifndef CONFIGCCCC |
| 2 | +#define CONFIGCCCC |
| 3 | + |
| 4 | +#include "/home/lsq/software/Vitis_2022.1/Vitis_HLS/2022.1/include/gmp.h" |
| 5 | +#include <stdint.h> |
| 6 | +#include <hls_stream.h> |
| 7 | +#include <ap_fixed.h> |
| 8 | +#include <string.h> |
| 9 | + |
| 10 | +typedef float val_t; |
| 11 | +typedef uint32_t id_t; |
| 12 | + |
| 13 | +#define CACHE_FIRST_HIT 1 |
| 14 | +#define CACHE_FIRST_MISS 2 |
| 15 | +#define CACHE_IDLE 3 |
| 16 | +#define CACHE_READ 1 |
| 17 | +#define CACHE_WRITE 2 |
| 18 | +#define CACHE_FIRST_READ 0 |
| 19 | + |
| 20 | +#define RCACHE_CACHELINE_BYTES 16 |
| 21 | +#define RCACHE_SET_NUM 128 |
| 22 | +#define RCACHE_BANK_NUM 32 |
| 23 | +#define RCACHE_TAG_OFFSET 11 |
| 24 | + |
| 25 | +#define VCCACHE_CACHELINE_BYTES 16 |
| 26 | +#define VCCACHE_SET_NUM 512 |
| 27 | +#define VCCACHE_BANK_NUM 256 |
| 28 | +#define VCCACHE_TAG_OFFSET 13 |
| 29 | + |
| 30 | +#define B_VAL 0 |
| 31 | +#define B_CID 1 |
| 32 | + |
| 33 | +#define TERMINATE 0xFFFFFFFF |
| 34 | + |
| 35 | +struct rcsr { |
| 36 | + id_t ridx; |
| 37 | + id_t rlen; |
| 38 | +}; |
| 39 | + |
| 40 | +struct rinfo { |
| 41 | + id_t rid; |
| 42 | + id_t rlen; |
| 43 | +}; |
| 44 | + |
| 45 | +struct Avc { |
| 46 | + val_t val; |
| 47 | + id_t cid; |
| 48 | + id_t rid; |
| 49 | +}; |
| 50 | + |
| 51 | +struct __attribute__ ((packed)) pe_job { |
| 52 | + val_t val; |
| 53 | + id_t rid; |
| 54 | + bool partial_end; |
| 55 | + bool end; |
| 56 | +}; |
| 57 | + |
| 58 | +struct __attribute__ ((packed)) rcache_request { |
| 59 | + ap_uint<3> dest; |
| 60 | + bool end; |
| 61 | + ap_uint<2> type; |
| 62 | + id_t Acid; |
| 63 | + id_t Acid1; |
| 64 | + ap_uint<160> data; |
| 65 | +}; |
| 66 | + |
| 67 | +struct __attribute__ ((packed)) rcache_response { |
| 68 | + bool end; |
| 69 | + bool no_use; |
| 70 | + ap_uint<3> dest; |
| 71 | + ap_uint<3> result; |
| 72 | + ap_uint<160> data; |
| 73 | +}; |
| 74 | + |
| 75 | +struct __attribute__ ((packed)) manager_idle { |
| 76 | + bool end; |
| 77 | + ap_uint<3> dest; |
| 78 | + bool idle; |
| 79 | +}; |
| 80 | + |
| 81 | +struct __attribute__ ((packed)) B_row_request { |
| 82 | + bool end; |
| 83 | + ap_uint<3> peID; |
| 84 | + id_t bridx; |
| 85 | + id_t brlen; |
| 86 | +}; |
| 87 | + |
| 88 | +struct __attribute__ ((packed)) lru_struct { |
| 89 | + id_t way_n; |
| 90 | + id_t counter; |
| 91 | +}; |
| 92 | + |
| 93 | +struct __attribute__ ((packed)) vccache_request { |
| 94 | + bool end; |
| 95 | + ap_uint<2> target; |
| 96 | + ap_uint<3> type; |
| 97 | + ap_uint<3> peID; |
| 98 | + ap_uint<5> dest; |
| 99 | + ap_uint<3> write_idx; |
| 100 | + id_t brid; |
| 101 | + id_t brlen; |
| 102 | + ap_uint<128> data; |
| 103 | +}; |
| 104 | + |
| 105 | +struct __attribute__ ((packed)) vccache_result { |
| 106 | + bool end; |
| 107 | + ap_uint<3> type; |
| 108 | + ap_uint<3> peID; |
| 109 | + ap_uint<1024> data; |
| 110 | +}; |
| 111 | + |
| 112 | +struct __attribute__ ((packed)) vccache_response { |
| 113 | + ap_uint<2> result; |
| 114 | + bool end; |
| 115 | + ap_uint<3> peID; |
| 116 | +}; |
| 117 | + |
| 118 | +struct __attribute__ ((packed)) internal_control { |
| 119 | + bool end; |
| 120 | + ap_uint<3> peID; |
| 121 | + id_t bridx; |
| 122 | + id_t brlen; |
| 123 | +}; |
| 124 | + |
| 125 | +struct __attribute__ ((packed)) merge_item { |
| 126 | + val_t val; |
| 127 | + id_t cid; |
| 128 | + bool end; |
| 129 | + bool global_end; |
| 130 | +}; |
| 131 | + |
| 132 | +struct __attribute__ ((packed)) merge_control { |
| 133 | + id_t rid; |
| 134 | + id_t rlen; |
| 135 | + bool end; |
| 136 | + bool partial_end; |
| 137 | +}; |
| 138 | + |
| 139 | +struct __attribute__ ((packed)) merge_control_r { |
| 140 | + ap_uint<2> source; |
| 141 | + bool whether_push; |
| 142 | + id_t rlen; |
| 143 | + bool end; |
| 144 | +}; |
| 145 | + |
| 146 | +struct __attribute__ ((packed)) vccache_block { |
| 147 | + ap_uint<3> peID; |
| 148 | + bool end; |
| 149 | + ap_uint<128> data; |
| 150 | +}; |
| 151 | + |
| 152 | +struct __attribute__ ((packed)) block { |
| 153 | + ap_uint<3> begin; |
| 154 | + ap_uint<3> end; |
| 155 | + ap_uint<128> data; |
| 156 | +}; |
| 157 | + |
| 158 | +struct __attribute__ ((packed)) partial_block { |
| 159 | + ap_uint<128> data; |
| 160 | + ap_uint<128> cid; |
| 161 | + ap_uint<3> begin; |
| 162 | + ap_uint<3> end; |
| 163 | + bool finish; |
| 164 | +}; |
| 165 | + |
| 166 | +struct __attribute__ ((packed)) off_chip_access { |
| 167 | + bool end; |
| 168 | + ap_uint<3> type; |
| 169 | + id_t begin; |
| 170 | + id_t last; |
| 171 | + ap_uint<5> sourceID; |
| 172 | +}; |
| 173 | + |
| 174 | +typedef hls::stream<id_t> id_stream; |
| 175 | +typedef hls::stream<val_t> val_stream; |
| 176 | +typedef hls::stream<rinfo> rinfo_stream; |
| 177 | +typedef hls::stream<Avc> avc_stream; |
| 178 | +typedef hls::stream<pe_job> pe_stream; |
| 179 | +typedef hls::stream<rcache_request> rcache_stream; |
| 180 | +typedef hls::stream<rcache_response> rresponse_stream; |
| 181 | + |
| 182 | +typedef hls::stream<B_row_request> B_request_stream; |
| 183 | +typedef hls::stream<vccache_request> vcrequest_stream; |
| 184 | +typedef hls::stream<vccache_response> vcresponse_stream; |
| 185 | +typedef hls::stream<vccache_result> vcresult_stream; |
| 186 | + |
| 187 | + |
| 188 | +typedef hls::stream<internal_control> internal_control_stream; |
| 189 | + |
| 190 | +typedef hls::stream<vccache_block> vcblock_stream; |
| 191 | +typedef hls::stream<block> block_stream; |
| 192 | + |
| 193 | +typedef hls::stream<partial_block> partial_stream; |
| 194 | + |
| 195 | +typedef hls::stream<merge_item> merge_stream; |
| 196 | +typedef hls::stream<merge_control> mcontrol_stream; |
| 197 | +typedef hls::stream<merge_control_r> mcontrolr_stream; |
| 198 | + |
| 199 | +typedef hls::stream<ap_uint<128> > B_data_stream; |
| 200 | +typedef hls::stream<ap_uint<160> > rcacheline_stream; |
| 201 | +typedef hls::stream<ap_uint<1024> > cacheline_stream; |
| 202 | + |
| 203 | +typedef hls::stream<off_chip_access> off_chip_stream; |
| 204 | + |
| 205 | +typedef hls::stream<bool> bool_stream; |
| 206 | +typedef hls::stream<manager_idle> mi_stream; |
| 207 | + |
| 208 | +template<typename To, typename From> |
| 209 | +inline To Reinterpret(const From& val){ |
| 210 | + return reinterpret_cast<const To&>(val); |
| 211 | +} |
| 212 | + |
| 213 | +void spmm(id_t* A_rcsr, id_t* A_cid, val_t* A_val, id_t arnum, id_t atnum, |
| 214 | + ap_uint<128>* B_rcsr1, ap_uint<128>* B_rcsr2, ap_uint<128>* B_rcsr3, ap_uint<128>* B_rcsr4, |
| 215 | + id_t* B_rcsr5, id_t* B_rcsr6, id_t* B_rcsr7, id_t* B_rcsr8, |
| 216 | + ap_uint<128>* B_val1, ap_uint<128>* B_cid1, ap_uint<128>* B_val2, ap_uint<128>* B_cid2, |
| 217 | + ap_uint<128>* B_val3, ap_uint<128>* B_cid3, ap_uint<128>* B_val4, ap_uint<128>* B_cid4, |
| 218 | + ap_uint<128>* B_val5, ap_uint<128>* B_cid5, ap_uint<128>* B_val6, ap_uint<128>* B_cid6, |
| 219 | + ap_uint<128>* B_val7, ap_uint<128>* B_cid7, ap_uint<128>* B_val8, ap_uint<128>* B_cid8, |
| 220 | + id_t brnum, id_t btnum, ap_uint<128>* B_val_port1, ap_uint<128>* B_cid_port1, |
| 221 | + ap_uint<128>* B_val_port2, ap_uint<128>* B_cid_port2, ap_uint<128>* B_val_port3, ap_uint<128>* B_cid_port3, |
| 222 | + ap_uint<128>* B_val_port4, ap_uint<128>* B_cid_port4, |
| 223 | + id_t* C_rcsr, id_t* C_cid, val_t* C_val, |
| 224 | + id_t B_rcsr_base, id_t B_val_base, id_t B_cid_base, |
| 225 | + id_t* r1acc, id_t* r1hit, id_t* r2acc, id_t* r2hit, id_t* r3acc, id_t* r3hit, id_t* r4acc, id_t* r4hit, |
| 226 | + id_t* r5acc, id_t* r5hit, id_t* r6acc, id_t* r6hit, id_t* r7acc, id_t* r7hit, id_t* r8acc, id_t* r8hit, |
| 227 | + id_t* vc1acc, id_t* vc1hit, id_t* vc2acc, id_t* vc2hit, id_t* vc3acc, id_t* vc3hit, id_t* vc4acc, id_t* vc4hit, |
| 228 | + id_t* vc5acc, id_t* vc5hit, id_t* vc6acc, id_t* vc6hit, id_t* vc7acc, id_t* vc7hit, id_t* vc8acc, id_t* vc8hit, |
| 229 | + id_t* fnum); |
| 230 | + |
| 231 | +#endif |
0 commit comments