Generate signal initial values from `initial' processes
This commit is contained in:
parent
0a8fd50c4a
commit
be3c4cf268
|
|
@ -198,9 +198,8 @@ static int draw_nbassign(vhdl_process *proc, stmt_container *container,
|
|||
// declaration
|
||||
// The second test ensures that we only try to initialise
|
||||
// internal signals not ports
|
||||
if (proc->is_initial()
|
||||
&& !proc->get_parent()->get_parent()->get_decl(signame)) {
|
||||
std::cout << "Pushing " << signame << " init up" << std::endl;
|
||||
if (proc->is_initial() && ivl_signal_port(sig) == IVL_SIP_NONE) {
|
||||
decl->set_initial(rhs);
|
||||
}
|
||||
else {
|
||||
// The type here can be null as it is never actually needed
|
||||
|
|
|
|||
|
|
@ -371,6 +371,15 @@ vhdl_decl::~vhdl_decl()
|
|||
{
|
||||
if (type_ != NULL)
|
||||
delete type_;
|
||||
if (initial_ != NULL)
|
||||
delete initial_;
|
||||
}
|
||||
|
||||
void vhdl_decl::set_initial(vhdl_expr *initial)
|
||||
{
|
||||
if (initial_ != NULL)
|
||||
delete initial_;
|
||||
initial_ = initial;
|
||||
}
|
||||
|
||||
void vhdl_port_decl::emit(std::ofstream &of, int level) const
|
||||
|
|
@ -396,6 +405,12 @@ void vhdl_var_decl::emit(std::ofstream &of, int level) const
|
|||
{
|
||||
of << "variable " << name_ << " : ";
|
||||
type_->emit(of, level);
|
||||
|
||||
if (initial_) {
|
||||
of << " := ";
|
||||
initial_->emit(of, level);
|
||||
}
|
||||
|
||||
of << ";";
|
||||
emit_comment(of, level, true);
|
||||
}
|
||||
|
|
@ -404,6 +419,12 @@ void vhdl_signal_decl::emit(std::ofstream &of, int level) const
|
|||
{
|
||||
of << "signal " << name_ << " : ";
|
||||
type_->emit(of, level);
|
||||
|
||||
if (initial_) {
|
||||
of << " := ";
|
||||
initial_->emit(of, level);
|
||||
}
|
||||
|
||||
of << ";";
|
||||
emit_comment(of, level, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -314,15 +314,18 @@ private:
|
|||
*/
|
||||
class vhdl_decl : public vhdl_element {
|
||||
public:
|
||||
vhdl_decl(const char *name, vhdl_type *type=NULL)
|
||||
: name_(name), type_(type) {}
|
||||
vhdl_decl(const char *name, vhdl_type *type = NULL,
|
||||
vhdl_expr *initial = NULL)
|
||||
: name_(name), type_(type), initial_(initial) {}
|
||||
virtual ~vhdl_decl();
|
||||
|
||||
const std::string &get_name() const { return name_; }
|
||||
const vhdl_type *get_type() const { return type_; }
|
||||
void set_initial(vhdl_expr *initial);
|
||||
protected:
|
||||
std::string name_;
|
||||
vhdl_type *type_;
|
||||
vhdl_expr *initial_;
|
||||
};
|
||||
|
||||
typedef std::list<vhdl_decl*> decl_list_t;
|
||||
|
|
|
|||
Loading…
Reference in New Issue