srecord  1.65.0
mif.h
Go to the documentation of this file.
1 //
2 // srecord - Manipulate EPROM load files
3 // Copyright (C) 2009-2011 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or (at
8 // your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 //
18 
19 #ifndef SRECORD_OUTPUT_FILE_MIF_H
20 #define SRECORD_OUTPUT_FILE_MIF_H
21 
22 #include <srecord/output/file.h>
23 
24 namespace srecord
25 {
26 
27 /**
28  * The srecord::output_file_mif class is used to represent the output state
29  * of a file in Memory Initialization File (MIF) format (Altera).
30  */
32  public output_file
33 {
34 public:
35  /**
36  * The destructor.
37  */
38  virtual ~output_file_mif();
39 
40 private:
41  /**
42  * The constructor. It is private on purpose, use the #create
43  * class method instead.
44  *
45  * @param file_name
46  * The name of the file to be written. The special name "-"
47  * indicates the standard output is to be used.
48  */
49  output_file_mif(const std::string &file_name);
50 
51 public:
52  /**
53  * The create class method is used to create new dynamically
54  * allocated instances of this class.
55  *
56  * @param file_name
57  * The name of the file to be written.
58  */
59  static pointer create(const std::string &file_name);
60 
61 protected:
62  // See base class for documentation
63  void write(const record &);
64 
65  // See base class for documentation
66  void line_length_set(int);
67 
68  // See base class for documentation
69  void address_length_set(int);
70 
71  // See base class for documentation
73 
74  // See base class for documentation.
75  bool preferred_block_size_set(int nbytes);
76 
77  // See base class for documentation
78  void command_line(arglex_tool *cmdln);
79 
80  // See base class for documentation.
81  const char *format_name() const;
82 
83  // See base class for documentation.
84  void notify_upper_bound(unsigned long addr);
85 
86 private:
87  /**
88  * The depth instance variable is used to remember how many bytes
89  * of data there is. Kind of broken, because we don't know this
90  * when the header is actually printed.
91  */
92  unsigned long depth;
93 
94  /**
95  * The width instance variable is used to remember how many bits
96  * there are per data item. Default to 8 (traditional bytes).
97  */
98  unsigned width;
99 
100  /**
101  * The width_in_bytes instance variable is used to remember how
102  * many bytes there are per data item. Defaults to 1.
103  */
104  unsigned width_in_bytes;
105 
106  /**
107  * The actual_depth instance variable is used to remember how many
108  * bytes of data there were. This is printed in the footer.
109  */
110  unsigned long actual_depth;
111 
112  /**
113  * The header_done instance variable is used to remember whether
114  * the emit_header method has already been called.
115  */
116  bool header_done;
117 
118  /**
119  * The pref_blk_sz instance variable is used to remember the
120  * preferred block size, in bytes.
121  */
122  int pref_blk_sz;
123 
124  /**
125  * The emit_header method is used to emit the file header,
126  * if necessary.
127  */
128  void emit_header();
129 
130  /**
131  * The default constructor. Do not use.
132  */
133  output_file_mif();
134 
135  /**
136  * The copy constructor. Do not use.
137  */
139 
140  /**
141  * The assignment operator. Do not use.
142  */
143  output_file_mif &operator=(const output_file_mif &);
144 };
145 
146 };
147 
148 // vim: set ts=8 sw=4 et :
149 #endif // SRECORD_OUTPUT_FILE_MIF_H
The srecord::arglex_tool is used to parse command line with srec-specific arguments.
Definition: tool.h:41
The srecord::output_file_mif class is used to represent the output state of a file in Memory Initiali...
Definition: mif.h:33
void address_length_set(int)
The address_length_set method is used to set the minimum number of bytes to be written for addresses ...
void write(const record &)
The write method is used to write a recordonto an output.
int preferred_block_size_get() const
The preferred_block_size_get method is used to get the proferred block size of the output fformat.
virtual ~output_file_mif()
The destructor.
void command_line(arglex_tool *cmdln)
The command_line method is used by arglex_srec::get_output when parsing the command line,...
static pointer create(const std::string &file_name)
The create class method is used to create new dynamically allocated instances of this class.
void line_length_set(int)
The set_line_length method is used to set the maximum length of an output line, for those formats for...
void notify_upper_bound(unsigned long addr)
The notify_upper_bound method is used to notify the output class of the upper bound (highest address ...
const char * format_name() const
The format_name method is used to obtain the name of this output format.
bool preferred_block_size_set(int nbytes)
The preferred_block_size_set method is is to set a precific number of bytes for the preferred block s...
The srecord::output_file class is used to represent a generic output file.
Definition: file.h:35
std::shared_ptr< output > pointer
Definition: output.h:41
The srecord::record class is used to represent a data record read from a file.
Definition: record.h:35