<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://www.verific.com/faq/index.php?action=history&amp;feed=atom&amp;title=Using_stream_input_to_ignore_input_file</id>
		<title>Using stream input to ignore input file - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://www.verific.com/faq/index.php?action=history&amp;feed=atom&amp;title=Using_stream_input_to_ignore_input_file"/>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Using_stream_input_to_ignore_input_file&amp;action=history"/>
		<updated>2026-05-02T12:41:03Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.3</generator>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Using_stream_input_to_ignore_input_file&amp;diff=462&amp;oldid=prev</id>
		<title>Hoa: Created page with &quot;This example shows how to use stream input to ignore input files that meet certain conditions.  The example uses only filename as the &quot;ignore&quot; category. But you can have other...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Using_stream_input_to_ignore_input_file&amp;diff=462&amp;oldid=prev"/>
				<updated>2020-02-13T00:04:10Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;This example shows how to use stream input to ignore input files that meet certain conditions.  The example uses only filename as the &amp;quot;ignore&amp;quot; category. But you can have other...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This example shows how to use stream input to ignore input files that meet certain conditions.&lt;br /&gt;
&lt;br /&gt;
The example uses only filename as the &amp;quot;ignore&amp;quot; category. But you can have other tests.&lt;br /&gt;
&lt;br /&gt;
C++:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;VerificStream.h&amp;quot;&lt;br /&gt;
#include &amp;quot;veri_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Message.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#ifdef VERIFIC_NAMESPACE&lt;br /&gt;
using namespace Verific;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
// Define a stream class that always returns EOF when read.&lt;br /&gt;
class my_eof_stream : public verific_stream&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
    my_eof_stream() : verific_stream() { }&lt;br /&gt;
    virtual ~my_eof_stream() { }&lt;br /&gt;
&lt;br /&gt;
    virtual bool read(char *buf, long max_size) { *buf = '\0'; (void) max_size; return true; }&lt;br /&gt;
    virtual std::streamsize gcount() const      { return 0; }&lt;br /&gt;
    virtual bool            eof() const         { return 1; }&lt;br /&gt;
    virtual bool            fail() const        { return 0; }&lt;br /&gt;
    virtual bool            bad() const         { return 0; }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
static verific_stream *&lt;br /&gt;
my_file_stream(const char *file_name)&lt;br /&gt;
{&lt;br /&gt;
    if (Strings::compare(&amp;quot;ToBeIgnored.v&amp;quot;, file_name)) { // Use your own condition here&lt;br /&gt;
        Message::Msg(VERIFIC_INFO, 0, 0, &amp;quot;Ignoring file %s&amp;quot;, file_name);&lt;br /&gt;
        return new my_eof_stream(); // Return the EOF stream object (file is not used)&lt;br /&gt;
    }&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    Message::PrintLine(&amp;quot;Normal read, will produce error.&amp;quot;);&lt;br /&gt;
    veri_file::Analyze(&amp;quot;test.v&amp;quot;, veri_file::VERILOG_2K);&lt;br /&gt;
&lt;br /&gt;
    Message::PrintLine(&amp;quot;&amp;quot;);&lt;br /&gt;
    Message::PrintLine(&amp;quot;Reset parsetree and read again, ignoring the \&amp;quot;bad\&amp;quot; file.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    // Reset parser&lt;br /&gt;
    veri_file::ResetParser();&lt;br /&gt;
    // Ignore the included file this time&lt;br /&gt;
    veri_file::RegisterFlexStreamCallBack(my_file_stream);&lt;br /&gt;
&lt;br /&gt;
    // Should not error out&lt;br /&gt;
    if (!veri_file::Analyze(&amp;quot;test.v&amp;quot;, veri_file::VERILOG_2K)) return 1;&lt;br /&gt;
    veri_file::PrettyPrint(&amp;quot;pp_out.v&amp;quot;, 0);&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
test.v:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module test ();&lt;br /&gt;
`include &amp;quot;ToBeIgnored.v&amp;quot;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ToBeIgnored.v:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
This file is not Verilog-legal.&lt;br /&gt;
It will be ignored.&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Normal read, will produce error.&lt;br /&gt;
-- Analyzing Verilog file 'test.v' (VERI-1482)&lt;br /&gt;
test.v(2): INFO: analyzing included file 'ToBeIgnored.v' (VERI-1328)&lt;br /&gt;
ToBeIgnored.v(1): ERROR: syntax error near 'is' (VERI-1137)&lt;br /&gt;
test.v(2): INFO: back to file 'test.v' (VERI-2320)&lt;br /&gt;
-- Verilog file 'test.v' ignored due to errors (VERI-1483)&lt;br /&gt;
-- &lt;br /&gt;
-- Reset parsetree and read again, ignoring the &amp;quot;bad&amp;quot; file.&lt;br /&gt;
-- Analyzing Verilog file 'test.v' (VERI-1482)&lt;br /&gt;
INFO: Ignoring file ToBeIgnored.v&lt;br /&gt;
test.v(2): INFO: analyzing included file 'ToBeIgnored.v' (VERI-1328)&lt;br /&gt;
test.v(2): INFO: back to file 'test.v' (VERI-2320)&lt;br /&gt;
-- Pretty printing all design elements in all libraries to file 'pp_out.v' (VERI-1492)&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pp_out.v:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module test () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	</feed>