Bring discipline natures all the way to the ivl_target API.
The natures of disciplines were already available, this just brings the information forward to the ivl_target.h API and exposes them via access functions.
This commit is contained in:
parent
c73199942b
commit
eb240ddb73
2
PExpr.h
2
PExpr.h
|
|
@ -595,7 +595,7 @@ class PECallFunction : public PExpr {
|
|||
bool check_call_matches_definition_(Design*des, NetScope*dscope) const;
|
||||
|
||||
NetExpr* elaborate_sfunc_(Design*des, NetScope*scope, int expr_wid) const;
|
||||
NetExpr* elaborate_access_func_(Design*des, NetScope*scope, nature_t*) const;
|
||||
NetExpr* elaborate_access_func_(Design*des, NetScope*scope, ivl_nature_t) const;
|
||||
unsigned test_width_sfunc_(Design*des, NetScope*scope,
|
||||
unsigned min, unsigned lval,
|
||||
ivl_variable_type_t&expr_type,
|
||||
|
|
|
|||
|
|
@ -19,17 +19,17 @@
|
|||
|
||||
# include "discipline.h"
|
||||
|
||||
nature_t::nature_t(perm_string name__, perm_string access__)
|
||||
ivl_nature_s::ivl_nature_s(perm_string name__, perm_string access__)
|
||||
: name_(name__), access_(access__)
|
||||
{
|
||||
}
|
||||
|
||||
nature_t::~nature_t()
|
||||
ivl_nature_s::~ivl_nature_s()
|
||||
{
|
||||
}
|
||||
|
||||
ivl_discipline_s::ivl_discipline_s(perm_string name__, ivl_dis_domain_t domain__,
|
||||
nature_t*pot, nature_t*flow__)
|
||||
ivl_nature_t pot, ivl_nature_t flow__)
|
||||
: name_(name__), domain_(domain__), potential_(pot), flow_(flow__)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
20
discipline.h
20
discipline.h
|
|
@ -33,10 +33,10 @@
|
|||
|
||||
extern std::ostream& operator << (std::ostream&, ivl_dis_domain_t);
|
||||
|
||||
class nature_t : public LineInfo {
|
||||
class ivl_nature_s : public LineInfo {
|
||||
public:
|
||||
explicit nature_t(perm_string name, perm_string access);
|
||||
~nature_t();
|
||||
explicit ivl_nature_s(perm_string name, perm_string access);
|
||||
~ivl_nature_s();
|
||||
|
||||
perm_string name() const { return name_; }
|
||||
// Identifier for the access function for this nature
|
||||
|
|
@ -50,28 +50,28 @@ class nature_t : public LineInfo {
|
|||
class ivl_discipline_s : public LineInfo {
|
||||
public:
|
||||
explicit ivl_discipline_s (perm_string name, ivl_dis_domain_t dom,
|
||||
nature_t*pot, nature_t*flow);
|
||||
ivl_nature_t pot, ivl_nature_t flow);
|
||||
~ivl_discipline_s();
|
||||
|
||||
perm_string name() const { return name_; }
|
||||
ivl_dis_domain_t domain() const { return domain_; }
|
||||
const nature_t*potential() const { return potential_; }
|
||||
const nature_t*flow() const { return flow_; }
|
||||
const ivl_nature_t potential() const { return potential_; }
|
||||
const ivl_nature_t flow() const { return flow_; }
|
||||
|
||||
private:
|
||||
perm_string name_;
|
||||
ivl_dis_domain_t domain_;
|
||||
nature_t*potential_;
|
||||
nature_t*flow_;
|
||||
ivl_nature_t potential_;
|
||||
ivl_nature_t flow_;
|
||||
|
||||
private: // not implemented
|
||||
ivl_discipline_s(const ivl_discipline_s&);
|
||||
ivl_discipline_s& operator = (const ivl_discipline_s&);
|
||||
};
|
||||
|
||||
extern map<perm_string,nature_t*> natures;
|
||||
extern map<perm_string,ivl_nature_t> natures;
|
||||
extern map<perm_string,ivl_discipline_t> disciplines;
|
||||
// Map access function name to the nature that it accesses.
|
||||
extern map<perm_string,nature_t*> access_function_nature;
|
||||
extern map<perm_string,ivl_nature_t> access_function_nature;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ bool type_is_vectorable(ivl_variable_type_t type)
|
|||
}
|
||||
}
|
||||
|
||||
static nature_t* find_access_function(const pform_name_t&path)
|
||||
static ivl_nature_t find_access_function(const pform_name_t&path)
|
||||
{
|
||||
if (path.size() != 1)
|
||||
return 0;
|
||||
|
|
@ -1228,7 +1228,7 @@ NetExpr* PECallFunction::elaborate_sfunc_(Design*des, NetScope*scope, int expr_w
|
|||
}
|
||||
|
||||
NetExpr* PECallFunction::elaborate_access_func_(Design*des, NetScope*scope,
|
||||
nature_t*nature) const
|
||||
ivl_nature_t nature) const
|
||||
{
|
||||
// An access function must have 1 or 2 arguments.
|
||||
ivl_assert(*this, parms_.size()==2 || parms_.size()==1);
|
||||
|
|
@ -1276,7 +1276,7 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope,
|
|||
// Not a user defined function. Maybe it is an access
|
||||
// function for a nature? If so then elaborate it that
|
||||
// way.
|
||||
nature_t*access_nature = find_access_function(path_);
|
||||
ivl_nature_t access_nature = find_access_function(path_);
|
||||
if (access_nature)
|
||||
return elaborate_access_func_(des, scope, access_nature);
|
||||
|
||||
|
|
|
|||
2
ivl.def
2
ivl.def
|
|
@ -16,7 +16,9 @@ ivl_const_type
|
|||
ivl_const_width
|
||||
|
||||
ivl_discipline_domain
|
||||
ivl_discipline_flow
|
||||
ivl_discipline_name
|
||||
ivl_discipline_potential
|
||||
|
||||
ivl_event_any
|
||||
ivl_event_basename
|
||||
|
|
|
|||
|
|
@ -572,6 +572,8 @@ extern double ivl_const_real(ivl_net_const_t net);
|
|||
*/
|
||||
extern const char*ivl_discipline_name(ivl_discipline_t net);
|
||||
extern ivl_dis_domain_t ivl_discipline_domain(ivl_discipline_t net);
|
||||
extern ivl_nature_t ivl_discipline_potential(ivl_discipline_t net);
|
||||
extern ivl_nature_t ivl_discipline_flow(ivl_discipline_t net);
|
||||
|
||||
/* EVENTS
|
||||
*
|
||||
|
|
|
|||
2
main.cc
2
main.cc
|
|
@ -700,7 +700,7 @@ int main(int argc, char*argv[])
|
|||
if (pf_path) {
|
||||
ofstream out (pf_path);
|
||||
out << "PFORM DUMP NATURES:" << endl;
|
||||
for (map<perm_string,nature_t*>::iterator cur = natures.begin()
|
||||
for (map<perm_string,ivl_nature_t>::iterator cur = natures.begin()
|
||||
; cur != natures.end() ; cur ++ ) {
|
||||
pform_dump(out, (*cur).second);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -600,7 +600,7 @@ ivl_variable_type_t NetESFunc::expr_type() const
|
|||
return type_;
|
||||
}
|
||||
|
||||
NetEAccess::NetEAccess(NetBranch*br, nature_t*nat)
|
||||
NetEAccess::NetEAccess(NetBranch*br, ivl_nature_t nat)
|
||||
: branch_(br), nature_(nat)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,8 +68,6 @@ class NetTaskDef;
|
|||
class NetEvTrig;
|
||||
class NetEvWait;
|
||||
|
||||
class nature_t;
|
||||
|
||||
struct target;
|
||||
struct functor_t;
|
||||
|
||||
|
|
@ -2982,7 +2980,7 @@ class NetEUFunc : public NetExpr {
|
|||
class NetEAccess : public NetExpr {
|
||||
|
||||
public:
|
||||
explicit NetEAccess(NetBranch*br, nature_t*nat);
|
||||
explicit NetEAccess(NetBranch*br, ivl_nature_t nat);
|
||||
~NetEAccess();
|
||||
|
||||
virtual ivl_variable_type_t expr_type() const;
|
||||
|
|
@ -2994,7 +2992,7 @@ class NetEAccess : public NetExpr {
|
|||
|
||||
private:
|
||||
NetBranch*branch_;
|
||||
nature_t*nature_;
|
||||
ivl_nature_t nature_;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
2
pform.h
2
pform.h
|
|
@ -389,7 +389,7 @@ extern void pform_discipline_flow(const struct vlltype&loc, const char*name);
|
|||
extern void pform_attach_discipline(const struct vlltype&loc,
|
||||
ivl_discipline_t discipline, list<perm_string>*names);
|
||||
|
||||
extern void pform_dump(ostream&out, const nature_t*);
|
||||
extern void pform_dump(ostream&out, const ivl_nature_s*);
|
||||
extern void pform_dump(ostream&out, const ivl_discipline_s*);
|
||||
|
||||
/* ** pform_analog.cc
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@
|
|||
# include "parse_misc.h"
|
||||
# include "discipline.h"
|
||||
|
||||
map<perm_string,nature_t*> natures;
|
||||
map<perm_string,ivl_nature_t> natures;
|
||||
map<perm_string,ivl_discipline_t> disciplines;
|
||||
map<perm_string,nature_t*> access_function_nature;
|
||||
map<perm_string,ivl_nature_t> access_function_nature;
|
||||
|
||||
static perm_string nature_name = perm_string::perm_string();
|
||||
static perm_string nature_access = perm_string::perm_string();
|
||||
|
|
@ -62,14 +62,14 @@ void pform_end_nature(const struct vlltype&loc)
|
|||
nature_access = nature_name;
|
||||
}
|
||||
|
||||
nature_t*tmp = new nature_t(nature_name, nature_access);
|
||||
ivl_nature_s*tmp = new ivl_nature_s(nature_name, nature_access);
|
||||
FILE_NAME(tmp, loc);
|
||||
|
||||
natures[nature_name] = tmp;
|
||||
|
||||
// Make sure the access function is not used by multiple
|
||||
// different natures.
|
||||
if (nature_t*dup_access_nat = access_function_nature[nature_access]) {
|
||||
if (ivl_nature_t dup_access_nat = access_function_nature[nature_access]) {
|
||||
cerr << tmp->get_fileline() << ": error: "
|
||||
<< "Access function name " << nature_access
|
||||
<< " is already used by nature " << dup_access_nat->name()
|
||||
|
|
@ -89,8 +89,8 @@ void pform_end_nature(const struct vlltype&loc)
|
|||
|
||||
static perm_string discipline_name;
|
||||
static ivl_dis_domain_t discipline_domain = IVL_DIS_NONE;
|
||||
static nature_t* discipline_potential = 0;
|
||||
static nature_t* discipline_flow = 0;
|
||||
static ivl_nature_t discipline_potential = 0;
|
||||
static ivl_nature_t discipline_flow = 0;
|
||||
|
||||
void pform_start_discipline(const char*name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1293,7 +1293,7 @@ void PUdp::dump(ostream&out) const
|
|||
out << "endprimitive" << endl;
|
||||
}
|
||||
|
||||
void pform_dump(std::ostream&out, const nature_t*nat)
|
||||
void pform_dump(std::ostream&out, const ivl_nature_s*nat)
|
||||
{
|
||||
out << "nature " << nat->name() << endl;
|
||||
out << " access " << nat->access() << ";" << endl;
|
||||
|
|
@ -1304,9 +1304,9 @@ void pform_dump(std::ostream&out, const ivl_discipline_s*dis)
|
|||
{
|
||||
out << "discipline " << dis->name() << endl;
|
||||
out << " domain " << dis->domain() << ";" << endl;
|
||||
if (const nature_t*tmp = dis->potential())
|
||||
if (const ivl_nature_s*tmp = dis->potential())
|
||||
out << " potential " << tmp->name() << ";" << endl;
|
||||
if (const nature_t*tmp = dis->flow())
|
||||
if (const ivl_nature_s*tmp = dis->flow())
|
||||
out << " flow " << tmp->name() << ";" << endl;
|
||||
out << "enddiscipline" << endl;
|
||||
}
|
||||
|
|
|
|||
10
t-dll-api.cc
10
t-dll-api.cc
|
|
@ -87,11 +87,21 @@ extern "C" ivl_dis_domain_t ivl_discipline_domain(ivl_discipline_t net)
|
|||
return net->domain();
|
||||
}
|
||||
|
||||
extern "C" ivl_nature_t ivl_discipline_flow(ivl_discipline_t net)
|
||||
{
|
||||
return net->flow();
|
||||
}
|
||||
|
||||
extern "C" const char* ivl_discipline_name(ivl_discipline_t net)
|
||||
{
|
||||
return net->name();
|
||||
}
|
||||
|
||||
extern "C" ivl_nature_t ivl_discipline_potential(ivl_discipline_t net)
|
||||
{
|
||||
return net->potential();
|
||||
}
|
||||
|
||||
extern "C" ivl_expr_type_t ivl_expr_type(ivl_expr_t net)
|
||||
{
|
||||
if (net == 0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue