LOLA
ppu.h
Go to the documentation of this file.
1 #pragma once
2 #include "halco/common/typed_heap_array.h"
3 #include "halco/hicann-dls/vx/coordinates.h"
4 #include "haldls/cerealization.h"
5 #include "hate/visibility.h"
7 #include "lola/vx/genpybind.h"
8 #include <boost/hana/adapt_struct.hpp>
9 
10 #include "haldls/vx/fpga.h"
11 #include "haldls/vx/ppu.h"
12 
13 class Elf;
14 
15 namespace lola {
16 namespace vx GENPYBIND_TAG_LOLA_VX {
17 
21 class GENPYBIND(visible) ExternalPPUMemoryBlock
22 {
23 public:
24  typedef halco::hicann_dls::vx::ExternalPPUMemoryBlockOnFPGA coordinate_type;
25  typedef std::false_type has_local_data;
26 
27  typedef std::vector<haldls::vx::ExternalPPUMemoryByte> bytes_type;
28 
29  typedef halco::hicann_dls::vx::ExternalPPUMemoryBlockSize size_type;
30 
32  size_type size = size_type(halco::hicann_dls::vx::ExternalPPUMemoryByteOnFPGA::size))
33  SYMBOL_VISIBLE;
34 
35  haldls::vx::ExternalPPUMemoryByte& at(size_t index) SYMBOL_VISIBLE;
36  haldls::vx::ExternalPPUMemoryByte const& at(size_t index) const SYMBOL_VISIBLE;
37  haldls::vx::ExternalPPUMemoryByte& operator[](size_t index) SYMBOL_VISIBLE;
38  haldls::vx::ExternalPPUMemoryByte const& operator[](size_t index) const SYMBOL_VISIBLE;
39 
40  ExternalPPUMemoryBlock get_subblock(size_t begin, size_type length) const SYMBOL_VISIBLE;
41  void set_subblock(size_t begin, ExternalPPUMemoryBlock const& subblock) SYMBOL_VISIBLE;
42 
43  size_type size() const SYMBOL_VISIBLE;
44 
45  GENPYBIND(getter_for(bytes))
46  bytes_type const& get_bytes() const SYMBOL_VISIBLE;
47  GENPYBIND(setter_for(bytes))
48  void set_bytes(bytes_type const& bytes) SYMBOL_VISIBLE;
49 
50  bool operator==(ExternalPPUMemoryBlock const& other) const SYMBOL_VISIBLE;
51  bool operator!=(ExternalPPUMemoryBlock const& other) const SYMBOL_VISIBLE;
52 
53  GENPYBIND(stringstream)
54  friend std::ostream& operator<<(std::ostream& os, ExternalPPUMemoryBlock const& config)
55  SYMBOL_VISIBLE;
56 
57  std::string to_string() const SYMBOL_VISIBLE;
58 
59  friend haldls::vx::detail::VisitPreorderImpl<ExternalPPUMemoryBlock>;
60 
61 private:
62  friend class cereal::access;
63  template <typename Archive>
64  void serialize(Archive& ar, std::uint32_t const version);
65 
66  bytes_type m_bytes;
67 };
68 
69 
73 class GENPYBIND(visible) ExternalPPUMemory
74 {
75 public:
76  typedef halco::hicann_dls::vx::ExternalPPUMemoryOnFPGA coordinate_type;
77  typedef std::false_type has_local_data;
78 
79  typedef halco::common::typed_heap_array<
80  haldls::vx::ExternalPPUMemoryByte,
81  halco::hicann_dls::vx::ExternalPPUMemoryByteOnFPGA>
82  Bytes GENPYBIND(opaque);
83 
84  typedef halco::hicann_dls::vx::ExternalPPUMemoryBlockSize size_type;
85 
86  ExternalPPUMemory() SYMBOL_VISIBLE;
87 
88  Bytes bytes;
89 
90  ExternalPPUMemoryBlock get_subblock(size_t begin, size_type length) const SYMBOL_VISIBLE;
91  void set_subblock(size_t begin, ExternalPPUMemoryBlock const& subblock) SYMBOL_VISIBLE;
92 
93  bool operator==(ExternalPPUMemory const& other) const SYMBOL_VISIBLE;
94  bool operator!=(ExternalPPUMemory const& other) const SYMBOL_VISIBLE;
95 
96  GENPYBIND(stringstream)
97  friend std::ostream& operator<<(std::ostream& os, ExternalPPUMemory const& config)
98  SYMBOL_VISIBLE;
99 
104  std::string to_string() const SYMBOL_VISIBLE;
105 
106  friend haldls::vx::detail::VisitPreorderImpl<ExternalPPUMemory>;
107 
108 private:
109  friend class cereal::access;
110  template <typename Archive>
111  void serialize(Archive& ar, std::uint32_t const version);
112 };
113 
114 
115 class GENPYBIND(visible) PPUProgram
116 {
117 public:
122  class GENPYBIND(visible) Symbol
123  {
124  public:
128  enum class Type
129  {
130  object,
131  function,
132  other
133  };
134 
138  Symbol() SYMBOL_VISIBLE;
139 
143  Symbol(Type const& type, halco::hicann_dls::vx::PPUMemoryBlockOnPPU const& coord)
144  SYMBOL_VISIBLE;
145 
147  Type type;
148 
150  halco::hicann_dls::vx::PPUMemoryBlockOnPPU coordinate;
151 
152  bool operator==(Symbol const& other) const SYMBOL_VISIBLE;
153 
154  bool operator!=(Symbol const& other) const SYMBOL_VISIBLE;
155 
156  GENPYBIND(stringstream)
157  friend std::ostream& operator<<(std::ostream& os, Symbol const& symbol) SYMBOL_VISIBLE;
158  };
159 };
160 
161 
165 class GENPYBIND(visible) PPUElfFile
166 {
167 public:
171  typedef std::map<std::string, PPUProgram::Symbol> symbols_type;
172 
177  PPUElfFile(std::string const& filename) SYMBOL_VISIBLE;
178 
183  symbols_type read_symbols() SYMBOL_VISIBLE;
184 
190  haldls::vx::PPUMemoryBlock read_program() SYMBOL_VISIBLE;
191 
195  ~PPUElfFile() SYMBOL_VISIBLE;
196 
197 private:
198  int m_fd;
199  Elf* m_elf_ptr;
200 };
201 
202 } // namespace vx
203 } // namespace lola
204 
205 #include "lola/vx/ppu.tcc"
Contiguous block of bytes in the external PPU memory.
Definition: ppu.h:22
std::false_type has_local_data
Definition: ppu.h:25
size_type size() const SYMBOL_VISIBLE
haldls::vx::ExternalPPUMemoryByte & operator[](size_t index) SYMBOL_VISIBLE
haldls::vx::ExternalPPUMemoryByte const & at(size_t index) const SYMBOL_VISIBLE
ExternalPPUMemoryBlock(size_type size=size_type(halco::hicann_dls::vx::ExternalPPUMemoryByteOnFPGA::size)) SYMBOL_VISIBLE
haldls::vx::ExternalPPUMemoryByte & at(size_t index) SYMBOL_VISIBLE
std::vector< haldls::vx::ExternalPPUMemoryByte > bytes_type
Definition: ppu.h:27
void set_subblock(size_t begin, ExternalPPUMemoryBlock const &subblock) SYMBOL_VISIBLE
halco::hicann_dls::vx::ExternalPPUMemoryBlockSize size_type
Definition: ppu.h:29
halco::hicann_dls::vx::ExternalPPUMemoryBlockOnFPGA coordinate_type
Definition: ppu.h:24
haldls::vx::ExternalPPUMemoryByte const & operator[](size_t index) const SYMBOL_VISIBLE
ExternalPPUMemoryBlock get_subblock(size_t begin, size_type length) const SYMBOL_VISIBLE
Complete external PPU memory.
Definition: ppu.h:74
halco::hicann_dls::vx::ExternalPPUMemoryOnFPGA coordinate_type
Definition: ppu.h:76
ExternalPPUMemory() SYMBOL_VISIBLE
halco::common::typed_heap_array< haldls::vx::ExternalPPUMemoryByte, halco::hicann_dls::vx::ExternalPPUMemoryByteOnFPGA > Bytes
Definition: ppu.h:82
halco::hicann_dls::vx::ExternalPPUMemoryBlockSize size_type
Definition: ppu.h:84
std::false_type has_local_data
Definition: ppu.h:77
Read-access to memory and symbol data of PPU program file in the ELF file format.
Definition: ppu.h:166
PPUElfFile(std::string const &filename) SYMBOL_VISIBLE
Open file.
std::map< std::string, PPUProgram::Symbol > symbols_type
Map of named symbols.
Definition: ppu.h:171
symbols_type read_symbols() SYMBOL_VISIBLE
Read symbol data.
Symbol of PPU program describing the location and type of a continuous block of memory.
Definition: ppu.h:123
Symbol() SYMBOL_VISIBLE
Default construct a symbol of type 'other' and default coordinate.
#define GENPYBIND_TAG_LOLA_VX
Definition: genpybind.h:4
Definition: cadc.h:465
Definition: dac.h:14