forked from eda-ricercatore/Lombardia-STIL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_analyzer.h
186 lines (160 loc) · 5.64 KB
/
file_analyzer.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/**
* This is written by Zhiyang Ong to parse a STIL file into a FLAT tabular
* test pattern format that contains input test patterns for execution on
* automatic test equipment
*
* Function to parse files for static analysis, and generation of output
* file containing the test patterns for the automatic test equipment
*/
// Import Header files from the C++ STL
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <list>
#include <iterator>
#include "signalZ.h"
#ifndef __FILE_ANALYZER_H
#define __FILE_ANALYZER_H
using namespace std;
// =======================================================================
// List of strings
typedef list<string> str_list;
// Pointer to list of strings
typedef list<string>::iterator str_l_p;
// List of signalZs
typedef list<signalZ *> sig_list;
// Pointer to list of signalZs
typedef list<signalZ *>::iterator sig_l_p;
// Class definition...
class file_analyzer
{
private:
// Declaration of instance variables...
// Name of input file
string in_file;
// Name of output file
string out_file;
// Input stream for the appropriate input filename
ifstream inputfile;
// Output stream for the appropriate output filename
ofstream outputfile;
// List of strings tokens found in the input file
str_list list_tokens;
// Stack for temporary storage of parentheses in processing blocks
str_list list_blocks;
// Duration of the period for the selected clock (using UNIT_OF_TIME)
int period_t;
// List of input signals in the test pattern or output file
sig_list list_of_ip_signals;
// List of output signals in the test pattern or output file
sig_list list_of_op_signals;
// Currently enumerated signal in the test pattern
signalZ *temp_sig;
// List of string pattern to be substituted in the scanproc defintion
str_list str_patterns;
// --------------------------------------------------------------
public:
// Initialize constants...
// Quantization unit of time that is measured in nanoseconds
static const int MEASURE_OF_TIME = 5;
/**
* Flag to indicate that the index of this character in a string
* is invalid
*/
static const int INVALID_CHAR_INDEX = -9999999;
// Assumed maximum number of characters per line
static const int MAX_NUM_OF_CHAR_PER_LINE=1000;
static const string INVALID;
static const string ALLPINS;
static const string BASEWFT;
static const string MACRODEFS;
static const string MACRO;
static const string PATTERN;
static const string PERIOD;
static const string PROCEDURE;
static const string SCANLOAD;
static const string SCANUNLOAD;
static const string SCANPROC;
static const string SCANIN;
static const string SCANOUT;
static const string SCANOUT1;
static const string SCANOUT2;
static const string SCANCLK;
static const string SIGNALGROUPS;
static const string SHIFT;
static const string TIMING;
static const string MASTERCLK;
static const string WAVEFORMTABLE;
static const string WAVEFORMS;
static const string V;
static const string W;
static const string C;
static const string P;
static const string HEADER;
static const string PIPINS;
static const string POPINS;
static const string CLOCK;
static const string OPEN_BRACKET;
static const string CLOSE_BRACKET;
static const string UNIT_OF_TIME;
// =========================================================
// Default constructor
file_analyzer();
// Standard Constructor...
file_analyzer(string input_filename, string output_filename);
// =========================================================
// Define headers for functions...
// Functions to parse blocks/segments of code
// To be completed
void parse_input();
void process_sig_grps();
void process_header();
// To be completed
void process_pattern_blk();
// To be completed
void process_macro_blk(string macro_name);
// To be completed
int process_scanproc_blk(string s);
// To be completed
int process_v_blk(str_l_p p, string vector_type);
int process_waveform_blk(string wave);
int process_pipins(str_l_p p);
int process_popins(str_l_p p);
// Used for master and scan clocks
int process_clk(str_l_p p, string clk_type);
void set_cond_or_val(string sig_name, string sig_val, string sig_type);
void update_indv_sig(string sig_name, string sig_val, string sig_type);
void scan_process();
// Clear waveform properties of all signals
void clear_wave_properties(string key);
// Functions to handle input and output processing
void print_output_ln(string current_ln);
void close_io_streams();
void dump_output();
// Functions for string manipulation/operation
bool search_key_found(string search_key, string cur_token);
string int_to_str(int num);
// The following method is useless... It is defined/implemented, but not used
string time_to_string(int duration, int logic_value);
str_l_p find_token(string key);
string truncate_semicolon(string s);
str_list delimit_string(string delimit_str);
string chop_ns(string clk_time);
string truncate_whitespace(string s);
// Functions for inter-class communication
void transmit_patterns(str_list signame_n_pattern);
void update_sig_period(int period_of_sig);
// Functions for functional verification
void check_waveform();
void check_signal_condition();
void check_signal_value();
void check_scan_block();
};
#endif