13 const bool& displaced_en,
14 std::vector<road_collection_t>& zone_roads)
const {
15 typedef ap_uint<v3::kHitmapNCols + v3::kPatternMatchingPadding * 2> padded_row_t;
16 typedef ap_uint<v3::kHitmapNRows> pattern_activation_t;
17 typedef std::array<pattern_activation_t, v3::kHitmapNCols> pattern_activation_collection_t;
19 const padded_row_t padded_one = 1;
23 for (
unsigned int i_zone = 0; i_zone < zone_hitmaps.size(); ++i_zone) {
24 auto& hitmap = zone_hitmaps[i_zone];
25 auto* model_pc = &(
model.zones_[i_zone].prompt_patterns);
26 auto* model_ql = &(
model.zones_[i_zone].prompt_quality_lut);
29 model_pc = &(
model.zones_[i_zone].disp_patterns);
30 model_ql = &(
model.zones_[i_zone].disp_quality_lut);
34 auto& roads = zone_roads.emplace_back();
37 roads[i_col].pattern = 0;
38 roads[i_col].quality = 0;
42 for (
unsigned int i_pattern = 0; i_pattern < model_pc->size(); ++i_pattern) {
43 auto& model_pat = (*model_pc)[i_pattern];
46 pattern_activation_collection_t pac;
56 const auto& hitmap_row = hitmap[i_row];
57 auto& model_pat_row = model_pat[i_row];
64 padded_row_t padded_hm_row = hitmap_row;
68 padded_row_t padded_pat_row = 0;
70 unsigned int offset = model_pat_row.begin;
72 unsigned int bw = model_pat_row.end - model_pat_row.begin + 1;
74 for (
unsigned int i_bit = 0; i_bit < bw; ++i_bit)
75 padded_pat_row |= (padded_one << (
offset + i_bit));
81 padded_row_t
result = padded_pat_row & padded_hm_row;
84 pac[i_col] = pac[i_col] | (1 << i_row);
87 padded_pat_row = padded_pat_row << 1;
98 auto& activation = pac[i_col];
99 auto quality = (*model_ql)[activation];
101 auto& current_road = roads[i_col];
103 if (current_road.quality <
quality) {
104 current_road.pattern = i_pattern;
105 current_road.quality =
quality;
113 if (roads[i_col].
quality == 0) {
118 <<
" zone " << i_zone <<
" col " << i_col <<
" pat " << roads[i_col].pattern
119 <<
" qual " << roads[i_col].quality << std::endl;
constexpr int kHitmapNRows
constexpr int kHitmapNCols
const EMTFContext & context_
constexpr int kPatternMatchingPadding
void apply(const std::vector< hitmap_t > &, const bool &, std::vector< road_collection_t > &) const
Log< level::Info, false > LogInfo
PatternMatchingLayer(const EMTFContext &)
EMTFConfiguration config_