├── .gitignore ├── README.md ├── app ├── clog2coverage │ ├── Makefile │ ├── Makefile.config │ └── src │ │ ├── clog2coverage.hpp │ │ ├── clog2coverage_b.cpp │ │ └── clog2coverage_eb.cpp ├── clog2log │ ├── Makefile │ ├── Makefile.config │ └── src │ │ ├── clog2log.hpp │ │ ├── clog2log_b.cpp │ │ └── clog2log_eb.cpp ├── clog2mkcfg │ ├── Makefile │ └── src │ │ ├── clog2mkcfg.cpp │ │ └── clog2mkcfg.hpp ├── report_flit │ ├── Makefile │ ├── Makefile.config │ └── src │ │ ├── report_flit.hpp │ │ ├── report_flit_b.cpp │ │ ├── report_flit_c.cpp │ │ └── report_flit_eb.cpp └── xsdb2clog │ ├── Makefile │ └── src │ ├── xsdb2clog.cpp │ └── xsdb2clog.hpp ├── chi ├── basic │ ├── chi_conn.hpp │ └── chi_parameters.hpp ├── spec │ ├── chi_link_channels.hpp │ ├── chi_link_channels_header.hpp │ ├── chi_link_interfaces.hpp │ ├── chi_link_interfaces_header.hpp │ ├── chi_link_links.hpp │ ├── chi_link_links_header.hpp │ ├── chi_link_ports.hpp │ ├── chi_link_ports_header.hpp │ ├── chi_protocol_encoding.hpp │ ├── chi_protocol_encoding_header.hpp │ ├── chi_protocol_flits.hpp │ └── chi_protocol_flits_header.hpp ├── util │ ├── chi_util_decoding.hpp │ ├── chi_util_decoding_header.hpp │ ├── chi_util_flit.hpp │ └── chi_util_flit_header.hpp └── xact │ ├── chi_joint.hpp │ ├── chi_joint_header.hpp │ ├── chi_xact_base.hpp │ ├── chi_xact_base_header.hpp │ ├── chi_xact_checkers_field.hpp │ ├── chi_xact_checkers_field_header.hpp │ ├── chi_xact_field.hpp │ ├── chi_xact_field_eb.hpp │ ├── chi_xact_field_header.hpp │ ├── chi_xactions.hpp │ └── chi_xactions_header.hpp ├── chi_b ├── spec │ ├── chi_b_link.hpp │ ├── chi_b_link_channels.hpp │ ├── chi_b_link_interfaces.hpp │ ├── chi_b_link_links.hpp │ ├── chi_b_link_ports.hpp │ ├── chi_b_protocol.hpp │ ├── chi_b_protocol_encoding.hpp │ └── chi_b_protocol_flits.hpp └── util │ ├── chi_b_util_decoding.hpp │ └── chi_b_util_flit.hpp ├── chi_c └── spec │ └── chi_c_protocol_flits.hpp ├── chi_eb ├── spec │ ├── chi_eb_link.hpp │ ├── chi_eb_link_channels.hpp │ ├── chi_eb_link_interfaces.hpp │ ├── chi_eb_link_links.hpp │ ├── chi_eb_link_ports.hpp │ ├── chi_eb_protocol.hpp │ ├── chi_eb_protocol_encoding.hpp │ └── chi_eb_protocol_flits.hpp ├── util │ ├── chi_eb_util_decoding.hpp │ └── chi_eb_util_flit.hpp └── xact │ ├── chi_eb_joint.hpp │ ├── chi_eb_xact_base.hpp │ ├── chi_eb_xact_checkers_field.hpp │ ├── chi_eb_xact_field.hpp │ └── chi_eb_xactions.hpp ├── clog ├── clog.hpp ├── clog_b │ ├── clog_b.hpp │ ├── clog_b_tag.hpp │ ├── clogdpi_b.cpp │ ├── clogdpi_b.hpp │ └── clogdpi_b.svh └── clog_t │ ├── clog_t.hpp │ ├── clog_t_util.hpp │ ├── clogdpi_t.cpp │ ├── clogdpi_t.hpp │ └── clogdpi_t.svh └── common ├── concurrentqueue.hpp ├── eventbus.hpp ├── nonstdint.hpp └── utility.hpp /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | out 3 | *.user 4 | *.run 5 | *.log 6 | *.out 7 | .vscode -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CHIron: Open-source AMBA CHI Infrastructure 2 | 3 | ## Summary 4 | 5 | > World's first open-source AMBA CHI toolset 6 | 7 | - **Currently serving or served XiangShan in-house development** ([About OpenXiangShan](https://github.com/OpenXiangShan)) 8 | - Currently mainly supporting AMBA CHI Issue E, with basic support and future plan for Issue B/C/G 9 | - Constructing complete protocol level abstraction 10 | - Completing transaction level abstraction 11 | - Fully covered demands of XiangShan Kunminghu V2 12 | - Designed to be infrastructure of infrastructures 13 | - Aimed at supporting prototyping, testing, verification and profiling demands 14 | - All codes were designed to be API, feel free to call or modify 15 | - Possible to be kernel or UVMs, but no longer stuck on UVM platforms 16 | - **Freedom to use in open-source projects** 17 | 18 | ## Documentations 19 | 20 | **Sorry, no public documentation available for now :(** 21 | But we are going to work on this part in near future! 22 | 23 | ----------------------- 24 | 25 | [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/RISMicroDevices/CHIron) for project preview. -------------------------------------------------------------------------------- /app/clog2coverage/Makefile: -------------------------------------------------------------------------------- 1 | ISSUE ?= B 2 | O ?= build 3 | 4 | SRC_DIR := src 5 | BUILD_DIR := $(O) 6 | 7 | CHIRON_DIR := ../.. 8 | 9 | -include Makefile.user 10 | -include Makefile.config 11 | 12 | ifeq ($(ISSUE), B) 13 | main := $(SRC_DIR)/clog2coverage_b.cpp 14 | endif 15 | 16 | ifeq ($(ISSUE), E.b) 17 | main := $(SRC_DIR)/clog2coverage_eb.cpp 18 | endif 19 | 20 | ifeq ($(main),) 21 | $(error "Unknown CHI Issue specified: $(ISSUE)") 22 | endif 23 | 24 | build: $(main) FORCE 25 | test -d $(BUILD_DIR) || mkdir $(BUILD_DIR) 26 | $(CXX) -std=c++20 -O3 $(main) -I$(SRC_DIR) -I$(CHIRON_DIR) -lz -o $(BUILD_DIR)/clog2coverage \ 27 | -DCHI_NODEID_WIDTH=$(NODEID_WIDTH) \ 28 | -DCHI_REQ_ADDR_WIDTH=$(REQ_ADDR_WIDTH) \ 29 | -DCHI_REQ_RSVDC_WIDTH=$(REQ_RSVDC_WIDTH) \ 30 | -DCHI_DAT_RSVDC_WIDTH=$(DAT_RSVDC_WIDTH) \ 31 | -DCHI_DATA_WIDTH=$(DATA_WIDTH) \ 32 | -DCHI_DATACHECK_PRESENT=$(DATACHECK_PRESENT) \ 33 | -DCHI_POISON_PRESENT=$(POISON_PRESENT) \ 34 | -DCHI_MPAM_PRESENT=$(MPAM_PRESENT) 35 | 36 | run: 37 | @$(BUILD_DIR)/./clog2coverage 38 | 39 | clean: 40 | rm -rf build 41 | 42 | FORCE: 43 | .PHONY: FORCE 44 | -------------------------------------------------------------------------------- /app/clog2coverage/Makefile.config: -------------------------------------------------------------------------------- 1 | # 2 | # Change / create your CHI flit configuration here 3 | # 4 | 5 | # 6 | # The CHI Issue. 7 | # Permitted value: "B", "E.b" 8 | # 9 | ISSUE ?= B 10 | 11 | # 12 | # The width of Node ID. 13 | # Permitted value: 7 to 11 14 | # 15 | NODEID_WIDTH ?= 7 16 | 17 | # 18 | # The width of address of REQ flit, which also effects the SNP flit. 19 | # Permitted value: 44 to 52 20 | # 21 | REQ_ADDR_WIDTH ?= 48 22 | 23 | # 24 | # The width of RSVDC field of REQ flit. 25 | # Permitted value: 0 or 4, 8, 12, 16, 24, 32 26 | # 27 | REQ_RSVDC_WIDTH ?= 0 28 | 29 | # 30 | # The width of RSVDC field of DAT flit. 31 | # Permitted value: 0 or 4, 8, 12, 16, 24, 32 32 | # 33 | DAT_RSVDC_WIDTH ?= 0 34 | 35 | # 36 | # The width of Data field of DAT flit. 37 | # Permitted value: 128, 256, 512 38 | # 39 | DATA_WIDTH ?= 256 40 | 41 | # 42 | # The presence of DataCheck field of DAT flit. 43 | # Permitted value: true, false, 0, 1 44 | # 45 | DATACHECK_PRESENT ?= false 46 | 47 | # 48 | # The presence of Poison field of DAT flit. 49 | # Permitted value: true, false, 0, 1 50 | # 51 | POISON_PRESENT ?= false 52 | 53 | # 54 | # The presence of MPAM field. 55 | # *Only applicable in Issue E.b* 56 | # Permitted value: true, false, 0, 1 57 | # 58 | MPAM_PRESENT ?= false 59 | -------------------------------------------------------------------------------- /app/clog2coverage/src/clog2coverage_b.cpp: -------------------------------------------------------------------------------- 1 | #define CLOG2COVERAGE__STANDALONE 2 | 3 | #define CHI_ISSUE_B_ENABLE 4 | #include "clog2coverage.hpp" 5 | #undef CHI_ISSUE_B_ENABLE 6 | 7 | int main(int argc, char* argv[]) 8 | { 9 | return clog2coverage(argc, argv); 10 | } 11 | -------------------------------------------------------------------------------- /app/clog2coverage/src/clog2coverage_eb.cpp: -------------------------------------------------------------------------------- 1 | #define CLOG2COVERAGE__STANDALONE 2 | 3 | #define CHI_ISSUE_EB_ENABLE 4 | #include "clog2coverage.hpp" 5 | #undef CHI_ISSUE_EB_ENABLE 6 | 7 | int main(int argc, char* argv[]) 8 | { 9 | return clog2coverage(argc, argv); 10 | } 11 | -------------------------------------------------------------------------------- /app/clog2log/Makefile: -------------------------------------------------------------------------------- 1 | ISSUE ?= B 2 | O ?= build 3 | 4 | SRC_DIR := src 5 | BUILD_DIR := $(O) 6 | 7 | CHIRON_DIR := ../.. 8 | 9 | -include Makefile.user 10 | -include Makefile.config 11 | 12 | ifeq ($(ISSUE), B) 13 | main := $(SRC_DIR)/clog2log_b.cpp 14 | endif 15 | 16 | ifeq ($(ISSUE), E.b) 17 | main := $(SRC_DIR)/clog2log_eb.cpp 18 | endif 19 | 20 | ifeq ($(main),) 21 | $(error "Unknown CHI Issue specified: $(ISSUE)") 22 | endif 23 | 24 | build: $(main) FORCE 25 | test -d $(BUILD_DIR) || mkdir $(BUILD_DIR) 26 | $(CXX) -std=c++20 -O3 $(main) -I$(SRC_DIR) -I$(CHIRON_DIR) -lz -o $(BUILD_DIR)/clog2log \ 27 | -DCHI_NODEID_WIDTH=$(NODEID_WIDTH) \ 28 | -DCHI_REQ_ADDR_WIDTH=$(REQ_ADDR_WIDTH) \ 29 | -DCHI_REQ_RSVDC_WIDTH=$(REQ_RSVDC_WIDTH) \ 30 | -DCHI_DAT_RSVDC_WIDTH=$(DAT_RSVDC_WIDTH) \ 31 | -DCHI_DATA_WIDTH=$(DATA_WIDTH) \ 32 | -DCHI_DATACHECK_PRESENT=$(DATACHECK_PRESENT) \ 33 | -DCHI_POISON_PRESENT=$(POISON_PRESENT) \ 34 | -DCHI_MPAM_PRESENT=$(MPAM_PRESENT) 35 | 36 | run: 37 | @$(BUILD_DIR)/./clog2log 38 | 39 | clean: 40 | rm -rf build 41 | 42 | FORCE: 43 | .PHONY: FORCE 44 | -------------------------------------------------------------------------------- /app/clog2log/Makefile.config: -------------------------------------------------------------------------------- 1 | # 2 | # Change / create your CHI flit configuration here 3 | # 4 | 5 | # 6 | # The CHI Issue. 7 | # Permitted value: "B", "E.b" 8 | # 9 | ISSUE ?= B 10 | 11 | # 12 | # The width of Node ID. 13 | # Permitted value: 7 to 11 14 | # 15 | NODEID_WIDTH ?= 7 16 | 17 | # 18 | # The width of address of REQ flit, which also effects the SNP flit. 19 | # Permitted value: 44 to 52 20 | # 21 | REQ_ADDR_WIDTH ?= 48 22 | 23 | # 24 | # The width of RSVDC field of REQ flit. 25 | # Permitted value: 0 or 4, 8, 12, 16, 24, 32 26 | # 27 | REQ_RSVDC_WIDTH ?= 0 28 | 29 | # 30 | # The width of RSVDC field of DAT flit. 31 | # Permitted value: 0 or 4, 8, 12, 16, 24, 32 32 | # 33 | DAT_RSVDC_WIDTH ?= 0 34 | 35 | # 36 | # The width of Data field of DAT flit. 37 | # Permitted value: 128, 256, 512 38 | # 39 | DATA_WIDTH ?= 256 40 | 41 | # 42 | # The presence of DataCheck field of DAT flit. 43 | # Permitted value: true, false, 0, 1 44 | # 45 | DATACHECK_PRESENT ?= false 46 | 47 | # 48 | # The presence of Poison field of DAT flit. 49 | # Permitted value: true, false, 0, 1 50 | # 51 | POISON_PRESENT ?= false 52 | 53 | # 54 | # The presence of MPAM field. 55 | # *Only applicable in Issue E.b* 56 | # Permitted value: true, false, 0, 1 57 | # 58 | MPAM_PRESENT ?= false 59 | -------------------------------------------------------------------------------- /app/clog2log/src/clog2log_b.cpp: -------------------------------------------------------------------------------- 1 | #define CLOG2LOG__STANDALONE 2 | 3 | #define CHI_ISSUE_B_ENABLE 4 | #include "clog2log.hpp" 5 | #undef CHI_ISSUE_B_ENABLE 6 | 7 | int main(int argc, char* argv[]) 8 | { 9 | return clog2log(argc, argv); 10 | } 11 | -------------------------------------------------------------------------------- /app/clog2log/src/clog2log_eb.cpp: -------------------------------------------------------------------------------- 1 | #define CLOG2LOG__STANDALONE 2 | 3 | #define CHI_ISSUE_EB_ENABLE 4 | #include "clog2log.hpp" 5 | #undef CHI_ISSUE_EB_ENABLE 6 | 7 | int main(int argc, char* argv[]) 8 | { 9 | return clog2log(argc, argv); 10 | } 11 | -------------------------------------------------------------------------------- /app/clog2mkcfg/Makefile: -------------------------------------------------------------------------------- 1 | O ?= build 2 | 3 | SRC_DIR := src 4 | BUILD_DIR := $(O) 5 | 6 | CHIRON_DIR := ../.. 7 | 8 | build: FORCE 9 | test -d $(BUILD_DIR) || mkdir $(BUILD_DIR) 10 | $(CXX) -std=c++20 $(SRC_DIR)/clog2mkcfg.cpp -I$(SRC_DIR) -I$(CHIRON_DIR) \ 11 | -o $(BUILD_DIR)/clog2mkcfg 12 | 13 | run: 14 | @$(BUILD_DIR)/./clog2mkcfg --version 15 | 16 | clean: 17 | rm -rf build 18 | 19 | FORCE: 20 | .PHONY: FORCE 21 | -------------------------------------------------------------------------------- /app/clog2mkcfg/src/clog2mkcfg.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "../../../clog/clog_t/clog_t.hpp" 8 | #include "../../../clog/clog_t/clog_t_util.hpp" 9 | 10 | // 11 | std::ostream* output; 12 | 13 | // 14 | static std::string ToString(CLog::Issue issue) noexcept 15 | { 16 | switch (issue) 17 | { 18 | case CLog::Issue::B: return "B"; 19 | case CLog::Issue::Eb: return "E.b"; 20 | default: return ""; 21 | } 22 | } 23 | 24 | // 25 | static void print_version() noexcept 26 | { 27 | std::cerr << std::endl; 28 | std::cerr << " CHIron Toolset" << std::endl; 29 | std::cerr << std::endl; 30 | std::cerr << " xsdb2clog - " << __DATE__ << std::endl; 31 | std::cerr << std::endl; 32 | std::cerr << " clog2mkcfg: CLog to CHIron Makefile configuration extractor" << std::endl; 33 | std::cerr << std::endl; 34 | } 35 | 36 | static void print_help() noexcept 37 | { 38 | std::cout << "Usage: clog2mkcfg [OPTION...]" << std::endl; 39 | std::cout << std::endl; 40 | std::cout << " -h, --help print help info" << std::endl; 41 | std::cout << " -v, --version print version info" << std::endl; 42 | std::cout << " -o, --output=FILE specify makefile output. by default, the makefile output" << std::endl; 43 | std::cout << " is written to the standard console output" << std::endl; 44 | std::cout << " -T, --clogT *default* specify output format as CLog.T" << std::endl; 45 | std::cout << " -B, --clogB [WIP] specify output format as CLog.B" << std::endl; 46 | std::cout << " -Z, --clogBz [WIP] specify output format as CLog.Bz" << std::endl; 47 | std::cout << " -f, --param-file=FILE specify CLog input files for CHI parameters" << std::endl; 48 | std::cout << " -s, --seg, --segment enable segment mode for CLog input files for CHI parameters" << std::endl; 49 | std::cout << std::endl; 50 | } 51 | 52 | int main(int argc, char* argv[]) 53 | { 54 | // 55 | std::string outputFile; 56 | 57 | std::vector clogParamFiles; 58 | bool clogParamFilesSegmentMode = false; 59 | 60 | // input parameters 61 | const struct option long_options[] = { 62 | { "help" , 0, NULL, 'h' }, 63 | { "version" , 0, NULL, 'v' }, 64 | { "output" , 1, NULL, 'o' }, 65 | { "clogT" , 0, NULL, 'T' }, 66 | { "clogB" , 0, NULL, 'B' }, 67 | { "clogBz" , 0, NULL, 'Z' }, 68 | { "segment" , 0, NULL, 's' }, 69 | { "seg" , 0, NULL, 's' }, 70 | { "param-file" , 1, NULL, 'f' }, 71 | { 0 , 0, NULL, 0 } 72 | }; 73 | 74 | int long_index = 0; 75 | int o; 76 | while ((o = getopt_long(argc, argv, "hvo:TBZsf:", long_options, &long_index)) != -1) 77 | { 78 | switch (o) 79 | { 80 | case 0: 81 | switch (long_index) 82 | { 83 | default: 84 | print_help(); 85 | return 1; 86 | } 87 | 88 | case 'h': 89 | print_help(); 90 | return 0; 91 | 92 | case 'v': 93 | print_version(); 94 | return 0; 95 | 96 | case 'o': 97 | outputFile = optarg; 98 | break; 99 | 100 | case 'T': 101 | break; 102 | 103 | case 'B': 104 | std::cerr << "$ERROR: format CLog.B not supported currently, hold tight on future versions!" << std::endl; 105 | return 1; 106 | 107 | case 'Z': 108 | std::cerr << "$ERROR: format CLog.Bz not supported currently, hold tight on future versions!" << std::endl; 109 | return 1; 110 | 111 | case 's': 112 | clogParamFilesSegmentMode = true; 113 | break; 114 | 115 | case 'f': 116 | clogParamFiles.push_back(std::string(optarg)); 117 | break; 118 | 119 | default: 120 | print_help(); 121 | return 1; 122 | } 123 | } 124 | 125 | // 126 | print_version(); 127 | 128 | /* Extract parameters from param-file(s) */ 129 | CLog::CLogT::Parser<> parser; 130 | 131 | CLog::Parameters params; 132 | CLog::CLogT::ParametersSerDes<> paramsSerDes; 133 | 134 | parser.SetStopOnSegmentEnd(true); 135 | parser.SetSegmentMode(clogParamFilesSegmentMode); 136 | 137 | paramsSerDes.SetParametersReference(¶ms); 138 | paramsSerDes.RegisterAsDeserializer(parser); 139 | paramsSerDes.ApplySegmentToken(parser); 140 | paramsSerDes.ApplySegmentMask(parser); 141 | 142 | for (auto& clogParamFile : clogParamFiles) 143 | { 144 | if (clogParamFile.empty()) 145 | continue; 146 | 147 | std::ifstream ifs(clogParamFile); 148 | 149 | if (!ifs) 150 | { 151 | std::cerr << "%ERROR: cannot open input param file: " << clogParamFile << std::endl; 152 | return 3; 153 | } 154 | 155 | std::cerr << "%INFO: reading params from input param-file: " << clogParamFile; 156 | 157 | if (!parser.Parse(ifs)) 158 | { 159 | std::cerr << "%ERROR: CLog.T parsing error on file: " << clogParamFile 160 | << ", after " << parser.GetExecutionCounter() << " tokens." << std::endl; 161 | return -1; 162 | } 163 | 164 | std::cerr << ": " << parser.GetExecutionCounter() << std::endl; 165 | parser.SetExecutionCounter(0); 166 | } 167 | 168 | /* Specify output direction */ 169 | std::ofstream foutput; 170 | if (outputFile.empty()) 171 | { 172 | output = &std::cout; 173 | } 174 | else 175 | { 176 | foutput.open(outputFile.c_str()); 177 | 178 | if (!foutput) 179 | { 180 | std::cerr << "%ERROR: cannot open output file: " << outputFile << std::endl; 181 | return 3; 182 | } 183 | 184 | output = &foutput; 185 | 186 | std::cerr << "%INFO: ready to write into output file: " << outputFile << std::endl; 187 | } 188 | 189 | // 190 | foutput << "#" << std::endl; 191 | foutput << "# The CHI Issue." << std::endl; 192 | foutput << "# Permitted value: \"B\", \"E.b\"" << std::endl; 193 | foutput << "#" << std::endl; 194 | foutput << "ISSUE ?= " << ToString(params.GetIssue()) << std::endl; 195 | foutput << std::endl; 196 | 197 | foutput << "#" << std::endl; 198 | foutput << "# The width of Node ID." << std::endl; 199 | foutput << "# Permitted value: 7 to 11" << std::endl; 200 | foutput << "#" << std::endl; 201 | foutput << "NODEID_WIDTH ?= " << params.GetNodeIdWidth() << std::endl; 202 | foutput << std::endl; 203 | 204 | foutput << "#" << std::endl; 205 | foutput << "# The width of address of REQ flit, which also effects the SNP flit." << std::endl; 206 | foutput << "# Permitted value: 44 to 52" << std::endl; 207 | foutput << "#" << std::endl; 208 | foutput << "REQ_ADDR_WIDTH ?= " << params.GetReqAddrWidth() << std::endl; 209 | foutput << std::endl; 210 | 211 | foutput << "#" << std::endl; 212 | foutput << "# The width of RSVDC field of REQ flit." << std::endl; 213 | foutput << "# Permitted value: 0 or 4, 8, 12, 16, 24, 32" << std::endl; 214 | foutput << "#" << std::endl; 215 | foutput << "REQ_RSVDC_WIDTH ?= " << params.GetReqRSVDCWidth() << std::endl; 216 | foutput << std::endl; 217 | 218 | foutput << "#" << std::endl; 219 | foutput << "# The width of RSVDC field of DAT flit." << std::endl; 220 | foutput << "# Permitted value: 0 or 4, 8, 12, 16, 24, 32" << std::endl; 221 | foutput << "#" << std::endl; 222 | foutput << "DAT_RSVDC_WIDTH ?= " << params.GetDatRSVDCWidth() << std::endl; 223 | foutput << std::endl; 224 | 225 | foutput << "#" << std::endl; 226 | foutput << "# The width of Data field of DAT flit." << std::endl; 227 | foutput << "# Permitted value: 128, 256, 512" << std::endl; 228 | foutput << "#" << std::endl; 229 | foutput << "DATA_WIDTH ?= " << params.GetDataWidth() << std::endl; 230 | foutput << std::endl; 231 | 232 | foutput << "#" << std::endl; 233 | foutput << "# The presence of DataCheck field of DAT flit." << std::endl; 234 | foutput << "# Permitted value: true, false, 0, 1" << std::endl; 235 | foutput << "#" << std::endl; 236 | foutput << "DATACHECK_PRESENT ?= " << params.IsDataCheckPresent() << std::endl; 237 | foutput << std::endl; 238 | 239 | foutput << "#" << std::endl; 240 | foutput << "# The presence of Poison field of DAT flit." << std::endl; 241 | foutput << "# Permitted value: true, false, 0, 1" << std::endl; 242 | foutput << "#" << std::endl; 243 | foutput << "POISON_PRESENT ?= " << params.IsPoisonPresent() << std::endl; 244 | foutput << std::endl; 245 | 246 | foutput << "#" << std::endl; 247 | foutput << "# The presence of MPAM field." << std::endl; 248 | foutput << "# *Only applicable to Issue E.b*" << std::endl; 249 | foutput << "# Permitted value: true, false, 0, 1" << std::endl; 250 | foutput << "#" << std::endl; 251 | foutput << "MPAM_PRESENT ?= " << params.IsMPAMPresent() << std::endl; 252 | foutput << std::endl; 253 | 254 | // 255 | std::cerr << "%INFO: operation done" << std::endl; 256 | 257 | return 0; 258 | } 259 | -------------------------------------------------------------------------------- /app/clog2mkcfg/src/clog2mkcfg.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CLOG2MKCFG 4 | #define __CLOG2MKCFG 5 | 6 | 7 | #endif // __CLOG2MKCFG 8 | -------------------------------------------------------------------------------- /app/report_flit/Makefile: -------------------------------------------------------------------------------- 1 | ISSUE ?= B 2 | O ?= build 3 | 4 | SRC_DIR := src 5 | BUILD_DIR := $(O) 6 | 7 | CHIRON_DIR := ../.. 8 | 9 | -include Makefile.user 10 | -include Makefile.config 11 | 12 | ifeq ($(ISSUE), B) 13 | main := $(SRC_DIR)/report_flit_b.cpp 14 | endif 15 | 16 | ifeq ($(ISSUE), C) 17 | main := $(SRC_DIR)/report_flit_c.cpp 18 | endif 19 | 20 | ifeq ($(ISSUE), E.b) 21 | main := $(SRC_DIR)/report_flit_eb.cpp 22 | endif 23 | 24 | ifeq ($(main),) 25 | $(error "Unknown CHI Issue specified: $(ISSUE)") 26 | endif 27 | 28 | build: $(main) FORCE 29 | test -d $(BUILD_DIR) || mkdir $(BUILD_DIR) 30 | $(CXX) -std=c++20 $(main) -I$(SRC_DIR) -I$(CHIRON_DIR) -o $(BUILD_DIR)/report_flit \ 31 | -D_NODEID_WIDTH=$(NODEID_WIDTH) \ 32 | -D_REQ_ADDR_WIDTH=$(REQ_ADDR_WIDTH) \ 33 | -D_REQ_RSVDC_WIDTH=$(REQ_RSVDC_WIDTH) \ 34 | -D_DAT_RSVDC_WIDTH=$(DAT_RSVDC_WIDTH) \ 35 | -D_DATA_WIDTH=$(DATA_WIDTH) \ 36 | -D_DATACHECK_PRESENT=$(DATACHECK_PRESENT) \ 37 | -D_POISON_PRESENT=$(POISON_PRESENT) \ 38 | -D_MPAM_PRESENT=$(MPAM_PRESENT) 39 | 40 | run: 41 | @$(BUILD_DIR)/./report_flit 42 | 43 | clean: 44 | rm -rf build 45 | 46 | FORCE: 47 | .PHONY: FORCE 48 | -------------------------------------------------------------------------------- /app/report_flit/Makefile.config: -------------------------------------------------------------------------------- 1 | # 2 | # Change / create your CHI flit configuration here 3 | # 4 | 5 | # 6 | # The CHI Issue. 7 | # Permitted value: "B", "C", "E.b" 8 | # 9 | ISSUE ?= B 10 | 11 | # 12 | # The width of Node ID. 13 | # Permitted value: 7 to 11 14 | # 15 | NODEID_WIDTH ?= 7 16 | 17 | # 18 | # The width of address of REQ flit, which also effects the SNP flit. 19 | # Permitted value: 44 to 52 20 | # 21 | REQ_ADDR_WIDTH ?= 48 22 | 23 | # 24 | # The width of RSVDC field of REQ flit. 25 | # Permitted value: 0 or 4, 8, 12, 16, 24, 32 26 | # 27 | REQ_RSVDC_WIDTH ?= 0 28 | 29 | # 30 | # The width of RSVDC field of DAT flit. 31 | # Permitted value: 0 or 4, 8, 12, 16, 24, 32 32 | # 33 | DAT_RSVDC_WIDTH ?= 0 34 | 35 | # 36 | # The width of Data field of DAT flit. 37 | # Permitted value: 128, 256, 512 38 | # 39 | DATA_WIDTH ?= 256 40 | 41 | # 42 | # The presence of DataCheck field of DAT flit. 43 | # Permitted value: true, false, 0, 1 44 | # 45 | DATACHECK_PRESENT ?= false 46 | 47 | # 48 | # The presence of Poison field of DAT flit. 49 | # Permitted value: true, false, 0, 1 50 | # 51 | POISON_PRESENT ?= false 52 | 53 | # 54 | # The presence of MPAM field. 55 | # *Only applicable in Issue E.b* 56 | # Permitted value: true, false, 0, 1 57 | # 58 | MPAM_PRESENT ?= false 59 | -------------------------------------------------------------------------------- /app/report_flit/src/report_flit.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef REPORT_FLIT__STANDALONE 4 | # define CHI_ISSUE_B_ENABLE 5 | #endif 6 | 7 | #ifndef _NODEID_WIDTH 8 | # define _NODEID_WIDTH 7 9 | #endif 10 | 11 | #ifndef _REQ_ADDR_WIDTH 12 | # define _REQ_ADDR_WIDTH 48 13 | #endif 14 | 15 | #ifndef _REQ_RSVDC_WIDTH 16 | # define _REQ_RSVDC_WIDTH 0 17 | #endif 18 | 19 | #ifndef _DAT_RSVDC_WIDTH 20 | # define _DAT_RSVDC_WIDTH 0 21 | #endif 22 | 23 | #ifndef _DATA_WIDTH 24 | # define _DATA_WIDTH 256 25 | #endif 26 | 27 | #ifndef _DATACHECK_PRESENT 28 | # define _DATACHECK_PRESENT false 29 | #endif 30 | 31 | #ifndef _POISON_PRESENT 32 | # define _POISON_PRESENT false 33 | #endif 34 | 35 | #ifndef _MPAM_PRESENT 36 | # define _MPAM_PRESENT false 37 | #endif 38 | 39 | #ifdef CHI_ISSUE_B_ENABLE 40 | #include "../../../chi_b/spec/chi_b_protocol_flits.hpp" // IWYU pragma: keep 41 | #define CHI_ISSUE_B_ENABLE 42 | using namespace CHI::B::Flits; 43 | using config = CHI::B::FlitConfiguration< 44 | _NODEID_WIDTH, 45 | _REQ_ADDR_WIDTH, 46 | _REQ_RSVDC_WIDTH, 47 | _DAT_RSVDC_WIDTH, 48 | _DATA_WIDTH, 49 | _DATACHECK_PRESENT, 50 | _POISON_PRESENT 51 | >; 52 | #endif 53 | 54 | #ifdef CHI_ISSUE_C_ENABLE 55 | #include "../../../chi_c/spec/chi_c_protocol_flits.hpp" // IWYU pragma: keep 56 | #define CHI_ISSUE_C_ENABLE 57 | using namespace CHI::C::Flits; 58 | using config = CHI::C::FlitConfiguration< 59 | _NODEID_WIDTH, 60 | _REQ_ADDR_WIDTH, 61 | _REQ_RSVDC_WIDTH, 62 | _DAT_RSVDC_WIDTH, 63 | _DATA_WIDTH, 64 | _DATACHECK_PRESENT, 65 | _POISON_PRESENT 66 | >; 67 | #endif 68 | 69 | #ifdef CHI_ISSUE_EB_ENABLE 70 | #include "../../../chi_eb/spec/chi_eb_protocol_flits.hpp" // IWYU pragma: keep 71 | #define CHI_ISSUE_EB_ENABLE 72 | using namespace CHI::Eb::Flits; 73 | using config = CHI::Eb::FlitConfiguration< 74 | _NODEID_WIDTH, 75 | _REQ_ADDR_WIDTH, 76 | _REQ_RSVDC_WIDTH, 77 | _DAT_RSVDC_WIDTH, 78 | _DATA_WIDTH, 79 | _DATACHECK_PRESENT, 80 | _POISON_PRESENT, 81 | _MPAM_PRESENT 82 | >; 83 | #endif 84 | 85 | #define NUM_FORMATL std::left << std::setw(3) << std::setfill(' ') 86 | #define NUM_FORMATR std::right << std::setw(3) << std::setfill(' ') 87 | 88 | #define INFO_FORMAT(root, name) NUM_FORMATL << root::name##_WIDTH << std::right << " Range: [" << NUM_FORMATR << root::name##_MSB << ":" << NUM_FORMATR << root::name##_LSB << "]" 89 | 90 | static void print_version() noexcept 91 | { 92 | std::cerr << std::endl; 93 | std::cerr << " CHIron Toolset" << std::endl; 94 | std::cerr << std::endl; 95 | std::cerr << " report_flit - " << __DATE__ << std::endl; 96 | std::cerr << std::endl; 97 | std::cerr << " report_flit: Static CHI Flit information reporter" << std::endl; 98 | std::cerr << std::endl; 99 | } 100 | 101 | inline int report_flit_main() 102 | { 103 | print_version(); 104 | 105 | // 106 | std::cout << "========================================================" << std::endl; 107 | #ifdef CHI_ISSUE_B_ENABLE 108 | std::cout << "report_flit (Issue B)" << std::endl; 109 | #endif 110 | #ifdef CHI_ISSUE_C_ENABLE 111 | std::cout << "report_flit (Issue C)" << std::endl; 112 | #endif 113 | #ifdef CHI_ISSUE_EB_ENABLE 114 | std::cout << "report_flit (Issue E.b)" << std::endl; 115 | #endif 116 | // 117 | std::cout << "=Parameters=============================================" << std::endl; 118 | std::cout << "config::nodeIdWidth = " << config::nodeIdWidth << std::endl; 119 | std::cout << "config::reqAddrWidth = " << config::reqAddrWidth << std::endl; 120 | std::cout << "config::snpAddrWidth = " << config::snpAddrWidth << std::endl; 121 | #ifdef CHI_ISSUE_EB_ENABLE 122 | std::cout << "config::tagWidth = " << config::tagWidth << std::endl; 123 | std::cout << "config::tagUpdateWidth = " << config::tagUpdateWidth << std::endl; 124 | #endif 125 | std::cout << "config::reqRsvdcWidth = " << config::reqRsvdcWidth << std::endl; 126 | std::cout << "config::datRsvdcWidth = " << config::datRsvdcWidth << std::endl; 127 | std::cout << "config::dataWidth = " << config::dataWidth << std::endl; 128 | std::cout << "config::byteEnableWidth = " << config::byteEnableWidth << std::endl; 129 | std::cout << "config::dataCheckWidth = " << config::dataCheckWidth << std::endl; 130 | std::cout << "config::poisonWidth = " << config::poisonWidth << std::endl; 131 | #ifdef CHI_ISSUE_EB_ENABLE 132 | std::cout << "config::mpamWidth = " << config::mpamWidth << std::endl; 133 | #endif 134 | std::cout << std::endl; 135 | std::cout << "=CHI Overall============================================" << std::endl; 136 | std::cout << "CHI REQ Width: " << REQ::WIDTH << std::endl; 137 | std::cout << "CHI RSP Width: " << RSP::WIDTH << std::endl; 138 | std::cout << "CHI SNP Width: " << SNP::WIDTH << std::endl; 139 | std::cout << "CHI DAT Width: " << DAT::WIDTH << std::endl; 140 | std::cout << std::endl; 141 | std::cout << "=REQ====================================================" << std::endl; 142 | std::cout << "CHI REQ Width: " << REQ::WIDTH << std::endl; 143 | std::cout << "--------------------------------------------------------" << std::endl; 144 | std::cout << "CHI REQ::QoS Width: " << INFO_FORMAT(REQ, QOS) << std::endl; 145 | std::cout << "CHI REQ::TgtId Width: " << INFO_FORMAT(REQ, TGTID) << std::endl; 146 | std::cout << "CHI REQ::SrcId Width: " << INFO_FORMAT(REQ, SRCID) << std::endl; 147 | std::cout << "CHI REQ::TxnId Width: " << INFO_FORMAT(REQ, TXNID) << std::endl; 148 | std::cout << "CHI REQ::ReturnNID Width: " << INFO_FORMAT(REQ, RETURNNID) << std::endl; 149 | std::cout << " -> StashNID Width: " << INFO_FORMAT(REQ, STASHNID) << std::endl; 150 | #ifdef CHI_ISSUE_EB_ENABLE 151 | std::cout << " -> SLCRepHint Width: " << INFO_FORMAT(REQ, SLCREPHINT) << std::endl; 152 | #endif 153 | std::cout << "CHI REQ::StashNIDValid Width: " << INFO_FORMAT(REQ, STASHNIDVALID) << std::endl; 154 | std::cout << " -> Endian Width: " << INFO_FORMAT(REQ, ENDIAN) << std::endl; 155 | #ifdef CHI_ISSUE_EB_ENABLE 156 | std::cout << " -> Deep Width: " << INFO_FORMAT(REQ, DEEP) << std::endl; 157 | #endif 158 | std::cout << "CHI REQ::ReturnTxnID Width: " << INFO_FORMAT(REQ, RETURNTXNID) << std::endl; 159 | std::cout << " -> StashLPIDValid Width: " << INFO_FORMAT(REQ, STASHLPIDVALID) << std::endl; 160 | std::cout << " -> StashLPID Width: " << INFO_FORMAT(REQ, STASHLPID) << std::endl; 161 | std::cout << "CHI REQ::Opcode Width: " << INFO_FORMAT(REQ, OPCODE) << std::endl; 162 | std::cout << "CHI REQ::Size Width: " << INFO_FORMAT(REQ, SSIZE) << std::endl; 163 | std::cout << "CHI REQ::Addr Width: " << INFO_FORMAT(REQ, ADDR) << std::endl; 164 | std::cout << "CHI REQ::NS Width: " << INFO_FORMAT(REQ, NS) << std::endl; 165 | std::cout << "CHI REQ::LikelyShared Width: " << INFO_FORMAT(REQ, LIKELYSHARED) << std::endl; 166 | std::cout << "CHI REQ::AllowRetry Width: " << INFO_FORMAT(REQ, ALLOWRETRY) << std::endl; 167 | std::cout << "CHI REQ::Order Width: " << INFO_FORMAT(REQ, ORDER) << std::endl; 168 | std::cout << "CHI REQ::PCrdType Width: " << INFO_FORMAT(REQ, PCRDTYPE) << std::endl; 169 | std::cout << "CHI REQ::MemAttr Width: " << INFO_FORMAT(REQ, MEMATTR) << std::endl; 170 | std::cout << "CHI REQ::SnpAttr Width: " << INFO_FORMAT(REQ, SNPATTR) << std::endl; 171 | #ifdef CHI_ISSUE_EB_ENABLE 172 | std::cout << " -> DoDWT Width: " << INFO_FORMAT(REQ, DODWT) << std::endl; 173 | #endif 174 | std::cout << "CHI REQ::LPID Width: " << INFO_FORMAT(REQ, LPID) << std::endl; 175 | #ifdef CHI_ISSUE_EB_ENABLE 176 | std::cout << " -> PGroupID Width: " << INFO_FORMAT(REQ, PGROUPID) << std::endl; 177 | std::cout << " -> StashGroupID Width: " << INFO_FORMAT(REQ, STASHGROUPID) << std::endl; 178 | std::cout << " -> TagGroupID Width: " << INFO_FORMAT(REQ, TAGGROUPID) << std::endl; 179 | #endif 180 | std::cout << "CHI REQ::Excl Width: " << INFO_FORMAT(REQ, EXCL) << std::endl; 181 | std::cout << " -> SnoopMe Width: " << INFO_FORMAT(REQ, SNOOPME) << std::endl; 182 | std::cout << "CHI REQ::ExpCompAck Width: " << INFO_FORMAT(REQ, EXPCOMPACK) << std::endl; 183 | #ifdef CHI_ISSUE_EB_ENABLE 184 | std::cout << "CHI REQ::TagOp Width: " << INFO_FORMAT(REQ, TAGOP) << std::endl; 185 | #endif 186 | std::cout << "CHI REQ::TraceTag Width: " << INFO_FORMAT(REQ, TRACETAG) << std::endl; 187 | #ifdef CHI_ISSUE_EB_ENABLE 188 | if constexpr (REQ::hasMPAM) 189 | std::cout << "CHI REQ::MPAM Width: " << INFO_FORMAT(REQ, MPAM) << std::endl; 190 | else 191 | std::cout << "CHI REQ::MPAM (N/A)" << std::endl; 192 | #endif 193 | if constexpr (REQ::hasRSVDC) 194 | std::cout << "CHI REQ::RSVDC Width: " << INFO_FORMAT(REQ, RSVDC) << std::endl; 195 | else 196 | std::cout << "CHI REQ::RSVDC (N/A)" << std::endl; 197 | std::cout << std::endl; 198 | std::cout << "=RSP====================================================" << std::endl; 199 | std::cout << "CHI RSP Width: " << RSP::WIDTH << std::endl; 200 | std::cout << "--------------------------------------------------------" << std::endl; 201 | std::cout << "CHI RSP::QoS Width: " << INFO_FORMAT(RSP, QOS) << std::endl; 202 | std::cout << "CHI RSP::TgtId Width: " << INFO_FORMAT(RSP, TGTID) << std::endl; 203 | std::cout << "CHI RSP::SrcId Width: " << INFO_FORMAT(RSP, SRCID) << std::endl; 204 | std::cout << "CHI RSP::TxnId Width: " << INFO_FORMAT(RSP, TXNID) << std::endl; 205 | std::cout << "CHI RSP::Opcode Width: " << INFO_FORMAT(RSP, OPCODE) << std::endl; 206 | std::cout << "CHI RSP::RespErr Width: " << INFO_FORMAT(RSP, RESPERR) << std::endl; 207 | std::cout << "CHI RSP::Resp Width: " << INFO_FORMAT(RSP, RESP) << std::endl; 208 | std::cout << "CHI RSP::FwdState Width: " << INFO_FORMAT(RSP, FWDSTATE) << std::endl; 209 | std::cout << " -> DataPull Width: " << INFO_FORMAT(RSP, DATAPULL) << std::endl; 210 | #ifdef CHI_ISSUE_EB_ENABLE 211 | std::cout << "CHI RSP::CBusy Width: " << INFO_FORMAT(RSP, CBUSY) << std::endl; 212 | #endif 213 | std::cout << "CHI RSP::DBID Width: " << INFO_FORMAT(RSP, DBID) << std::endl; 214 | #ifdef CHI_ISSUE_EB_ENABLE 215 | std::cout << " -> PGroupID Width: " << INFO_FORMAT(RSP, PGROUPID) << std::endl; 216 | std::cout << " -> StashGroupID Width: " << INFO_FORMAT(RSP, STASHGROUPID) << std::endl; 217 | std::cout << " -> TagGroupID Width: " << INFO_FORMAT(RSP, TAGGROUPID) << std::endl; 218 | #endif 219 | std::cout << "CHI RSP::PCrdType Width: " << INFO_FORMAT(RSP, PCRDTYPE) << std::endl; 220 | #ifdef CHI_ISSUE_EB_ENABLE 221 | std::cout << "CHI RSP::TagOp Width: " << INFO_FORMAT(RSP, TAGOP) << std::endl; 222 | #endif 223 | std::cout << "CHI RSP::TraceTag Width: " << INFO_FORMAT(RSP, TRACETAG) << std::endl; 224 | std::cout << std::endl; 225 | std::cout << "=SNP====================================================" << std::endl; 226 | std::cout << "CHI SNP Width: " << SNP::WIDTH << std::endl; 227 | std::cout << "--------------------------------------------------------" << std::endl; 228 | std::cout << "CHI SNP::QoS Width: " << INFO_FORMAT(SNP, QOS) << std::endl; 229 | std::cout << "CHI SNP::SrcId Width: " << INFO_FORMAT(SNP, SRCID) << std::endl; 230 | std::cout << "CHI SNP::TxnId Width: " << INFO_FORMAT(SNP, TXNID) << std::endl; 231 | std::cout << "CHI SNP::FwdNID Width: " << INFO_FORMAT(SNP, FWDNID) << std::endl; 232 | std::cout << "CHI SNP::FwdTxnID Width: " << INFO_FORMAT(SNP, FWDTXNID) << std::endl; 233 | std::cout << " -> StashLPIDValid Width: " << INFO_FORMAT(SNP, STASHLPIDVALID) << std::endl; 234 | std::cout << " -> StashLPID Width: " << INFO_FORMAT(SNP, STASHLPID) << std::endl; 235 | std::cout << " -> VMIDExt Width: " << INFO_FORMAT(SNP, VMIDEXT) << std::endl; 236 | std::cout << "CHI SNP::Opcode Width: " << INFO_FORMAT(SNP, OPCODE) << std::endl; 237 | std::cout << "CHI SNP::Addr Width: " << INFO_FORMAT(SNP, ADDR) << std::endl; 238 | std::cout << "CHI SNP::NS Width: " << INFO_FORMAT(SNP, NS) << std::endl; 239 | std::cout << "CHI SNP::DoNotGoToSD Width: " << INFO_FORMAT(SNP, DONOTGOTOSD) << std::endl; 240 | #if defined(CHI_ISSUE_B_ENABLE) || defined(CHI_ISSUE_C_ENABLE) 241 | std::cout << " -> DoNotDataPull Width: " << INFO_FORMAT(SNP, DONOTDATAPULL) << std::endl; 242 | #endif 243 | std::cout << "CHI SNP::RetToSrc Width: " << INFO_FORMAT(SNP, RETTOSRC) << std::endl; 244 | std::cout << "CHI SNP::TraceTag Width: " << INFO_FORMAT(SNP, TRACETAG) << std::endl; 245 | #ifdef CHI_ISSUE_EB_ENABLE 246 | if constexpr (SNP::hasMPAM) 247 | std::cout << "CHI SNP::MPAM Width: " << INFO_FORMAT(SNP, MPAM) << std::endl; 248 | else 249 | std::cout << "CHI SNP::MPAM (N/A)" << std::endl; 250 | #endif 251 | std::cout << std::endl; 252 | std::cout << "=DAT====================================================" << std::endl; 253 | std::cout << "CHI DAT Width: " << DAT::WIDTH << std::endl; 254 | std::cout << "--------------------------------------------------------" << std::endl; 255 | std::cout << "CHI DAT::QoS Width: " << INFO_FORMAT(DAT, QOS) << std::endl; 256 | std::cout << "CHI DAT::TgtID Width: " << INFO_FORMAT(DAT, TGTID) << std::endl; 257 | std::cout << "CHI DAT::SrcID Width: " << INFO_FORMAT(DAT, SRCID) << std::endl; 258 | std::cout << "CHI DAT::TxnID Width: " << INFO_FORMAT(DAT, TXNID) << std::endl; 259 | std::cout << "CHI DAT::HomeNID Width: " << INFO_FORMAT(DAT, HOMENID) << std::endl; 260 | std::cout << "CHI DAT::Opcode Width: " << INFO_FORMAT(DAT, OPCODE) << std::endl; 261 | std::cout << "CHI DAT::RespErr Width: " << INFO_FORMAT(DAT, RESPERR) << std::endl; 262 | std::cout << "CHI DAT::Resp Width: " << INFO_FORMAT(DAT, RESP) << std::endl; 263 | std::cout << "CHI DAT::FwdState Width: " << INFO_FORMAT(DAT, FWDSTATE) << std::endl; 264 | std::cout << " -> DataPull Width: " << INFO_FORMAT(DAT, DATAPULL) << std::endl; 265 | std::cout << " -> DataSource Width: " << INFO_FORMAT(DAT, DATASOURCE) << std::endl; 266 | #ifdef CHI_ISSUE_EB_ENABLE 267 | std::cout << "CHI DAT::CBusy Width: " << INFO_FORMAT(DAT, CBUSY) << std::endl; 268 | #endif 269 | std::cout << "CHI DAT::DBID Width: " << INFO_FORMAT(DAT, DBID) << std::endl; 270 | std::cout << "CHI DAT::CCID Width: " << INFO_FORMAT(DAT, CCID) << std::endl; 271 | std::cout << "CHI DAT::DataID Width: " << INFO_FORMAT(DAT, DATAID) << std::endl; 272 | #ifdef CHI_ISSUE_EB_ENABLE 273 | std::cout << "CHI DAT::TagOp Width: " << INFO_FORMAT(DAT, TAGOP) << std::endl; 274 | std::cout << "CHI DAT::Tag Width: " << INFO_FORMAT(DAT, TAG) << std::endl; 275 | std::cout << "CHI DAT::TU Width: " << INFO_FORMAT(DAT, TU) << std::endl; 276 | #endif 277 | std::cout << "CHI DAT::TraceTag Width: " << INFO_FORMAT(DAT, TRACETAG) << std::endl; 278 | if constexpr (DAT::hasRSVDC) 279 | std::cout << "CHI DAT::RSVDC Width: " << INFO_FORMAT(DAT, RSVDC) << std::endl; 280 | else 281 | std::cout << "CHI DAT::RSVDC (N/A)" << std::endl; 282 | std::cout << "CHI DAT::BE Width: " << INFO_FORMAT(DAT, BE) << std::endl; 283 | std::cout << "CHI DAT::Data Width: " << INFO_FORMAT(DAT, DATA) << std::endl; 284 | if constexpr (DAT::hasDataCheck) 285 | std::cout << "CHI DAT::DataCheck Width: " << INFO_FORMAT(DAT, DATACHECK) << std::endl; 286 | else 287 | std::cout << "CHI DAT::DataCheck (N/A)" << std::endl; 288 | if constexpr (DAT::hasPoison) 289 | std::cout << "CHI DAT::Poison Width: " << INFO_FORMAT(DAT, POISON) << std::endl; 290 | else 291 | std::cout << "CHI DAT::Poison (N/A)" << std::endl; 292 | std::cout << std::endl; 293 | std::cout << "========================================================" << std::endl; 294 | 295 | return 0; 296 | } -------------------------------------------------------------------------------- /app/report_flit/src/report_flit_b.cpp: -------------------------------------------------------------------------------- 1 | #define REPORT_FLIT__STANDALONE 2 | 3 | #define CHI_ISSUE_B_ENABLE 4 | #include "report_flit.hpp" 5 | #undef CHI_ISSUE_B_ENABLE 6 | 7 | int main() 8 | { 9 | return report_flit_main(); 10 | } 11 | -------------------------------------------------------------------------------- /app/report_flit/src/report_flit_c.cpp: -------------------------------------------------------------------------------- 1 | #define REPORT_FLIT__STANDALONE 2 | 3 | #define CHI_ISSUE_C_ENABLE 4 | #include "report_flit.hpp" 5 | #undef CHI_ISSUE_C_ENABLE 6 | 7 | int main() 8 | { 9 | return report_flit_main(); 10 | } 11 | -------------------------------------------------------------------------------- /app/report_flit/src/report_flit_eb.cpp: -------------------------------------------------------------------------------- 1 | #define REPORT_FLIT__STANDALONE 2 | 3 | #define CHI_ISSUE_EB_ENABLE 4 | #include "report_flit.hpp" 5 | #undef CHI_ISSUE_EB_ENABLE 6 | 7 | int main() 8 | { 9 | return report_flit_main(); 10 | } 11 | -------------------------------------------------------------------------------- /app/xsdb2clog/Makefile: -------------------------------------------------------------------------------- 1 | O ?= build 2 | 3 | SRC_DIR := src 4 | BUILD_DIR := $(O) 5 | 6 | CHIRON_DIR := ../.. 7 | 8 | build: FORCE 9 | test -d $(BUILD_DIR) || mkdir $(BUILD_DIR) 10 | $(CXX) -std=c++20 $(SRC_DIR)/xsdb2clog.cpp -I$(SRC_DIR) -I$(CHIRON_DIR) \ 11 | -lsqlite3 -o $(BUILD_DIR)/xsdb2clog 12 | 13 | run: 14 | @$(BUILD_DIR)/./xsdb2clog --version 15 | 16 | clean: 17 | rm -rf build 18 | 19 | FORCE: 20 | .PHONY: FORCE 21 | -------------------------------------------------------------------------------- /app/xsdb2clog/src/xsdb2clog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "xsdb2clog.hpp" 16 | 17 | #include "../../../clog/clog_b/clog_b.hpp" 18 | #include "../../../clog/clog_t/clog_t.hpp" 19 | #include "../../../clog/clog_t/clog_t_util.hpp" 20 | 21 | 22 | std::string current_site; 23 | uint64_t current_stamp; 24 | uint64_t current_channel; 25 | uint64_t current_flit[7]; 26 | 27 | size_t record_count = 0; 28 | 29 | // 30 | std::ostream* output; 31 | 32 | // 33 | CLog::Channel GetChannel(uint64_t xsdbChannel) 34 | { 35 | switch (xsdbChannel) 36 | { 37 | case XSDB::CHIChannel::TXREQ: return CLog::Channel::TXREQ; 38 | case XSDB::CHIChannel::RXRSP: return CLog::Channel::RXRSP; 39 | case XSDB::CHIChannel::RXDAT: return CLog::Channel::RXDAT; 40 | case XSDB::CHIChannel::RXSNP: return CLog::Channel::RXSNP; 41 | case XSDB::CHIChannel::TXRSP: return CLog::Channel::TXRSP; 42 | case XSDB::CHIChannel::TXDAT: return CLog::Channel::TXDAT; 43 | default: break; 44 | } 45 | 46 | std::cerr << "%ERROR: unrecognized CHI channel (" << xsdbChannel << ") from xsdb" << std::endl; 47 | 48 | throw std::exception(); 49 | } 50 | 51 | // 52 | static void CallbackSite(const std::string& str) 53 | { 54 | current_site = str; 55 | } 56 | 57 | static void CallbackStamp(uint64_t val) 58 | { 59 | current_stamp = val; 60 | } 61 | 62 | static void CallbackChannel(uint64_t val) 63 | { 64 | current_channel = val; 65 | } 66 | 67 | static void CallbackFlit0(uint64_t val) 68 | { 69 | current_flit[0] = val; 70 | } 71 | 72 | static void CallbackFlit1(uint64_t val) 73 | { 74 | current_flit[1] = val; 75 | } 76 | 77 | static void CallbackFlit2(uint64_t val) 78 | { 79 | current_flit[2] = val; 80 | } 81 | 82 | static void CallbackFlit3(uint64_t val) 83 | { 84 | current_flit[3] = val; 85 | } 86 | 87 | static void CallbackFlit4(uint64_t val) 88 | { 89 | current_flit[4] = val; 90 | } 91 | 92 | static void CallbackFlit5(uint64_t val) 93 | { 94 | current_flit[5] = val; 95 | } 96 | 97 | static void CallbackFlit6(uint64_t val) 98 | { 99 | current_flit[6] = val; 100 | } 101 | 102 | static void print_version() noexcept 103 | { 104 | std::cerr << std::endl; 105 | std::cerr << " CHIron Toolset" << std::endl; 106 | std::cerr << std::endl; 107 | std::cerr << " xsdb2clog - " << __DATE__ << std::endl; 108 | std::cerr << std::endl; 109 | std::cerr << " xsdb2clog: XiangShan ChiselDB to CLog Converter" << std::endl; 110 | std::cerr << std::endl; 111 | } 112 | 113 | static void print_help() noexcept 114 | { 115 | std::cout << "Usage: xsdb2clog [OPTION...]" << std::endl; 116 | std::cout << std::endl; 117 | std::cout << " -h, --help print help info" << std::endl; 118 | std::cout << " -v, --version print version info" << std::endl; 119 | std::cout << " -i, --xsdb=FILE *necessary* specify XiangShan ChiselDB file" << std::endl; 120 | std::cout << " -o, --output=FILE specify CLog output file. by default, the clog output" << std::endl; 121 | std::cout << " is written to the standard console output" << std::endl; 122 | std::cout << " -T, --clogT *default* specify output format as CLog.T" << std::endl; 123 | std::cout << " -B, --clogB [WIP] specify output format as CLog.B" << std::endl; 124 | std::cout << " -Z, --clogBz [WIP] specify output format as CLog.Bz" << std::endl; 125 | std::cout << " -f, --param-file specify CLog input files for CHI parameters" << std::endl; 126 | std::cout << " -s, --seg, --segment enable segment mode for CLog input files for CHI parameters" << std::endl; 127 | std::cout << std::endl; 128 | } 129 | 130 | int main(int argc, char* argv[]) 131 | { 132 | // 133 | std::string xsdbFile; 134 | std::string clogFile; 135 | 136 | std::string xsdbTableName = "CHILog"; 137 | 138 | std::vector clogParamFiles; 139 | bool clogParamFilesSegmentMode = false; 140 | 141 | // input parameters 142 | const struct option long_options[] = { 143 | { "help" , 0, NULL, 'h' }, 144 | { "version" , 0, NULL, 'v' }, 145 | { "xsdb" , 1, NULL, 'i' }, 146 | { "output" , 1, NULL, 'o' }, 147 | { "clogT" , 0, NULL, 'T' }, 148 | { "clogB" , 0, NULL, 'B' }, 149 | { "clogBz" , 0, NULL, 'Z' }, 150 | { "segment" , 0, NULL, 's' }, 151 | { "seg" , 0, NULL, 's' }, 152 | { "param-file" , 1, NULL, 'f' }, 153 | { 0 , 0, NULL, 0 } 154 | }; 155 | 156 | int long_index = 0; 157 | int o; 158 | while ((o = getopt_long(argc, argv, "hvi:o:TBZsf:", long_options, &long_index)) != -1) 159 | { 160 | switch (o) 161 | { 162 | case 0: 163 | switch (long_index) 164 | { 165 | default: 166 | print_help(); 167 | return 1; 168 | } 169 | 170 | case 'h': 171 | print_help(); 172 | return 0; 173 | 174 | case 'v': 175 | print_version(); 176 | return 0; 177 | 178 | case 'i': 179 | xsdbFile = optarg; 180 | break; 181 | 182 | case 'o': 183 | clogFile = optarg; 184 | break; 185 | 186 | case 'T': 187 | break; 188 | 189 | case 'B': 190 | std::cerr << "$ERROR: format CLog.B not supported currently, hold tight on future versions!" << std::endl; 191 | return 1; 192 | 193 | case 'Z': 194 | std::cerr << "$ERROR: format CLog.Bz not supported currently, hold tight on future versions!" << std::endl; 195 | return 1; 196 | 197 | case 's': 198 | clogParamFilesSegmentMode = true; 199 | break; 200 | 201 | case 'f': 202 | clogParamFiles.push_back(std::string(optarg)); 203 | break; 204 | 205 | default: 206 | print_help(); 207 | return 1; 208 | } 209 | } 210 | 211 | // 212 | print_version(); 213 | 214 | // 215 | if (xsdbFile.empty()) 216 | { 217 | std::cerr << "%ERROR: please specify input XiangShan ChiselDB file with option '-i' or '--xsdb'" << std::endl; 218 | return 2; 219 | } 220 | 221 | /* Extract parameters from param-file(s) */ 222 | CLog::CLogT::Parser<> parser; 223 | 224 | CLog::Parameters params; 225 | CLog::CLogT::ParametersSerDes<> paramsSerDes; 226 | 227 | parser.SetStopOnSegmentEnd(true); 228 | parser.SetSegmentMode(clogParamFilesSegmentMode); 229 | 230 | paramsSerDes.SetParametersReference(¶ms); 231 | paramsSerDes.RegisterAsDeserializer(parser); 232 | paramsSerDes.ApplySegmentToken(parser); 233 | paramsSerDes.ApplySegmentMask(parser); 234 | 235 | for (auto& clogParamFile : clogParamFiles) 236 | { 237 | if (clogParamFile.empty()) 238 | continue; 239 | 240 | std::ifstream ifs(clogParamFile); 241 | 242 | if (!ifs) 243 | { 244 | std::cerr << "%ERROR: cannot open input param file: " << clogParamFile << std::endl; 245 | return 3; 246 | } 247 | 248 | std::cerr << "%INFO: reading params from input param-file: " << clogParamFile; 249 | 250 | if (!parser.Parse(ifs)) 251 | { 252 | std::cerr << "%ERROR: CLog.T parsing error on file: " << clogParamFile 253 | << ", after " << parser.GetExecutionCounter() << " tokens." << std::endl; 254 | return -1; 255 | } 256 | 257 | std::cerr << ": " << parser.GetExecutionCounter() << std::endl; 258 | parser.SetExecutionCounter(0); 259 | } 260 | 261 | /* Specify output direction */ 262 | std::ofstream foutput; 263 | if (clogFile.empty()) 264 | { 265 | output = &std::cout; 266 | } 267 | else 268 | { 269 | foutput.open(clogFile.c_str()); 270 | 271 | if (!foutput) 272 | { 273 | std::cerr << "%ERROR: cannot open output file: " << clogFile << std::endl; 274 | return 3; 275 | } 276 | 277 | output = &foutput; 278 | 279 | std::cerr << "%INFO: ready to write into output file: " << clogFile << std::endl; 280 | } 281 | 282 | /* Write param segment */ 283 | paramsSerDes.SerializeTo(foutput, true); 284 | 285 | /* */ 286 | sqlite3* db; 287 | sqlite3_stmt* dbstmt; 288 | 289 | const char* zTail; 290 | char* zErrMsg; 291 | int rc; 292 | 293 | /* Open database */ 294 | rc = sqlite3_open(xsdbFile.c_str(), &db); 295 | 296 | if (rc) 297 | { 298 | std::cerr << "%ERROR: cannot open database: " << sqlite3_errmsg(db) << std::endl; 299 | return -1; 300 | } 301 | else 302 | std::cerr << "%INFO: database opened" << std::endl; 303 | 304 | /* Create SQL statement */ 305 | std::ostringstream sql; 306 | 307 | sql << "SELECT "; 308 | sql << XSDB::COLUMN_SITE << ", "; 309 | sql << XSDB::COLUMN_CHANNEL << ", "; 310 | sql << XSDB::COLUMN_STAMP << ", "; 311 | sql << XSDB::COLUMN_FLIT0 << ", "; 312 | sql << XSDB::COLUMN_FLIT1 << ", "; 313 | sql << XSDB::COLUMN_FLIT2 << ", "; 314 | sql << XSDB::COLUMN_FLIT3 << ", "; 315 | sql << XSDB::COLUMN_FLIT4 << ", "; 316 | sql << XSDB::COLUMN_FLIT5 << " "; 317 | sql << "FROM " << xsdbTableName; 318 | 319 | /* Execute SQL statement */ 320 | std::cerr << "%INFO: converting xsdb to clog ... " << std::endl; 321 | 322 | auto beforeTime = std::chrono::system_clock::now(); 323 | 324 | rc = sqlite3_prepare_v2(db, sql.str().c_str(), sql.str().length(), &dbstmt, &zTail); 325 | 326 | if (rc != SQLITE_OK) 327 | { 328 | std::cerr << "%ERROR: database error: " << zErrMsg << std::endl; 329 | sqlite3_free(zErrMsg); 330 | 331 | return -1; 332 | } 333 | 334 | try 335 | { 336 | while (sqlite3_step(dbstmt) == SQLITE_ROW) 337 | { 338 | int dbcol = 0; 339 | 340 | CallbackSite(std::string( 341 | (const char*) sqlite3_column_text(dbstmt, dbcol++) 342 | )); 343 | 344 | CallbackChannel( 345 | sqlite3_column_int64(dbstmt, dbcol++) 346 | ); 347 | 348 | CallbackStamp( 349 | sqlite3_column_int64(dbstmt, dbcol++) 350 | ); 351 | 352 | CallbackFlit0( 353 | sqlite3_column_int64(dbstmt, dbcol++) 354 | ); 355 | 356 | CallbackFlit1( 357 | sqlite3_column_int64(dbstmt, dbcol++) 358 | ); 359 | 360 | CallbackFlit2( 361 | sqlite3_column_int64(dbstmt, dbcol++) 362 | ); 363 | 364 | CallbackFlit3( 365 | sqlite3_column_int64(dbstmt, dbcol++) 366 | ); 367 | 368 | CallbackFlit4( 369 | sqlite3_column_int64(dbstmt, dbcol++) 370 | ); 371 | 372 | CallbackFlit5( 373 | sqlite3_column_int64(dbstmt, dbcol++) 374 | ); 375 | 376 | record_count++; 377 | 378 | CLog::CLogT::WriteCHISentenceLog( 379 | *output, 380 | current_stamp, 381 | 4, 382 | GetChannel(current_channel), 383 | (uint32_t*) current_flit, 384 | 14); 385 | 386 | if ((record_count & 0x3FF) == 0) 387 | std::cerr << "."; 388 | 389 | if ((record_count & 0x7FFF) == 0) 390 | std::cerr << std::endl; 391 | } 392 | } 393 | catch (std::exception& e) 394 | { 395 | sqlite3_finalize(dbstmt); 396 | sqlite3_close(db); 397 | 398 | return -1; 399 | } 400 | 401 | auto afterTime = std::chrono::system_clock::now(); 402 | 403 | std::cerr << std::endl; 404 | std::cerr << "%INFO: operation done for " << record_count << " records" 405 | << " in " << std::chrono::duration(afterTime - beforeTime).count() << " ms" << std::endl; 406 | 407 | sqlite3_finalize(dbstmt); 408 | sqlite3_close(db); 409 | 410 | return 0; 411 | } 412 | -------------------------------------------------------------------------------- /app/xsdb2clog/src/xsdb2clog.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __XSDB2CLOG 4 | #define __XSDB2CLOG 5 | 6 | #include 7 | 8 | 9 | namespace XSDB 10 | { 11 | /* 12 | * CHI Channel encoding in ChiselDB::CHILog 13 | */ 14 | // 15 | class CHIChannel { 16 | public: 17 | static constexpr const uint64_t TXREQ = 0; 18 | static constexpr const uint64_t RXRSP = 1; 19 | static constexpr const uint64_t RXDAT = 2; 20 | static constexpr const uint64_t RXSNP = 3; 21 | static constexpr const uint64_t TXRSP = 4; 22 | static constexpr const uint64_t TXDAT = 5; 23 | }; 24 | // 25 | 26 | /* 27 | * SQLite column names in ChiselDB::CHILog 28 | */ 29 | // 30 | static constexpr const char* COLUMN_SITE = "SITE"; 31 | static constexpr const char* COLUMN_CHANNEL = "CHANNEL"; 32 | static constexpr const char* COLUMN_STAMP = "STAMP"; 33 | static constexpr const char* COLUMN_FLIT0 = "FLITALL_0"; 34 | static constexpr const char* COLUMN_FLIT1 = "FLITALL_1"; 35 | static constexpr const char* COLUMN_FLIT2 = "FLITALL_2"; 36 | static constexpr const char* COLUMN_FLIT3 = "FLITALL_3"; 37 | static constexpr const char* COLUMN_FLIT4 = "FLITALL_4"; 38 | static constexpr const char* COLUMN_FLIT5 = "FLITALL_5"; 39 | static constexpr const char* COLUMN_FLIT6 = "FLITALL_6"; 40 | // 41 | } 42 | 43 | 44 | #endif // __XSDB2CLOG 45 | -------------------------------------------------------------------------------- /chi/basic/chi_conn.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CHI_CONN 4 | #define __CHI__CHI_CONN 5 | 6 | #include // IWYU pragma: keep 7 | 8 | 9 | namespace CHI { 10 | 11 | /* 12 | General Connection Configuration for all levels. 13 | -------------------------------- 14 | Indicates the life cycle management of specified level of CHI bundle object. 15 | This is designed for zero-copy procedure implementation and performance optimization. 16 | CHI bundle object would be configured to reference (pointer type) if connected = true. 17 | Otherwise, it would hold all bundle data in local instance memory. 18 | */ 19 | template 25 | struct Connection { 26 | static constexpr bool connectedIO = ConnectedIO; 27 | static constexpr bool connectedFlit = ConnectedFlit; 28 | static constexpr bool connectedChannel = ConnectedChannel; 29 | static constexpr bool connectedInterface = ConnectedInterface; 30 | // static constexpr bool connectedLink = ConnectedLink; 31 | static constexpr bool connectedPort = ConnectedPort; 32 | }; 33 | 34 | 35 | /* 36 | IO-level Connection Configuration concept 37 | */ 38 | template 39 | concept IOLevelConnectionConcept = requires { 40 | { T::connectedIO } -> std::convertible_to; 41 | }; 42 | 43 | /* 44 | Flit-level Connection Configuration concept 45 | */ 46 | template 47 | concept FlitLevelConnectionConcept = requires { 48 | { T::connectedIO } -> std::convertible_to; 49 | { T::connectedFlit } -> std::convertible_to; 50 | }; 51 | 52 | /* 53 | Channel-level Connection Configuration concept 54 | */ 55 | template 56 | concept ChannelLevelConnectionConcept = requires { 57 | { T::connectedIO } -> std::convertible_to; 58 | { T::connectedFlit } -> std::convertible_to; 59 | { T::connectedChannel } -> std::convertible_to; 60 | }; 61 | 62 | /* 63 | Interface-level Connection Configuration concept 64 | */ 65 | template 66 | concept InterfaceLevelConnectionConcept = requires { 67 | { T::connectedIO } -> std::convertible_to; 68 | { T::connectedFlit } -> std::convertible_to; 69 | { T::connectedChannel } -> std::convertible_to; 70 | { T::connectedInterface } -> std::convertible_to; 71 | }; 72 | 73 | /* 74 | Link-level Connection Configuration concept 75 | */ 76 | template 77 | concept LinkLevelConnectionConcept = requires { 78 | { T::connectedIO } -> std::convertible_to; 79 | { T::connectedFlit } -> std::convertible_to; 80 | { T::connectedChannel } -> std::convertible_to; 81 | { T::connectedInterface } -> std::convertible_to; 82 | // { T::connectedLink } -> std::convertible_to; 83 | }; 84 | 85 | /* 86 | Port-level Connection Configuration concept 87 | */ 88 | template 89 | concept PortLevelConnectionConcept = requires { 90 | { T::connectedIO } -> std::convertible_to; 91 | { T::connectedFlit } -> std::convertible_to; 92 | { T::connectedChannel } -> std::convertible_to; 93 | { T::connectedInterface } -> std::convertible_to; 94 | // { T::connectedLink } -> std::convertible_to; 95 | { T::connectedPort } -> std::convertible_to; 96 | }; 97 | }; 98 | 99 | 100 | namespace CHI { 101 | 102 | /* 103 | decay: 104 | Decay the type of a reference to the type of the object it refers to. 105 | If the field is configured as connected (pointer type), it would return the reference type, 106 | decaying the pointer type to the reference type. 107 | This is designed for better general Flit Object interaction. 108 | 109 | Example: 110 | decay::qos_t>(flit.QoS) = 0; 111 | */ 112 | template 113 | inline constexpr T& decay(U& t) noexcept 114 | { 115 | if constexpr (std::is_same_v) 116 | return t; 117 | else 118 | return *t; 119 | } 120 | 121 | template 122 | inline constexpr const T& decay(const U& t) noexcept 123 | { 124 | if constexpr (std::is_same_v) 125 | return t; 126 | else 127 | return *t; 128 | } 129 | } 130 | 131 | 132 | #endif // __CHI__CHI_CONN 133 | -------------------------------------------------------------------------------- /chi/basic/chi_parameters.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CHI_PARAMETERS 4 | #define __CHI__CHI_PARAMETERS 5 | 6 | #include 7 | 8 | 9 | namespace CHI { 10 | 11 | /* 12 | Constraint checkers for CHI parameters. 13 | */ 14 | 15 | /* 16 | * Constraint checker for CHI parameter 17 | * -> Legal values of are 7 to 11 18 | */ 19 | inline static constexpr bool CheckNodeIdWidth(size_t nodeIdWidth) noexcept 20 | { 21 | return nodeIdWidth >= 7 && nodeIdWidth <= 11; 22 | } 23 | 24 | /* 25 | * Constraint checker for CHI parameter 26 | * -> Legal values of are 44 to 52 27 | */ 28 | inline static constexpr bool CheckReqAddrWidth(size_t reqAddrWidth) noexcept 29 | { 30 | return reqAddrWidth >= 44 && reqAddrWidth <= 52; 31 | } 32 | 33 | /* 34 | * Constraint checker for CHI parameter 35 | * -> Legal values of are 128, 256, and 512 36 | */ 37 | inline static constexpr bool CheckDataWidth(size_t dataWidth) noexcept 38 | { 39 | return dataWidth == 128 || dataWidth == 256 || dataWidth == 512; 40 | } 41 | 42 | /* 43 | * Constraint checker for CHI configuration of RSVDC width 44 | * -> Legal values are 0 or 4, 8, 12, 16, 24, 32 45 | */ 46 | inline static constexpr bool CheckRSVDCWidth(size_t rsvdcWidth) noexcept 47 | { 48 | return rsvdcWidth == 0 || rsvdcWidth == 4 || rsvdcWidth == 8 49 | || rsvdcWidth == 12 || rsvdcWidth == 16 50 | || rsvdcWidth == 24 || rsvdcWidth == 32; 51 | } 52 | } 53 | 54 | 55 | #endif // __CHI__CHI_PARAMETERS 56 | -------------------------------------------------------------------------------- /chi/spec/chi_link_channels.hpp: -------------------------------------------------------------------------------- 1 | //#pragma once 2 | 3 | //#ifndef __CHI_B__CHI_LINK_CHANNELS 4 | //#define __CHI_B__CHI_LINK_CHANNELS 5 | 6 | #ifndef CHI_LINK_CHANNELS__STANDALONE 7 | # include "chi_link_channels_header.hpp" // IWYU pragma: keep 8 | # include "chi_protocol_flits.hpp" 9 | #endif 10 | 11 | 12 | #if (!defined(CHI_ISSUE_B_ENABLE) || !defined(__CHI__CHI_LINK_CHANNELS_B)) \ 13 | && (!defined(CHI_ISSUE_EB_ENABLE) || !defined(__CHI__CHI_LINK_CHANNELS_EB)) 14 | 15 | #ifdef CHI_ISSUE_B_ENABLE 16 | # define __CHI__CHI_LINK_CHANNELS_B 17 | #endif 18 | #ifdef CHI_ISSUE_EB_ENABLE 19 | # define __CHI__CHI_LINK_CHANNELS_EB 20 | #endif 21 | 22 | 23 | /* 24 | namespace CHI::B { 25 | */ 26 | 27 | namespace Channels { 28 | 29 | // 30 | template, 31 | CHI::FlitLevelConnectionConcept conn = CHI::Connection<>> 32 | class REQ { 33 | public: 34 | /* 35 | REQFLITPEND: 1 bit 36 | Request Flit Pending. Early indication that a request flit might be transmitted in the following 37 | cycle. See Flit level clock gating on page 13-319. 38 | */ 39 | using flitpend_t = uint1_t; 40 | 41 | /* 42 | REQFLITV: 1 bit 43 | Request Flit Valid. The transmitter sets this signal HIGH to indicate when REQFLIT[(R-1):0] is 44 | valid. 45 | */ 46 | using flitv_t = uint1_t; 47 | 48 | /* 49 | REQFLIT: bundle 50 | Request Flit. See Request flit on page 12-289 for a description of the request flit format. 51 | */ 52 | using flit_t = Flits::REQ; 53 | 54 | /* 55 | REQLCRDV: 1 bit 56 | Request L-Credit Valid. The receiver sets this signal HIGH to return a request channel L-Credit to 57 | a transmitter. See L-Credit flow control on page 13-317. 58 | */ 59 | using lcrdv_t = uint1_t; 60 | 61 | 62 | // REQ channel signals 63 | public: 64 | as_pointer_if_t FLITPEND; 65 | as_pointer_if_t FLITV; 66 | as_pointer_if_t FLIT; 67 | as_pointer_if_t LCRDV; 68 | }; 69 | 70 | 71 | // 72 | template, 73 | CHI::FlitLevelConnectionConcept conn = CHI::Connection<>> 74 | class RSP { 75 | public: 76 | /* 77 | RSPFLITPEND: 1 bit 78 | Response Flit Pending. Early indication that a response flit might be transmitted in the following 79 | cycle. See Flit level clock gating on page 13-319. 80 | */ 81 | using flitpend_t = uint1_t; 82 | 83 | /* 84 | RSPFLITV: 1 bit 85 | Response Flit Valid. The transmitter sets this signal HIGH to indicate when RSPFLIT[(R-1):0] is 86 | valid. 87 | */ 88 | using flitv_t = uint1_t; 89 | 90 | /* 91 | RSPFLIT: bundle 92 | Response Flit. See Response flit on page 12-290 for a description of the response flit format. 93 | */ 94 | using flit_t = Flits::RSP; 95 | 96 | /* 97 | RSPLCRDV: 1 bit 98 | Response L-Credit Valid. The receiver sets this signal HIGH to return a response channel L-Credit to 99 | a transmitter. See L-Credit flow control on page 13-317. 100 | */ 101 | using lcrdv_t = uint1_t; 102 | 103 | // RSP channel signals 104 | public: 105 | as_pointer_if_t FLITPEND; 106 | as_pointer_if_t FLITV; 107 | as_pointer_if_t FLIT; 108 | as_pointer_if_t LCRDV; 109 | }; 110 | 111 | 112 | // 113 | template, 114 | CHI::FlitLevelConnectionConcept conn = CHI::Connection<>> 115 | class SNP { 116 | public: 117 | /* 118 | SNPFLITPEND: 1 bit 119 | Snoop Flit Pending. Early indication that a snoop flit might be transmitted in the following cycle. 120 | See Flit level clock gating on page 13-319. 121 | */ 122 | using flitpend_t = uint1_t; 123 | 124 | /* 125 | SNPFLITV: 1 bit 126 | Snoop Flit Valid. The transmitter sets this signal HIGH to indicate when SNPFLIT[(R-1):0] is valid. 127 | */ 128 | using flitv_t = uint1_t; 129 | 130 | /* 131 | SNPFLIT: bundle 132 | Snoop Flit. See Snoop flit on page 12-291 for a description of the snoop flit format. 133 | */ 134 | using flit_t = Flits::SNP; 135 | 136 | /* 137 | SNPLCRDV: 1 bit 138 | Snoop L-Credit Valid. The receiver sets this signal HIGH to return a snoop channel L-Credit to a 139 | transmitter. See L-Credit flow control on page 13-317. 140 | */ 141 | using lcrdv_t = uint1_t; 142 | 143 | // SNP channel signals 144 | public: 145 | as_pointer_if_t FLITPEND; 146 | as_pointer_if_t FLITV; 147 | as_pointer_if_t FLIT; 148 | as_pointer_if_t LCRDV; 149 | }; 150 | 151 | 152 | // 153 | template, 154 | CHI::FlitLevelConnectionConcept conn = CHI::Connection<>> 155 | class DAT { 156 | public: 157 | /* 158 | DATFLITPEND: 1 bit 159 | Data Flit Pending. Early indication that a data flit might be transmitted in the following cycle. 160 | See Flit level clock gating on page 13-319. 161 | */ 162 | using flitpend_t = uint1_t; 163 | 164 | /* 165 | DATFLITV: 1 bit 166 | Data Flit Valid. The transmitter sets this signal HIGH to indicate when DATFLIT[(R-1):0] is valid. 167 | */ 168 | using flitv_t = uint1_t; 169 | 170 | /* 171 | DATFLIT: bundle 172 | Data Flit. See Data flit on page 12-292 for a description of the data flit format. 173 | */ 174 | using flit_t = Flits::DAT; 175 | 176 | /* 177 | DATLCRDV: 1 bit 178 | Data L-Credit Valid. The receiver sets this signal HIGH to return a data channel L-Credit to a 179 | transmitter. See L-Credit flow control on page 13-317. 180 | */ 181 | using lcrdv_t = uint1_t; 182 | 183 | // DAT channel signals 184 | public: 185 | as_pointer_if_t FLITPEND; 186 | as_pointer_if_t FLITV; 187 | as_pointer_if_t FLIT; 188 | as_pointer_if_t LCRDV; 189 | }; 190 | 191 | 192 | namespace RN { 193 | 194 | /* 195 | TXREQ. Outbound Request Channel. 196 | */ 197 | template, 198 | class conn = CHI::Connection<>> 199 | using TXREQ = Channels::REQ; 200 | 201 | /* 202 | TXRSP. Outbound Response Channel. 203 | */ 204 | template, 205 | class conn = CHI::Connection<>> 206 | using TXRSP = Channels::RSP; 207 | 208 | /* 209 | TXDAT. Outbound Data Channel. 210 | */ 211 | template, 212 | class conn = CHI::Connection<>> 213 | using TXDAT = Channels::DAT; 214 | 215 | /* 216 | RXRSP. Inbound Response Channel. 217 | */ 218 | template, 219 | class conn = CHI::Connection<>> 220 | using RXRSP = Channels::RSP; 221 | 222 | /* 223 | RXDAT. Inbound Data Channel. 224 | */ 225 | template, 226 | class conn = CHI::Connection<>> 227 | using RXDAT = Channels::DAT; 228 | 229 | /* 230 | RXSNP. Inbound Snoop Channel. 231 | */ 232 | template, 233 | class conn = CHI::Connection<>> 234 | using RXSNP = Channels::SNP; 235 | }; 236 | 237 | 238 | namespace SN { 239 | 240 | /* 241 | RXREQ. Inbound Request Channel. 242 | */ 243 | template, 244 | class conn = CHI::Connection<>> 245 | using RXREQ = Channels::REQ; 246 | 247 | /* 248 | TXRSP. Outbound Response Channel. 249 | */ 250 | template, 251 | class conn = CHI::Connection<>> 252 | using TXRSP = Channels::RSP; 253 | 254 | /* 255 | TXDAT. Outbound Data Channel. 256 | */ 257 | template, 258 | class conn = CHI::Connection<>> 259 | using TXDAT = Channels::DAT; 260 | 261 | /* 262 | RXDAT. Inbound Data Channel. 263 | */ 264 | template, 265 | class conn = CHI::Connection<>> 266 | using RXDAT = Channels::DAT; 267 | }; 268 | } 269 | 270 | /* 271 | } 272 | */ 273 | 274 | 275 | #endif // __CHI__CHI_LINK_CHANNELS_* 276 | -------------------------------------------------------------------------------- /chi/spec/chi_link_channels_header.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CHI_LINK_CHANNELS_HEADER 4 | #define __CHI__CHI_LINK_CHANNELS_HEADER 5 | 6 | #include "../../common/nonstdint.hpp" // IWYU pragma: export 7 | #include "../../common/utility.hpp" // IWYU pragma: export 8 | 9 | #endif // __CHI__CHI_LINK_CHANNELS_HEADER 10 | -------------------------------------------------------------------------------- /chi/spec/chi_link_interfaces.hpp: -------------------------------------------------------------------------------- 1 | //#pragma once 2 | 3 | //#ifndef __CHI_B__CHI_LINK_INTERFACES 4 | //#define __CHI_B__CHI_LINK_INTERFACES 5 | 6 | #ifndef CHI_LINK_INTERFACES__STANDALONE 7 | # include "chi_link_interfaces_header.hpp" // IWYU pragma: keep 8 | # include "chi_link_channels.hpp" 9 | #endif 10 | 11 | 12 | #if (!defined(CHI_ISSUE_B_ENABLE) || !defined(__CHI__CHI_LINK_INTERFACES_B)) \ 13 | && (!defined(CHI_ISSUE_EB_ENABLE) || !defined(__CHI__CHI_LINK_INTERFACES_EB)) 14 | 15 | #ifdef CHI_ISSUE_B_ENABLE 16 | # define __CHI__CHI_LINK_INTERFACES_B 17 | #endif 18 | #ifdef CHI_ISSUE_EB_ENABLE 19 | # define __CHI__CHI_LINK_INTERFACES_EB 20 | #endif 21 | 22 | 23 | /* 24 | namespace CHI { 25 | */ 26 | namespace Interfaces { 27 | 28 | // 29 | class TX {}; 30 | class RX {}; 31 | 32 | // 33 | template 34 | concept InterfaceTXConcept = std::derived_from; 35 | 36 | // 37 | template 38 | concept InterfaceRXConcept = std::derived_from; 39 | 40 | 41 | // 42 | template 43 | concept InterfaceWithTXConcept = InterfaceTXConcept; 44 | 45 | // 46 | template 47 | concept InterfaceWithRXConcept = InterfaceRXConcept; 48 | 49 | 50 | // 51 | namespace RN { 52 | 53 | /* 54 | RN-F interface. 55 | */ 56 | template, 57 | CHI::ChannelLevelConnectionConcept conn = CHI::Connection<>> 58 | class F { 59 | public: 60 | 61 | /* 62 | RN-F TX interface. 63 | */ 64 | class TX : public F, public Interfaces::TX { 65 | public: 66 | as_pointer_if_t> REQ; 67 | as_pointer_if_t> RSP; 68 | as_pointer_if_t> DAT; 69 | }; 70 | 71 | /* 72 | RN-F RX interface. 73 | */ 74 | class RX : public F, public Interfaces::RX { 75 | public: 76 | as_pointer_if_t> RSP; 77 | as_pointer_if_t> DAT; 78 | as_pointer_if_t> SNP; 79 | }; 80 | }; 81 | 82 | 83 | /* 84 | RN-D interface. 85 | */ 86 | template, 87 | CHI::ChannelLevelConnectionConcept conn = CHI::Connection<>> 88 | class D { 89 | public: 90 | 91 | /* 92 | RN-D TX interface. 93 | */ 94 | class TX : public D, public Interfaces::TX { 95 | public: 96 | as_pointer_if_t> REQ; 97 | as_pointer_if_t> RSP; 98 | as_pointer_if_t> DAT; 99 | }; 100 | 101 | /* 102 | RN-D RX interface. 103 | */ 104 | class RX : public D, public Interfaces::RX { 105 | public: 106 | as_pointer_if_t> RSP; 107 | as_pointer_if_t> DAT; 108 | as_pointer_if_t> SNP; 109 | }; 110 | }; 111 | 112 | 113 | /* 114 | RN-I interface. 115 | */ 116 | template, 117 | CHI::ChannelLevelConnectionConcept conn = CHI::Connection<>> 118 | class I { 119 | public: 120 | 121 | /* 122 | RN-I TX interface. 123 | */ 124 | class TX : public I, public Interfaces::TX { 125 | public: 126 | as_pointer_if_t> REQ; 127 | as_pointer_if_t> RSP; 128 | as_pointer_if_t> DAT; 129 | }; 130 | 131 | /* 132 | RN-I RX interface. 133 | */ 134 | class RX : public I, public Interfaces::RX { 135 | public: 136 | as_pointer_if_t> RSP; 137 | as_pointer_if_t> DAT; 138 | }; 139 | }; 140 | } 141 | 142 | 143 | // 144 | namespace SN { 145 | 146 | /* 147 | SN-F interface. 148 | */ 149 | template, 150 | CHI::ChannelLevelConnectionConcept conn = CHI::Connection<>> 151 | class F { 152 | public: 153 | 154 | /* 155 | SN-F TX interface. 156 | */ 157 | class TX : public F, public Interfaces::TX { 158 | public: 159 | as_pointer_if_t> RSP; 160 | as_pointer_if_t> DAT; 161 | }; 162 | 163 | /* 164 | SN-F RX interface. 165 | */ 166 | class RX : public F, public Interfaces::RX { 167 | public: 168 | as_pointer_if_t> REQ; 169 | as_pointer_if_t> DAT; 170 | }; 171 | }; 172 | 173 | 174 | /* 175 | SN-I interface. 176 | */ 177 | template, 178 | CHI::ChannelLevelConnectionConcept conn = CHI::Connection<>> 179 | class I { 180 | public: 181 | 182 | /* 183 | SN-I TX interface. 184 | */ 185 | class TX : public I, public Interfaces::TX { 186 | public: 187 | as_pointer_if_t> RSP; 188 | as_pointer_if_t> DAT; 189 | }; 190 | 191 | /* 192 | SN-I RX interface. 193 | */ 194 | class RX : public I, public Interfaces::RX { 195 | public: 196 | as_pointer_if_t> REQ; 197 | as_pointer_if_t> DAT; 198 | }; 199 | }; 200 | } 201 | } 202 | /* 203 | } 204 | */ 205 | 206 | 207 | #endif // __CHI__CHI_LINK_INTERFACES_* 208 | 209 | //#endif // __CHI_B__CHI_LINK_INTERFACES 210 | -------------------------------------------------------------------------------- /chi/spec/chi_link_interfaces_header.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CHI_LINK_INTERFACES_HEADER 4 | #define __CHI__CHI_LINK_INTERFACES_HEADER 5 | 6 | #endif // __CHI__CHI_LINK_INTERFACES_HEADER 7 | -------------------------------------------------------------------------------- /chi/spec/chi_link_links.hpp: -------------------------------------------------------------------------------- 1 | // #pragma once 2 | 3 | // #ifndef __CHI__CHI_LINK_LINKS 4 | // #define __CHI__CHI_LINK_LINKS 5 | 6 | #ifndef CHI_LINK_LINKS__STANDALONE 7 | # include "chi_link_links_header.hpp" 8 | # include "chi_link_interfaces.hpp" 9 | #endif 10 | 11 | 12 | #if (!defined(CHI_ISSUE_B_ENABLE) || !defined(__CHI__CHI_LINK_LINKS_B)) \ 13 | && (!defined(CHI_ISSUE_EB_ENABLE) || !defined(__CHI__CHI_LINK_LINKS_EB)) 14 | 15 | #ifdef CHI_ISSUE_B_ENABLE 16 | # define __CHI__CHI_LINK_LINKS_B 17 | #endif 18 | #ifdef CHI_ISSUE_EB_ENABLE 19 | # define __CHI__CHI_LINK_LINKS_EB 20 | #endif 21 | 22 | 23 | /* 24 | namespace CHI { 25 | */ 26 | namespace Links { 27 | 28 | // 29 | template 30 | concept InterfaceWithTXConcept = Interfaces::InterfaceWithTXConcept; 31 | 32 | template 33 | concept InterfaceWithRXConcept = Interfaces::InterfaceWithRXConcept; 34 | 35 | 36 | /* 37 | Outbound link. 38 | */ 39 | template, 41 | CHI::InterfaceLevelConnectionConcept conn = CHI::Connection<>> 42 | class Outbound { 43 | public: 44 | /* 45 | TXLINKACTIVEREQ: 1 bit 46 | See 13.5 Interface activation and deactivation on 13-320. 47 | */ 48 | using txlinkactivereq_t = uint1_t; 49 | 50 | /* 51 | TXLINKACTIVEACK: 1 bit 52 | See 13.5 Interface activation and deactivation on 13-320. 53 | */ 54 | using txlinkactiveack_t = uint1_t; 55 | 56 | /* 57 | TX: interface bundle 58 | */ 59 | using tx_t = inf::TX; 60 | 61 | 62 | // Outbound Link signals 63 | public: 64 | as_pointer_if_t TXLINKACTIVEREQ; 65 | as_pointer_if_t TXLINKACTIVEACK; 66 | as_pointer_if_t TX; 67 | }; 68 | 69 | 70 | /* 71 | Inbound link. 72 | */ 73 | template, 75 | CHI::InterfaceLevelConnectionConcept conn = CHI::Connection<>> 76 | class Inbound { 77 | public: 78 | /* 79 | RXLINKACTIVEREQ: 1 bit 80 | See 13.5 Interface activation and deactivation on 13-320. 81 | */ 82 | using rxlinkactivereq_t = uint1_t; 83 | 84 | /* 85 | RXLINKACTIVEACK: 1 bit 86 | See 13.5 Interface activation and deactivation on 13-320. 87 | */ 88 | using rxlinkactiveack_t = uint1_t; 89 | 90 | /* 91 | RX: interface bundle 92 | */ 93 | using rx_t = inf::RX; 94 | 95 | 96 | // Inbound Link signals 97 | public: 98 | as_pointer_if_t RXLINKACTIVEREQ; 99 | as_pointer_if_t RXLINKACTIVEACK; 100 | as_pointer_if_t RX; 101 | }; 102 | 103 | 104 | // 105 | template 106 | concept LinkBoundConcept = std::is_class_v && std::is_class_v; 107 | 108 | 109 | // 110 | namespace RN { 111 | 112 | /* 113 | Links of RN-F. 114 | */ 115 | template, 116 | CHI::InterfaceLevelConnectionConcept conn = CHI::Connection<>> 117 | class F { 118 | public: 119 | using Outbound = Links::Outbound , config, conn>; 120 | using Inbound = Links::Inbound , config, conn>; 121 | }; 122 | 123 | /* 124 | Links of RN-D. 125 | */ 126 | template, 127 | CHI::InterfaceLevelConnectionConcept conn = CHI::Connection<>> 128 | class D { 129 | public: 130 | using Outbound = Links::Outbound , config, conn>; 131 | using Inbound = Links::Inbound , config, conn>; 132 | }; 133 | 134 | /* 135 | Links of RN-I. 136 | */ 137 | template, 138 | CHI::InterfaceLevelConnectionConcept conn = CHI::Connection<>> 139 | class I { 140 | public: 141 | using Outbound = Links::Outbound , config, conn>; 142 | using Inbound = Links::Inbound , config, conn>; 143 | }; 144 | }; 145 | 146 | 147 | // 148 | namespace SN { 149 | 150 | /* 151 | Links of SN-F. 152 | */ 153 | template, 154 | CHI::InterfaceLevelConnectionConcept conn = CHI::Connection<>> 155 | class F { 156 | public: 157 | using Outbound = Links::Outbound , config, conn>; 158 | using Inbound = Links::Inbound , config, conn>; 159 | }; 160 | 161 | /* 162 | Links of SN-I. 163 | */ 164 | template, 165 | CHI::InterfaceLevelConnectionConcept conn = CHI::Connection<>> 166 | class I { 167 | public: 168 | using Outbound = Links::Outbound , config, conn>; 169 | using Inbound = Links::Inbound , config, conn>; 170 | }; 171 | }; 172 | } 173 | /* 174 | } 175 | */ 176 | 177 | 178 | #endif // __CHI__CHI_LINK_LINKS_* 179 | 180 | // #endif // __CHI__CHI_LINK_LINKS 181 | -------------------------------------------------------------------------------- /chi/spec/chi_link_links_header.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CHI_LINK_LINKS_HEADER 4 | #define __CHI__CHI_LINK_LINKS_HEADER 5 | 6 | #include // IWYU pragma: export 7 | #include // IWYU pragma: export 8 | 9 | #include "../../common/nonstdint.hpp" // IWYU pragma: export 10 | 11 | 12 | #endif // __CHI__CHI_LINK_LINKS_HEADER 13 | -------------------------------------------------------------------------------- /chi/spec/chi_link_ports.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //#ifndef __CHI__CHI_LINK_PORTS 4 | //#define __CHI__CHI_LINK_PORTS 5 | 6 | #ifndef CHI_LINK_PORTS__STANDALONE 7 | # include "chi_link_links.hpp" 8 | #endif 9 | 10 | 11 | #if (!defined(CHI_ISSUE_B_ENABLE) || !defined(__CHI__CHI_LINK_PORTS_B)) \ 12 | && (!defined(CHI_ISSUE_EB_ENABLE) || !defined(__CHI__CHI_LINK_PORTS_EB)) 13 | 14 | #ifdef CHI_ISSUE_B_ENABLE 15 | # define __CHI__CHI_LINK_PORTS_B 16 | #endif 17 | #ifdef CHI_ISSUE_EB_ENABLE 18 | # define __CHI__CHI_LINK_PORTS_EB 19 | #endif 20 | 21 | 22 | /* 23 | namespace CHI::B { 24 | */ 25 | namespace Ports { 26 | 27 | // 28 | template 29 | concept LinkBoundConcept = Links::LinkBoundConcept; 30 | 31 | 32 | /* 33 | Port. 34 | */ 35 | template, 37 | class conn = CHI::Connection<>> 38 | class Port : public link::Outbound, public link::Inbound { 39 | public: 40 | /* 41 | TXSACTIVE: 1 bit 42 | See 13.7 Protocol layer activity indication on 13-332. 43 | */ 44 | using txsactive_t = uint1_t; 45 | 46 | /* 47 | RXSACTIVE: 1 bit 48 | See 13.7 Protocol layer activity indication on 13-332. 49 | */ 50 | using rxsactive_t = uint1_t; 51 | 52 | 53 | // Port signals (extended), others from link::Outbound and link::Inbound 54 | public: 55 | as_pointer_if_t TXSACTIVE; 56 | as_pointer_if_t RXSACTIVE; 57 | }; 58 | 59 | 60 | // 61 | namespace RN { 62 | 63 | /* 64 | Port of RN-F. 65 | */ 66 | template, 67 | CHI::FlitLevelConnectionConcept conn = CHI::Connection<>> 68 | using F = Port>; 69 | 70 | /* 71 | Port of RN-D. 72 | */ 73 | template, 74 | CHI::FlitLevelConnectionConcept conn = CHI::Connection<>> 75 | using D = Port>; 76 | 77 | /* 78 | Port of RN-I. 79 | */ 80 | template, 81 | CHI::FlitLevelConnectionConcept conn = CHI::Connection<>> 82 | using I = Port>; 83 | }; 84 | 85 | 86 | // 87 | namespace SN { 88 | 89 | /* 90 | Ports of SN-F. 91 | */ 92 | template, 93 | CHI::FlitLevelConnectionConcept conn = CHI::Connection<>> 94 | using F = Port>; 95 | 96 | /* 97 | Ports of SN-I. 98 | */ 99 | template, 100 | CHI::FlitLevelConnectionConcept conn = CHI::Connection<>> 101 | using I = Port>; 102 | }; 103 | } 104 | /* 105 | } 106 | */ 107 | 108 | 109 | #endif // __CHI__CHI_LINK_PORTS_* 110 | 111 | //#endif // __CHI__CHI_LINK_PORTS 112 | -------------------------------------------------------------------------------- /chi/spec/chi_link_ports_header.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CHI_LINK_PORTS_HEADER 4 | #define __CHI__CHI_LINK_PORTS_HEADER 5 | 6 | #endif // __CHI__CHI_LINK_PORTS_HEADER 7 | -------------------------------------------------------------------------------- /chi/spec/chi_protocol_encoding_header.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CHI_PROTOCOL_ENCODING_HEADER 4 | #define __CHI__CHI_PROTOCOL_ENCODING_HEADER 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /chi/spec/chi_protocol_flits_header.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CHI_PROTOCOL_FILTS_HEADER 4 | #define __CHI__CHI_PROTOCOL_FLITS_HEADER 5 | 6 | #include // IWYU pragma: export 7 | #include // IWYU pragma: export 8 | #include // IWYU pragma: export 9 | #include // IWYU pragma: export 10 | 11 | #include "../../common/utility.hpp" // IWYU pragma: export 12 | #include "../../common/nonstdint.hpp" // IWYU pragma: export 13 | 14 | #include "../basic/chi_conn.hpp" // IWYU pragma: export 15 | #include "../basic/chi_parameters.hpp" // IWYU pragma: export 16 | 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /chi/util/chi_util_decoding_header.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CHI_UTIL_DECODING_HEADER 4 | #define __CHI__CHI_UTIL_DECODING_HEADER 5 | 6 | #include // IWYU pragma: export 7 | 8 | #endif // __CHI__CHI_UTIL_DECODING_HEADER -------------------------------------------------------------------------------- /chi/util/chi_util_flit_header.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CHI_UTIL_FLIT_HEADER 4 | #define __CHI__CHI_UTIL_FLIT_HEADER 5 | 6 | #include // IWYU pragma: export 7 | 8 | #endif // __CHI__CHI_UTIL_FLIT_HEADER 9 | -------------------------------------------------------------------------------- /chi/xact/chi_joint_header.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CHI_XACT_JOINT_HEADER 4 | #define __CHI__CHI_XACT_JOINT_HEADER 5 | 6 | #include // IWYU pragma: export 7 | #include // IWYU pragma: export 8 | #include // IWYU pragma: export 9 | #include // IWYU pragma: export 10 | #include // IWYU pragma: export 11 | #include // IWYU pragma: export 12 | #include // IWYU pragma: export 13 | #include "../../common/eventbus.hpp" // IWYU pragma: export 14 | 15 | 16 | #endif // __CHI__CHI_XACT_JOINT_HEADER 17 | -------------------------------------------------------------------------------- /chi/xact/chi_xact_base_header.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CHI_XACT_BASE_HEADER 4 | #define __CHI__CHI_XACT_BASE_HEADER 5 | 6 | #include // IWYU pragma: export 7 | #include // IWYU pragma: export 8 | #include "../../common/utility.hpp" // IWYU pragma: export 9 | 10 | #endif // __CHI__CHI_XACT_BASE_HEADER 11 | -------------------------------------------------------------------------------- /chi/xact/chi_xact_checkers_field.hpp: -------------------------------------------------------------------------------- 1 | //#pragma once 2 | 3 | //#ifndef __CHI__CHI_XACT_CHECKERS_FIELD 4 | //#define __CHI__CHI_XACT_CHECKERS_FIELD 5 | 6 | #ifndef CHI_XACT_CHECKERS_FIELD__STANDALONE 7 | # include "chi_xact_checkers_field_header.hpp" // IWYU pragma: keep 8 | 9 | # include "../spec/chi_protocol_encoding_header.hpp" // IWYU pragma: keep 10 | # include "../spec/chi_protocol_encoding.hpp" // IWYU pragma: keep 11 | 12 | # include "chi_xact_base_header.hpp" // IWYU pragma: keep 13 | # include "chi_xact_base.hpp" // IWYU pragma: keep 14 | 15 | # include "chi_xact_field_header.hpp" // IWYU pragma: keep 16 | # ifdef CHI_ISSUE_B_ENABLE 17 | # include "chi_xact_field_b.hpp" // IWYU pragma: keep 18 | # endif 19 | # ifdef CHI_ISSUE_EB_ENABLE 20 | # include "chi_xact_field_eb.hpp" // IWYU pragma: keep 21 | # endif 22 | #endif 23 | 24 | 25 | #if (!defined(CHI_ISSUE_B_ENABLE) || !defined(__CHI__CHI_XACT_CHECKERS_B)) \ 26 | && (!defined(CHI_ISSUE_EB_ENABLE) || !defined(__CHI__CHI_XACT_CHECKERS_EB)) 27 | 28 | #ifdef CHI_ISSUE_B_ENABLE 29 | # define __CHI__CHI_XACT_CHECKERS_FIELD_B 30 | #endif 31 | #ifdef CHI_ISSUE_EB_ENABLE 32 | # define __CHI__CHI_XACT_CHECKERS_FIELD_EB 33 | #endif 34 | 35 | 36 | /* 37 | namespace CHI { 38 | */ 39 | namespace Xact { 40 | 41 | /* 42 | * Basic Field Checkers based on Field Mapping Table 43 | * without transaction specific checks. 44 | */ 45 | template> 47 | class RequestFieldMappingChecker { 48 | public: 49 | RequestFieldMappingTable table; 50 | 51 | public: 52 | XactDenialEnum Check(const Flits::REQ&) noexcept; 53 | }; 54 | 55 | template> 57 | class ResponseFieldMappingChecker { 58 | public: 59 | ResponseFieldMappingTable table; 60 | 61 | public: 62 | XactDenialEnum Check(const Flits::RSP&) noexcept; 63 | }; 64 | 65 | template> 67 | class DataFieldMappingChecker { 68 | public: 69 | DataFieldMappingTable table; 70 | 71 | public: 72 | XactDenialEnum Check(const Flits::DAT&) noexcept; 73 | }; 74 | 75 | template> 77 | class SnoopFieldMappingChecker { 78 | public: 79 | SnoopFieldMappingTable table; 80 | 81 | public: 82 | XactDenialEnum Check(const Flits::SNP&) noexcept; 83 | }; 84 | 85 | template> 87 | class FieldMappingChecker { 88 | // TODO 89 | }; 90 | /**/ 91 | 92 | 93 | namespace details { 94 | 95 | template 96 | inline bool Check(FieldConvention conv, Tv val) 97 | { 98 | switch (conv) 99 | { 100 | case FieldConvention::A0: 101 | if (val != 0) 102 | return false; 103 | break; 104 | 105 | case FieldConvention::A1: 106 | if (val != 1) 107 | return false; 108 | break; 109 | 110 | case FieldConvention::I0: 111 | if (val != 0) 112 | return false; 113 | break; 114 | 115 | case FieldConvention::X: 116 | break; 117 | 118 | case FieldConvention::Y: 119 | // should be checked by Fine-Grained Field Checkers, not here 120 | break; 121 | 122 | case FieldConvention::B8: 123 | if (val != Size<8>::value) 124 | return false; 125 | break; 126 | 127 | case FieldConvention::B64: 128 | if (val != Size<64>::value) 129 | return false; 130 | break; 131 | 132 | case FieldConvention::S: 133 | break; 134 | 135 | case FieldConvention::D: 136 | // TODO: pass MPAM default values to here maybe 137 | break; 138 | 139 | default: 140 | return false; 141 | } 142 | 143 | return true; 144 | } 145 | 146 | template 147 | inline bool CheckDataArray(FieldConvention conv, Tv val) 148 | { 149 | switch (conv) 150 | { 151 | case FieldConvention::X: 152 | return true; 153 | 154 | case FieldConvention::Y: 155 | return true; 156 | 157 | default: 158 | return false; 159 | } 160 | 161 | return true; 162 | } 163 | } 164 | } 165 | /* 166 | } 167 | */ 168 | 169 | 170 | // Implementation of: class RequestFieldMappingChecker 171 | namespace /*CHI::*/Xact { 172 | /* 173 | RequestFieldMappingTable table; 174 | */ 175 | 176 | template 178 | inline XactDenialEnum RequestFieldMappingChecker::Check(const Flits::REQ& reqFlit) noexcept 179 | { 180 | #define CHECK_REQ(field, denial) \ 181 | if (!details::Check(mapping->field, reqFlit.field())) \ 182 | return XactDenial::DENIED_REQ_FIELD_##denial; 183 | 184 | #define CHECK_REQ_IF(field, denial) \ 185 | if constexpr (reqFlit.has##field) \ 186 | if (!details::Check(mapping->field, reqFlit.field())) \ 187 | return XactDenial::DENIED_REQ_FIELD_##denial; 188 | 189 | #define CHECK_REQ_EX(field, req_field, denial) \ 190 | if (!details::Check(mapping->field, req_field)) \ 191 | return XactDenial::DENIED_REQ_FIELD_##denial; 192 | 193 | RequestFieldMapping mapping = table.Get(reqFlit.Opcode()); 194 | 195 | if (!mapping) 196 | return XactDenial::DENIED_OPCODE; 197 | 198 | CHECK_REQ (QoS , QOS ); 199 | CHECK_REQ (TgtID , TGTID ); 200 | CHECK_REQ (SrcID , SRCID ); 201 | CHECK_REQ (TxnID , TXNID ); 202 | CHECK_REQ (Opcode , OPCODE ); 203 | CHECK_REQ (AllowRetry , ALLOWRETRY ); 204 | CHECK_REQ (PCrdType , PCRDTYPE ); 205 | CHECK_REQ_IF(RSVDC , RSVDC ); 206 | #ifdef CHI_ISSUE_EB_ENABLE 207 | CHECK_REQ (TagOp , TAGOP ); 208 | #endif 209 | CHECK_REQ (TraceTag , TRACETAG ); 210 | #ifdef CHI_ISSUE_EB_ENABLE 211 | CHECK_REQ_IF(MPAM , MPAM ); 212 | #endif 213 | CHECK_REQ (Addr , ADDR ); 214 | CHECK_REQ (NS , NS ); 215 | CHECK_REQ (Size , SIZE ); 216 | CHECK_REQ_EX(Allocate , MemAttr::ExtractAllocate(reqFlit.MemAttr()) != 0 , MEMATTR_ALLOCATE ); 217 | CHECK_REQ_EX(Cacheable , MemAttr::ExtractCacheable(reqFlit.MemAttr()) != 0 , MEMATTR_CACHEABLE ); 218 | CHECK_REQ_EX(Device , MemAttr::ExtractDevice(reqFlit.MemAttr()) != 0 , MEMATTR_DEVICE ); 219 | CHECK_REQ_EX(EWA , MemAttr::ExtractEWA(reqFlit.MemAttr()) != 0 , MEMATTR_EWA ); 220 | CHECK_REQ (SnpAttr , SNPATTR ); 221 | #ifdef CHI_ISSUE_EB_ENABLE 222 | CHECK_REQ (DoDWT , DODWT ); 223 | #endif 224 | CHECK_REQ (Order , ORDER ); 225 | CHECK_REQ (LikelyShared , LIKELYSHARED ); 226 | CHECK_REQ (Excl , EXCL ); 227 | CHECK_REQ (SnoopMe , SNOOPME ); 228 | CHECK_REQ (ExpCompAck , EXPCOMPACK ); 229 | CHECK_REQ (LPID , LPID ); 230 | #ifdef CHI_ISSUE_EB_ENABLE 231 | CHECK_REQ (TagGroupID , TAGGROUPID ); 232 | CHECK_REQ (StashGroupID , STASHGROUPID ); 233 | CHECK_REQ (PGroupID , PGROUPID ); 234 | #endif 235 | CHECK_REQ (ReturnNID , RETURNNID ); 236 | CHECK_REQ (StashNID , STASHNID ); 237 | #ifdef CHI_ISSUE_EB_ENABLE 238 | CHECK_REQ (SLCRepHint , SLCREPHINT ); 239 | #endif 240 | CHECK_REQ (StashNIDValid , STASHNIDVALID ); 241 | CHECK_REQ (Endian , ENDIAN ); 242 | #ifdef CHI_ISSUE_EB_ENABLE 243 | CHECK_REQ (Deep , DEEP ); 244 | #endif 245 | CHECK_REQ (ReturnTxnID , RETURNTXNID ); 246 | CHECK_REQ (StashLPIDValid , STASHLPIDVALID); 247 | CHECK_REQ (StashLPID , STASHLPID ); 248 | 249 | #undef CHECK_REQ 250 | #undef CHECK_REQ_IF 251 | #undef CHECK_REQ_EX 252 | 253 | return XactDenial::ACCEPTED; 254 | } 255 | } 256 | 257 | 258 | // Implementation of: class ResponseFieldMappingChecker 259 | namespace /*CHI::*/Xact { 260 | /* 261 | ResponseFieldMappingTable table; 262 | */ 263 | 264 | template 266 | inline XactDenialEnum ResponseFieldMappingChecker::Check(const Flits::RSP& rspFlit) noexcept 267 | { 268 | #define CHECK_RSP(field, denial) \ 269 | if (!details::Check(mapping->field, rspFlit.field())) \ 270 | return XactDenial::DENIED_RSP_FIELD_##denial; 271 | 272 | #define CHECK_RSP_IF(field, denial) \ 273 | if constexpr (rsqFlit.has##field) \ 274 | if (!details::Check(mapping->field, rspFlit.field())) \ 275 | return XactDenial::DENIED_RSP_FIELD_##denial; 276 | 277 | #define CHECK_RSP_EX(field, rsp_field, denial) \ 278 | if (!details::Check(mapping->field, rsp_field)) \ 279 | return XactDenial::DENIED_RSP_FIELD_##denial; 280 | 281 | ResponseFieldMapping mapping = table.Get(rspFlit.Opcode()); 282 | 283 | if (!mapping) 284 | return XactDenial::DENIED_OPCODE; 285 | 286 | CHECK_RSP (QoS , QOS ); 287 | CHECK_RSP (TgtID , TGTID ); 288 | CHECK_RSP (SrcID , SRCID ); 289 | CHECK_RSP (TxnID , TXNID ); 290 | CHECK_RSP (Opcode , OPCODE ); 291 | CHECK_RSP (RespErr , RESPERR ); 292 | CHECK_RSP (Resp , RESP ); 293 | #ifdef CHI_ISSUE_EB_ENABLE 294 | CHECK_RSP (CBusy , CBUSY ); 295 | #endif 296 | CHECK_RSP (DBID , DBID ); 297 | #ifdef CHI_ISSUE_EB_ENABLE 298 | CHECK_RSP (TagGroupID , TAGGROUPID ); 299 | CHECK_RSP (StashGroupID , STASHGROUPID ); 300 | CHECK_RSP (PGroupID , PGROUPID ); 301 | #endif 302 | CHECK_RSP (PCrdType , PCRDTYPE ); 303 | CHECK_RSP (FwdState , FWDSTATE ); 304 | CHECK_RSP (DataPull , DATAPULL ); 305 | #ifdef CHI_ISSUE_EB_ENABLE 306 | CHECK_RSP (TagOp , TAGOP ); 307 | #endif 308 | CHECK_RSP (TraceTag , TRACETAG ); 309 | 310 | #undef CHECK_RSP 311 | #undef CHECK_RSP_IF 312 | #undef CHECK_RSP_EX 313 | 314 | return XactDenial::ACCEPTED; 315 | } 316 | } 317 | 318 | 319 | // Implementation of: class DataFieldMappingChecker 320 | namespace /*CHI::*/Xact { 321 | /* 322 | DataFieldMappingTable table; 323 | */ 324 | 325 | template 327 | inline XactDenialEnum DataFieldMappingChecker::Check(const Flits::DAT& datFlit) noexcept 328 | { 329 | #define CHECK_DAT(field, denial) \ 330 | if (!details::Check(mapping->field, datFlit.field())) \ 331 | return XactDenial::DENIED_DAT_FIELD_##denial; 332 | 333 | #define CHECK_DAT_DS(field, denial) \ 334 | if (!details::CheckDataArray(mapping->field, datFlit.field())) \ 335 | return XactDenial::DENIED_DAT_FIELD_##denial; 336 | 337 | #define CHECK_DAT_IF(field, denial) \ 338 | if constexpr (datFlit.has##field) \ 339 | if (!details::Check(mapping->field, datFlit.field())) \ 340 | return XactDenial::DENIED_DAT_FIELD_##denial; 341 | 342 | #define CHECK_DAT_EX(field, dat_field, denial) \ 343 | if (!details::Check(mapping->field, dat_field)) \ 344 | return XactDenial::DENIED_DAT_FIELD_##denial; 345 | 346 | DataFieldMapping mapping = table.Get(datFlit.Opcode()); 347 | 348 | if (!mapping) 349 | return XactDenial::DENIED_OPCODE; 350 | 351 | CHECK_DAT (QoS , QOS ); 352 | CHECK_DAT (TgtID , TGTID ); 353 | CHECK_DAT (SrcID , SRCID ); 354 | CHECK_DAT (TxnID , TXNID ); 355 | CHECK_DAT (Opcode , OPCODE ); 356 | CHECK_DAT (RespErr , RESPERR ); 357 | CHECK_DAT (Resp , RESP ); 358 | #ifdef CHI_ISSUE_EB_ENABLE 359 | CHECK_DAT (CBusy , CBUSY ); 360 | #endif 361 | CHECK_DAT (DBID , DBID ); 362 | CHECK_DAT (CCID , CCID ); 363 | CHECK_DAT (DataID , DATAID ); 364 | CHECK_DAT (RSVDC , RSVDC ); 365 | CHECK_DAT (BE , BE ); 366 | CHECK_DAT_DS(Data , DATA ); 367 | CHECK_DAT (HomeNID , HOMENID ); 368 | CHECK_DAT (FwdState , FWDSTATE ); 369 | CHECK_DAT (DataPull , DATAPULL ); 370 | CHECK_DAT (DataSource , DATASOURCE ); 371 | CHECK_DAT (TraceTag , TRACETAG ); 372 | CHECK_DAT_IF(DataCheck , DATACHECK ); 373 | CHECK_DAT_IF(Poison , POISON ); 374 | CHECK_DAT (TagOp , TAGOP ); 375 | CHECK_DAT (Tag , TAG ); 376 | CHECK_DAT (TU , TU ); 377 | 378 | #undef CHECK_DAT 379 | #undef CHECK_DAT_DS 380 | #undef CHECK_DAT_IF 381 | #undef CHECK_DAT_EX 382 | 383 | return XactDenial::ACCEPTED; 384 | } 385 | } 386 | 387 | 388 | // Implementation of: class SnoopFieldMappingChecker 389 | namespace /*CHI::*/Xact { 390 | /* 391 | SnoopFieldMappingTable table; 392 | */ 393 | 394 | template 396 | inline XactDenialEnum SnoopFieldMappingChecker::Check(const Flits::SNP& snpFlit) noexcept 397 | { 398 | #define CHECK_SNP(field, denial) \ 399 | if (!details::Check(mapping->field, snpFlit.field())) \ 400 | return XactDenial::DENIED_SNP_FIELD_##denial; 401 | 402 | #define CHECK_SNP_IF(field, denial) \ 403 | if constexpr (snpFlit.has##field) \ 404 | if (!details::Check(mapping->field, snpFlit.field())) \ 405 | return XactDenial::DENIED_SNP_FIELD_##denial; 406 | 407 | #define CHECK_SNP_EX(field, snp_field, denial) \ 408 | if (!details::Check(mapping->field, snp_field)) \ 409 | return XactDenial::DENIED_SNP_FIELD_##denial; 410 | 411 | SnoopFieldMapping mapping = table.Get(snpFlit.Opcode()); 412 | 413 | if (!mapping) 414 | return XactDenial::DENIED_OPCODE; 415 | 416 | CHECK_SNP (QoS , QOS ); 417 | CHECK_SNP (SrcID , SRCID ); 418 | CHECK_SNP (TxnID , TXNID ); 419 | CHECK_SNP (Opcode , OPCODE ); 420 | CHECK_SNP (Addr , ADDR ); 421 | CHECK_SNP (NS , NS ); 422 | CHECK_SNP (FwdNID , FWDNID ); 423 | CHECK_SNP (FwdTxnID , FWDTXNID ); 424 | CHECK_SNP (StashLPIDValid , STASHLPIDVALID); 425 | CHECK_SNP (StashLPID , STASHLPID ); 426 | CHECK_SNP (VMIDExt , VMIDEXT ); 427 | CHECK_SNP (DoNotGoToSD , DONOTGOTOSD ); 428 | #ifdef CHI_ISSUE_B_ENABLE 429 | CHECK_SNP (DoNotDataPull , DONOTDATAPULL ); 430 | #endif 431 | CHECK_SNP (RetToSrc , RETTOSRC ); 432 | CHECK_SNP (TraceTag , TRACETAG ); 433 | #ifdef CHI_ISSUE_EB_ENABLE 434 | CHECK_SNP_IF(MPAM , MPAM ); 435 | #endif 436 | 437 | #undef CHECK_SNP 438 | #undef CHECK_SNP_IF 439 | #undef CHECK_SNP_EX 440 | 441 | return XactDenial::ACCEPTED; 442 | } 443 | } 444 | 445 | 446 | #endif // __CHI__CHI_XACT_CHECKERS_* 447 | 448 | //#endif // __CHI__CHI_XACT_CHECKERS 449 | -------------------------------------------------------------------------------- /chi/xact/chi_xact_checkers_field_header.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CHI_XACT_CHECKERS_FIELD_HEADER 4 | #define __CHI__CHI_XACT_CHECKERS_FIELD_HEADER 5 | 6 | #endif // __CHI__CHI_XACT_CHECKERS_FIELD_HEADER 7 | -------------------------------------------------------------------------------- /chi/xact/chi_xact_field.hpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | namespace CHI { 4 | */ 5 | namespace Xact { 6 | 7 | enum class FieldConvention { 8 | A0 = 0, // Applicable. Must be zero. 9 | A1 = 1, // Applicable. Must be one. 10 | I0, // Inapplicable. Must be zero. 11 | X, // Inapplicable. Can take any value. 12 | Y, // Applicable. Specification constrained. 13 | B8, // Size field must be 8-byte encoding. 14 | B64, // Size field must be 64-byte encoding. 15 | S, // Assigned to another shared field. 16 | D // Inapplicable. Must be default value of MPAM field. 17 | }; 18 | 19 | namespace FieldTrait { 20 | 21 | inline constexpr bool IsApplicable(FieldConvention convention) noexcept 22 | { 23 | return !( 24 | convention == FieldConvention::I0 25 | || convention == FieldConvention::X 26 | || convention == FieldConvention::D 27 | ); 28 | } 29 | }; 30 | } 31 | /* 32 | } 33 | */ 34 | -------------------------------------------------------------------------------- /chi/xact/chi_xact_field_header.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CHI_XACT_FIELD_HEADER 4 | #define __CHI__CHI_XACT_FIELD_HEADER 5 | 6 | #include // IWYU pragma: export 7 | #include // IWYU pragma: export 8 | 9 | #include "../spec/chi_protocol_encoding_header.hpp" // IWYU pragma: export 10 | #include "../spec/chi_protocol_encoding.hpp" // IWYU pragma: export 11 | 12 | #endif // __CHI__CHI_XACT_FIELD_HEADER 13 | -------------------------------------------------------------------------------- /chi/xact/chi_xactions_header.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CHI_XACT_XACTIONS_HEADER 4 | #define __CHI__CHI_XACT_XACTIONS_HEADER 5 | 6 | #include // IWYU pragma: export 7 | #include // IWYU pragma: export 8 | #include // IWYU pragma: export 9 | #include // IWYU pragma: export 10 | #include // IWYU pragma: export 11 | #include // IWYU pragma: export 12 | #include // IWYU pragma: export 13 | #include "../../common/utility.hpp" // IWYU pragma: export 14 | 15 | 16 | #endif // __CHI__CHI_XACT_XACTIONS_HEADER 17 | -------------------------------------------------------------------------------- /chi_b/spec/chi_b_link.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_B__CHI_LINK 4 | #define __CHI_B__CHI_LINK 5 | 6 | #include "chi_b_link_channels.hpp" // IWYU pragma: export 7 | #include "chi_b_link_interfaces.hpp" // IWYU pragma: export 8 | #include "chi_b_link_links.hpp" // IWYU pragma: export 9 | #include "chi_b_link_ports.hpp" // IWYU pragma: export 10 | 11 | // CHI Link Layer headers 12 | 13 | 14 | // CHI Link Layer utilities in CHI root namespace 15 | namespace CHI::B { 16 | 17 | /* 18 | General Port instance. 19 | ------------------------------------- 20 | Example: 21 | RN-F Port: Port> 22 | SN-I Port: Port> 23 | or with all default configurations: 24 | RN-F Port: Port> 25 | SN-I Port: Port> 26 | */ 27 | template, 29 | class conn = Connection<>> 30 | using Port = CHI::B::Ports::Port; 31 | 32 | 33 | /* 34 | Port instances of RN. 35 | */ 36 | template, 37 | class conn = Connection<>> 38 | using PortRN_F = CHI::B::Ports::RN::F; 39 | 40 | template, 41 | class conn = Connection<>> 42 | using PortRN_D = CHI::B::Ports::RN::D; 43 | 44 | template, 45 | class conn = Connection<>> 46 | using PortRN_I = CHI::B::Ports::RN::I; 47 | 48 | /* 49 | Port instances of SN. 50 | */ 51 | template, 52 | class conn = Connection<>> 53 | using PortSN_F = CHI::B::Ports::SN::F; 54 | 55 | template, 56 | class conn = Connection<>> 57 | using PortSN_I = CHI::B::Ports::SN::I; 58 | } 59 | 60 | 61 | #endif // __CHI_B__CHI_LINK 62 | -------------------------------------------------------------------------------- /chi_b/spec/chi_b_link_channels.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_B__CHI_LINK_CHANNELS 4 | #define __CHI_B__CHI_LINK_CHANNELS 5 | 6 | #include "../../chi/spec/chi_link_channels_header.hpp" // IWYU pragma: keep 7 | #include "chi_b_protocol_flits.hpp" // IWYU pragma: keep 8 | 9 | #define CHI_LINK_CHANNELS__STANDALONE 10 | 11 | namespace CHI::B { 12 | 13 | #define CHI_ISSUE_B_ENABLE 14 | #include "../../chi/spec/chi_link_channels.hpp" 15 | #undef CHI_ISSUE_B_ENABLE 16 | } 17 | 18 | 19 | #undef CHI_LINK_CHANNELS__STANDALONE 20 | 21 | #endif // __CHI_B__CHI_LINK_CHANNELS 22 | -------------------------------------------------------------------------------- /chi_b/spec/chi_b_link_interfaces.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_B__CHI_LINK_INTERFACES 4 | #define __CHI_B__CHI_LINK_INTERFACES 5 | 6 | #include "../../chi/spec/chi_link_interfaces_header.hpp" // IWYU pragma: keep 7 | #include "chi_b_link_channels.hpp" // IWYU pragma: keep 8 | 9 | #define CHI_LINK_INTERFACES__STANDALONE 10 | 11 | namespace CHI::B { 12 | 13 | #define CHI_ISSUE_B_ENABLE 14 | #include "../../chi/spec/chi_link_interfaces.hpp" 15 | #undef CHI_ISSUE_B_ENABLE 16 | } 17 | 18 | 19 | #undef CHI_LINK_INTERFACES__STANDALONE 20 | 21 | #endif // __CHI_B__CHI_LINK_INTERFACES 22 | -------------------------------------------------------------------------------- /chi_b/spec/chi_b_link_links.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_B__CHI_LINK_LINKS 4 | #define __CHI_B__CHI_LINK_LINKS 5 | 6 | #include "../../chi/spec/chi_link_links_header.hpp" // IWYU pragma: keep 7 | #include "chi_b_link_interfaces.hpp" // IWYU pragma: keep 8 | 9 | #define CHI_LINK_LINKS__STANDALONE 10 | 11 | namespace CHI::B { 12 | 13 | #define CHI_ISSUE_B_ENABLE 14 | #include "../../chi/spec/chi_link_links.hpp" 15 | #undef CHI_ISSUE_B_ENABLE 16 | } 17 | 18 | 19 | #undef CHI_LINK_LINKS__STANDALONE 20 | 21 | #endif // __CHI_B__CHI_LINK_LINKS 22 | -------------------------------------------------------------------------------- /chi_b/spec/chi_b_link_ports.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_B__CHI_LINK_PORTS 4 | #define __CHI_B__CHI_LINK_PORTS 5 | 6 | #include "../../chi/spec/chi_link_ports_header.hpp" // IWYU pragma: keep 7 | #include "chi_b_link_links.hpp" // IWYU pragma: keep 8 | 9 | #define CHI_LINK_PORTS__STANDALONE 10 | 11 | namespace CHI::B { 12 | 13 | #define CHI_ISSUE_B_ENABLE 14 | #include "../../chi/spec/chi_link_ports.hpp" 15 | #undef CHI_ISSUE_B_ENABLE 16 | } 17 | 18 | 19 | #undef CHI_LINK_PORTS__STANDALONE 20 | 21 | #endif // __CHI_B__CHI_LINK_PORTS 22 | -------------------------------------------------------------------------------- /chi_b/spec/chi_b_protocol.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_B__CHI_PROTOCOL 4 | #define __CHI_B__CHI_PROTOCOL 5 | 6 | #include "chi_b_protocol_flits.hpp" // IWYU pragma: export 7 | #include "chi_b_protocol_encoding.hpp" // IWYU pragma: export 8 | 9 | // CHI Protocol Layer headers 10 | 11 | #endif // __CHI_B__CHI_PROTOCOL 12 | -------------------------------------------------------------------------------- /chi_b/spec/chi_b_protocol_encoding.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_B__CHI_PROTOCOL_ENCODING 4 | #define __CHI_B__CHI_PROTOCOL_ENCODING 5 | 6 | #include "../../chi/spec/chi_protocol_encoding_header.hpp" // IWYU pragma: keep 7 | #include "chi_b_protocol_flits.hpp" // IWYU pragma: keep 8 | 9 | #define CHI_PROTOCOL_ENCODING__STANDALONE 10 | 11 | namespace CHI::B { 12 | 13 | #define CHI_ISSUE_B_ENABLE 14 | #include "../../chi/spec/chi_protocol_encoding.hpp" 15 | #undef CHI_ISSUE_B_ENABLE 16 | } 17 | 18 | 19 | #undef CHI_PROTOCOL_ENCODING__STANDALONE 20 | 21 | #endif // __CHI_B__CHI_PROTOCOL_ENCODING 22 | -------------------------------------------------------------------------------- /chi_b/spec/chi_b_protocol_flits.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_B__CHI_PROTOCOL_FLITS 4 | #define __CHI_B__CHI_PROTOCOL_FLITS 5 | 6 | #include "../../chi/spec/chi_protocol_flits_header.hpp" // IWYU pragma: keep 7 | 8 | #define CHI_PROTOCOL_FLITS__STANDALONE 9 | 10 | namespace CHI::B { 11 | 12 | #define CHI_ISSUE_B_ENABLE 13 | #include "../../chi/spec/chi_protocol_flits.hpp" 14 | #undef CHI_ISSUE_B_ENABLE 15 | } 16 | 17 | 18 | #undef CHI_PROTOCOL_FLITS__STANDALONE 19 | 20 | #endif // __CHI_B__CHI_PROTOCOL_FLITS 21 | -------------------------------------------------------------------------------- /chi_b/util/chi_b_util_decoding.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_B__CHI_UTIL_DECODING 4 | #define __CHI_B__CHI_UTIL_DECODING 5 | 6 | #include "../../chi/util/chi_util_decoding_header.hpp" // IWYU pragma: keep 7 | #include "../spec/chi_b_protocol_encoding.hpp" // IWYU pragma: keep 8 | 9 | #define CHI_UTIL_DECODING__STANDALONE 10 | 11 | namespace CHI::B { 12 | 13 | #define CHI_ISSUE_B_ENABLE 14 | #include "../../chi/util/chi_util_decoding.hpp" 15 | #undef CHI_ISSUE_B_ENABLE 16 | } 17 | 18 | 19 | #undef CHI_UTIL_DECODING__STANDALONE 20 | 21 | #endif // __CHI_B__CHI_UTIL_DECODING 22 | -------------------------------------------------------------------------------- /chi_b/util/chi_b_util_flit.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_B__CHI_UTIL_FLIT 4 | #define __CHI_B__CHI_UTIL_FLIT 5 | 6 | #include "../../chi/util/chi_util_flit_header.hpp" // IWYU pragma: keep 7 | #include "../spec/chi_b_protocol_flits.hpp" // IWYU pragma: keep 8 | 9 | #define CHI_UTIL_FLIT__STANDALONE 10 | 11 | namespace CHI::B { 12 | 13 | #define CHI_ISSUE_B_ENABLE 14 | #include "../../chi/util/chi_util_flit.hpp" 15 | #undef CHI_ISSUE_B_ENABLE 16 | } 17 | 18 | 19 | #undef CHI_UTIL_FLIT__STANDALONE 20 | 21 | #endif // __CHI_B__CHI_UTIL_FLIT 22 | -------------------------------------------------------------------------------- /chi_c/spec/chi_c_protocol_flits.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_C__CHI_PROTOCOL_FLITS 4 | #define __CHI_C__CHI_PROTOCOL_FLITS 5 | 6 | #include "../../chi/spec/chi_protocol_flits_header.hpp" // IWYU pragma: keep 7 | 8 | #define CHI_PROTOCOL_FLITS__STANDALONE 9 | 10 | namespace CHI::C { 11 | 12 | #define CHI_ISSUE_C_ENABLE 13 | #include "../../chi/spec/chi_protocol_flits.hpp" 14 | #undef CHI_ISSUE_C_ENABLE 15 | } 16 | 17 | 18 | #undef CHI_PROTOCOL_FLITS__STANDALONE 19 | 20 | #endif // __CHI_C__CHI_PROTOCOL_FLITS 21 | -------------------------------------------------------------------------------- /chi_eb/spec/chi_eb_link.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_EB__CHI_LINK 4 | #define __CHI_EB__CHI_LINK 5 | 6 | #include "chi_eb_link_channels.hpp" // IWYU pragma: export 7 | #include "chi_eb_link_interfaces.hpp" // IWYU pragma: export 8 | #include "chi_eb_link_links.hpp" // IWYU pragma: export 9 | #include "chi_eb_link_ports.hpp" // IWYU pragma: export 10 | 11 | // CHI Link Layer headers 12 | 13 | 14 | // CHI Link Layer utilities in CHI root namespace 15 | namespace CHI::Eb { 16 | 17 | /* 18 | General Port instance. 19 | ------------------------------------- 20 | Example: 21 | RN-F Port: Port> 22 | SN-I Port: Port> 23 | or with all default configurations: 24 | RN-F Port: Port> 25 | SN-I Port: Port> 26 | */ 27 | template, 29 | class conn = Connection<>> 30 | using Port = CHI::Eb::Ports::Port; 31 | 32 | 33 | /* 34 | Port instances of RN. 35 | */ 36 | template, 37 | class conn = Connection<>> 38 | using PortRN_F = CHI::Eb::Ports::RN::F; 39 | 40 | template, 41 | class conn = Connection<>> 42 | using PortRN_D = CHI::Eb::Ports::RN::D; 43 | 44 | template, 45 | class conn = Connection<>> 46 | using PortRN_I = CHI::Eb::Ports::RN::I; 47 | 48 | /* 49 | Port instances of SN. 50 | */ 51 | template, 52 | class conn = Connection<>> 53 | using PortSN_F = CHI::Eb::Ports::SN::F; 54 | 55 | template, 56 | class conn = Connection<>> 57 | using PortSN_I = CHI::Eb::Ports::SN::I; 58 | } 59 | 60 | 61 | #endif // __CHI_EB__CHI_LINK 62 | -------------------------------------------------------------------------------- /chi_eb/spec/chi_eb_link_channels.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_EB__CHI_LINK_CHANNELS 4 | #define __CHI_EB__CHI_LINK_CHANNELS 5 | 6 | #include "../../chi/spec/chi_link_channels_header.hpp" // IWYU pragma: keep 7 | #include "chi_eb_protocol_flits.hpp" // IWYU pragma: keep 8 | 9 | #define CHI_LINK_CHANNELS__STANDALONE 10 | 11 | namespace CHI::Eb { 12 | 13 | #define CHI_ISSUE_EB_ENABLE 14 | #include "../../chi/spec/chi_link_channels.hpp" 15 | #undef CHI_ISSUE_EB_ENABLE 16 | } 17 | 18 | 19 | #undef CHI_LINK_CHANNELS__STANDALONE 20 | 21 | #endif // __CHI_EB__CHI_LINK_CHANNELS 22 | -------------------------------------------------------------------------------- /chi_eb/spec/chi_eb_link_interfaces.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_EB__CHI_LINK_INTERFACES 4 | #define __CHI_EB__CHI_LINK_INTERFACES 5 | 6 | #include "../../chi/spec/chi_link_interfaces_header.hpp" // IWYU pragma: keep 7 | #include "chi_eb_link_channels.hpp" // IWYU pragma: keep 8 | 9 | #define CHI_LINK_INTERFACES__STANDALONE 10 | 11 | namespace CHI::Eb { 12 | 13 | #define CHI_ISSUE_EB_ENABLE 14 | #include "../../chi/spec/chi_link_interfaces.hpp" 15 | #undef CHI_ISSUE_EB_ENABLE 16 | } 17 | 18 | 19 | #undef CHI_LINK_INTERFACES__STANDALONE 20 | 21 | #endif // __CHI_EB__CHI_LINK_INTERFACES 22 | -------------------------------------------------------------------------------- /chi_eb/spec/chi_eb_link_links.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_EB__CHI_LINK_LINKS 4 | #define __CHI_EB__CHI_LINK_LINKS 5 | 6 | #include "../../chi/spec/chi_link_links_header.hpp" // IWYU pragma: keep 7 | #include "chi_eb_link_interfaces.hpp" // IWYU pragma: keep 8 | 9 | #define CHI_LINK_LINKS__STANDALONE 10 | 11 | namespace CHI::Eb { 12 | 13 | #define CHI_ISSUE_EB_ENABLE 14 | #include "../../chi/spec/chi_link_links.hpp" 15 | #undef CHI_ISSUE_EB_ENABLE 16 | } 17 | 18 | 19 | #undef CHI_LINK_LINKS__STANDALONE 20 | 21 | #endif // __CHI_EB__CHI_LINK_LINKS 22 | -------------------------------------------------------------------------------- /chi_eb/spec/chi_eb_link_ports.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_EB__CHI_LINK_PORTS 4 | #define __CHI_EB__CHI_LINK_PORTS 5 | 6 | #include "../../chi/spec/chi_link_ports_header.hpp" // IWYU pragma: keep 7 | #include "chi_eb_link_links.hpp" // IWYU pragma: keep 8 | 9 | #define CHI_LINK_PORTS__STANDALONE 10 | 11 | namespace CHI::Eb { 12 | 13 | #define CHI_ISSUE_EB_ENABLE 14 | #include "../../chi/spec/chi_link_ports.hpp" 15 | #undef CHI_ISSUE_EB_ENABLE 16 | } 17 | 18 | 19 | #undef CHI_LINK_PORTS__STANDALONE 20 | 21 | #endif // __CHI_EB__CHI_LINK_PORTS 22 | -------------------------------------------------------------------------------- /chi_eb/spec/chi_eb_protocol.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_EB__CHI_PROTOCOL 4 | #define __CHI_EB__CHI_PROTOCOL 5 | 6 | #include "chi_eb_protocol_flits.hpp" // IWYU pragma: export 7 | #include "chi_eb_protocol_encoding.hpp" // IWYU pragma: export 8 | 9 | // CHI Protocol Layer headers 10 | 11 | #endif // __CHI_EB__CHI_PROTOCOL 12 | -------------------------------------------------------------------------------- /chi_eb/spec/chi_eb_protocol_encoding.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_EB__CHI_PROTOCOL_ENCODING 4 | #define __CHI_EB__CHI_PROTOCOL_ENCODING 5 | 6 | #include "../../chi/spec/chi_protocol_encoding_header.hpp" // IWYU pragma: keep 7 | #include "chi_eb_protocol_flits.hpp" // IWYU pragma: keep 8 | 9 | #define CHI_PROTOCOL_ENCODING__STANDALONE 10 | 11 | namespace CHI::Eb { 12 | 13 | #define CHI_ISSUE_EB_ENABLE 14 | #include "../../chi/spec/chi_protocol_encoding.hpp" 15 | #undef CHI_ISSUE_EB_ENABLE 16 | } 17 | 18 | 19 | #undef CHI_PROTOCOL_ENCODING__STANDALONE 20 | 21 | #endif // __CHI_EB__CHI_PROTOCOL_ENCODING 22 | -------------------------------------------------------------------------------- /chi_eb/spec/chi_eb_protocol_flits.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_EB__CHI_PROTOCOL_FLITS 4 | #define __CHI_EB__CHI_PROTOCOL_FLITS 5 | 6 | #include "../../chi/spec/chi_protocol_flits_header.hpp" // IWYU pragma: keep 7 | 8 | #define CHI_PROTOCOL_FLITS__STANDALONE 9 | 10 | namespace CHI::Eb { 11 | 12 | #define CHI_ISSUE_EB_ENABLE 13 | #include "../../chi/spec/chi_protocol_flits.hpp" 14 | #undef CHI_ISSUE_EB_ENABLE 15 | } 16 | 17 | 18 | #undef CHI_PROTOCOL_FLITS__STANDALONE 19 | 20 | #endif // __CHI_EB__CHI_PROTOCOL_FLITS 21 | -------------------------------------------------------------------------------- /chi_eb/util/chi_eb_util_decoding.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_EB__CHI_UTIL_DECODING 4 | #define __CHI_EB__CHI_UTIL_DECODING 5 | 6 | #include "../../chi/util/chi_util_decoding_header.hpp" // IWYU pragma: keep 7 | #include "../spec/chi_eb_protocol_encoding.hpp" // IWYU pragma: keep 8 | 9 | #define CHI_UTIL_DECODING__STANDALONE 10 | 11 | namespace CHI::Eb { 12 | 13 | #define CHI_ISSUE_EB_ENABLE 14 | #include "../../chi/util/chi_util_decoding.hpp" 15 | #undef CHI_ISSUE_EB_ENABLE 16 | } 17 | 18 | 19 | #undef CHI_UTIL_DECODING__STANDALONE 20 | 21 | #endif // __CHI_EB__CHI_UTIL_DECODING 22 | -------------------------------------------------------------------------------- /chi_eb/util/chi_eb_util_flit.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_EB__CHI_UTIL_FLIT 4 | #define __CHI_EB__CHI_UTIL_FLIT 5 | 6 | #include "../../chi/util/chi_util_flit_header.hpp" // IWYU pragma: keep 7 | #include "../spec/chi_eb_protocol_flits.hpp" // IWYU pragma: keep 8 | 9 | #define CHI_UTIL_FLIT__STANDALONE 10 | 11 | namespace CHI::Eb { 12 | 13 | #define CHI_ISSUE_EB_ENABLE 14 | #include "../../chi/util/chi_util_flit.hpp" 15 | #undef CHI_ISSUE_EB_ENABLE 16 | } 17 | 18 | 19 | #undef CHI_UTIL_FLIT__STANDALONE 20 | 21 | #endif // __CHI_EB__CHI_UTIL_FLIT 22 | -------------------------------------------------------------------------------- /chi_eb/xact/chi_eb_joint.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_EB__CHI_JOINT 4 | #define __CHI_EB__CHI_JOINT 5 | 6 | #include "../../chi/xact/chi_joint_header.hpp" // IWYU pragma: keep 7 | #include "../util/chi_eb_util_decoding.hpp" // IWYU pragma: keep 8 | #include "chi_eb_xactions.hpp" // IWYU pragma: keep 9 | 10 | #define CHI_XACT_XACTIONS__STANDALONE 11 | 12 | namespace CHI::Eb { 13 | 14 | #define CHI_ISSUE_EB_ENABLE 15 | #include "../../chi/xact/chi_joint.hpp" 16 | #undef CHI_ISSUE_EB_ENABLE 17 | } 18 | 19 | #undef CHI_XACT_XACTIONS__STANDALONE 20 | 21 | #endif // __CHI_EB__CHI_JOINT 22 | -------------------------------------------------------------------------------- /chi_eb/xact/chi_eb_xact_base.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_EB__CHI_XACT_BASE 4 | #define __CHI_EB__CHI_XACT_BASE 5 | 6 | #include "../../chi/xact/chi_xact_base_header.hpp" // IWYU pragma: keep 7 | #include "../spec/chi_eb_protocol_encoding.hpp" // IWYU pragma: keep 8 | 9 | #define CHI_XACT_BASE__STANDALONE 10 | 11 | namespace CHI::Eb { 12 | 13 | #define CHI_ISSUE_EB_ENABLE 14 | #include "../../chi/xact/chi_xact_base.hpp" 15 | #undef CHI_ISSUE_EB_ENABLE 16 | } 17 | 18 | 19 | #undef CHI_XACT_BASE__STANDALONE 20 | 21 | #endif // __CHI_EB__CHI_XACT_BASE 22 | -------------------------------------------------------------------------------- /chi_eb/xact/chi_eb_xact_checkers_field.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_EB__CHI_XACT_CHECKERS_FIELD 4 | #define __CHI_EB__CHI_XACT_CHECKERS_FIELD 5 | 6 | #include "../../chi/xact/chi_xact_checkers_field_header.hpp" // IWYU pragma: keep 7 | #include "../spec/chi_eb_protocol_encoding.hpp" // IWYU pragma: keep 8 | #include "chi_eb_xact_base.hpp" // IWYU pragma: keep 9 | #include "chi_eb_xact_field.hpp" // IWYU pragma: keep 10 | 11 | namespace CHI::Eb { 12 | 13 | #define CHI_ISSUE_EB_ENABLE 14 | #include "../../chi/xact/chi_xact_checkers_field.hpp" 15 | #undef CHI_ISSUE_EB_ENABLE 16 | } 17 | 18 | #endif // __CHI_EB__CHI_XACT_CHECKERS_FIELD 19 | -------------------------------------------------------------------------------- /chi_eb/xact/chi_eb_xact_field.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_EB__CHI_XACT_FIELD 4 | #define __CHI_EB__CHI_XACT_FIELD 5 | 6 | #include "../../chi/xact/chi_xact_field_header.hpp" // IWYU pragma: keep 7 | 8 | namespace CHI::Eb { 9 | 10 | #define CHI_ISSUE_EB_ENABLE 11 | #include "../../chi/xact/chi_xact_field_eb.hpp" 12 | #undef CHI_ISSUE_EB_ENABLE 13 | } 14 | 15 | #endif // __CHI_EB__CHI_XACT_FIELD 16 | -------------------------------------------------------------------------------- /chi_eb/xact/chi_eb_xactions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI_EB__CHI_XACT_XACTIONS 4 | #define __CHI_EB__CHI_XACT_XACTIONS 5 | 6 | #include "../../chi/xact/chi_xactions_header.hpp" // IWYU pragma: keep 7 | #include "chi_eb_xact_base.hpp" // IWYU pragma: keep 8 | #include "chi_eb_xact_checkers_field.hpp" // IWYU pragma: keep 9 | 10 | #define CHI_XACT_XACTIONS__STANDALONE 11 | 12 | namespace CHI::Eb { 13 | 14 | #define CHI_ISSUE_EB_ENABLE 15 | #include "../../chi/xact/chi_xactions.hpp" 16 | #undef CHI_ISSUE_EB_ENABLE 17 | } 18 | 19 | 20 | #undef CHI_XACT_XACTIONS__STANDALONE 21 | 22 | #endif // __CHI_EB__CHI_XACT_XACTIONS 23 | -------------------------------------------------------------------------------- /clog/clog.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CLOG 4 | #define __CHI__CLOG 5 | 6 | #include // IWYU pragma: keep 7 | #include 8 | 9 | //#define CLOG_STANDALONE 10 | 11 | #ifndef CLOG_STANDALONE 12 | # include "../chi/basic/chi_parameters.hpp" 13 | #endif 14 | 15 | 16 | namespace CLog { 17 | 18 | /* 19 | * Enumeration of CHI Issue versions 20 | */ 21 | enum class Issue { 22 | B = 0, 23 | Eb = 3 24 | }; 25 | 26 | /* 27 | * Enumeration of CHI standard node types 28 | */ 29 | enum class NodeType { 30 | RN_F = 1, 31 | RN_D = 2, 32 | RN_I = 3, 33 | HN_F = 5, 34 | HN_I = 7, 35 | SN_F = 9, 36 | SN_I = 11, 37 | MN = 12 38 | }; 39 | 40 | std::string NodeTypeToString(NodeType type) noexcept; 41 | 42 | /* 43 | * Enumeration of CHI channels 44 | */ 45 | enum class Channel { 46 | TXREQ = 0, 47 | TXRSP = 1, 48 | TXDAT = 2, 49 | TXSNP = 3, 50 | 51 | RXREQ = 4, 52 | RXRSP = 5, 53 | RXDAT = 6, 54 | RXSNP = 7, 55 | }; 56 | 57 | /* 58 | * CHI parameter container 59 | */ 60 | class Parameters { 61 | protected: 62 | Issue issue; 63 | size_t nodeIdWidth; 64 | size_t reqAddrWidth; 65 | size_t reqRsvdcWidth; 66 | size_t datRsvdcWidth; 67 | size_t dataWidth; 68 | bool dataCheckPresent; 69 | bool poisonPresent; 70 | bool mpamPresent; 71 | 72 | public: 73 | Parameters() noexcept; 74 | 75 | public: 76 | void SetIssue(Issue issue) noexcept; 77 | bool SetNodeIdWidth(size_t nodeIdWidth) noexcept; 78 | bool SetReqAddrWidth(size_t reqAddrWidth) noexcept; 79 | bool SetReqRSVDCWidth(size_t reqRsvdcWidth) noexcept; 80 | bool SetDatRSVDCWidth(size_t datRsvdcWidth) noexcept; 81 | bool SetDataWidth(size_t dataWidth) noexcept; 82 | void SetDataCheckPresent(bool dataCheckPresent) noexcept; 83 | void SetPoisonPresent(bool poisonPresent) noexcept; 84 | void SetMPAMPresent(bool mpamPresent) noexcept; 85 | 86 | public: 87 | Issue GetIssue() const noexcept; 88 | size_t GetNodeIdWidth() const noexcept; 89 | size_t GetReqAddrWidth() const noexcept; 90 | size_t GetReqRSVDCWidth() const noexcept; 91 | size_t GetDatRSVDCWidth() const noexcept; 92 | size_t GetDataWidth() const noexcept; 93 | bool IsDataCheckPresent() const noexcept; 94 | bool IsPoisonPresent() const noexcept; 95 | bool IsMPAMPresent() const noexcept; 96 | }; 97 | } 98 | 99 | 100 | // Implementation of: class Parameters 101 | namespace CLog { 102 | /* 103 | Issue issue; 104 | size_t nodeIdWidth; 105 | size_t reqAddrWidth; 106 | size_t reqRsvdcWidth; 107 | size_t datRsvdcWidth; 108 | size_t dataWidth; 109 | bool dataCheckPresent; 110 | bool poisonPresent; 111 | bool mpamPresent; 112 | */ 113 | 114 | inline Parameters::Parameters() noexcept 115 | : issue (Issue::B) 116 | , nodeIdWidth (7) 117 | , reqAddrWidth (44) 118 | , reqRsvdcWidth (0) 119 | , datRsvdcWidth (0) 120 | , dataWidth (128) 121 | , dataCheckPresent (false) 122 | , poisonPresent (false) 123 | , mpamPresent (false) 124 | { } 125 | 126 | inline void Parameters::SetIssue(Issue issue) noexcept 127 | { 128 | this->issue = issue; 129 | } 130 | 131 | inline bool Parameters::SetNodeIdWidth(size_t nodeIdWidth) noexcept 132 | { 133 | #ifndef CLOG_STANDALONE 134 | if (!CHI::CheckNodeIdWidth(nodeIdWidth)) 135 | return false; 136 | #endif 137 | 138 | this->nodeIdWidth = nodeIdWidth; 139 | 140 | return true; 141 | } 142 | 143 | inline bool Parameters::SetReqAddrWidth(size_t reqAddrWidth) noexcept 144 | { 145 | #ifndef CLOG_STANDALONE 146 | if (!CHI::CheckReqAddrWidth(reqAddrWidth)) 147 | return false; 148 | #endif 149 | 150 | this->reqAddrWidth = reqAddrWidth; 151 | 152 | return true; 153 | } 154 | 155 | inline bool Parameters::SetReqRSVDCWidth(size_t reqRsvdcWidth) noexcept 156 | { 157 | #ifndef CLOG_STANDALONE 158 | if (!CHI::CheckRSVDCWidth(reqRsvdcWidth)) 159 | return false; 160 | #endif 161 | 162 | this->reqRsvdcWidth = reqRsvdcWidth; 163 | 164 | return true; 165 | } 166 | 167 | inline bool Parameters::SetDatRSVDCWidth(size_t datRsvdcWidth) noexcept 168 | { 169 | #ifndef CLOG_STANDALONE 170 | if (!CHI::CheckRSVDCWidth(datRsvdcWidth)) 171 | return false; 172 | #endif 173 | 174 | this->datRsvdcWidth = datRsvdcWidth; 175 | 176 | return true; 177 | } 178 | 179 | inline bool Parameters::SetDataWidth(size_t dataWidth) noexcept 180 | { 181 | #ifndef CLOG_STANDALONE 182 | if (!CHI::CheckDataWidth(dataWidth)) 183 | return false; 184 | #endif 185 | 186 | this->dataWidth = dataWidth; 187 | 188 | return true; 189 | } 190 | 191 | inline void Parameters::SetDataCheckPresent(bool dataCheckPresent) noexcept 192 | { 193 | this->dataCheckPresent = dataCheckPresent; 194 | } 195 | 196 | inline void Parameters::SetPoisonPresent(bool poisonPresent) noexcept 197 | { 198 | this->poisonPresent = poisonPresent; 199 | } 200 | 201 | inline void Parameters::SetMPAMPresent(bool mpamPresent) noexcept 202 | { 203 | this->mpamPresent = mpamPresent; 204 | } 205 | 206 | inline Issue Parameters::GetIssue() const noexcept 207 | { 208 | return issue; 209 | } 210 | 211 | inline size_t Parameters::GetNodeIdWidth() const noexcept 212 | { 213 | return nodeIdWidth; 214 | } 215 | 216 | inline size_t Parameters::GetReqAddrWidth() const noexcept 217 | { 218 | return reqAddrWidth; 219 | } 220 | 221 | inline size_t Parameters::GetReqRSVDCWidth() const noexcept 222 | { 223 | return reqRsvdcWidth; 224 | } 225 | 226 | inline size_t Parameters::GetDatRSVDCWidth() const noexcept 227 | { 228 | return datRsvdcWidth; 229 | } 230 | 231 | inline size_t Parameters::GetDataWidth() const noexcept 232 | { 233 | return dataWidth; 234 | } 235 | 236 | inline bool Parameters::IsDataCheckPresent() const noexcept 237 | { 238 | return dataCheckPresent; 239 | } 240 | 241 | inline bool Parameters::IsPoisonPresent() const noexcept 242 | { 243 | return poisonPresent; 244 | } 245 | 246 | inline bool Parameters::IsMPAMPresent() const noexcept 247 | { 248 | return mpamPresent; 249 | } 250 | } 251 | 252 | 253 | // Implementation of: NodeTypeToString 254 | namespace CLog { 255 | inline std::string NodeTypeToString(NodeType type) noexcept 256 | { 257 | switch (type) 258 | { 259 | case NodeType::RN_F: return "RN-F"; 260 | case NodeType::RN_D: return "RN-D"; 261 | case NodeType::RN_I: return "RN-I"; 262 | case NodeType::HN_F: return "HN-F"; 263 | case NodeType::HN_I: return "HN-I"; 264 | case NodeType::SN_F: return "SN-F"; 265 | case NodeType::SN_I: return "SN-I"; 266 | case NodeType::MN: return "MN"; 267 | default: return ""; 268 | } 269 | } 270 | } 271 | 272 | 273 | #endif // __CHI__CLOG 274 | -------------------------------------------------------------------------------- /clog/clog_b/clog_b.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CLOG_B 4 | #define __CHI__CLOG_B 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "clog_b_tag.hpp" 14 | 15 | namespace CLog::CLogB { 16 | 17 | /* CLog.B Tag Reader */ 18 | class Reader { 19 | public: 20 | virtual ~Reader() noexcept; 21 | 22 | public: 23 | std::shared_ptr Next(std::istream& is, std::string& errorMessage) noexcept; 24 | 25 | public: 26 | virtual bool OnTagCHIParameters(std::shared_ptr tag, std::string& errorMessage) noexcept; 27 | virtual bool OnTagCHITopologies(std::shared_ptr tag, std::string& errorMessage) noexcept; 28 | virtual bool OnTagCHIRecords(std::shared_ptr tag, std::string& errorMessage) noexcept; 29 | }; 30 | 31 | /* CLog.B Tag Reader with Callbacks */ 32 | class ReaderWithCallback : public Reader { 33 | public: 34 | ReaderWithCallback() noexcept; 35 | virtual ~ReaderWithCallback() noexcept; 36 | 37 | public: 38 | using CallbackOnTagCHIParameters = 39 | std::function, std::string&)>; 40 | 41 | using CallbackOnTagCHITopologies = 42 | std::function, std::string&)>; 43 | 44 | using CallbackOnTagCHIRecords = 45 | std::function, std::string&)>; 46 | 47 | public: 48 | CallbackOnTagCHIParameters callbackOnTagCHIParameters; 49 | CallbackOnTagCHITopologies callbackOnTagCHITopologies; 50 | CallbackOnTagCHIRecords callbackOnTagCHIRecords; 51 | 52 | public: 53 | virtual bool OnTagCHIParameters(std::shared_ptr tag, std::string& errorMessage) noexcept override; 54 | virtual bool OnTagCHITopologies(std::shared_ptr tag, std::string& errorMessage) noexcept override; 55 | virtual bool OnTagCHIRecords(std::shared_ptr tag, std::string& errorMessage) noexcept override; 56 | }; 57 | 58 | /* CLog.B Tag Writer */ 59 | class Writer { 60 | public: 61 | void Next(std::ostream& os, const Tag* tag) const noexcept; 62 | }; 63 | } 64 | 65 | 66 | // Implementation of: class Reader 67 | namespace CLog::CLogB { 68 | /* 69 | */ 70 | 71 | inline Reader::~Reader() noexcept 72 | { } 73 | 74 | inline bool Reader::OnTagCHIParameters(std::shared_ptr tag, std::string& errorMessage) noexcept 75 | { 76 | return true; 77 | } 78 | 79 | inline bool Reader::OnTagCHITopologies(std::shared_ptr tag, std::string& errorMessage) noexcept 80 | { 81 | return true; 82 | } 83 | 84 | inline bool Reader::OnTagCHIRecords(std::shared_ptr tag, std::string& errorMessage) noexcept 85 | { 86 | return true; 87 | } 88 | 89 | inline std::shared_ptr Reader::Next(std::istream& is, std::string& errorMessage) noexcept 90 | { 91 | // read tag type 92 | tagtype_t type; 93 | 94 | if (!is.read(reinterpret_cast(&type), 1)) 95 | return std::shared_ptr(new TagEOF); 96 | 97 | // read length 98 | size_t length; 99 | 100 | if (!is.read(reinterpret_cast(&length), 8)) 101 | { 102 | errorMessage = "Reader: length: unexpected EOF"; 103 | return nullptr; 104 | } 105 | 106 | length = details::__bswap64_to_little(length); 107 | 108 | // 109 | if (type == Encodings::CHI_PARAMETERS) 110 | { 111 | std::shared_ptr tag(new TagCHIParameters); 112 | 113 | if (!tag->Deserialize(is, errorMessage)) 114 | return nullptr; 115 | 116 | if (!OnTagCHIParameters(tag, errorMessage)) 117 | return nullptr; 118 | 119 | return tag; 120 | } 121 | else if (type == Encodings::CHI_TOPOS) 122 | { 123 | std::shared_ptr tag(new TagCHITopologies); 124 | 125 | if (!tag->Deserialize(is, errorMessage)) 126 | return nullptr; 127 | 128 | if (!OnTagCHITopologies(tag, errorMessage)) 129 | return nullptr; 130 | 131 | return tag; 132 | } 133 | else if (type == Encodings::CHI_RECORDS) 134 | { 135 | std::shared_ptr tag(new TagCHIRecords); 136 | 137 | if (!tag->Deserialize(is, errorMessage)) 138 | return nullptr; 139 | 140 | if (!OnTagCHIRecords(tag, errorMessage)) 141 | return nullptr; 142 | 143 | return tag; 144 | } 145 | else 146 | { 147 | errorMessage = StringAppender("Reader: ") 148 | .Append("unrecognized tag type: ", uint64_t(type)) 149 | .ToString(); 150 | return nullptr; 151 | } 152 | } 153 | } 154 | 155 | 156 | // Implementation of: class ReaderWithCallback 157 | namespace CLog::CLogB { 158 | /* 159 | CallbackOnTagCHIParameters callbackOnTagCHIParameters; 160 | CallbackOnTagCHITopologies callbackOnTagCHITopologies; 161 | CallbackOnTagCHIRecords callbackOnTagCHIRecords; 162 | */ 163 | 164 | inline ReaderWithCallback::ReaderWithCallback() noexcept 165 | : callbackOnTagCHIParameters ([](auto, auto) { return true; }) 166 | , callbackOnTagCHITopologies ([](auto, auto) { return true; }) 167 | , callbackOnTagCHIRecords ([](auto, auto) { return true; }) 168 | { } 169 | 170 | inline ReaderWithCallback::~ReaderWithCallback() noexcept 171 | { } 172 | 173 | inline bool ReaderWithCallback::OnTagCHIParameters(std::shared_ptr tag, std::string& errorMessage) noexcept 174 | { 175 | return callbackOnTagCHIParameters(tag, errorMessage); 176 | } 177 | 178 | inline bool ReaderWithCallback::OnTagCHITopologies(std::shared_ptr tag, std::string& errorMessage) noexcept 179 | { 180 | return callbackOnTagCHITopologies(tag, errorMessage); 181 | } 182 | 183 | inline bool ReaderWithCallback::OnTagCHIRecords(std::shared_ptr tag, std::string& errorMessage) noexcept 184 | { 185 | return callbackOnTagCHIRecords(tag, errorMessage); 186 | } 187 | } 188 | 189 | 190 | // Implementation of: class Writer 191 | namespace CLog::CLogB { 192 | /* 193 | */ 194 | 195 | inline void Writer::Next(std::ostream& os, const Tag* tag) const noexcept 196 | { 197 | std::ostringstream oss(std::ios_base::out | std::ios_base::binary); 198 | 199 | // write tag type 200 | os.write(reinterpret_cast(&(tag->type)), 1); 201 | 202 | // serialize tag 203 | tag->Serialize(oss); 204 | 205 | // write tag length 206 | size_t length = details::__bswap64_to_little(oss.tellp()); 207 | os.write(reinterpret_cast(&length), 8); 208 | 209 | // write tag 210 | os.write(reinterpret_cast(oss.str().c_str()), length); 211 | } 212 | } 213 | 214 | 215 | #endif // __CHI__CLOG_B 216 | -------------------------------------------------------------------------------- /clog/clog_b/clogdpi_b.cpp: -------------------------------------------------------------------------------- 1 | #include "clogdpi_b.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "../../common/concurrentqueue.hpp" 13 | 14 | #include "clog_b.hpp" 15 | 16 | 17 | #define CLOG_B_RECORD_BLOCK_LIMIT 1048576 18 | #define CLOG_B_RECORD_BLOCK_COMPRESSION 1 19 | 20 | 21 | /* 22 | * CLog.B operation handle and structures. 23 | */ 24 | struct CLogBHandle { 25 | std::ofstream* ofs; 26 | std::string ofpath; 27 | moodycamel::ConcurrentQueue* 28 | queue; 29 | std::atomic_bool stop; 30 | std::thread worker; 31 | 32 | std::vector 33 | topos; 34 | 35 | CLog::CLogB::TagCHIRecords* records; 36 | uint64_t lastRecordTime; 37 | }; 38 | 39 | std::unordered_map SHARED_HANDLES; 40 | 41 | 42 | /* 43 | * CLog.B file handle operations implementations. 44 | */ 45 | 46 | extern "C" void* CLogB_OpenFile( 47 | const char* path, 48 | uint32_t* status) 49 | { 50 | CLogBHandle* handle = new CLogBHandle; 51 | 52 | std::ofstream* ofs = 53 | new std::ofstream(path, std::ios_base::out | std::ios_base::trunc); 54 | 55 | if (!*ofs) 56 | { 57 | *status = 1; 58 | std::cout << "[CLog.B] unable to open file: " << path << std::endl; 59 | return NULL; 60 | } 61 | else 62 | { 63 | std::cout << "[CLog.B] opened file: " << path << std::endl; 64 | } 65 | 66 | *status = 0; 67 | 68 | handle->ofs = ofs; 69 | handle->ofpath = path; 70 | handle->queue = new moodycamel::ConcurrentQueue; 71 | handle->stop = false; 72 | 73 | std::atomic_thread_fence(std::memory_order_seq_cst); 74 | 75 | handle->worker = std::thread([=]() -> void { 76 | CLog::CLogB::TagCHIRecords* records; 77 | while (1) 78 | { 79 | if (handle->queue->try_dequeue(records)) 80 | { 81 | CLog::CLogB::Writer().Next(*handle->ofs, records); 82 | delete records; 83 | } 84 | else if (handle->stop) 85 | return; 86 | } 87 | }); 88 | 89 | handle->records = nullptr; 90 | 91 | return handle; 92 | } 93 | 94 | extern "C" void CLogB_CloseFile( 95 | void* handle) 96 | { 97 | CLogBHandle* chandle = (CLogBHandle*) handle; 98 | 99 | if (chandle->records) 100 | { 101 | while (!chandle->queue->try_enqueue(chandle->records)); 102 | chandle->records = nullptr; 103 | } 104 | 105 | while (chandle->queue->size_approx()); 106 | 107 | chandle->stop = true; 108 | 109 | chandle->worker.join(); 110 | 111 | chandle->ofs->close(); 112 | 113 | std::cout << "[CLog.B] closed file: " << chandle->ofpath << std::endl; 114 | 115 | delete chandle->ofs; 116 | delete chandle->queue; 117 | if (chandle->records) 118 | delete chandle->records; 119 | delete chandle; 120 | } 121 | 122 | extern "C" void CLogB_ShareHandle( 123 | const char* id, 124 | void* handle) 125 | { 126 | SHARED_HANDLES[std::string(id)] = (CLogBHandle*) handle; 127 | } 128 | 129 | extern "C" int CLogB_UnshareHandle( 130 | const char* id) 131 | { 132 | return SHARED_HANDLES.erase(std::string(id)); 133 | } 134 | 135 | extern "C" void* CLogB_GetSharedHandle( 136 | const char* id) 137 | { 138 | auto iter = SHARED_HANDLES.find(std::string(id)); 139 | 140 | if (iter == SHARED_HANDLES.end()) 141 | return nullptr; 142 | 143 | return iter->second; 144 | } 145 | 146 | 147 | /* 148 | * CLog.B parameters write operations implementations. 149 | */ 150 | extern "C" void CLogB_WriteParameters( 151 | void* handle, 152 | uint32_t issue, 153 | uint32_t nodeidWidth, 154 | uint32_t addrWidth, 155 | uint32_t reqRsvdcWidth, 156 | uint32_t datRsvdcWidth, 157 | uint32_t dataWidth, 158 | uint32_t dataCheckPresent, 159 | uint32_t poisonPresent, 160 | uint32_t mpamPresent) 161 | { 162 | // 163 | CLog::Parameters params; 164 | params.SetIssue(CLog::Issue(issue)); 165 | params.SetNodeIdWidth(nodeidWidth); 166 | params.SetReqAddrWidth(addrWidth); 167 | params.SetReqRSVDCWidth(reqRsvdcWidth); 168 | params.SetDatRSVDCWidth(datRsvdcWidth); 169 | params.SetDataWidth(dataWidth); 170 | params.SetDataCheckPresent(dataCheckPresent); 171 | params.SetPoisonPresent(poisonPresent); 172 | params.SetMPAMPresent(mpamPresent); 173 | 174 | // 175 | CLogBHandle* chandle = (CLogBHandle*) handle; 176 | 177 | CLog::CLogB::TagCHIParameters tag; 178 | tag.parameters = params; 179 | 180 | CLog::CLogB::Writer().Next(*chandle->ofs, &tag); 181 | } 182 | 183 | extern "C" void CLogB_SharedWriteParameters( 184 | const char* id, 185 | uint32_t issue, 186 | uint32_t nodeIdWidth, 187 | uint32_t addrWidth, 188 | uint32_t reqRsvdcWidth, 189 | uint32_t datRsvdcWidth, 190 | uint32_t dataWidth, 191 | uint32_t dataCheckPresent, 192 | uint32_t poisonPresent, 193 | uint32_t mpamPresent) 194 | { 195 | auto iter = SHARED_HANDLES.find(std::string(id)); 196 | 197 | if (iter == SHARED_HANDLES.end()) 198 | return; 199 | 200 | CLogB_WriteParameters( 201 | iter->second, 202 | issue, 203 | nodeIdWidth, 204 | addrWidth, 205 | reqRsvdcWidth, 206 | datRsvdcWidth, 207 | dataWidth, 208 | dataCheckPresent, 209 | poisonPresent, 210 | mpamPresent 211 | ); 212 | } 213 | 214 | 215 | /* 216 | * CLog.B topologies write operations implementations. 217 | */ 218 | extern "C" void CLogB_WriteTopo( 219 | void* handle, 220 | uint32_t nodeId, 221 | uint32_t nodeType) 222 | { 223 | CLogBHandle* chandle = (CLogBHandle*) handle; 224 | 225 | chandle->topos.push_back(CLog::CLogB::TagCHITopologies::Node { 226 | .type = CLog::NodeType(nodeType), 227 | .id = uint16_t(nodeId) 228 | }); 229 | } 230 | 231 | extern "C" void CLogB_WriteTopoEnd( 232 | void* handle) 233 | { 234 | CLogBHandle* chandle = (CLogBHandle*) handle; 235 | 236 | CLog::CLogB::TagCHITopologies tag; 237 | tag.nodes = chandle->topos; 238 | 239 | CLog::CLogB::Writer().Next(*chandle->ofs, &tag); 240 | } 241 | 242 | extern "C" void CLogB_SharedWriteTopo( 243 | const char* id, 244 | uint32_t nodeId, 245 | uint32_t nodeType) 246 | { 247 | auto iter = SHARED_HANDLES.find(std::string(id)); 248 | 249 | if (iter == SHARED_HANDLES.end()) 250 | return; 251 | 252 | CLogB_WriteTopo( 253 | iter->second, 254 | nodeId, 255 | nodeType 256 | ); 257 | } 258 | 259 | extern "C" void CLogB_SharedWriteTopoEnd( 260 | const char* id) 261 | { 262 | auto iter = SHARED_HANDLES.find(std::string(id)); 263 | 264 | if (iter == SHARED_HANDLES.end()) 265 | return; 266 | 267 | CLogB_WriteTopoEnd( 268 | iter->second 269 | ); 270 | } 271 | 272 | 273 | /* 274 | * CLog.B log record write operations. 275 | */ 276 | extern "C" void CLogB_WriteRecord( 277 | void* handle, 278 | uint64_t time, 279 | uint32_t nodeId, 280 | uint32_t channel, 281 | const uint32_t* flit, 282 | uint32_t flitLength) 283 | { 284 | // 285 | size_t flitLength8 = (flitLength + 7) >> 3; 286 | 287 | // 288 | CLogBHandle* chandle = (CLogBHandle*) handle; 289 | 290 | uint64_t timeShift = chandle->records ? (time - ( 291 | chandle->records->records.empty() ? chandle->records->head.timeBase 292 | : chandle->lastRecordTime 293 | )) : 0; 294 | 295 | // allocate or split block 296 | if ((!chandle->records) // allocate 297 | || (chandle->records->records.size() >= CLOG_B_RECORD_BLOCK_LIMIT) // split on block limit 298 | || (timeShift >= uint64_t(UINT32_MAX))) // split on time limit 299 | { 300 | if (chandle->records) 301 | while(!chandle->queue->try_enqueue(chandle->records)); // dispatch block to worker thread 302 | 303 | chandle->records = new CLog::CLogB::TagCHIRecords; 304 | chandle->records->head.timeBase = time; 305 | 306 | #if CLOG_B_RECORD_BLOCK_COMPRESSION 307 | chandle->records->head.compressed = 1; 308 | #else 309 | chandle->records->head.compressed = 0; 310 | #endif 311 | 312 | timeShift = 0; 313 | } 314 | 315 | // append record 316 | size_t flitLength32 = (flitLength8 + 3) >> 2; 317 | std::shared_ptr flitData(new uint32_t[flitLength32]); 318 | 319 | std::memcpy(flitData.get(), flit, flitLength8); 320 | 321 | chandle->records->records.push_back({ 322 | .timeShift = uint32_t(timeShift), 323 | .nodeId = uint16_t(nodeId), 324 | .channel = CLog::Channel(channel), 325 | .flitLength = uint8_t(flitLength8), 326 | .flit = flitData 327 | }); 328 | 329 | chandle->lastRecordTime = time; 330 | } 331 | 332 | extern "C" void CLogB_SharedWriteRecord( 333 | const char* id, 334 | uint64_t time, 335 | uint32_t nodeId, 336 | uint32_t channel, 337 | const uint32_t* flit, 338 | uint32_t flitLength) 339 | { 340 | auto iter = SHARED_HANDLES.find(std::string(id)); 341 | 342 | if (iter == SHARED_HANDLES.end()) 343 | return; 344 | 345 | CLogB_WriteRecord( 346 | iter->second, 347 | time, 348 | nodeId, 349 | channel, 350 | flit, 351 | flitLength 352 | ); 353 | } 354 | -------------------------------------------------------------------------------- /clog/clog_b/clogdpi_b.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | /* 6 | * CLog.B file handle operations. 7 | */ 8 | extern "C" void* CLogB_OpenFile( 9 | const char* path, 10 | uint32_t* status); 11 | 12 | extern "C" void CLogB_CloseFile( 13 | void* handle); 14 | 15 | extern "C" void CLogB_ShareHandle( 16 | const char* id, 17 | void* handle); 18 | 19 | extern "C" int CLogB_UnshareHandle( 20 | const char* id); 21 | 22 | extern "C" void* CLogB_GetSharedHandle( 23 | const char* id 24 | ); 25 | 26 | 27 | /* 28 | * CLog.B parameters write operations. 29 | */ 30 | extern "C" void CLogB_WriteParameters( 31 | void* handle, 32 | uint32_t issue, 33 | uint32_t nodeidWidth, 34 | uint32_t addrWidth, 35 | uint32_t reqRsvdcWidth, 36 | uint32_t datRsvdcWidth, 37 | uint32_t dataWidth, 38 | uint32_t dataCheckPresent, 39 | uint32_t poisonPresent, 40 | uint32_t mpamPresent); 41 | 42 | extern "C" void CLogB_SharedWriteParameters( 43 | const char* id, 44 | uint32_t issue, 45 | uint32_t nodeidWidth, 46 | uint32_t addrWidth, 47 | uint32_t reqRsvdcWidth, 48 | uint32_t datRsvdcWidth, 49 | uint32_t dataWidth, 50 | uint32_t dataCheckPresent, 51 | uint32_t poisonPresent, 52 | uint32_t mpamPresent); 53 | 54 | 55 | /* 56 | * CLog.B topologies write operations. 57 | */ 58 | extern "C" void CLogB_WriteTopo( 59 | void* handle, 60 | uint32_t nodeId, 61 | uint32_t nodeType 62 | ); 63 | 64 | extern "C" void CLogB_WriteTopoEnd( 65 | void* handle); 66 | 67 | extern "C" void CLogB_SharedWriteTopo( 68 | const char* id, 69 | uint32_t nodeId, 70 | uint32_t nodeType 71 | ); 72 | 73 | extern "C" void CLogB_SharedWriteTopoEnd( 74 | const char* id); 75 | 76 | 77 | /* 78 | * CLog.B log record write operations. 79 | */ 80 | extern "C" void CLogB_WriteRecord( 81 | void* handle, 82 | uint64_t time, 83 | uint32_t nodeId, 84 | uint32_t channel, 85 | const uint32_t* flit, 86 | uint32_t flitLength 87 | ); 88 | 89 | extern "C" void CLogB_SharedWriteRecord( 90 | const char* id, 91 | uint64_t time, 92 | uint32_t nodeId, 93 | uint32_t channel, 94 | const uint32_t* flit, 95 | uint32_t flitLength 96 | ); 97 | -------------------------------------------------------------------------------- /clog/clog_b/clogdpi_b.svh: -------------------------------------------------------------------------------- 1 | /* 2 | * Value Definitions. 3 | */ 4 | `define CLOG_ISSUE_B 0 5 | `define CLOG_ISSUE_E 3 6 | 7 | `define CLOG_NODE_TYPE_RN_F 1 8 | `define CLOG_NODE_TYPE_RN_D 2 9 | `define CLOG_NODE_TYPE_RN_I 3 10 | `define CLOG_NODE_TYPE_HN_F 5 11 | `define CLOG_NODE_TYPE_HN_I 7 12 | `define CLOG_NODE_TYPE_SN_F 9 13 | `define CLOG_NODE_TYPE_SN_I 11 14 | `define CLOG_NODE_TYPE_MN 12 15 | 16 | `define CLOG_CHANNEL_TXREQ 0 17 | `define CLOG_CHANNEL_TXRSP 1 18 | `define CLOG_CHANNEL_TXDAT 2 19 | `define CLOG_CHANNEL_TXSNP 3 20 | `define CLOG_CHANNEL_RXREQ 4 21 | `define CLOG_CHANNEL_RXRSP 5 22 | `define CLOG_CHANNEL_RXDAT 6 23 | `define CLOG_CHANNEL_RXSNP 7 24 | 25 | 26 | /* 27 | * CLog.B file handle operations. 28 | */ 29 | import "DPI-C" function chandle CLogB_OpenFile ( 30 | input string path, 31 | output int status 32 | ); 33 | 34 | import "DPI-C" function void CLogB_CloseFile ( 35 | input chandle handle 36 | ); 37 | 38 | import "DPI-C" function void CLogB_ShareHandle ( 39 | input string id, 40 | input chandle handle 41 | ); 42 | 43 | import "DPI-C" function int CLogB_UnshareHandle ( 44 | input string id 45 | ); 46 | 47 | import "DPI-C" function chandle CLogB_GetSharedHandle ( 48 | input string id 49 | ); 50 | 51 | 52 | /* 53 | * CLog.B parameters write operations. 54 | */ 55 | import "DPI-C" function void CLogB_WriteParameters ( 56 | input chandle handle, 57 | input int issue, 58 | input int nodeIdWidth, 59 | input int addrWidth, 60 | input int reqRsvdcWidth, 61 | input int datRsvdcWidth, 62 | input int dataWidth, 63 | input int dataCheckPresent, 64 | input int poisonPresent, 65 | input int mpamPresent 66 | ); 67 | 68 | import "DPI-C" function void CLogB_SharedWriteParameters ( 69 | input string id, 70 | input int issue, 71 | input int nodeIdWidth, 72 | input int addrWidth, 73 | input int reqRsvdcWidth, 74 | input int datRsvdcWidth, 75 | input int dataWidth, 76 | input int dataCheckPresent, 77 | input int poisonPresent, 78 | input int mpamPresent 79 | ); 80 | 81 | 82 | /* 83 | * CLog.B topologies write operations. 84 | */ 85 | import "DPI-C" function void CLogB_WriteTopo ( 86 | input chandle handle, 87 | input int nodeId, 88 | input int nodeType 89 | ); 90 | 91 | import "DPI-C" function void CLogB_WriteTopoEnd ( 92 | input chandle handle 93 | ); 94 | 95 | import "DPI-C" function void CLogB_SharedWriteTopo ( 96 | input string id, 97 | input int nodeId, 98 | input int nodeType 99 | ); 100 | 101 | import "DPI-C" function void CLogB_SharedWriteTopoEnd ( 102 | input string id 103 | ); 104 | 105 | 106 | /* 107 | * CLog.B log record write operations. 108 | */ 109 | import "DPI-C" function void CLogB_WriteRecord ( 110 | input chandle handle, 111 | input longint cycletime, 112 | input int nodeId, 113 | input int channel, 114 | input bit [511:0] flit, 115 | input int flitLength 116 | ); 117 | 118 | import "DPI-C" function void CLogB_SharedWriteRecord ( 119 | input string id, 120 | input longint cycleTime, 121 | input int nodeId, 122 | input int channel, 123 | input bit [511:0] flit, 124 | input int flitLength 125 | ); 126 | -------------------------------------------------------------------------------- /clog/clog_t/clog_t_util.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __CHI__CLOG_T_UTIL 4 | #define __CHI__CLOG_T_UTIL 5 | 6 | #include "clog_t.hpp" 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | namespace CLog::CLogT { 14 | 15 | template 16 | class ParametersSerDes { 17 | private: 18 | Parameters* params; 19 | 20 | public: 21 | Parameters* GetParametersReference() noexcept; 22 | const Parameters* GetParametersReference() const noexcept; 23 | void SetParametersReference(Parameters* params) noexcept; 24 | 25 | public: 26 | void SerializeTo(std::ostream&, bool segmentWrap = false) const; 27 | 28 | public: 29 | void RegisterAsDeserializer(Parser& parser) noexcept; 30 | void Unregister(Parser& parser) const noexcept; 31 | 32 | void ApplySegmentToken(Parser& parser) const noexcept; 33 | void ApplySegmentMask(Parser& parser) const noexcept; 34 | 35 | protected: 36 | virtual bool OnCHI_ISSUE (Parser& parser, TContext, std::istream& is); 37 | virtual bool OnCHI_WIDTH_NODEID (Parser& parser, TContext, std::istream& is); 38 | virtual bool OnCHI_WIDTH_ADDR (Parser& parser, TContext, std::istream& is); 39 | virtual bool OnCHI_WIDTH_RSVDC_REQ (Parser& parser, TContext, std::istream& is); 40 | virtual bool OnCHI_WIDTH_RSVDC_DAT (Parser& parser, TContext, std::istream& is); 41 | virtual bool OnCHI_WIDTH_DATA (Parser& parser, TContext, std::istream& is); 42 | virtual bool OnCHI_ENABLE_DATACHECK (Parser& parser, TContext, std::istream& is); 43 | virtual bool OnCHI_ENABLE_POISON (Parser& parser, TContext, std::istream& is); 44 | virtual bool OnCHI_ENABLE_MPAM (Parser& parser, TContext, std::istream& is); 45 | }; 46 | } 47 | 48 | 49 | // Implementation of: class ParametersSerDes 50 | namespace CLog::CLogT { 51 | /* 52 | Parameters* params; 53 | */ 54 | 55 | template 56 | inline Parameters* ParametersSerDes::GetParametersReference() noexcept 57 | { 58 | return params; 59 | } 60 | 61 | template 62 | inline const Parameters* ParametersSerDes::GetParametersReference() const noexcept 63 | { 64 | return params; 65 | } 66 | 67 | template 68 | inline void ParametersSerDes::SetParametersReference(Parameters* params) noexcept 69 | { 70 | this->params = params; 71 | } 72 | 73 | template 74 | inline void ParametersSerDes::SerializeTo(std::ostream& os, bool segmentWrap) const 75 | { 76 | if (segmentWrap) 77 | WriteCLogSegmentParamBegin(os); 78 | 79 | if (params) 80 | { 81 | WriteCHISentenceIssue (os, params->GetIssue()); 82 | WriteCHISentenceNodeIDWidth (os, params->GetNodeIdWidth()); 83 | WriteCHISentenceAddrWidth (os, params->GetReqAddrWidth()); 84 | WriteCHISentenceReqRSVDCWidth (os, params->GetReqRSVDCWidth()); 85 | WriteCHISentenceDatRSVDCWidth (os, params->GetDatRSVDCWidth()); 86 | WriteCHISentenceDataWidth (os, params->GetDataWidth()); 87 | WriteCHISentenceDataCheckPresent(os, params->IsDataCheckPresent()); 88 | WriteCHISentencePoisonPresent (os, params->IsPoisonPresent()); 89 | WriteCHISentenceMPAMPresent (os, params->IsMPAMPresent()); 90 | } 91 | 92 | if (segmentWrap) 93 | WriteCLogSegmentParamEnd(os); 94 | } 95 | 96 | template 97 | inline void ParametersSerDes::RegisterAsDeserializer(Parser& parser) noexcept 98 | { 99 | parser.RegisterExecutor(Sentence::CHI_ISSUE::Token, 100 | std::bind(&ParametersSerDes::OnCHI_ISSUE, 101 | this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); 102 | 103 | parser.RegisterExecutor(Sentence::CHI_WIDTH_NODEID::Token, 104 | std::bind(&ParametersSerDes::OnCHI_WIDTH_NODEID, 105 | this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); 106 | 107 | parser.RegisterExecutor(Sentence::CHI_WIDTH_ADDR::Token, 108 | std::bind(&ParametersSerDes::OnCHI_WIDTH_ADDR, 109 | this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); 110 | 111 | parser.RegisterExecutor(Sentence::CHI_WIDTH_RSVDC_REQ::Token, 112 | std::bind(&ParametersSerDes::OnCHI_WIDTH_RSVDC_REQ, 113 | this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); 114 | 115 | parser.RegisterExecutor(Sentence::CHI_WIDTH_RSVDC_DAT::Token, 116 | std::bind(&ParametersSerDes::OnCHI_WIDTH_RSVDC_DAT, 117 | this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); 118 | 119 | parser.RegisterExecutor(Sentence::CHI_WIDTH_DATA::Token, 120 | std::bind(&ParametersSerDes::OnCHI_WIDTH_DATA, 121 | this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); 122 | 123 | parser.RegisterExecutor(Sentence::CHI_ENABLE_DATACHECK::Token, 124 | std::bind(&ParametersSerDes::OnCHI_ENABLE_DATACHECK, 125 | this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); 126 | 127 | parser.RegisterExecutor(Sentence::CHI_ENABLE_POISON::Token, 128 | std::bind(&ParametersSerDes::OnCHI_ENABLE_POISON, 129 | this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); 130 | 131 | parser.RegisterExecutor(Sentence::CHI_ENABLE_MPAM::Token, 132 | std::bind(&ParametersSerDes::OnCHI_ENABLE_MPAM, 133 | this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); 134 | } 135 | 136 | template 137 | inline void ParametersSerDes::Unregister(Parser& parser) const noexcept 138 | { 139 | parser.UnregisterExecutor(Sentence::CHI_ISSUE::Token); 140 | parser.UnregisterExecutor(Sentence::CHI_WIDTH_NODEID::Token); 141 | parser.UnregisterExecutor(Sentence::CHI_WIDTH_ADDR::Token); 142 | parser.UnregisterExecutor(Sentence::CHI_WIDTH_RSVDC_REQ::Token); 143 | parser.UnregisterExecutor(Sentence::CHI_WIDTH_RSVDC_DAT::Token); 144 | parser.UnregisterExecutor(Sentence::CHI_WIDTH_DATA::Token); 145 | parser.UnregisterExecutor(Sentence::CHI_ENABLE_DATACHECK::Token); 146 | parser.UnregisterExecutor(Sentence::CHI_ENABLE_POISON::Token); 147 | parser.UnregisterExecutor(Sentence::CHI_ENABLE_MPAM::Token); 148 | } 149 | 150 | template 151 | inline void ParametersSerDes::ApplySegmentToken(Parser& parser) const noexcept 152 | { 153 | parser.SetSegmentToken( 154 | Sentence::CLOG_SEGMENT_PARAM_BEGIN::Token, 155 | Sentence::CLOG_SEGMENT_PARAM_END::Token); 156 | } 157 | 158 | template 159 | inline void ParametersSerDes::ApplySegmentMask(Parser& parser) const noexcept 160 | { 161 | parser.AddSegmentMask({ 162 | Sentence::CHI_ISSUE ::Token, 163 | Sentence::CHI_WIDTH_NODEID ::Token, 164 | Sentence::CHI_WIDTH_ADDR ::Token, 165 | Sentence::CHI_WIDTH_RSVDC_REQ ::Token, 166 | Sentence::CHI_WIDTH_RSVDC_DAT ::Token, 167 | Sentence::CHI_WIDTH_DATA ::Token, 168 | Sentence::CHI_ENABLE_DATACHECK ::Token, 169 | Sentence::CHI_ENABLE_POISON ::Token, 170 | Sentence::CHI_ENABLE_MPAM ::Token 171 | }); 172 | } 173 | 174 | template 175 | inline bool ParametersSerDes::OnCHI_ISSUE(Parser& parser, TContext, std::istream& is) 176 | { 177 | Issue issue; 178 | if (!Sentence::CHI_ISSUE::Term::Read(is, issue)) 179 | return false; 180 | 181 | if (params) 182 | params->SetIssue(issue); 183 | 184 | return true; 185 | } 186 | 187 | template 188 | inline bool ParametersSerDes::OnCHI_WIDTH_NODEID(Parser& parser, TContext, std::istream& is) 189 | { 190 | size_t nodeIdWidth; 191 | if (!Sentence::CHI_WIDTH_NODEID::Term::Read(is, nodeIdWidth)) 192 | return false; 193 | 194 | if (params) 195 | return params->SetNodeIdWidth(nodeIdWidth); 196 | 197 | return true; 198 | } 199 | 200 | template 201 | inline bool ParametersSerDes::OnCHI_WIDTH_ADDR(Parser& parser, TContext, std::istream& is) 202 | { 203 | size_t reqAddrWidth; 204 | if (!Sentence::CHI_WIDTH_ADDR::Term::Read(is, reqAddrWidth)) 205 | return false; 206 | 207 | if (params) 208 | return params->SetReqAddrWidth(reqAddrWidth); 209 | 210 | return true; 211 | } 212 | 213 | template 214 | inline bool ParametersSerDes::OnCHI_WIDTH_RSVDC_REQ(Parser& parser, TContext, std::istream& is) 215 | { 216 | size_t reqRsvdcWidth; 217 | if (!Sentence::CHI_WIDTH_RSVDC_REQ::Term::Read(is, reqRsvdcWidth)) 218 | return false; 219 | 220 | if (params) 221 | return params->SetReqRSVDCWidth(reqRsvdcWidth); 222 | 223 | return true; 224 | } 225 | 226 | template 227 | inline bool ParametersSerDes::OnCHI_WIDTH_RSVDC_DAT(Parser& parser, TContext, std::istream& is) 228 | { 229 | size_t datRsvdcWidth; 230 | if (!Sentence::CHI_WIDTH_RSVDC_DAT::Term::Read(is, datRsvdcWidth)) 231 | return false; 232 | 233 | if (params) 234 | return params->SetDatRSVDCWidth(datRsvdcWidth); 235 | 236 | return true; 237 | } 238 | 239 | template 240 | inline bool ParametersSerDes::OnCHI_WIDTH_DATA(Parser& parser, TContext, std::istream& is) 241 | { 242 | size_t dataWidth; 243 | if (!Sentence::CHI_WIDTH_DATA::Term::Read(is, dataWidth)) 244 | return false; 245 | 246 | if (params) 247 | return params->SetDataWidth(dataWidth); 248 | 249 | return true; 250 | } 251 | 252 | template 253 | inline bool ParametersSerDes::OnCHI_ENABLE_DATACHECK(Parser& parser, TContext, std::istream& is) 254 | { 255 | bool dataCheckPresent; 256 | if (!Sentence::CHI_ENABLE_DATACHECK::Term::Read(is, dataCheckPresent)) 257 | return false; 258 | 259 | if (params) 260 | params->SetDataCheckPresent(dataCheckPresent); 261 | 262 | return true; 263 | } 264 | 265 | template 266 | inline bool ParametersSerDes::OnCHI_ENABLE_POISON(Parser& parser, TContext, std::istream& is) 267 | { 268 | bool poisonPresent; 269 | if (!Sentence::CHI_ENABLE_POISON::Term::Read(is, poisonPresent)) 270 | return false; 271 | 272 | if (params) 273 | params->SetPoisonPresent(poisonPresent); 274 | 275 | return true; 276 | } 277 | 278 | template 279 | inline bool ParametersSerDes::OnCHI_ENABLE_MPAM(Parser& parser, TContext, std::istream& is) 280 | { 281 | bool mpamPresent; 282 | if (!Sentence::CHI_ENABLE_MPAM::Term::Read(is, mpamPresent)) 283 | return false; 284 | 285 | if (params) 286 | params->SetMPAMPresent(mpamPresent); 287 | 288 | return true; 289 | } 290 | } 291 | 292 | #endif // __CHI__CLOG_T_UTIL 293 | -------------------------------------------------------------------------------- /clog/clog_t/clogdpi_t.cpp: -------------------------------------------------------------------------------- 1 | #include "clogdpi_t.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "../../common/concurrentqueue.hpp" 10 | 11 | #include "clog_t.hpp" 12 | 13 | 14 | // 15 | struct LogTask { 16 | uint64_t time; 17 | uint32_t nodeId; 18 | uint32_t channel; 19 | uint32_t flit[16]; 20 | uint32_t flitLength; 21 | }; 22 | 23 | class CLogHandle { 24 | public: 25 | std::ofstream* ofs; 26 | moodycamel::ConcurrentQueue* queue; 27 | std::atomic_bool stop; 28 | std::thread worker; 29 | }; 30 | 31 | 32 | // 33 | extern "C" void* CLogT_OpenFile(const char* path, 34 | uint32_t* status) 35 | { 36 | CLogHandle* handle = new CLogHandle; 37 | 38 | std::ofstream* ofs = 39 | new std::ofstream(path, std::ios_base::out | std::ios_base::trunc); 40 | 41 | if (!*ofs) 42 | { 43 | *status = 1; 44 | std::cout << "[CLog.T] unable to open file: " << path << std::endl; 45 | return NULL; 46 | } 47 | else 48 | { 49 | std::cout << "[CLog.T] opened file: " << path << std::endl; 50 | } 51 | 52 | *status = 0; 53 | 54 | handle->ofs = ofs; 55 | handle->queue = new moodycamel::ConcurrentQueue; 56 | handle->stop = false; 57 | 58 | std::atomic_thread_fence(std::memory_order_seq_cst); 59 | 60 | handle->worker = std::thread([=]() -> void { 61 | LogTask task; 62 | while (1) 63 | { 64 | if (handle->queue->try_dequeue(task)) 65 | { 66 | CLog::CLogT::WriteCHISentenceLog( 67 | *handle->ofs, 68 | task.time, 69 | task.nodeId, 70 | CLog::Channel(task.channel), 71 | task.flit, 72 | task.flitLength 73 | ); 74 | } 75 | else if (handle->stop) 76 | return; 77 | } 78 | }); 79 | 80 | return handle; 81 | } 82 | 83 | extern "C" void CLogT_CloseFile(void* handle) 84 | { 85 | CLogHandle* chandle = (CLogHandle*) handle; 86 | 87 | while (chandle->queue->size_approx()); 88 | 89 | chandle->stop = true; 90 | 91 | chandle->worker.join(); 92 | 93 | chandle->ofs->close(); 94 | delete chandle->ofs; 95 | delete chandle->queue; 96 | delete chandle; 97 | } 98 | 99 | 100 | // 101 | extern "C" void CLogT_WriteSegmentParamBegin(void* handle) 102 | { 103 | CLogHandle* chandle = (CLogHandle*) handle; 104 | 105 | CLog::CLogT::WriteCLogSegmentParamBegin(*chandle->ofs); 106 | } 107 | 108 | extern "C" void CLogT_WriteSegmentParamEnd(void* handle) 109 | { 110 | CLogHandle* chandle = (CLogHandle*) handle; 111 | 112 | CLog::CLogT::WriteCLogSegmentParamEnd(*chandle->ofs); 113 | } 114 | 115 | extern "C" void CLogT_WriteSegmentTopoBegin(void* handle) 116 | { 117 | CLogHandle* chandle = (CLogHandle*) handle; 118 | 119 | CLog::CLogT::WriteCLogSegmentTopoBegin(*chandle->ofs); 120 | } 121 | 122 | extern "C" void CLogT_WriteSegmentTopoEnd(void* handle) 123 | { 124 | CLogHandle* chandle = (CLogHandle*) handle; 125 | 126 | CLog::CLogT::WriteCLogSegmentTopoEnd(*chandle->ofs); 127 | } 128 | 129 | 130 | // 131 | extern "C" void CLogT_WriteIssue(void* handle, 132 | uint32_t issue) 133 | { 134 | CLogHandle* chandle = (CLogHandle*) handle; 135 | 136 | CLog::CLogT::WriteCHISentenceIssue( 137 | *chandle->ofs, 138 | CLog::Issue(issue)); 139 | } 140 | 141 | extern "C" void CLogT_WriteWidthNodeID(void* handle, 142 | uint32_t nodeIdWidth) 143 | { 144 | CLogHandle* chandle = (CLogHandle*) handle; 145 | 146 | CLog::CLogT::WriteCHISentenceNodeIDWidth( 147 | *chandle->ofs, 148 | nodeIdWidth); 149 | } 150 | 151 | extern "C" void CLogT_WriteWidthAddr(void* handle, 152 | uint32_t addrWidth) 153 | { 154 | CLogHandle* chandle = (CLogHandle*) handle; 155 | 156 | CLog::CLogT::WriteCHISentenceAddrWidth( 157 | *chandle->ofs, 158 | addrWidth); 159 | } 160 | 161 | extern "C" void CLogT_WriteWidthReqRSVDC(void* handle, 162 | uint32_t reqRsvdcWidth) 163 | { 164 | CLogHandle* chandle = (CLogHandle*) handle; 165 | 166 | CLog::CLogT::WriteCHISentenceReqRSVDCWidth( 167 | *chandle->ofs, 168 | reqRsvdcWidth); 169 | } 170 | 171 | extern "C" void CLogT_WriteWidthDatRSVDC(void* handle, 172 | uint32_t datRsvdcWidth) 173 | { 174 | CLogHandle* chandle = (CLogHandle*) handle; 175 | 176 | CLog::CLogT::WriteCHISentenceDatRSVDCWidth( 177 | *chandle->ofs, 178 | datRsvdcWidth); 179 | } 180 | 181 | extern "C" void CLogT_WriteWidthData(void* handle, 182 | uint32_t dataWidth) 183 | { 184 | CLogHandle* chandle = (CLogHandle*) handle; 185 | 186 | CLog::CLogT::WriteCHISentenceDataWidth( 187 | *chandle->ofs, 188 | dataWidth); 189 | } 190 | 191 | extern "C" void CLogT_WriteEnableDataCheck(void* handle, 192 | uint32_t dataCheckPresent) 193 | { 194 | CLogHandle* chandle = (CLogHandle*) handle; 195 | 196 | CLog::CLogT::WriteCHISentenceDataCheckPresent( 197 | *chandle->ofs, 198 | dataCheckPresent); 199 | } 200 | 201 | extern "C" void CLogT_WriteEnablePoison(void* handle, 202 | uint32_t poisonPresent) 203 | { 204 | CLogHandle* chandle = (CLogHandle*) handle; 205 | 206 | CLog::CLogT::WriteCHISentencePoisonPresent( 207 | *chandle->ofs, 208 | poisonPresent); 209 | } 210 | 211 | extern "C" void CLogT_WriteEnableMPAM(void* handle, 212 | uint32_t mpamPresent) 213 | { 214 | CLogHandle* chandle = (CLogHandle*) handle; 215 | 216 | CLog::CLogT::WriteCHISentenceMPAMPresent( 217 | *chandle->ofs, 218 | mpamPresent); 219 | } 220 | 221 | extern "C" void CLogT_WriteTopo(void* handle, 222 | uint32_t nodeId, 223 | uint32_t nodeType) 224 | { 225 | CLogHandle* chandle = (CLogHandle*) handle; 226 | 227 | CLog::CLogT::WriteCHISentenceTopo( 228 | *chandle->ofs, 229 | nodeId, 230 | CLog::NodeType(nodeType)); 231 | } 232 | 233 | extern "C" void CLogT_WriteLog(void* handle, 234 | uint64_t time, 235 | uint32_t nodeId, 236 | uint32_t channel, 237 | const uint32_t* flit, 238 | uint32_t flitLength) 239 | { 240 | CLogHandle* chandle = (CLogHandle*) handle; 241 | 242 | flitLength = (flitLength + 31) / 32; 243 | 244 | while (!chandle->queue->try_enqueue(LogTask { 245 | .time = time, 246 | .nodeId = nodeId, 247 | .channel = channel, 248 | .flit = { 249 | flit[0], 250 | flit[1], 251 | flit[2], 252 | flit[3], 253 | flit[4], 254 | flit[5], 255 | flit[6], 256 | flit[7], 257 | flit[8], 258 | flit[9], 259 | flit[10], 260 | flit[11], 261 | flit[12], 262 | flit[13], 263 | flit[14], 264 | flit[15] 265 | }, 266 | .flitLength = flitLength 267 | })); 268 | } 269 | 270 | -------------------------------------------------------------------------------- /clog/clog_t/clogdpi_t.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | /* 6 | * CLog.T file handle operations. 7 | */ 8 | extern "C" void* CLogT_OpenFile( 9 | const char* path, 10 | uint32_t* status); 11 | 12 | extern "C" void CLogT_CloseFile( 13 | void* handle); 14 | 15 | /* 16 | * CLog.T segment write operations. 17 | */ 18 | extern "C" void CLogT_WriteSegmentParamBegin( 19 | void* handle); 20 | 21 | extern "C" void CLogT_WriteSegmentParamEnd( 22 | void* handle); 23 | 24 | extern "C" void CLogT_WriteSegmentTopoBegin( 25 | void* handle); 26 | 27 | extern "C" void CLogT_WriteSegmentTopoEnd( 28 | void* handle); 29 | 30 | /* 31 | * CLog.T parameters write operations. 32 | */ 33 | extern "C" void CLogT_WriteIssue( 34 | void* handle, 35 | uint32_t issue); 36 | 37 | extern "C" void CLogT_WriteWidthNodeID( 38 | void* handle, 39 | uint32_t nodeIdWidth); 40 | 41 | extern "C" void CLogT_WriteWidthAddr( 42 | void* handle, 43 | uint32_t addrWidth); 44 | 45 | extern "C" void CLogT_WriteWidthReqRSVDC( 46 | void* handle, 47 | uint32_t reqRsvdcWidth); 48 | 49 | extern "C" void CLogT_WriteWidthDatRSVDC( 50 | void* handle, 51 | uint32_t datRsvdcWidth); 52 | 53 | extern "C" void CLogT_WriteWidthData( 54 | void* handle, 55 | uint32_t dataWidth); 56 | 57 | extern "C" void CLogT_WriteEnableDataCheck( 58 | void* handle, 59 | uint32_t dataCheckPresent); 60 | 61 | extern "C" void CLogT_WriteEnablePoison( 62 | void* handle, 63 | uint32_t poisonPresent); 64 | 65 | extern "C" void CLogT_WriteEnableMPAM( 66 | void* handle, 67 | uint32_t mpamPresent); 68 | 69 | extern "C" void CLogT_WriteTopo( 70 | void* handle, 71 | uint32_t nodeId, 72 | uint32_t nodeType); 73 | 74 | /* 75 | * CLog.T log write operations. 76 | */ 77 | extern "C" void CLogT_WriteLog( 78 | void* handle, 79 | uint64_t time, 80 | uint32_t nodeId, 81 | uint32_t channel, 82 | const uint32_t* flit, 83 | uint32_t flitLength); 84 | -------------------------------------------------------------------------------- /clog/clog_t/clogdpi_t.svh: -------------------------------------------------------------------------------- 1 | /* 2 | * Value Definitions. 3 | */ 4 | `define CLOG_ISSUE_B 0 5 | `define CLOG_ISSUE_E 3 6 | 7 | `define CLOG_NODE_TYPE_RN_F 1 8 | `define CLOG_NODE_TYPE_RN_D 2 9 | `define CLOG_NODE_TYPE_RN_I 3 10 | `define CLOG_NODE_TYPE_HN_F 5 11 | `define CLOG_NODE_TYPE_HN_I 7 12 | `define CLOG_NODE_TYPE_SN_F 9 13 | `define CLOG_NODE_TYPE_SN_I 11 14 | `define CLOG_NODE_TYPE_MN 12 15 | 16 | `define CLOG_CHANNEL_TXREQ 0 17 | `define CLOG_CHANNEL_TXRSP 1 18 | `define CLOG_CHANNEL_TXDAT 2 19 | `define CLOG_CHANNEL_TXSNP 3 20 | `define CLOG_CHANNEL_RXREQ 4 21 | `define CLOG_CHANNEL_RXRSP 5 22 | `define CLOG_CHANNEL_RXDAT 6 23 | `define CLOG_CHANNEL_RXSNP 7 24 | 25 | 26 | /* 27 | * File handle operations. 28 | */ 29 | import "DPI-C" function chandle CLogT_OpenFile ( 30 | input string path, 31 | output int status 32 | ); 33 | 34 | import "DPI-C" function void CLogT_CloseFile ( 35 | input chandle handle 36 | ); 37 | 38 | /* 39 | * CLog.T operations. 40 | */ 41 | import "DPI-C" function void CLogT_WriteSegmentParamBegin ( 42 | input chandle handle 43 | ); 44 | 45 | import "DPI-C" function void CLogT_WriteSegmentParamEnd ( 46 | input chandle handle 47 | ); 48 | 49 | import "DPI-C" function void CLogT_WriteSegmentTopoBegin ( 50 | input chandle handle 51 | ); 52 | 53 | import "DPI-C" function void CLogT_WriteSegmentTopoEnd ( 54 | input chandle handle 55 | ); 56 | 57 | import "DPI-C" function void CLogT_WriteIssue ( 58 | input chandle handle, 59 | input int issue 60 | ); 61 | 62 | import "DPI-C" function void CLogT_WriteWidthNodeID ( 63 | input chandle handle, 64 | input int nodeIdWidth 65 | ); 66 | 67 | import "DPI-C" function void CLogT_WriteWidthAddr ( 68 | input chandle handle, 69 | input int addrWidth 70 | ); 71 | 72 | import "DPI-C" function void CLogT_WriteWidthReqRSVDC ( 73 | input chandle handle, 74 | input int reqRsvdcWidth 75 | ); 76 | 77 | import "DPI-C" function void CLogT_WriteWidthDatRSVDC ( 78 | input chandle handle, 79 | input int datRsvdcWidth 80 | ); 81 | 82 | import "DPI-C" function void CLogT_WriteWidthData ( 83 | input chandle handle, 84 | input int dataWidth 85 | ); 86 | 87 | import "DPI-C" function void CLogT_WriteEnableDataCheck ( 88 | input chandle handle, 89 | input int dataCheckPresent 90 | ); 91 | 92 | import "DPI-C" function void CLogT_WriteEnablePoison ( 93 | input chandle handle, 94 | input int poisonPresent 95 | ); 96 | 97 | import "DPI-C" function void CLogT_WriteEnableMPAM ( 98 | input chandle handle, 99 | input int mpamPresent 100 | ); 101 | 102 | import "DPI-C" function void CLogT_WriteTopo ( 103 | input chandle handle, 104 | input int nodeId, 105 | input int nodeType 106 | ); 107 | 108 | import "DPI-C" function void CLogT_WriteLog ( 109 | input chandle handle, 110 | input longint cycle, 111 | input int nodeId, 112 | input int channel, 113 | input bit [511:0] flit, 114 | input int flitLength 115 | ); 116 | -------------------------------------------------------------------------------- /common/utility.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | #ifndef __BULLSEYE_SIMS_GRAVITY__UTILITY 5 | #define __BULLSEYE_SIMS_GRAVITY__UTILITY 6 | */ 7 | 8 | #ifndef __CHILOG_COMMON__UTILITY 9 | #define __CHILOG_COMMON__UTILITY 10 | 11 | #include 12 | #include 13 | 14 | 15 | /* 16 | * Type Utility 17 | */ 18 | /* 19 | namespace Gravity { 20 | */ 21 | 22 | /* 23 | * as_pointer_if: 24 | * - If B is true, as_pointer_if::type = T*, 25 | * otherwise as_pointer_if::type = T. 26 | * 27 | * as_pointer_if_t: Helper template of as_pointer_if 28 | */ 29 | // 30 | template 31 | struct as_pointer_if { 32 | using type = std::conditional_t; 33 | }; 34 | 35 | template 36 | using as_pointer_if_t = typename as_pointer_if::type; 37 | // 38 | 39 | 40 | /* 41 | * is_same_size: 42 | * - If sizeof(T) == sizeof(U), is_same_size::value = true, 43 | * otherwise is_same_size::value = false. 44 | * 45 | * is_same_size_v: 46 | * Helper template of is_same_size 47 | * 48 | * assert_same_size(...): 49 | * Asserts (static assert) that sizeof(T) == sizeof(U). 50 | */ 51 | // 52 | template 53 | struct is_same_size { 54 | static constexpr bool value = sizeof(T) == sizeof(U); 55 | }; 56 | 57 | template 58 | inline constexpr bool is_same_size_v = is_same_size::value; 59 | 60 | template 61 | inline constexpr void assert_same_size() noexcept 62 | { 63 | static_assert(is_same_size_v, "structural size mismatch"); 64 | } 65 | 66 | template 67 | inline constexpr T& assert_same_size(T& passed_t) noexcept 68 | { 69 | static_assert(is_same_size_v, "structural size mismatch"); 70 | return passed_t; 71 | } 72 | 73 | template 74 | inline constexpr T&& assert_same_size(T&& passed_t, const U& unused_u) noexcept 75 | { 76 | (void) unused_u; 77 | static_assert(is_same_size_v, "structural size mismatch"); 78 | // Take is easy :), it just forwards everything of 'passed_t', including type information. 79 | return std::forward(passed_t); 80 | } 81 | // 82 | /* 83 | } 84 | */ 85 | 86 | 87 | /* 88 | * String Utility 89 | */ 90 | /* 91 | namespace Gravity { 92 | */ 93 | 94 | /* 95 | * String Appender (builder pattern helper for std::ostringstream) 96 | * ---------------------------------------------------------------- 97 | * Usage: 98 | * StringAppender appender("Hello"); 99 | * appender.Append(", ").Append("World!").Append(123).ToString(); 100 | * or 101 | * StringAppender().Append("Hello, ").Append("World!").Append(123).ToString(); 102 | * StringAppender("Hello, ").Append("World!").Append(123).ToString(); 103 | */ 104 | class StringAppender { 105 | private: 106 | std::ostringstream oss; 107 | 108 | public: 109 | inline StringAppender() noexcept {}; 110 | inline ~StringAppender() noexcept {}; 111 | 112 | template 113 | inline StringAppender(const T& value) noexcept 114 | { oss << value; } 115 | 116 | template 117 | inline StringAppender(const T& value, const U&... args) noexcept 118 | { oss << value; Append(args...); } 119 | 120 | inline StringAppender& Hex() noexcept 121 | { oss << std::hex; return *this; } 122 | 123 | inline StringAppender& Dec() noexcept 124 | { oss << std::dec; return *this; } 125 | 126 | inline StringAppender& Oct() noexcept 127 | { oss << std::oct; return *this; } 128 | 129 | inline StringAppender& Fixed() noexcept 130 | { oss << std::fixed; return *this; } 131 | 132 | inline StringAppender& Scientific() noexcept 133 | { oss << std::scientific; return *this; } 134 | 135 | inline StringAppender& HexFloat() noexcept 136 | { oss << std::hexfloat; return *this; } 137 | 138 | inline StringAppender& DefaultFloat() noexcept 139 | { oss << std::defaultfloat; return *this; } 140 | 141 | inline StringAppender& Base(int n) noexcept 142 | { oss << std::setbase(n); return *this; } 143 | 144 | template 145 | inline StringAppender& Fill(CharT c) noexcept 146 | { oss << std::setfill(c); return *this; } 147 | 148 | inline StringAppender& Precision(int n) noexcept 149 | { oss << std::setprecision(n); return *this; } 150 | 151 | inline StringAppender& NextWidth(int n) noexcept 152 | { oss << std::setw(n); return *this; } 153 | 154 | inline StringAppender& BoolAlpha() noexcept 155 | { oss << std::boolalpha; return *this; } 156 | 157 | inline StringAppender& NoBoolAlpha() noexcept 158 | { oss << std::noboolalpha; return *this; } 159 | 160 | inline StringAppender& ShowBase() noexcept 161 | { oss << std::showbase; return *this; } 162 | 163 | inline StringAppender& NoShowBase() noexcept 164 | { oss << std::noshowbase; return *this; } 165 | 166 | inline StringAppender& ShowPoint() noexcept 167 | { oss << std::showpoint; return *this; } 168 | 169 | inline StringAppender& NoShowPoint() noexcept 170 | { oss << std::noshowpoint; return *this; } 171 | 172 | inline StringAppender& ShowPos() noexcept 173 | { oss << std::showpos; return *this; } 174 | 175 | inline StringAppender& NoShowPos() noexcept 176 | { oss << std::noshowpos; return *this; } 177 | 178 | inline StringAppender& SkipWs() noexcept 179 | { oss << std::skipws; return *this; } 180 | 181 | inline StringAppender& NoSkipWs() noexcept 182 | { oss << std::noskipws; return *this; } 183 | 184 | inline StringAppender& Left() noexcept 185 | { oss << std::left; return *this; } 186 | 187 | inline StringAppender& Right() noexcept 188 | { oss << std::right; return *this; } 189 | 190 | inline StringAppender& Internal() noexcept 191 | { oss << std::internal; return *this; } 192 | 193 | inline StringAppender& NewLine() noexcept 194 | { oss << std::endl; return *this; } 195 | 196 | inline StringAppender& EndLine() noexcept 197 | { oss << std::endl; return *this; } 198 | 199 | template 200 | inline StringAppender& Append() noexcept 201 | { return *this; } 202 | 203 | template 204 | inline StringAppender& Append(const T& value) noexcept 205 | { oss << value; return *this; } 206 | 207 | template 208 | inline StringAppender& Append(const T& value, const U&... args) noexcept 209 | { oss << value; return Append(args...); } 210 | 211 | template 212 | inline StringAppender& operator<<(const T& value) noexcept 213 | { oss << value; return *this; } 214 | 215 | inline std::string ToString() const noexcept 216 | { return oss.str(); } 217 | }; 218 | 219 | /* 220 | } 221 | */ 222 | 223 | 224 | #endif // __BULLSEYE_SIMS_GRAVITY__UTILITY 225 | --------------------------------------------------------------------------------