4 #error "Requires CHIP_REVISION"
10 #include "fisch/vx/container.h"
11 #include "fisch/vx/container_cast.h"
12 #include "fisch/vx/fill.h"
13 #include "halco/hicann-dls/vx/capmem.h"
14 #include "halco/hicann-dls/vx/ppu.h"
15 #include "haldls/vx/common.h"
16 #include "haldls/vx/jtag.h"
17 #include "haldls/vx/traits.h"
18 #include "lola/vx/capmem.h"
23 #define STR(x) XSTR(x)
25 #define CONCAT(w, x, y, z) STR(ID(w)ID(/)ID(x)ID(/)ID(v)ID(y)ID(/)ID(z))
26 #include CONCAT(haldls,vx,CHIP_REVISION,capmem.h)
33 #if CHIP_REVISION == 2
34 #define CHIP_REVISION_STR v2
35 #elif CHIP_REVISION == 3
36 #define CHIP_REVISION_STR v3
38 #error "Unknown CHIP_REVISION"
52 typename T::coordinate_type
get_coord(T
const& config)
54 using namespace halco::hicann_dls::vx;
56 typename T::coordinate_type coord;
57 if constexpr (std::is_same<T, haldls::vx::PPUMemoryBlock>::value) {
58 coord = PPUMemoryBlockOnDLS(
60 PPUMemoryWordOnPPU(0), PPUMemoryWordOnPPU(config.get_words().size() - 1)),
63 if constexpr (std::is_same<T, lola::vx::ExternalPPUMemoryBlock>::value) {
64 coord = ExternalPPUMemoryBlockOnFPGA(
65 ExternalPPUMemoryByteOnFPGA(0),
66 ExternalPPUMemoryByteOnFPGA(config.get_bytes().size() - 1));
81 using namespace halco::hicann_dls::vx;
82 typedef typename haldls::vx::detail::BackendContainerTrait<T>::default_container word_type;
83 typedef std::vector<
typename decltype(
84 fisch::vx::container_cast(std::declval<word_type>()))::coordinate_type>
86 addresses_type addresses;
91 T mutable_config = config;
92 haldls::vx::visit_preorder(
94 return addresses.size();
109 typedef typename haldls::vx::detail::BackendContainerTrait<T>::default_container word_type;
110 typedef std::vector<word_type> words_type;
117 for (
auto& word : words) {
118 word = fisch::vx::container_cast(
119 fisch::vx::fill_random<decltype(fisch::vx::container_cast(std::declval<word_type>()))>(
135 typedef typename haldls::vx::detail::BackendContainerTrait<T>::default_container word_type;
136 typedef std::vector<word_type> words_type;
143 for (
auto& word : words) {
144 word = fisch::vx::container_cast(
145 fisch::vx::fill_ones<decltype(fisch::vx::container_cast(std::declval<word_type>()))>());
154 inline void decode_random(std::mt19937& gen, haldls::vx::JTAGIdCode& config)
157 std::uniform_int_distribution<fisch::vx::JTAGIdCode::Value::value_type> random_word(
158 std::numeric_limits<fisch::vx::JTAGIdCode::Value::value_type>::min(),
159 std::numeric_limits<fisch::vx::JTAGIdCode::Value::value_type>::max());
162 auto random_jtag_id_word = random_word(gen) | 1u;
165 fisch::vx::word_access_type::JTAGIdCode, haldls::vx::JTAGIdCode::read_config_size_in_words>
166 data{fisch::vx::word_access_type::JTAGIdCode(random_jtag_id_word)};
173 std::mt19937& gen, haldls::vx::CHIP_REVISION_STR::CapMemBlockConfig& config)
175 typedef haldls::vx::detail::BackendContainerTrait<
176 haldls::vx::CHIP_REVISION_STR::CapMemBlockConfig>::default_container word_type;
177 typedef std::vector<word_type> words_type;
184 for (
auto& word : words) {
185 word = fisch::vx::container_cast(
186 fisch::vx::fill_random<decltype(fisch::vx::container_cast(std::declval<word_type>()))>(
190 std::uniform_int_distribution<uintmax_t> hotbit_capmem_row(
191 0, halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemRowOnCapMemBlock::max);
192 words.at(0) = word_type(1ul << hotbit_capmem_row(gen));
195 std::uniform_int_distribution<uintmax_t> capmem_column(
196 0, halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemColumnOnCapMemBlock::max);
197 words.at(1) = word_type(capmem_column(gen));
200 std::uniform_int_distribution<uintmax_t> select(0, 2);
201 words.at(2) = word_type(select(gen));
202 words.at(5) = word_type(select(gen));
204 std::uniform_int_distribution<uintmax_t> prescale_ramp(
205 0, haldls::vx::CHIP_REVISION_STR::CapMemBlockConfig::PrescaleRamp::max);
206 std::uniform_int_distribution<uintmax_t> prescale_pause(
207 0, haldls::vx::CHIP_REVISION_STR::CapMemBlockConfig::PrescalePause::max);
208 std::uniform_int_distribution<uintmax_t> msbs(0, 0xf);
209 std::uniform_int_distribution<uintmax_t> lsbs(0, 0xfffff);
210 words.at(6) = word_type(
211 msbs(gen) << 28 | prescale_ramp(gen) << 24 | prescale_pause(gen) << 20 | lsbs(gen));
218 inline void decode_ones(haldls::vx::CHIP_REVISION_STR::CapMemBlockConfig& )
220 throw std::runtime_error(
"CapMemBlockConfig can't be initialized with all ones");
224 inline void decode_random(std::mt19937& gen, lola::vx::CHIP_REVISION_STR::CapMem& config)
226 typedef haldls::vx::detail::BackendContainerTrait<
227 lola::vx::CHIP_REVISION_STR::CapMem>::default_container word_type;
228 typedef std::vector<word_type> words_type;
235 for (
auto& word : words) {
236 word = fisch::vx::container_cast(
237 fisch::vx::fill_random<decltype(fisch::vx::container_cast(std::declval<word_type>()))>(
242 for (
size_t i = 0;
auto& block : config.blocks) {
244 words_type block_words;
245 haldls::vx::visit_preorder(
246 block, halco::hicann_dls::vx::CHIP_REVISION_STR::CapMemBlockConfigOnDLS(i),
248 for (
size_t j = 0; j < block_words.size(); ++j) {
249 words.at(i * block_words.size() + j) = block_words.at(j);
261 throw std::runtime_error(
"CapMem can't be initialized with all ones");
Fill the visited containers by decoding the specified configuration data.
Extract hardware configuration data for the visited containers.
T::coordinate_type get_coord(T const &config)
Get coordinate matching container, e.g.
size_t count_decoding_words(T const &config)
Get number of words expected for decoding.
void decode_random(std::mt19937 &gen, T &config)
Decode random data into a container.
void decode_ones(T &config)
Decode data with all bits set to one into a container.
Extract addresses for reading from hardware for the visited containers.