Fletchgen
The Fletcher Design Generator
design.h
1 // Copyright 2018-2019 Delft University of Technology
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <arrow/api.h>
18 #include <cerata/api.h>
19 #include <fletcher/common.h>
20 
21 #include <vector>
22 #include <memory>
23 #include <string>
24 
25 #include "fletchgen/schema.h"
26 #include "fletchgen/options.h"
27 #include "fletchgen/kernel.h"
28 #include "fletchgen/mantle.h"
29 #include "fletchgen/bus.h"
30 #include "fletchgen/recordbatch.h"
31 #include "fletchgen/mmio.h"
32 
33 namespace fletchgen {
34 
36 struct Design {
38  explicit Design(const std::shared_ptr<Options> &opts);
39 
41  void AnalyzeSchemas();
43  void AnalyzeRecordBatches();
45  void AnalyzeExternalIO();
46 
48  std::shared_ptr<Options> options;
49 
51  std::shared_ptr<SchemaSet> schema_set;
52 
54  std::vector<MmioReg> default_regs;
56  std::vector<MmioReg> recordbatch_regs;
58  std::vector<MmioReg> kernel_regs;
60  std::vector<MmioReg> profiling_regs;
62  std::vector<std::vector<MmioReg> *> all_regs = {&default_regs, &recordbatch_regs, &kernel_regs, &profiling_regs};
63 
64  Axi4LiteSpec mmio_spec;
65 
67  std::optional<std::shared_ptr<Type>> external;
68 
70  std::vector<fletcher::RecordBatchDescription> batch_desc;
71 
73  std::vector<std::shared_ptr<RecordBatch>> recordbatch_comps;
75  std::shared_ptr<Kernel> kernel_comp;
76 
79  std::shared_ptr<Mantle> mantle_comp;
80 
82  std::shared_ptr<Nucleus> nucleus_comp;
83 
85  std::shared_ptr<Component> mmio_comp;
86 
88  std::vector<cerata::OutputSpec> GetOutputSpec();
89 
91  static std::vector<MmioReg> GetRecordBatchRegs(const std::vector<fletcher::RecordBatchDescription> &batch_desc);
92 
94  static std::vector<MmioReg> ParseCustomRegs(const std::vector<std::string> &regs);
95 
97  static void RunVhdmmio(const std::vector<std::vector<MmioReg> *> &regs, Axi4LiteSpec axi_spec);
98 };
99 
100 } // namespace fletchgen
Contains all classes and functions related to Fletchgen.
Definition: array.cc:29
AXI4-lite bus specification.
Definition: axi4_lite.h:29
A structure for all components in a Fletcher design.
Definition: design.h:36
std::vector< MmioReg > profiling_regs
Profiling registers.
Definition: design.h:60
std::vector< MmioReg > kernel_regs
Custom registers.
Definition: design.h:58
std::vector< MmioReg > recordbatch_regs
RecordBatch registers.
Definition: design.h:56
void AnalyzeSchemas()
Analyze the supplied Schemas.
Definition: design.cc:50
std::shared_ptr< Options > options
The program options.
Definition: design.h:48
std::shared_ptr< Mantle > mantle_comp
Definition: design.h:79
static std::vector< MmioReg > GetRecordBatchRegs(const std::vector< fletcher::RecordBatchDescription > &batch_desc)
Obtain requited mmio registers based on the RecordBatch descriptions.
Definition: design.cc:125
std::shared_ptr< Kernel > kernel_comp
The Kernel component of this design.
Definition: design.h:75
std::shared_ptr< Component > mmio_comp
The Nucleus-level component generated by vhdmmio.
Definition: design.h:85
std::vector< std::shared_ptr< RecordBatch > > recordbatch_comps
The RecordBatch(Readers/Writers) in the design.
Definition: design.h:73
static std::vector< MmioReg > ParseCustomRegs(const std::vector< std::string > &regs)
Obtain required custom registers based on a vector of strings.
Definition: design.cc:97
std::vector< MmioReg > default_regs
Default registers.
Definition: design.h:54
std::vector< cerata::OutputSpec > GetOutputSpec()
Obtain a Cerata OutputSpec from this design for Cerata back-ends to generate output.
Definition: design.cc:224
static void RunVhdmmio(const std::vector< std::vector< MmioReg > * > &regs, Axi4LiteSpec axi_spec)
Generate vhdmmio yaml and run it.
Definition: design.cc:210
std::vector< std::vector< MmioReg > * > all_regs
Pointers to all registers vectors.
Definition: design.h:62
std::shared_ptr< SchemaSet > schema_set
The SchemaSet to base the design on.
Definition: design.h:51
Design(const std::shared_ptr< Options > &opts)
Make a new Design structure based on program options.
Definition: design.cc:159
void AnalyzeRecordBatches()
Analyze the supplied RecordBatches.
Definition: design.cc:67
std::optional< std::shared_ptr< Type > > external
External signals type.
Definition: design.h:67
std::vector< fletcher::RecordBatchDescription > batch_desc
The RecordBatchDescriptions to use in SREC generation.
Definition: design.h:70
std::shared_ptr< Nucleus > nucleus_comp
The Nucleus component, that wraps the kernel and mmio.
Definition: design.h:82
void AnalyzeExternalIO()
Analyze custom IO.
Definition: design.cc:256