-
Notifications
You must be signed in to change notification settings - Fork 25
/
svf2csvf.h
84 lines (72 loc) · 2.23 KB
/
svf2csvf.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* Copyright (C) 2009-2012 Chris McClelland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SVF2CSVF_H
#define SVF2CSVF_H
#include <libbuffer.h>
#include "libfpgalink.h"
#ifdef __cplusplus
extern "C" {
#endif
struct BitStore {
uint32 numBits;
struct Buffer tdi;
struct Buffer tdo;
struct Buffer mask;
// TODO: smask?
};
struct ParseContext {
struct BitStore dataHead;
struct BitStore insnHead;
struct BitStore dataBody;
struct BitStore insnBody;
struct BitStore dataTail;
struct BitStore insnTail;
uint32 curLength;
struct Buffer curMaskBuf;
uint32 curMaskBits;
uint32 lastCmdOffset;
uint32 lastRunTestOffset;
uint32 lastRunTestValue;
};
#define bitsToBytes(x) (((x)>>3) + ((x)&7 ? 1 : 0))
#define CHOMP() while ( *p == ' ' || *p == '\t' || *p == '\r' ) { p++; }
FLStatus headTail(
struct Buffer *dataBuf, struct Buffer *hdrBuf, struct Buffer *tailBuf,
uint32 dataBits, uint32 hdrBits, uint32 tailBits,
const char **error
) WARN_UNUSED_RESULT;
FLStatus readBytes(
struct Buffer *buffer, const char *hexDigits, const char **error
) WARN_UNUSED_RESULT;
FLStatus cxtInitialise(
struct ParseContext *cxt, const char **error
) WARN_UNUSED_RESULT;
void cxtDestroy(
struct ParseContext *cxt);
FLStatus parseLine(
struct ParseContext *cxt, const struct Buffer *lineBuf, struct Buffer *csvfBuf,
uint32 *maxBufSize, const char **error
) WARN_UNUSED_RESULT;
FLStatus insertRunTestBefore(
struct Buffer *buf, uint32 offset, uint32 count,
uint32 *lastRunTestOffset, uint32 *lastRunTestValue,
const char **error
) WARN_UNUSED_RESULT;
#ifdef __cplusplus
}
#endif
#endif