Give the branch access expression type some meat.

In the ivl_target API, the IVL_EX_BACCESS expression type gets some meat,
specifically references to the branch it accesses and the the nature to
be accessed on that branch.
This commit is contained in:
Stephen Williams 2008-11-11 20:41:14 -08:00
parent 35a8d42741
commit da85c4fe00
7 changed files with 36 additions and 2 deletions

View File

@ -729,12 +729,16 @@ extern unsigned ivl_expr_lineno(ivl_expr_t net);
/* IVL_EX_NUMBER */
extern const char* ivl_expr_bits(ivl_expr_t net);
/* IVL_EX_BACCESS */
extern ivl_branch_t ivl_expr_branch(ivl_expr_t net);
/* IVL_EX_UFUNC */
extern ivl_scope_t ivl_expr_def(ivl_expr_t net);
/* IVL_EX_REALNUM */
extern double ivl_expr_dvalue(ivl_expr_t net);
/* IVL_EX_SIGNAL, IVL_EX_SFUNC, IVL_EX_VARIABLE */
extern const char* ivl_expr_name(ivl_expr_t net);
/* IVL_EX_BACCESS */
extern ivl_nature_t ivl_expr_nature(ivl_expr_t net);
/* IVL_EX_BINARY IVL_EX_UNARY */
extern char ivl_expr_opcode(ivl_expr_t net);
/* IVL_EX_BINARY IVL_EX_UNARY, IVL_EX_MEMORY IVL_EX_TERNARY */

View File

@ -20,6 +20,7 @@
*/
# include <inttypes.h>
# include <vector>
/*
* This header has declarations related to the ivl_target.h API that
@ -47,7 +48,7 @@ class ivl_discipline_s;
struct ivl_island_s {
ivl_discipline_s*discipline;
// user accessible flags. They are initially false, always.
vector<bool> flags;
std::vector<bool> flags;
};
#endif

View File

@ -32,6 +32,7 @@
# include <set>
# include <utility>
# include "ivl_target.h"
# include "ivl_target_priv.h"
# include "pform_types.h"
# include "config.h"
# include "verinum.h"
@ -184,10 +185,15 @@ class NetBranch : public NetPins, public IslandBranch {
// If the branch is named, this returns the name.
perm_string name() const { return name_; }
ivl_branch_s* target_obj() const { return &target_obj_; }
void dump(ostream&, unsigned) const;
private:
perm_string name_;
mutable ivl_branch_s target_obj_;
// The design class uses this member to list the branches.
friend class Design;
NetBranch*next_;
@ -3007,6 +3013,9 @@ class NetEAccess : public NetExpr {
explicit NetEAccess(NetBranch*br, ivl_nature_t nat);
~NetEAccess();
ivl_nature_t get_nature() const { return nature_; }
NetBranch* get_branch() const { return branch_; }
virtual ivl_variable_type_t expr_type() const;
virtual void dump(ostream&) const;

View File

@ -261,6 +261,12 @@ extern "C" const char* ivl_expr_bits(ivl_expr_t net)
return net->u_.number_.bits_;
}
extern "C" ivl_branch_t ivl_expr_branch(ivl_expr_t net)
{
assert(net && (net->type_ == IVL_EX_BACCESS));
return net->u_.branch_.branch;
}
extern "C" ivl_scope_t ivl_expr_def(ivl_expr_t net)
{
assert(net);
@ -299,6 +305,12 @@ extern "C" const char* ivl_expr_name(ivl_expr_t net)
return 0;
}
extern "C" ivl_nature_t ivl_expr_nature(ivl_expr_t net)
{
assert(net && (net->type_ == IVL_EX_BACCESS));
return net->u_.branch_.nature;
}
extern "C" char ivl_expr_opcode(ivl_expr_t net)
{
assert(net);

View File

@ -160,6 +160,9 @@ void dll_target::expr_access_func(const NetEAccess*net)
expr_->lineno = net->get_lineno();
expr_->width_ = 1;
expr_->signed_= 1;
expr_->u_.branch_.branch = net->get_branch()->target_obj();
expr_->u_.branch_.nature = net->get_nature();
}
void dll_target::expr_binary(const NetEBinary*net)

View File

@ -780,7 +780,7 @@ void dll_target::make_const_delays_(struct ivl_net_const_s*obj,
bool dll_target::branch(const NetBranch*net)
{
struct ivl_branch_s*obj = new struct ivl_branch_s;
struct ivl_branch_s*obj = net->target_obj();
ivl_assert(*net, net->pin_count() == 2);
assert(net->pin(0).nexus()->t_cookie());

View File

@ -232,6 +232,11 @@ struct ivl_expr_s {
ivl_expr_t rig_;
} binary_;
struct {
ivl_branch_t branch;
ivl_nature_t nature;
} branch_;
struct {
unsigned rept;
unsigned parms;