Fix recently broken write of vhdl packages to work space.
This commit is contained in:
parent
a109df04bb
commit
eeeadea3ac
|
|
@ -62,8 +62,9 @@ M = StringHeap.o LineInfo.o
|
||||||
O = main.o architec.o compiler.o entity.o \
|
O = main.o architec.o compiler.o entity.o \
|
||||||
expression.o package.o scope.o sequential.o vsignal.o vtype.o \
|
expression.o package.o scope.o sequential.o vsignal.o vtype.o \
|
||||||
architec_elaborate.o entity_elaborate.o expression_elaborate.o \
|
architec_elaborate.o entity_elaborate.o expression_elaborate.o \
|
||||||
|
expression_evaluate.o \
|
||||||
sequential_elaborate.o \
|
sequential_elaborate.o \
|
||||||
entity_stream.o vtype_stream.o \
|
entity_stream.o expression_stream.o vtype_stream.o \
|
||||||
lexor.o lexor_keyword.o parse.o \
|
lexor.o lexor_keyword.o parse.o \
|
||||||
parse_misc.o library.o vhdlreal.o vhdlint.o \
|
parse_misc.o library.o vhdlreal.o vhdlint.o \
|
||||||
architec_emit.o entity_emit.o expression_emit.o sequential_emit.o vtype_emit.o \
|
architec_emit.o entity_emit.o expression_emit.o sequential_emit.o vtype_emit.o \
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,11 @@ class Expression : public LineInfo {
|
||||||
// called and only if elaborate_lval succeeded.
|
// called and only if elaborate_lval succeeded.
|
||||||
inline const VType*peek_type(void) const { return type_; }
|
inline const VType*peek_type(void) const { return type_; }
|
||||||
|
|
||||||
|
// This virtual method writes a VHDL-accurate representation
|
||||||
|
// of this expression to the designated stream. This is used
|
||||||
|
// for writing parsed types to library files.
|
||||||
|
virtual void write_to_stream(std::ostream&fd) =0;
|
||||||
|
|
||||||
// The emit virtual method is called by architecture emit to
|
// The emit virtual method is called by architecture emit to
|
||||||
// output the generated code for the expression. The derived
|
// output the generated code for the expression. The derived
|
||||||
// class fills in the details of what exactly happened.
|
// class fills in the details of what exactly happened.
|
||||||
|
|
@ -123,6 +128,9 @@ class ExpUnary : public Expression {
|
||||||
virtual ~ExpUnary() =0;
|
virtual ~ExpUnary() =0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
inline void write_to_stream_operand1(std::ostream&fd)
|
||||||
|
{ operand1_->write_to_stream(fd); }
|
||||||
|
|
||||||
int emit_operand1(ostream&out, Entity*ent, Architecture*arc);
|
int emit_operand1(ostream&out, Entity*ent, Architecture*arc);
|
||||||
void dump_operand1(ostream&out, int indent = 0) const;
|
void dump_operand1(ostream&out, int indent = 0) const;
|
||||||
|
|
||||||
|
|
@ -217,6 +225,7 @@ class ExpAggregate : public Expression {
|
||||||
~ExpAggregate();
|
~ExpAggregate();
|
||||||
|
|
||||||
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
||||||
|
void write_to_stream(std::ostream&fd);
|
||||||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||||
void dump(ostream&out, int indent = 0) const;
|
void dump(ostream&out, int indent = 0) const;
|
||||||
|
|
||||||
|
|
@ -243,6 +252,7 @@ class ExpArithmetic : public ExpBinary {
|
||||||
~ExpArithmetic();
|
~ExpArithmetic();
|
||||||
|
|
||||||
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
||||||
|
void write_to_stream(std::ostream&fd);
|
||||||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||||
virtual bool evaluate(ScopeBase*scope, int64_t&val) const;
|
virtual bool evaluate(ScopeBase*scope, int64_t&val) const;
|
||||||
void dump(ostream&out, int indent = 0) const;
|
void dump(ostream&out, int indent = 0) const;
|
||||||
|
|
@ -265,6 +275,7 @@ class ExpAttribute : public Expression {
|
||||||
|
|
||||||
const VType*probe_type(Entity*ent, Architecture*arc) const;
|
const VType*probe_type(Entity*ent, Architecture*arc) const;
|
||||||
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
||||||
|
void write_to_stream(std::ostream&fd);
|
||||||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||||
// Some attributes can be evaluated at compile time
|
// Some attributes can be evaluated at compile time
|
||||||
bool evaluate(ScopeBase*scope, int64_t&val) const;
|
bool evaluate(ScopeBase*scope, int64_t&val) const;
|
||||||
|
|
@ -283,6 +294,7 @@ class ExpBitstring : public Expression {
|
||||||
~ExpBitstring();
|
~ExpBitstring();
|
||||||
|
|
||||||
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
||||||
|
void write_to_stream(std::ostream&fd);
|
||||||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||||
void dump(ostream&out, int indent = 0) const;
|
void dump(ostream&out, int indent = 0) const;
|
||||||
|
|
||||||
|
|
@ -298,6 +310,7 @@ class ExpCharacter : public Expression {
|
||||||
~ExpCharacter();
|
~ExpCharacter();
|
||||||
|
|
||||||
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
||||||
|
void write_to_stream(std::ostream&fd);
|
||||||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||||
bool is_primary(void) const;
|
bool is_primary(void) const;
|
||||||
void dump(ostream&out, int indent = 0) const;
|
void dump(ostream&out, int indent = 0) const;
|
||||||
|
|
@ -326,6 +339,7 @@ class ExpConditional : public Expression {
|
||||||
|
|
||||||
const VType*probe_type(Entity*ent, Architecture*arc) const;
|
const VType*probe_type(Entity*ent, Architecture*arc) const;
|
||||||
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
||||||
|
void write_to_stream(std::ostream&fd);
|
||||||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||||
void dump(ostream&out, int indent = 0) const;
|
void dump(ostream&out, int indent = 0) const;
|
||||||
|
|
||||||
|
|
@ -350,6 +364,7 @@ class ExpEdge : public ExpUnary {
|
||||||
|
|
||||||
inline fun_t edge_fun() const { return fun_; }
|
inline fun_t edge_fun() const { return fun_; }
|
||||||
|
|
||||||
|
void write_to_stream(std::ostream&fd);
|
||||||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||||
void dump(ostream&out, int indent = 0) const;
|
void dump(ostream&out, int indent = 0) const;
|
||||||
|
|
||||||
|
|
@ -365,6 +380,7 @@ class ExpFunc : public Expression {
|
||||||
|
|
||||||
public: // Base methods
|
public: // Base methods
|
||||||
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
||||||
|
void write_to_stream(std::ostream&fd);
|
||||||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||||
void dump(ostream&out, int indent = 0) const;
|
void dump(ostream&out, int indent = 0) const;
|
||||||
|
|
||||||
|
|
@ -381,6 +397,7 @@ class ExpInteger : public Expression {
|
||||||
|
|
||||||
const VType*probe_type(Entity*ent, Architecture*arc) const;
|
const VType*probe_type(Entity*ent, Architecture*arc) const;
|
||||||
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
||||||
|
void write_to_stream(std::ostream&fd);
|
||||||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||||
bool is_primary(void) const;
|
bool is_primary(void) const;
|
||||||
bool evaluate(ScopeBase*scope, int64_t&val) const;
|
bool evaluate(ScopeBase*scope, int64_t&val) const;
|
||||||
|
|
@ -402,6 +419,7 @@ class ExpLogical : public ExpBinary {
|
||||||
inline fun_t logic_fun() const { return fun_; }
|
inline fun_t logic_fun() const { return fun_; }
|
||||||
|
|
||||||
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
||||||
|
void write_to_stream(std::ostream&fd);
|
||||||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||||
void dump(ostream&out, int indent = 0) const;
|
void dump(ostream&out, int indent = 0) const;
|
||||||
|
|
||||||
|
|
@ -427,6 +445,7 @@ class ExpName : public Expression {
|
||||||
int elaborate_rval(Entity*ent, Architecture*arc, const InterfacePort*);
|
int elaborate_rval(Entity*ent, Architecture*arc, const InterfacePort*);
|
||||||
const VType* probe_type(Entity*ent, Architecture*arc) const;
|
const VType* probe_type(Entity*ent, Architecture*arc) const;
|
||||||
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
||||||
|
void write_to_stream(std::ostream&fd);
|
||||||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||||
bool is_primary(void) const;
|
bool is_primary(void) const;
|
||||||
bool evaluate(ScopeBase*scope, int64_t&val) const;
|
bool evaluate(ScopeBase*scope, int64_t&val) const;
|
||||||
|
|
@ -465,6 +484,7 @@ class ExpRelation : public ExpBinary {
|
||||||
|
|
||||||
const VType* probe_type(Entity*ent, Architecture*arc) const;
|
const VType* probe_type(Entity*ent, Architecture*arc) const;
|
||||||
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
||||||
|
void write_to_stream(std::ostream&fd);
|
||||||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||||
void dump(ostream&out, int indent = 0) const;
|
void dump(ostream&out, int indent = 0) const;
|
||||||
|
|
||||||
|
|
@ -479,6 +499,7 @@ class ExpString : public Expression {
|
||||||
~ExpString();
|
~ExpString();
|
||||||
|
|
||||||
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
||||||
|
void write_to_stream(std::ostream&fd);
|
||||||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||||
bool is_primary(void) const;
|
bool is_primary(void) const;
|
||||||
void dump(ostream&out, int indent = 0) const;
|
void dump(ostream&out, int indent = 0) const;
|
||||||
|
|
@ -496,6 +517,7 @@ class ExpUAbs : public ExpUnary {
|
||||||
ExpUAbs(Expression*op1);
|
ExpUAbs(Expression*op1);
|
||||||
~ExpUAbs();
|
~ExpUAbs();
|
||||||
|
|
||||||
|
void write_to_stream(std::ostream&fd);
|
||||||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||||
void dump(ostream&out, int indent = 0) const;
|
void dump(ostream&out, int indent = 0) const;
|
||||||
};
|
};
|
||||||
|
|
@ -507,6 +529,7 @@ class ExpUNot : public ExpUnary {
|
||||||
~ExpUNot();
|
~ExpUNot();
|
||||||
|
|
||||||
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
||||||
|
void write_to_stream(std::ostream&fd);
|
||||||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||||
void dump(ostream&out, int indent = 0) const;
|
void dump(ostream&out, int indent = 0) const;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2011 Stephen Williams (steve@icarus.com)
|
||||||
|
*
|
||||||
|
* This source code is free software; you can redistribute it
|
||||||
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
* General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 2 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
# include "expression.h"
|
||||||
|
# include <iostream>
|
||||||
|
# include <ivl_assert.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void ExpAggregate::write_to_stream(ostream&)
|
||||||
|
{
|
||||||
|
ivl_assert(*this, !"Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExpArithmetic::write_to_stream(ostream&)
|
||||||
|
{
|
||||||
|
ivl_assert(*this, !"Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExpAttribute::write_to_stream(ostream&)
|
||||||
|
{
|
||||||
|
ivl_assert(*this, !"Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExpBitstring::write_to_stream(ostream&)
|
||||||
|
{
|
||||||
|
ivl_assert(*this, !"Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExpCharacter::write_to_stream(ostream&)
|
||||||
|
{
|
||||||
|
ivl_assert(*this, !"Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExpConditional::write_to_stream(ostream&)
|
||||||
|
{
|
||||||
|
ivl_assert(*this, !"Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExpEdge::write_to_stream(ostream&)
|
||||||
|
{
|
||||||
|
ivl_assert(*this, !"Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExpFunc::write_to_stream(ostream&)
|
||||||
|
{
|
||||||
|
ivl_assert(*this, !"Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExpInteger::write_to_stream(ostream&fd)
|
||||||
|
{
|
||||||
|
fd << value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExpLogical::write_to_stream(ostream&)
|
||||||
|
{
|
||||||
|
ivl_assert(*this, !"Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExpName::write_to_stream(ostream&fd)
|
||||||
|
{
|
||||||
|
fd << name_;
|
||||||
|
if (index_) {
|
||||||
|
fd << "(";
|
||||||
|
index_->write_to_stream(fd);
|
||||||
|
if (lsb_) {
|
||||||
|
fd << " downto ";
|
||||||
|
lsb_->write_to_stream(fd);
|
||||||
|
}
|
||||||
|
fd << ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExpRelation::write_to_stream(ostream&)
|
||||||
|
{
|
||||||
|
ivl_assert(*this, !"Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExpString::write_to_stream(ostream&fd)
|
||||||
|
{
|
||||||
|
ivl_assert(*this, !"Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExpUAbs::write_to_stream(ostream&fd)
|
||||||
|
{
|
||||||
|
fd << "abs ";
|
||||||
|
write_to_stream_operand1(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExpUNot::write_to_stream(ostream&fd)
|
||||||
|
{
|
||||||
|
fd << "not ";
|
||||||
|
write_to_stream_operand1(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# include "vtype.h"
|
# include "vtype.h"
|
||||||
|
# include "expression.h"
|
||||||
# include <typeinfo>
|
# include <typeinfo>
|
||||||
# include <cassert>
|
# include <cassert>
|
||||||
|
|
||||||
|
|
@ -35,8 +36,11 @@ void VTypeArray::write_to_stream(ostream&fd) const
|
||||||
fd << "std_logic_vector";
|
fd << "std_logic_vector";
|
||||||
if (! ranges_.empty()) {
|
if (! ranges_.empty()) {
|
||||||
assert(ranges_.size() < 2);
|
assert(ranges_.size() < 2);
|
||||||
fd << " (" << ranges_[0].msb()
|
fd << " (";
|
||||||
<< " downto " << ranges_[0].lsb() << ") ";
|
ranges_[0].msb()->write_to_stream(fd);
|
||||||
|
fd << " downto ";
|
||||||
|
ranges_[0].lsb()->write_to_stream(fd);
|
||||||
|
fd << ") ";
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -44,8 +48,11 @@ void VTypeArray::write_to_stream(ostream&fd) const
|
||||||
fd << "array ";
|
fd << "array ";
|
||||||
if (! ranges_.empty()) {
|
if (! ranges_.empty()) {
|
||||||
assert(ranges_.size() < 2);
|
assert(ranges_.size() < 2);
|
||||||
fd << "(" << ranges_[0].msb()
|
fd << "(";
|
||||||
<< " downto " << ranges_[0].lsb() << ") ";
|
ranges_[0].msb()->write_to_stream(fd);
|
||||||
|
fd << " downto ";
|
||||||
|
ranges_[0].lsb()->write_to_stream(fd);
|
||||||
|
fd << ") ";
|
||||||
}
|
}
|
||||||
|
|
||||||
fd << "of ";
|
fd << "of ";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue