Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle delayed signals in timing checks as assignments #966

Merged
merged 9 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ O = main.o async.o design_dump.o discipline.o dup_expr.o elaborate.o \
pform_types.o \
symbol_search.o sync.o sys_funcs.o verinum.o verireal.o vpi_modules.o target.o \
Attrib.o HName.o Module.o PClass.o PDelays.o PEvent.o PExpr.o PFunction.o \
PGate.o PGenerate.o PModport.o PNamedItem.o PPackage.o PScope.o PSpec.o \
PGate.o PGenerate.o PModport.o PNamedItem.o PPackage.o PScope.o PSpec.o PTimingCheck.o \
PTask.o PUdp.o PWire.o Statement.o AStatement.o $M $(FF) $(TT)

all: dep config.h _pli_types.h version_tag.h ivl@EXEEXT@ version.exe iverilog-vpi.man
Expand Down
4 changes: 4 additions & 0 deletions Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class PGate;
class PGenerate;
class PModport;
class PSpecPath;
class PTimingCheck;
class PTask;
class PFunction;
class PWire;
Expand Down Expand Up @@ -136,7 +137,9 @@ class Module : public PScopeExtra, public PNamedItem {
program blocks. */
std::map<perm_string,PModport*> modports;

/* List for specify paths and timing checks */
std::list<PSpecPath*> specify_paths;
std::list<PTimingCheck*> timing_checks;

// The mod_name() is the name of the module type.
perm_string mod_name() const { return pscope_name(); }
Expand Down Expand Up @@ -170,6 +173,7 @@ class Module : public PScopeExtra, public PNamedItem {

private:
void dump_specparams_(std::ostream&out, unsigned indent) const;
void dump_timingchecks_(std::ostream&out, unsigned indent) const;
std::list<PGate*> gates_;

private: // Not implemented
Expand Down
100 changes: 100 additions & 0 deletions PTimingCheck.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Copyright (c) 2006-2023 Stephen Williams <[email protected]>
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

# include "PTimingCheck.h"

PRecRem::PRecRem(event_t reference_event,
event_t data_event,
PExpr* setup_limit,
PExpr* hold_limit,
pform_name_t* notifier,
pform_name_t* timestamp_cond,
pform_name_t* timecheck_cond,
pform_name_t* delayed_reference,
pform_name_t* delayed_data)
:
reference_event_ (reference_event),
data_event_ (data_event),
setup_limit_ (setup_limit),
hold_limit_ (hold_limit),
notifier_ (notifier),
timestamp_cond_ (timestamp_cond),
timecheck_cond_ (timecheck_cond),
delayed_reference_ (delayed_reference),
delayed_data_ (delayed_data)
{
}

PRecRem::~PRecRem()
{
delete setup_limit_;
delete hold_limit_;
mole99 marked this conversation as resolved.
Show resolved Hide resolved

// Delete optional arguments
if (reference_event_.condition) delete reference_event_.condition;
if (data_event_.condition) delete data_event_.condition;

if(notifier_) delete notifier_;

if(timestamp_cond_) delete timestamp_cond_;
if(timecheck_cond_) delete timecheck_cond_;

if(delayed_reference_) delete delayed_reference_;
if(delayed_data_) delete delayed_data_;
}

PSetupHold::PSetupHold(event_t reference_event,
event_t data_event,
PExpr* setup_limit,
PExpr* hold_limit,
pform_name_t* notifier,
pform_name_t* timestamp_cond,
pform_name_t* timecheck_cond,
pform_name_t* delayed_reference,
pform_name_t* delayed_data)
:
reference_event_ (reference_event),
data_event_ (data_event),
setup_limit_ (setup_limit),
hold_limit_ (hold_limit),
notifier_ (notifier),
timestamp_cond_ (timestamp_cond),
timecheck_cond_ (timecheck_cond),
delayed_reference_ (delayed_reference),
delayed_data_ (delayed_data)
{
}

PSetupHold::~PSetupHold()
{
delete setup_limit_;
delete hold_limit_;

// Delete optional arguments
if (reference_event_.condition) delete reference_event_.condition;
if (data_event_.condition) delete data_event_.condition;

if(notifier_) delete notifier_;

if(timestamp_cond_) delete timestamp_cond_;
if(timecheck_cond_) delete timecheck_cond_;

if(delayed_reference_) delete delayed_reference_;
if(delayed_data_) delete delayed_data_;
}
138 changes: 138 additions & 0 deletions PTimingCheck.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#ifndef IVL_PTimingCheck_H
#define IVL_PTimingCheck_H
/*
* Copyright (c) 2006-2023 Stephen Williams <[email protected]>
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

# include "LineInfo.h"
# include "PExpr.h"
# include "pform_types.h"

/*
* The PTimingCheck is the base class for all timing checks
*/
class PTimingCheck : public LineInfo {

public:
enum EdgeType {EDGE_01, EDGE_0X, EDGE_10, EDGE_1X, EDGE_X0, EDGE_X1};

struct event_t {
pform_name_t name;
bool posedge;
bool negedge;
std::vector<EdgeType> edges;
PExpr* condition;
};

// This struct is used to parse the optional arguments
struct optional_args_t {
pform_name_t* notifier = nullptr;
pform_name_t* timestamp_cond = nullptr;
pform_name_t* timecheck_cond = nullptr;
pform_name_t* delayed_reference = nullptr;
pform_name_t* delayed_data = nullptr;
PExpr* event_based_flag = nullptr;
PExpr* remain_active_flag = nullptr;
};

PTimingCheck() { }
virtual ~PTimingCheck() { }

virtual void elaborate(class Design*des, class NetScope*scope) const = 0;

virtual void dump(std::ostream&out, unsigned ind) const = 0;
};

/*
* The PRecRem is the parse of a $recrem timing check
*/
class PRecRem : public PTimingCheck {

public:

PRecRem(event_t reference_event,
event_t data_event,
PExpr* setup_limit,
PExpr* hold_limit,
pform_name_t* notifier,
pform_name_t* timestamp_cond,
pform_name_t* timecheck_cond,
pform_name_t* delayed_reference,
pform_name_t* delayed_data);

~PRecRem();

void elaborate(class Design*des, class NetScope*scope) const override;

void dump(std::ostream&out, unsigned ind) const override;

private:
event_t reference_event_; // hierarchy_identifier
event_t data_event_;

PExpr* setup_limit_;
PExpr* hold_limit_;

pform_name_t* notifier_;

pform_name_t* timestamp_cond_;
pform_name_t* timecheck_cond_;

pform_name_t* delayed_reference_;
pform_name_t* delayed_data_;
};

/*
* The PSetupHold is the parse of a $setuphold timing check
*/
class PSetupHold : public PTimingCheck {

public:
PSetupHold(event_t reference_event,
event_t data_event,
PExpr* setup_limit,
PExpr* hold_limit,
pform_name_t* notifier,
pform_name_t* timestamp_cond,
pform_name_t* timecheck_cond,
pform_name_t* delayed_reference,
pform_name_t* delayed_data);

~PSetupHold();

void elaborate(class Design*des, class NetScope*scope) const override;

void dump(std::ostream&out, unsigned ind) const override;

private:
event_t reference_event_; // hierarchy_identifier
event_t data_event_;

PExpr* setup_limit_;
PExpr* hold_limit_;

pform_name_t* notifier_;

pform_name_t* timestamp_cond_;
pform_name_t* timecheck_cond_;

pform_name_t* delayed_reference_;
pform_name_t* delayed_data_;
};

#endif /* IVL_PTimingCheck_H */
Loading
Loading