17 #include <arrow/api.h>
18 #include <cerata/api.h>
19 #include <fletcher/common.h>
26 #include "fletchgen/utils.h"
27 #include "fletchgen/basic_types.h"
28 #include "fletchgen/schema.h"
29 #include "fletchgen/bus.h"
34 using cerata::Component;
35 using cerata::Instance;
37 using cerata::default_domain;
63 std::shared_ptr<arrow::Field>
field_;
80 std::shared_ptr<arrow::Field> field,
81 std::shared_ptr<FletcherSchema> fletcher_schema,
82 std::shared_ptr<cerata::Type> type,
84 std::shared_ptr<ClockDomain> domain,
86 : Port(std::move(name), std::move(type), dir, std::move(domain)),
93 std::shared_ptr<Object>
Copy()
const override;
104 std::shared_ptr<FieldPort>
arrow_port(
const std::shared_ptr<FletcherSchema> &fletcher_schema,
105 const std::shared_ptr<arrow::Field> &field,
107 const std::shared_ptr<ClockDomain> &domain = default_domain());
118 std::shared_ptr<FieldPort>
command_port(
const std::shared_ptr<FletcherSchema> &schema,
119 const std::shared_ptr<arrow::Field> &field,
120 const std::shared_ptr<Node> &index_width,
121 const std::shared_ptr<Node> &tag_width,
122 std::optional<std::shared_ptr<Node>> addr_width = std::nullopt,
123 const std::shared_ptr<ClockDomain> &domain = default_domain());
133 std::shared_ptr<FieldPort>
unlock_port(
const std::shared_ptr<FletcherSchema> &schema,
134 const std::shared_ptr<arrow::Field> &field,
135 const std::shared_ptr<Node> &tag_width,
136 const std::shared_ptr<ClockDomain> &domain = default_domain());
154 const std::shared_ptr<FletcherSchema> &fletcher_schema,
157 std::vector<std::shared_ptr<FieldPort>>
GetFieldPorts(
const std::optional<FieldPort::Function> &
function = {})
const;
173 void AddArrays(
const std::shared_ptr<FletcherSchema> &fletcher_schema);
185 void ConnectBusPorts(Instance *
array,
const std::string &prefix, cerata::NodeMap *rebinding);
189 std::shared_ptr<RecordBatch>
record_batch(
const std::string &name,
190 const std::shared_ptr<FletcherSchema> &fletcher_schema,
191 const fletcher::RecordBatchDescription &batch_desc);
Contains all classes and functions related to Fletchgen.
Component * array(Mode mode)
Return a Cerata component model of an Array(Reader/Writer).
std::shared_ptr< FieldPort > arrow_port(const std::shared_ptr< FletcherSchema > &fletcher_schema, const std::shared_ptr< arrow::Field > &field, bool reverse, const std::shared_ptr< ClockDomain > &domain)
Construct a field-derived port for Arrow data.
std::shared_ptr< FieldPort > unlock_port(const std::shared_ptr< FletcherSchema > &schema, const std::shared_ptr< arrow::Field > &field, const std::shared_ptr< Node > &tag_width, const std::shared_ptr< ClockDomain > &domain)
Construct a field-derived unlock port.
std::shared_ptr< RecordBatch > record_batch(const std::string &name, const std::shared_ptr< FletcherSchema > &fletcher_schema, const fletcher::RecordBatchDescription &batch_desc)
Make a new RecordBatch(Reader/Writer) component, based on a Fletcher schema.
std::shared_ptr< FieldPort > command_port(const std::shared_ptr< FletcherSchema > &schema, const std::shared_ptr< arrow::Field > &field, const std::shared_ptr< Node > &index_width, const std::shared_ptr< Node > &tag_width, std::optional< std::shared_ptr< Node >> addr_width, const std::shared_ptr< ClockDomain > &domain)
Construct a field-derived command port.
A port derived from an Arrow field.
std::shared_ptr< arrow::Field > field_
The Arrow field this port was derived from.
std::shared_ptr< FletcherSchema > fletcher_schema_
The Fletcher schema this port was derived from.
std::shared_ptr< Object > Copy() const override
Create a deep-copy of the FieldPort.
FieldPort(std::string name, Function function, std::shared_ptr< arrow::Field > field, std::shared_ptr< FletcherSchema > fletcher_schema, std::shared_ptr< cerata::Type > type, Port::Dir dir, std::shared_ptr< ClockDomain > domain, bool profile)
Construct a new port derived from an Arrow field.
bool profile_
Whether this field port should be profiled.
Function
Enumeration of FieldPort functions.
@ UNLOCK
Port that signals the kernel a command was completed.
@ ARROW
Port with Arrow data.
@ COMMAND
Port to issue commands to the generated interface.
enum fletchgen::FieldPort::Function function_
The function of this FieldPort.
A RecordBatch aggregating ArrayReaders/Writers.
std::shared_ptr< FletcherSchema > fletcher_schema_
Fletcher schema implemented by this RecordBatch(Reader/Writer)
Mode mode() const
Return the mode (read or write) of this RecordBatch.
std::vector< std::shared_ptr< FieldPort > > GetFieldPorts(const std::optional< FieldPort::Function > &function={}) const
Obtain all ports derived from an Arrow field with a specific function.
RecordBatch(const std::string &name, const std::shared_ptr< FletcherSchema > &fletcher_schema, fletcher::RecordBatchDescription batch_desc)
RecordBatch constructor.
FletcherSchema * schema()
Return the Fletcher schema this RecordBatch component is based on.
fletcher::RecordBatchDescription batch_desc_
The RecordBatch description.
std::vector< Instance * > array_instances_
A mapping from ArrayReader/Writer instances to their bus ports.
void AddArrays(const std::shared_ptr< FletcherSchema > &fletcher_schema)
Adds all ArrayReaders/Writers, un-concatenates ports and connects it to the top-level of this compone...
Mode mode_
Whether to read or write from/to the in-memoRecordBatch.
fletcher::RecordBatchDescription batch_desc() const
Return the description of the RecordBatch this component is based on.