2005-04-03 07:45:51 +02:00
|
|
|
#ifndef __delay_H
|
2001-11-10 19:07:11 +01:00
|
|
|
#define __delay_H
|
|
|
|
|
/*
|
2005-04-03 07:45:51 +02:00
|
|
|
* Copyright 2005 Stephen Williams
|
2001-11-10 19:07:11 +01:00
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
2002-08-12 03:34:58 +02:00
|
|
|
#ifdef HAVE_CVS_IDENT
|
2007-01-26 06:15:41 +01:00
|
|
|
#ident "$Id: delay.h,v 1.13 2007/01/26 05:15:41 steve Exp $"
|
2001-11-10 19:07:11 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*
|
2005-04-03 07:45:51 +02:00
|
|
|
*/
|
2001-11-10 19:07:11 +01:00
|
|
|
|
2005-04-03 07:45:51 +02:00
|
|
|
# include "vvp_net.h"
|
2005-06-02 18:02:11 +02:00
|
|
|
# include "schedule.h"
|
2001-11-10 19:07:11 +01:00
|
|
|
|
2006-09-29 05:57:01 +02:00
|
|
|
enum delay_edge_t {
|
|
|
|
|
DELAY_EDGE_01 = 0, DELAY_EDGE_10, DELAY_EDGE_0z,
|
|
|
|
|
DELAY_EDGE_z1, DELAY_EDGE_1z, DELAY_EDGE_z0,
|
|
|
|
|
DELAY_EDGE_0x, DELAY_EDGE_x1, DELAY_EDGE_1x,
|
|
|
|
|
DELAY_EDGE_x0, DELAY_EDGE_xz, DELAY_EDGE_zx,
|
|
|
|
|
DELAY_EDGE_COUNT
|
|
|
|
|
};
|
|
|
|
|
|
2005-04-03 07:45:51 +02:00
|
|
|
/*
|
|
|
|
|
* Instances of this object are functions that calculate the delay for
|
|
|
|
|
* the transition from the source vvp_bit4_t value to the destination
|
|
|
|
|
* value.
|
|
|
|
|
*/
|
|
|
|
|
class vvp_delay_t {
|
2001-11-10 19:07:11 +01:00
|
|
|
|
2005-04-03 07:45:51 +02:00
|
|
|
public:
|
|
|
|
|
vvp_delay_t(vvp_time64_t rise, vvp_time64_t fall);
|
|
|
|
|
vvp_delay_t(vvp_time64_t rise, vvp_time64_t fall, vvp_time64_t decay);
|
|
|
|
|
~vvp_delay_t();
|
2001-11-10 19:07:11 +01:00
|
|
|
|
2005-04-03 07:45:51 +02:00
|
|
|
vvp_time64_t get_delay(vvp_bit4_t from, vvp_bit4_t to);
|
2005-07-06 06:29:25 +02:00
|
|
|
vvp_time64_t get_min_delay() const;
|
2001-11-10 19:07:11 +01:00
|
|
|
|
2006-01-02 06:32:06 +01:00
|
|
|
void set_rise(vvp_time64_t val);
|
|
|
|
|
void set_fall(vvp_time64_t val);
|
|
|
|
|
void set_decay(vvp_time64_t val);
|
|
|
|
|
|
2005-04-03 07:45:51 +02:00
|
|
|
private:
|
|
|
|
|
vvp_time64_t rise_, fall_, decay_;
|
|
|
|
|
vvp_time64_t min_delay_;
|
2006-01-02 06:32:06 +01:00
|
|
|
|
|
|
|
|
void calculate_min_delay_();
|
2001-11-10 19:07:11 +01:00
|
|
|
};
|
|
|
|
|
|
2005-05-14 21:43:23 +02:00
|
|
|
/* vvp_fun_delay
|
|
|
|
|
* This is a lighter weight version of vvp_fun_drive, that only
|
|
|
|
|
* carries delays. The output that it propagates is vvp_vector4_t so
|
|
|
|
|
* drive strengths are lost, but then again it doesn't go through the
|
|
|
|
|
* effort of calculating strength values either.
|
2005-06-02 18:02:11 +02:00
|
|
|
*
|
|
|
|
|
* The node needs a pointer to the vvp_net_t input so that it knows
|
|
|
|
|
* how to find its output when propaging delayed output.
|
2005-07-06 06:29:25 +02:00
|
|
|
*
|
|
|
|
|
* NOTE: This node supports vec4 and real by repeating whatever was
|
|
|
|
|
* input. This is a bit of a hack, as it may be more efficient to
|
|
|
|
|
* create the right type of vvp_fun_delay_real.
|
2005-05-14 21:43:23 +02:00
|
|
|
*/
|
2005-06-02 18:02:11 +02:00
|
|
|
class vvp_fun_delay : public vvp_net_fun_t, private vvp_gen_event_s {
|
2005-05-14 21:43:23 +02:00
|
|
|
|
2007-01-26 06:15:41 +01:00
|
|
|
struct event_ {
|
|
|
|
|
event_(vvp_time64_t s) : sim_time(s) { }
|
|
|
|
|
void (vvp_fun_delay::*run_run_ptr)(struct vvp_fun_delay::event_*cur);
|
|
|
|
|
const vvp_time64_t sim_time;
|
|
|
|
|
vvp_vector4_t ptr_vec4;
|
|
|
|
|
vvp_vector8_t ptr_vec8;
|
|
|
|
|
double ptr_real;
|
|
|
|
|
struct event_*next;
|
|
|
|
|
};
|
|
|
|
|
|
2005-05-14 21:43:23 +02:00
|
|
|
public:
|
2005-06-02 18:02:11 +02:00
|
|
|
vvp_fun_delay(vvp_net_t*net, vvp_bit4_t init, const vvp_delay_t&d);
|
2005-05-14 21:43:23 +02:00
|
|
|
~vvp_fun_delay();
|
|
|
|
|
|
2005-06-22 02:04:48 +02:00
|
|
|
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
|
2006-01-02 06:32:06 +01:00
|
|
|
void recv_vec8(vvp_net_ptr_t port, vvp_vector8_t bit);
|
2005-07-06 06:29:25 +02:00
|
|
|
void recv_real(vvp_net_ptr_t port, double bit);
|
2005-05-14 21:43:23 +02:00
|
|
|
//void recv_long(vvp_net_ptr_t port, long bit);
|
|
|
|
|
|
|
|
|
|
private:
|
2005-06-02 18:02:11 +02:00
|
|
|
virtual void run_run();
|
|
|
|
|
|
2006-01-02 06:32:06 +01:00
|
|
|
|
2007-01-26 06:15:41 +01:00
|
|
|
void run_run_vec4_(struct vvp_fun_delay::event_*cur);
|
|
|
|
|
void run_run_vec8_(struct vvp_fun_delay::event_*cur);
|
|
|
|
|
void run_run_real_(struct vvp_fun_delay::event_*cur);
|
2006-01-02 06:32:06 +01:00
|
|
|
|
2005-06-02 18:02:11 +02:00
|
|
|
private:
|
|
|
|
|
vvp_net_t*net_;
|
2005-05-14 21:43:23 +02:00
|
|
|
vvp_delay_t delay_;
|
2005-07-06 06:29:25 +02:00
|
|
|
|
|
|
|
|
vvp_vector4_t cur_vec4_;
|
2006-01-02 06:32:06 +01:00
|
|
|
vvp_vector8_t cur_vec8_;
|
2005-07-06 06:29:25 +02:00
|
|
|
double cur_real_;
|
2007-01-26 06:15:41 +01:00
|
|
|
|
|
|
|
|
struct event_ *list_;
|
|
|
|
|
void enqueue_(struct event_*cur)
|
|
|
|
|
{
|
|
|
|
|
if (list_) {
|
|
|
|
|
cur->next = list_->next;
|
|
|
|
|
list_->next = cur;
|
|
|
|
|
list_ = cur;
|
|
|
|
|
} else {
|
|
|
|
|
cur->next = cur;
|
|
|
|
|
list_ = cur;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
struct event_* dequeue_(void)
|
|
|
|
|
{
|
|
|
|
|
if (list_ == 0)
|
|
|
|
|
return 0;
|
|
|
|
|
struct event_*cur = list_->next;
|
|
|
|
|
if (list_ == cur)
|
|
|
|
|
list_ = 0;
|
|
|
|
|
else
|
|
|
|
|
list_->next = cur->next;
|
|
|
|
|
return cur;
|
|
|
|
|
}
|
|
|
|
|
void clean_pulse_events_(vvp_time64_t use_delay);
|
2005-05-14 21:43:23 +02:00
|
|
|
};
|
|
|
|
|
|
2006-09-23 06:57:19 +02:00
|
|
|
class vvp_fun_modpath;
|
|
|
|
|
class vvp_fun_modpath_src;
|
|
|
|
|
|
|
|
|
|
class vvp_fun_modpath : public vvp_net_fun_t, private vvp_gen_event_s {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
vvp_fun_modpath(vvp_net_t*net);
|
|
|
|
|
~vvp_fun_modpath();
|
|
|
|
|
|
|
|
|
|
void add_modpath_src(vvp_fun_modpath_src*that);
|
|
|
|
|
|
|
|
|
|
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
virtual void run_run();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
vvp_net_t*net_;
|
|
|
|
|
|
|
|
|
|
vvp_vector4_t cur_vec4_;
|
|
|
|
|
|
|
|
|
|
vvp_fun_modpath_src*src_list_;
|
|
|
|
|
|
|
|
|
|
private: // not implemented
|
|
|
|
|
vvp_fun_modpath(const vvp_fun_modpath&);
|
|
|
|
|
vvp_fun_modpath& operator= (const vvp_fun_modpath&);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class vvp_fun_modpath_src : public vvp_net_fun_t {
|
|
|
|
|
|
|
|
|
|
friend class vvp_fun_modpath;
|
|
|
|
|
|
|
|
|
|
public:
|
2006-09-29 05:57:01 +02:00
|
|
|
vvp_fun_modpath_src(vvp_time64_t d[12]);
|
2006-09-23 06:57:19 +02:00
|
|
|
private:
|
|
|
|
|
~vvp_fun_modpath_src();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// FIXME: Needs to be a 12-value array
|
2006-09-29 05:57:01 +02:00
|
|
|
vvp_time64_t delay_[12];
|
2006-09-23 06:57:19 +02:00
|
|
|
// Used by vvp_fun_modpath to keep a list of modpath_src objects.
|
|
|
|
|
vvp_fun_modpath_src*next_;
|
|
|
|
|
|
|
|
|
|
vvp_time64_t wake_time_;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
vvp_fun_modpath_src(const vvp_fun_modpath_src&);
|
|
|
|
|
vvp_fun_modpath_src& operator = (const vvp_fun_modpath_src&);
|
|
|
|
|
};
|
|
|
|
|
|
2001-11-10 19:07:11 +01:00
|
|
|
/*
|
2005-04-03 07:45:51 +02:00
|
|
|
* $Log: delay.h,v $
|
2007-01-26 06:15:41 +01:00
|
|
|
* Revision 1.13 2007/01/26 05:15:41 steve
|
|
|
|
|
* More literal implementation of inertial delay model.
|
|
|
|
|
*
|
2006-09-29 05:57:01 +02:00
|
|
|
* Revision 1.12 2006/09/29 03:57:01 steve
|
|
|
|
|
* Modpath delay chooses correct delay for edge.
|
|
|
|
|
*
|
2006-09-23 06:57:19 +02:00
|
|
|
* Revision 1.11 2006/09/23 04:57:20 steve
|
|
|
|
|
* Basic support for specify timing.
|
|
|
|
|
*
|
2006-01-02 06:32:06 +01:00
|
|
|
* Revision 1.10 2006/01/02 05:32:07 steve
|
|
|
|
|
* Require explicit delay node from source.
|
|
|
|
|
*
|
2005-07-06 06:29:25 +02:00
|
|
|
* Revision 1.9 2005/07/06 04:29:25 steve
|
|
|
|
|
* Implement real valued signals and arith nodes.
|
|
|
|
|
*
|
2005-06-22 02:04:48 +02:00
|
|
|
* Revision 1.8 2005/06/22 00:04:49 steve
|
|
|
|
|
* Reduce vvp_vector4 copies by using const references.
|
|
|
|
|
*
|
2005-06-02 18:02:11 +02:00
|
|
|
* Revision 1.7 2005/06/02 16:02:11 steve
|
|
|
|
|
* Add support for notif0/1 gates.
|
|
|
|
|
* Make delay nodes support inertial delay.
|
|
|
|
|
* Add the %force/link instruction.
|
|
|
|
|
*
|
2005-05-14 21:43:23 +02:00
|
|
|
* Revision 1.6 2005/05/14 19:43:23 steve
|
|
|
|
|
* Move functor delays to vvp_delay_fun object.
|
|
|
|
|
*
|
2005-04-03 07:45:51 +02:00
|
|
|
* Revision 1.5 2005/04/03 05:45:51 steve
|
|
|
|
|
* Rework the vvp_delay_t class.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2001-11-10 19:07:11 +01:00
|
|
|
#endif // __delay_H
|