17 #include <arrow/api.h>
18 #include <cerata/api.h>
19 #include <fletcher/common.h>
30 constexpr
char COUNT[] =
"fletchgen_count";
32 constexpr
char LAST[] =
"fletchgen_last";
37 using cerata::ClockDomain;
38 using cerata::TypeMapper;
39 using cerata::Parameter;
42 #define BIT_DECL_FACTORY(NAME) std::shared_ptr<Type> NAME();
45 #define BIT_FACTORY(NAME) \
46 std::shared_ptr<Type> NAME() { \
47 static std::shared_ptr<Type> result = bit(); \
52 #define VEC_DECL_FACTORY(NAME, WIDTH) std::shared_ptr<Type> NAME();
55 #define VEC_FACTORY(NAME, WIDTH) \
56 std::shared_ptr<Type> NAME() { \
57 static std::shared_ptr<Type> result = vector(#NAME, WIDTH); \
62 #define PARAM_DECL_FACTORY(NAME, VALUE) std::shared_ptr<Parameter> NAME(int64_t value = VALUE, \
63 const std::string& prefix = "");
66 #define PARAM_FACTORY(NAME) \
67 std::shared_ptr<Parameter> NAME(int64_t value, const std::string& prefix) { \
68 auto name = std::string(#NAME); \
69 for (auto &ch : name) ch = std::toupper(ch); \
70 if (!prefix.empty()) {name = prefix + "_" + name;} \
71 auto result = parameter(name, cerata::integer(), intl(value)); \
76 BIT_DECL_FACTORY(validity)
77 VEC_DECL_FACTORY(bool_, 1)
78 VEC_DECL_FACTORY(int8, 8)
79 VEC_DECL_FACTORY(uint8, 8)
80 VEC_DECL_FACTORY(int16, 16)
81 VEC_DECL_FACTORY(uint16, 16)
82 VEC_DECL_FACTORY(int32, 32)
83 VEC_DECL_FACTORY(uint32, 32)
84 VEC_DECL_FACTORY(int64, 64)
85 VEC_DECL_FACTORY(uint64, 64)
86 VEC_DECL_FACTORY(float8, 8)
87 VEC_DECL_FACTORY(float16, 16)
88 VEC_DECL_FACTORY(float32, 32)
89 VEC_DECL_FACTORY(float64, 64)
90 VEC_DECL_FACTORY(date32, 32)
91 VEC_DECL_FACTORY(date64, 64)
92 VEC_DECL_FACTORY(date32, 32)
93 VEC_DECL_FACTORY(date64, 64)
94 VEC_DECL_FACTORY(time32, 32)
95 VEC_DECL_FACTORY(time64, 64)
96 VEC_DECL_FACTORY(timestamp, 64)
97 VEC_DECL_FACTORY(decimal128, 128)
98 VEC_DECL_FACTORY(utf8c, 8)
99 VEC_DECL_FACTORY(
byte, 8)
100 VEC_DECL_FACTORY(offset, 32)
103 std::shared_ptr<ClockDomain>
kernel_cd();
105 std::shared_ptr<ClockDomain>
bus_cd();
107 std::shared_ptr<Type>
cr();
109 std::shared_ptr<Type>
valid(
int width = 1,
bool on_primitive = false);
111 std::shared_ptr<Type>
ready(
int width = 1,
bool on_primitive = false);
113 std::shared_ptr<Type>
data(
int width);
115 std::shared_ptr<Type>
length(
int width);
117 std::shared_ptr<Type>
count(
int width);
119 std::shared_ptr<Type>
dvalid(
int width = 1,
bool on_primitive = false);
121 std::shared_ptr<Type>
last(
int width = 1,
bool on_primitive = false);
131 std::shared_ptr<Type>
ConvertFixedWidthType(const std::shared_ptr<arrow::DataType> &arrow_type,
int epc = 1);
139 std::optional<cerata::Port *>
GetClockResetPort(cerata::Graph *graph, const ClockDomain &domain);
Contains all classes and functions related to Fletchgen.
std::shared_ptr< ClockDomain > kernel_cd()
Fletcher accelerator clock domain.
std::shared_ptr< Type > valid(int width, bool on_primitive)
Fletcher valid.
std::shared_ptr< Type > cr()
Fletcher clock/reset;.
std::shared_ptr< Type > data(int width)
Fletcher data.
std::shared_ptr< Type > ConvertFixedWidthType(const std::shared_ptr< arrow::DataType > &arrow_type, int epc)
Convert a fixed-width arrow::DataType to a fixed-width Fletcher Type.
std::shared_ptr< Type > ready(int width, bool on_primitive)
Fletcher ready.
std::shared_ptr< Type > dvalid(int width, bool on_primitive)
Fletcher dvalid.
std::shared_ptr< Type > length(int width)
Fletcher length.
std::shared_ptr< Type > count(int width)
Fletcher count.
int GetFixedWidthTypeBitWidth(const arrow::DataType &arrow_type)
Returns the bit-width of a fixed-width Arrow type. Throws if it's not a fixed-width type.
std::shared_ptr< ClockDomain > bus_cd()
Fletcher bus clock domain.
std::shared_ptr< Type > last(int width, bool on_primitive)
Fletcher last.
std::optional< cerata::Port * > GetClockResetPort(cerata::Graph *graph, const ClockDomain &domain)
Return the clock/reset port of a graph for a specific clock domain, if it exists.