2 * yosys -- Yosys Open SYnthesis Suite
4 * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #include "kernel/yosys.h"
29 std::string pass_name
, short_help
;
30 Pass(std::string name
, std::string short_help
= "** document me **");
34 virtual void clear_flags();
35 virtual void execute(std::vector
<std::string
> args
, RTLIL::Design
*design
) = 0;
40 struct pre_post_exec_state_t
{
45 pre_post_exec_state_t
pre_execute();
46 void post_execute(pre_post_exec_state_t state
);
48 void cmd_log_args(const std::vector
<std::string
> &args
);
49 void cmd_error(const std::vector
<std::string
> &args
, size_t argidx
, std::string msg
);
50 void extra_args(std::vector
<std::string
> args
, size_t argidx
, RTLIL::Design
*design
, bool select
= true);
52 static void call(RTLIL::Design
*design
, std::string command
);
53 static void call(RTLIL::Design
*design
, std::vector
<std::string
> args
);
55 static void call_on_selection(RTLIL::Design
*design
, const RTLIL::Selection
&selection
, std::string command
);
56 static void call_on_selection(RTLIL::Design
*design
, const RTLIL::Selection
&selection
, std::vector
<std::string
> args
);
58 static void call_on_module(RTLIL::Design
*design
, RTLIL::Module
*module
, std::string command
);
59 static void call_on_module(RTLIL::Design
*design
, RTLIL::Module
*module
, std::vector
<std::string
> args
);
61 Pass
*next_queued_pass
;
62 virtual void run_register();
63 static void init_register();
64 static void done_register();
67 struct ScriptPass
: Pass
69 bool block_active
, help_mode
;
70 RTLIL::Design
*active_design
;
71 std::string active_run_from
, active_run_to
;
73 ScriptPass(std::string name
, std::string short_help
= "** document me **") : Pass(name
, short_help
) { }
75 virtual void script() = 0;
77 bool check_label(std::string label
, std::string info
= std::string());
78 void run(std::string command
, std::string info
= std::string());
79 void run_script(RTLIL::Design
*design
, std::string run_from
= std::string(), std::string run_to
= std::string());
83 struct Frontend
: Pass
85 // for reading of here documents
86 static FILE *current_script_file
;
87 static std::string last_here_document
;
89 std::string frontend_name
;
90 Frontend(std::string name
, std::string short_help
= "** document me **");
91 void run_register() YS_OVERRIDE
;
92 ~Frontend() YS_OVERRIDE
;
93 void execute(std::vector
<std::string
> args
, RTLIL::Design
*design
) YS_OVERRIDE YS_FINAL
;
94 virtual void execute(std::istream
*&f
, std::string filename
, std::vector
<std::string
> args
, RTLIL::Design
*design
) = 0;
96 static std::vector
<std::string
> next_args
;
97 void extra_args(std::istream
*&f
, std::string
&filename
, std::vector
<std::string
> args
, size_t argidx
, bool bin_input
= false);
99 static void frontend_call(RTLIL::Design
*design
, std::istream
*f
, std::string filename
, std::string command
);
100 static void frontend_call(RTLIL::Design
*design
, std::istream
*f
, std::string filename
, std::vector
<std::string
> args
);
103 struct Backend
: Pass
105 std::string backend_name
;
106 Backend(std::string name
, std::string short_help
= "** document me **");
107 void run_register() YS_OVERRIDE
;
108 ~Backend() YS_OVERRIDE
;
109 void execute(std::vector
<std::string
> args
, RTLIL::Design
*design
) YS_OVERRIDE YS_FINAL
;
110 virtual void execute(std::ostream
*&f
, std::string filename
, std::vector
<std::string
> args
, RTLIL::Design
*design
) = 0;
112 void extra_args(std::ostream
*&f
, std::string
&filename
, std::vector
<std::string
> args
, size_t argidx
, bool bin_output
= false);
114 static void backend_call(RTLIL::Design
*design
, std::ostream
*f
, std::string filename
, std::string command
);
115 static void backend_call(RTLIL::Design
*design
, std::ostream
*f
, std::string filename
, std::vector
<std::string
> args
);
118 // implemented in passes/cmds/select.cc
119 extern void handle_extra_select_args(Pass
*pass
, std::vector
<std::string
> args
, size_t argidx
, size_t args_size
, RTLIL::Design
*design
);
120 extern RTLIL::Selection
eval_select_args(const vector
<string
> &args
, RTLIL::Design
*design
);
121 extern void eval_select_op(vector
<RTLIL::Selection
> &work
, const string
&op
, RTLIL::Design
*design
);
123 extern std::map
<std::string
, Pass
*> pass_register
;
124 extern std::map
<std::string
, Frontend
*> frontend_register
;
125 extern std::map
<std::string
, Backend
*> backend_register
;