diff --git a/tgt-vhdl/vhdl_element.cc b/tgt-vhdl/vhdl_element.cc index 5391736f7..cdbd1fcff 100644 --- a/tgt-vhdl/vhdl_element.cc +++ b/tgt-vhdl/vhdl_element.cc @@ -38,14 +38,14 @@ int indent(int level) /* * Emit a newline and indent to the correct level. */ -void newline(std::ofstream &of, int level) +void newline(std::ostream &of, int level) { of << std::endl; while (level--) of << ' '; } -void blank_line(std::ofstream &of, int level) +void blank_line(std::ostream &of, int level) { of << std::endl; newline(of, level); @@ -61,7 +61,7 @@ void vhdl_element::set_comment(std::string comment) * a line before the element (end_of_line is false) or at the * end of the line containing the element (end_of_line is true). */ -void vhdl_element::emit_comment(std::ofstream &of, int level, +void vhdl_element::emit_comment(std::ostream &of, int level, bool end_of_line) const { if (comment_.size() > 0) { diff --git a/tgt-vhdl/vhdl_element.hh b/tgt-vhdl/vhdl_element.hh index f73ea0949..4bd6b3c05 100644 --- a/tgt-vhdl/vhdl_element.hh +++ b/tgt-vhdl/vhdl_element.hh @@ -34,11 +34,11 @@ class vhdl_element { public: virtual ~vhdl_element() {} - virtual void emit(std::ofstream &of, int level=0) const = 0; + virtual void emit(std::ostream &of, int level=0) const = 0; void set_comment(std::string comment); protected: - void emit_comment(std::ofstream &of, int level, + void emit_comment(std::ostream &of, int level, bool end_of_line=false) const; private: std::string comment_; @@ -47,8 +47,8 @@ private: typedef std::list element_list_t; int indent(int level); -void newline(std::ofstream &of, int level); -void blank_line(std::ofstream &of, int level); +void newline(std::ostream &of, int level); +void blank_line(std::ostream &of, int level); #endif diff --git a/tgt-vhdl/vhdl_helper.hh b/tgt-vhdl/vhdl_helper.hh index c1f9499ab..a3f6f0704 100644 --- a/tgt-vhdl/vhdl_helper.hh +++ b/tgt-vhdl/vhdl_helper.hh @@ -26,7 +26,7 @@ #include template -void emit_children(std::ofstream &of, +void emit_children(std::ostream &of, const std::list &children, int level, const char *delim="") { diff --git a/tgt-vhdl/vhdl_syntax.cc b/tgt-vhdl/vhdl_syntax.cc index 87629a46f..2d4d1e984 100644 --- a/tgt-vhdl/vhdl_syntax.cc +++ b/tgt-vhdl/vhdl_syntax.cc @@ -80,7 +80,7 @@ void vhdl_entity::add_port(vhdl_port_decl *decl) ports_.add_decl(decl); } -void vhdl_entity::emit(std::ofstream &of, int level) const +void vhdl_entity::emit(std::ostream &of, int level) const { // Pretty much every design will use std_logic so we // might as well include it by default @@ -122,7 +122,7 @@ void vhdl_arch::add_stmt(vhdl_conc_stmt *stmt) stmts_.push_back(stmt); } -void vhdl_arch::emit(std::ofstream &of, int level) const +void vhdl_arch::emit(std::ostream &of, int level) const { emit_comment(of, level); of << "architecture " << name_ << " of " << entity_; @@ -139,7 +139,7 @@ void vhdl_process::add_sensitivity(const char *name) sens_.push_back(name); } -void vhdl_process::emit(std::ofstream &of, int level) const +void vhdl_process::emit(std::ostream &of, int level) const { // If there are no statements in the body, this process // can't possibly do anything, so don't bother to emit it @@ -184,7 +184,7 @@ void stmt_container::add_stmt(vhdl_seq_stmt *stmt) stmts_.push_back(stmt); } -void stmt_container::emit(std::ofstream &of, int level) const +void stmt_container::emit(std::ostream &of, int level) const { emit_children(of, stmts_, level); } @@ -210,7 +210,7 @@ void vhdl_comp_inst::map_port(const char *name, vhdl_expr *expr) mapping_.push_back(pmap); } -void vhdl_comp_inst::emit(std::ofstream &of, int level) const +void vhdl_comp_inst::emit(std::ostream &of, int level) const { emit_comment(of, level); of << inst_name_ << ": " << comp_name_; @@ -258,7 +258,7 @@ vhdl_component_decl *vhdl_component_decl::component_decl_for(vhdl_entity *ent) return decl; } -void vhdl_component_decl::emit(std::ofstream &of, int level) const +void vhdl_component_decl::emit(std::ostream &of, int level) const { emit_comment(of, level); of << "component " << name_ << " is"; @@ -280,7 +280,7 @@ vhdl_wait_stmt::~vhdl_wait_stmt() delete expr_; } -void vhdl_wait_stmt::emit(std::ofstream &of, int level) const +void vhdl_wait_stmt::emit(std::ostream &of, int level) const { of << "wait"; @@ -318,7 +318,7 @@ void vhdl_decl::set_initial(vhdl_expr *initial) initial_ = initial; } -void vhdl_port_decl::emit(std::ofstream &of, int level) const +void vhdl_port_decl::emit(std::ostream &of, int level) const { of << name_ << " : "; @@ -337,7 +337,7 @@ void vhdl_port_decl::emit(std::ofstream &of, int level) const type_->emit(of, level); } -void vhdl_var_decl::emit(std::ofstream &of, int level) const +void vhdl_var_decl::emit(std::ostream &of, int level) const { of << "variable " << name_ << " : "; type_->emit(of, level); @@ -351,7 +351,7 @@ void vhdl_var_decl::emit(std::ofstream &of, int level) const emit_comment(of, level, true); } -void vhdl_signal_decl::emit(std::ofstream &of, int level) const +void vhdl_signal_decl::emit(std::ostream &of, int level) const { of << "signal " << name_ << " : "; type_->emit(of, level); @@ -435,7 +435,7 @@ vhdl_expr_list::~vhdl_expr_list() delete_children(exprs_); } -void vhdl_expr_list::emit(std::ofstream &of, int level) const +void vhdl_expr_list::emit(std::ostream &of, int level) const { of << "("; @@ -450,7 +450,7 @@ void vhdl_expr_list::emit(std::ofstream &of, int level) const of << ")"; } -void vhdl_pcall_stmt::emit(std::ofstream &of, int level) const +void vhdl_pcall_stmt::emit(std::ostream &of, int level) const { of << name_; if (!exprs_.empty()) @@ -464,7 +464,7 @@ vhdl_var_ref::~vhdl_var_ref() delete slice_; } -void vhdl_var_ref::emit(std::ofstream &of, int level) const +void vhdl_var_ref::emit(std::ostream &of, int level) const { of << name_; if (slice_) { @@ -474,7 +474,7 @@ void vhdl_var_ref::emit(std::ofstream &of, int level) const } } -void vhdl_const_string::emit(std::ofstream &of, int level) const +void vhdl_const_string::emit(std::ostream &of, int level) const { // In some instances a string literal can be ambiguous between // a String type and some other types (e.g. std_logic_vector) @@ -483,12 +483,12 @@ void vhdl_const_string::emit(std::ofstream &of, int level) const of << "String'(\"" << value_ << "\")"; } -void vhdl_null_stmt::emit(std::ofstream &of, int level) const +void vhdl_null_stmt::emit(std::ostream &of, int level) const { of << "null;"; } -void vhdl_fcall::emit(std::ofstream &of, int level) const +void vhdl_fcall::emit(std::ostream &of, int level) const { of << name_; exprs_.emit(of, level); @@ -502,7 +502,7 @@ vhdl_abstract_assign_stmt::~vhdl_abstract_assign_stmt() delete after_; } -void vhdl_nbassign_stmt::emit(std::ofstream &of, int level) const +void vhdl_nbassign_stmt::emit(std::ostream &of, int level) const { lhs_->emit(of, level); of << " <= "; @@ -516,7 +516,7 @@ void vhdl_nbassign_stmt::emit(std::ofstream &of, int level) const of << ";"; } -void vhdl_assign_stmt::emit(std::ofstream &of, int level) const +void vhdl_assign_stmt::emit(std::ostream &of, int level) const { lhs_->emit(of, level); of << " := "; @@ -569,7 +569,7 @@ vhdl_expr *vhdl_const_bits::cast(const vhdl_type *to) return vhdl_expr::cast(to); } -void vhdl_const_bits::emit(std::ofstream &of, int level) const +void vhdl_const_bits::emit(std::ostream &of, int level) const { if (qualified_) of << (signed_ ? "signed" : "unsigned") << "'(\""; @@ -584,17 +584,17 @@ void vhdl_const_bits::emit(std::ofstream &of, int level) const of << (qualified_ ? "\")" : "\""); } -void vhdl_const_bit::emit(std::ofstream &of, int level) const +void vhdl_const_bit::emit(std::ostream &of, int level) const { of << "'" << vl_to_vhdl_bit(bit_) << "'"; } -void vhdl_const_int::emit(std::ofstream &of, int level) const +void vhdl_const_int::emit(std::ostream &of, int level) const { of << value_; } -void vhdl_const_time::emit(std::ofstream &of, int level) const +void vhdl_const_time::emit(std::ostream &of, int level) const { of << value_; switch (units_) { @@ -609,7 +609,7 @@ vhdl_cassign_stmt::~vhdl_cassign_stmt() delete rhs_; } -void vhdl_cassign_stmt::emit(std::ofstream &of, int level) const +void vhdl_cassign_stmt::emit(std::ostream &of, int level) const { lhs_->emit(of, level); of << " <= "; @@ -617,7 +617,7 @@ void vhdl_cassign_stmt::emit(std::ofstream &of, int level) const of << ";"; } -void vhdl_assert_stmt::emit(std::ofstream &of, int level) const +void vhdl_assert_stmt::emit(std::ostream &of, int level) const { of << "assert false"; // TODO: Allow arbitrary expression of << " report \"" << reason_ << "\" severity failure;"; @@ -635,7 +635,7 @@ vhdl_if_stmt::~vhdl_if_stmt() delete test_; } -void vhdl_if_stmt::emit(std::ofstream &of, int level) const +void vhdl_if_stmt::emit(std::ostream &of, int level) const { of << "if "; test_->emit(of, level); @@ -653,7 +653,7 @@ vhdl_unaryop_expr::~vhdl_unaryop_expr() delete operand_; } -void vhdl_unaryop_expr::emit(std::ofstream &of, int level) const +void vhdl_unaryop_expr::emit(std::ostream &of, int level) const { switch (op_) { case VHDL_UNARYOP_NOT: @@ -681,7 +681,7 @@ void vhdl_binop_expr::add_expr(vhdl_expr *e) operands_.push_back(e); } -void vhdl_binop_expr::emit(std::ofstream &of, int level) const +void vhdl_binop_expr::emit(std::ostream &of, int level) const { // Expressions are fully parenthesized to remove any // ambiguity in the output @@ -711,7 +711,7 @@ vhdl_case_branch::~vhdl_case_branch() delete when_; } -void vhdl_case_branch::emit(std::ofstream &of, int level) const +void vhdl_case_branch::emit(std::ostream &of, int level) const { of << "when "; when_->emit(of, level); @@ -724,7 +724,7 @@ vhdl_case_stmt::~vhdl_case_stmt() delete test_; } -void vhdl_case_stmt::emit(std::ofstream &of, int level) const +void vhdl_case_stmt::emit(std::ostream &of, int level) const { of << "case "; test_->emit(of, level); @@ -743,7 +743,7 @@ vhdl_while_stmt::~vhdl_while_stmt() delete test_; } -void vhdl_while_stmt::emit(std::ofstream &of, int level) const +void vhdl_while_stmt::emit(std::ostream &of, int level) const { of << "while "; test_->emit(of, level); @@ -762,7 +762,7 @@ vhdl_function::vhdl_function(const char *name, vhdl_type *ret_type) variables_.set_parent(&scope_); } -void vhdl_function::emit(std::ofstream &of, int level) const +void vhdl_function::emit(std::ostream &of, int level) const { of << "function " << name_ << " ("; emit_children(of, scope_.get_decls(), level, ";"); @@ -777,7 +777,7 @@ void vhdl_function::emit(std::ofstream &of, int level) const of << "end function;"; } -void vhdl_param_decl::emit(std::ofstream &of, int level) const +void vhdl_param_decl::emit(std::ostream &of, int level) const { of << name_ << " : "; type_->emit(of, level); diff --git a/tgt-vhdl/vhdl_syntax.hh b/tgt-vhdl/vhdl_syntax.hh index 16cf8109a..2487840ed 100644 --- a/tgt-vhdl/vhdl_syntax.hh +++ b/tgt-vhdl/vhdl_syntax.hh @@ -54,7 +54,7 @@ public: : vhdl_expr(type), name_(name), slice_(slice) {} ~vhdl_var_ref(); - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; const std::string &get_name() const { return name_; } void set_slice(vhdl_expr *s) { slice_ = s; } private: @@ -93,7 +93,7 @@ public: ~vhdl_binop_expr(); void add_expr(vhdl_expr *e); - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; private: std::list operands_; vhdl_binop_t op_; @@ -111,7 +111,7 @@ public: : vhdl_expr(type), op_(op), operand_(operand) {} ~vhdl_unaryop_expr(); - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; private: vhdl_unaryop_t op_; vhdl_expr *operand_; @@ -123,7 +123,7 @@ public: vhdl_const_string(const char *value) : vhdl_expr(vhdl_type::string(), true), value_(value) {} - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; private: std::string value_; }; @@ -131,7 +131,7 @@ private: class vhdl_const_bits : public vhdl_expr { public: vhdl_const_bits(const char *value, int width, bool issigned); - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; const std::string &get_value() const { return value_; } vhdl_expr *cast(const vhdl_type *to); private: @@ -143,7 +143,7 @@ class vhdl_const_bit : public vhdl_expr { public: vhdl_const_bit(char bit) : vhdl_expr(vhdl_type::std_logic(), true), bit_(bit) {} - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; private: char bit_; }; @@ -156,7 +156,7 @@ class vhdl_const_time : public vhdl_expr { public: vhdl_const_time(int64_t value, time_unit_t units) : vhdl_expr(vhdl_type::time(), true), value_(value), units_(units) {} - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; private: int64_t value_; time_unit_t units_; @@ -166,7 +166,7 @@ class vhdl_const_int : public vhdl_expr { public: vhdl_const_int(int64_t value) : vhdl_expr(vhdl_type::integer(), true), value_(value) {} - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; private: int64_t value_; }; @@ -175,7 +175,7 @@ class vhdl_expr_list : public vhdl_element { public: ~vhdl_expr_list(); - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; bool empty() const { return exprs_.empty(); } void add_expr(vhdl_expr *e); private: @@ -193,7 +193,7 @@ public: ~vhdl_fcall() {} void add_expr(vhdl_expr *e) { exprs_.add_expr(e); } - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; private: std::string name_; vhdl_expr_list exprs_; @@ -219,7 +219,7 @@ public: : lhs_(lhs), rhs_(rhs) {} ~vhdl_cassign_stmt(); - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; private: vhdl_var_ref *lhs_; vhdl_expr *rhs_; @@ -243,7 +243,7 @@ public: ~stmt_container(); void add_stmt(vhdl_seq_stmt *stmt); - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; bool empty() const { return stmts_.empty(); } private: std::list stmts_; @@ -275,7 +275,7 @@ public: vhdl_nbassign_stmt(vhdl_var_ref *lhs, vhdl_expr *rhs) : vhdl_abstract_assign_stmt(lhs, rhs) {} - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; }; @@ -284,7 +284,7 @@ public: vhdl_assign_stmt(vhdl_var_ref *lhs, vhdl_expr *rhs) : vhdl_abstract_assign_stmt(lhs, rhs) {} - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; }; @@ -304,7 +304,7 @@ public: : type_(type), expr_(expr) {} ~vhdl_wait_stmt(); - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; private: vhdl_wait_type_t type_; vhdl_expr *expr_; @@ -313,7 +313,7 @@ private: class vhdl_null_stmt : public vhdl_seq_stmt { public: - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; }; @@ -322,7 +322,7 @@ public: vhdl_assert_stmt(const char *reason) : reason_(reason) {} - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; private: std::string reason_; }; @@ -335,7 +335,7 @@ public: stmt_container *get_then_container() { return &then_part_; } stmt_container *get_else_container() { return &else_part_; } - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; private: vhdl_expr *test_; stmt_container then_part_, else_part_; @@ -352,7 +352,7 @@ public: ~vhdl_case_branch(); stmt_container *get_container() { return &stmts_; } - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; private: vhdl_expr *when_; stmt_container stmts_; @@ -366,7 +366,7 @@ public: ~vhdl_case_stmt(); void add_branch(vhdl_case_branch *b) { branches_.push_back(b); } - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; private: vhdl_expr *test_; case_branch_list_t branches_; @@ -379,7 +379,7 @@ public: ~vhdl_while_stmt(); stmt_container *get_container() { return &stmts_; } - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; private: vhdl_expr *test_; stmt_container stmts_; @@ -394,7 +394,7 @@ class vhdl_pcall_stmt : public vhdl_seq_stmt { public: vhdl_pcall_stmt(const char *name) : name_(name) {} - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; void add_expr(vhdl_expr *e) { exprs_.add_expr(e); } private: std::string name_; @@ -438,7 +438,7 @@ class vhdl_component_decl : public vhdl_decl { public: static vhdl_component_decl *component_decl_for(vhdl_entity *ent); - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; private: vhdl_component_decl(const char *name); @@ -454,7 +454,7 @@ class vhdl_var_decl : public vhdl_decl { public: vhdl_var_decl(const char *name, vhdl_type *type) : vhdl_decl(name, type) {} - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; }; @@ -465,7 +465,7 @@ class vhdl_signal_decl : public vhdl_decl { public: vhdl_signal_decl(const char *name, vhdl_type *type) : vhdl_decl(name, type) {} - virtual void emit(std::ofstream &of, int level) const; + virtual void emit(std::ostream &of, int level) const; }; @@ -476,7 +476,7 @@ class vhdl_param_decl : public vhdl_decl { public: vhdl_param_decl(const char *name, vhdl_type *type) : vhdl_decl(name, type) {} - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; }; enum vhdl_port_mode_t { @@ -496,7 +496,7 @@ public: vhdl_port_mode_t mode) : vhdl_decl(name, type), mode_(mode) {} - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; private: vhdl_port_mode_t mode_; }; @@ -520,7 +520,7 @@ public: vhdl_comp_inst(const char *inst_name, const char *comp_name); ~vhdl_comp_inst(); - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; void map_port(const char *name, vhdl_expr *expr); private: std::string comp_name_, inst_name_; @@ -580,7 +580,7 @@ class vhdl_function : public vhdl_decl, public vhdl_procedural { public: vhdl_function(const char *name, vhdl_type *ret_type); - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; vhdl_scope *get_scope() { return &variables_; } void add_param(vhdl_param_decl *p) { scope_.add_decl(p); } private: @@ -592,7 +592,7 @@ class vhdl_process : public vhdl_conc_stmt, public vhdl_procedural { public: vhdl_process(const char *name = "") : name_(name) {} - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; void add_sensitivity(const char *name); private: std::string name_; @@ -609,7 +609,7 @@ public: : name_(name), entity_(entity) {} virtual ~vhdl_arch(); - void emit(std::ofstream &of, int level=0) const; + void emit(std::ostream &of, int level=0) const; void add_stmt(vhdl_process *proc); void add_stmt(vhdl_conc_stmt *stmt); vhdl_scope *get_scope() { return &scope_; } @@ -631,7 +631,7 @@ public: vhdl_arch *arch); virtual ~vhdl_entity(); - void emit(std::ofstream &of, int level=0) const; + void emit(std::ostream &of, int level=0) const; void add_port(vhdl_port_decl *decl); vhdl_arch *get_arch() const { return arch_; } const std::string &get_name() const { return name_; } diff --git a/tgt-vhdl/vhdl_type.cc b/tgt-vhdl/vhdl_type.cc index 4176cfce4..77b3a7b0f 100644 --- a/tgt-vhdl/vhdl_type.cc +++ b/tgt-vhdl/vhdl_type.cc @@ -112,7 +112,7 @@ std::string vhdl_type::get_decl_string() const } } -void vhdl_type::emit(std::ofstream &of, int level) const +void vhdl_type::emit(std::ostream &of, int level) const { of << get_decl_string(); } diff --git a/tgt-vhdl/vhdl_type.hh b/tgt-vhdl/vhdl_type.hh index e4e41d3e2..b0e0c6f3b 100644 --- a/tgt-vhdl/vhdl_type.hh +++ b/tgt-vhdl/vhdl_type.hh @@ -47,7 +47,7 @@ public: : name_(name), msb_(msb), lsb_(lsb) {} virtual ~vhdl_type() {} - void emit(std::ofstream &of, int level) const; + void emit(std::ostream &of, int level) const; vhdl_type_name_t get_name() const { return name_; } std::string get_string() const; std::string get_decl_string() const;