-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdesign_common.h
62 lines (57 loc) · 2.03 KB
/
design_common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Copyright (C) 2006, 2007 Jean-Baptiste Note <[email protected]>
*
* This file is part of debit.
*
* Debit is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Debit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with debit. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _DESIGN_COMMON_H
#define _DESIGN_COMMON_H
/*
* The frame index is a four-way lookup table. We have chosen for now to use
* a two-way lookup table to index the frames internally, redoing most
* of the computation for the v4.
*/
static inline
const gchar **get_frame_loc(const bitstream_parsed_t *parsed,
const guint type,
const guint row,
const guint top,
const guint idx,
const guint frame) {
const chip_struct_t *chip_struct = parsed->chip_struct;
const unsigned rowcount = chip_struct->row_count;
const unsigned framecount = chip_struct->frame_count[type];
const unsigned *col_count = chip_struct->col_count;
g_assert(type < V__NB_CFG);
g_assert(idx < type_col_count(col_count, type));
g_assert(row < rowcount);
g_assert(frame < framecount);
(void) col_count;
/* This is a double-lookup method */
return &parsed->frames[type][ framecount * ((idx * 2 + top) * rowcount + row)
+ frame ];
}
static inline
const gchar *get_frame(const bitstream_parsed_t *parsed,
const guint type,
const guint row,
const guint top,
const guint idx,
const guint frame) {
const gchar *frameptr = *get_frame_loc(parsed, type, row, top, idx, frame);
g_assert(frameptr != NULL);
return frameptr;
}
#endif /* _DESIGN_COMMON_H */