CIRCT 24.0.0git
Loading...
Searching...
No Matches
AXI4Types.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
11#include "mlir/IR/Builders.h"
12#include "mlir/IR/DialectImplementation.h"
13#include "llvm/ADT/TypeSwitch.h"
14#include "llvm/Support/MathExtras.h"
15
16using namespace circt;
17using namespace axi4;
18using namespace mlir;
19
20#define GET_TYPEDEF_CLASSES
21#include "circt/Dialect/AXI4/AXI4Types.cpp.inc"
22
23LogicalResult PortType::verify(function_ref<InFlightDiagnostic()> emitError,
24 uint32_t addr_width, uint32_t data_width,
25 uint32_t write_id_width, uint32_t read_id_width,
26 uint32_t user_width, WindowSetAttr windows,
27 uint32_t outstanding_writes,
28 uint32_t outstanding_reads) {
29 if (addr_width > 64)
30 return emitError() << "port 'addr_width' must be at most 64, got "
31 << addr_width;
32 if (data_width < 8 || data_width > 1024 || !llvm::isPowerOf2_32(data_width))
33 return emitError() << "port 'data_width' must be a power of two between 8 "
34 "and 1024, got "
35 << data_width;
36 if (write_id_width > 32)
37 return emitError() << "port 'write_id_width' must be at most 32, got "
38 << write_id_width;
39 if (read_id_width > 32)
40 return emitError() << "port 'read_id_width' must be at most 32, got "
41 << read_id_width;
42 // Bounds computed in 64 bits to avoid 32-bit overflow if ID widths are 32.
43 if (outstanding_writes > (uint64_t{1} << write_id_width))
44 return emitError() << "port 'outstanding_writes' must be at most "
45 << (uint64_t{1} << write_id_width)
46 << " for a 'write_id_width' of " << write_id_width
47 << ", got " << outstanding_writes;
48 if (outstanding_reads > (uint64_t{1} << read_id_width))
49 return emitError() << "port 'outstanding_reads' must be at most "
50 << (uint64_t{1} << read_id_width)
51 << " for a 'read_id_width' of " << read_id_width
52 << ", got " << outstanding_reads;
53 return success();
54}
55
56void AXI4Dialect::registerTypes() {
57 addTypes<
58#define GET_TYPEDEF_LIST
59#include "circt/Dialect/AXI4/AXI4Types.cpp.inc"
60 >();
61}
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.