2014-07-23 22:39:29 +02:00
|
|
|
#ifndef IVL_part_H
|
|
|
|
|
#define IVL_part_H
|
2005-09-20 02:51:53 +02:00
|
|
|
/*
|
2025-07-22 08:30:57 +02:00
|
|
|
* Copyright (c) 2005-2025 Stephen Williams (steve@icarus.com)
|
2005-09-20 02:51:53 +02: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
|
2012-08-29 03:41:23 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-09-20 02:51:53 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
# include "schedule.h"
|
2009-01-30 02:23:09 +01:00
|
|
|
# include "config.h"
|
2005-09-20 02:51:53 +02:00
|
|
|
|
|
|
|
|
/* vvp_fun_part
|
|
|
|
|
* This node takes a part select of the input vector. Input 0 is the
|
|
|
|
|
* vector to be selected from, and input 1 is the location where the
|
|
|
|
|
* select starts. Input 2, which is typically constant, is the width
|
|
|
|
|
* of the result.
|
|
|
|
|
*/
|
2008-10-28 18:52:39 +01:00
|
|
|
class vvp_fun_part : public vvp_net_fun_t {
|
2005-09-20 02:51:53 +02:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
vvp_fun_part(unsigned base, unsigned wid);
|
|
|
|
|
~vvp_fun_part();
|
|
|
|
|
|
2023-08-30 09:50:00 +02:00
|
|
|
unsigned get_base() const { return base_; }
|
|
|
|
|
unsigned get_wid() const { return wid_; }
|
|
|
|
|
|
2008-10-28 18:52:39 +01:00
|
|
|
protected:
|
|
|
|
|
unsigned base_;
|
|
|
|
|
unsigned wid_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Statically allocated vvp_fun_part.
|
|
|
|
|
*/
|
|
|
|
|
class vvp_fun_part_sa : public vvp_fun_part, public vvp_gen_event_s {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
vvp_fun_part_sa(unsigned base, unsigned wid);
|
|
|
|
|
~vvp_fun_part_sa();
|
|
|
|
|
|
2005-09-20 02:51:53 +02:00
|
|
|
public:
|
2008-10-28 18:52:39 +01:00
|
|
|
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
|
2025-07-22 08:30:57 +02:00
|
|
|
vvp_context_t) override;
|
2005-09-20 02:51:53 +02:00
|
|
|
|
2006-11-16 02:11:26 +01:00
|
|
|
void recv_vec4_pv(vvp_net_ptr_t port, const vvp_vector4_t&bit,
|
2025-07-22 08:30:57 +02:00
|
|
|
unsigned base, unsigned vwid, vvp_context_t) override;
|
2006-11-16 02:11:26 +01:00
|
|
|
|
2005-09-20 02:51:53 +02:00
|
|
|
private:
|
2025-07-22 08:30:57 +02:00
|
|
|
void run_run() override;
|
2005-09-20 02:51:53 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
vvp_vector4_t val_;
|
|
|
|
|
vvp_net_t*net_;
|
|
|
|
|
};
|
|
|
|
|
|
2008-10-28 18:52:39 +01:00
|
|
|
/*
|
|
|
|
|
* Automatically allocated vvp_fun_part.
|
|
|
|
|
*/
|
|
|
|
|
class vvp_fun_part_aa : public vvp_fun_part, public automatic_hooks_s {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
vvp_fun_part_aa(unsigned base, unsigned wid);
|
|
|
|
|
~vvp_fun_part_aa();
|
|
|
|
|
|
|
|
|
|
public:
|
2025-07-22 08:30:57 +02:00
|
|
|
void alloc_instance(vvp_context_t context) override;
|
|
|
|
|
void reset_instance(vvp_context_t context) override;
|
2009-01-30 02:23:09 +01:00
|
|
|
#ifdef CHECK_WITH_VALGRIND
|
2025-07-22 08:30:57 +02:00
|
|
|
void free_instance(vvp_context_t context) override;
|
2009-01-30 02:23:09 +01:00
|
|
|
#endif
|
2008-10-28 18:52:39 +01:00
|
|
|
|
|
|
|
|
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
|
2025-07-22 08:30:57 +02:00
|
|
|
vvp_context_t context) override;
|
2008-10-28 18:52:39 +01:00
|
|
|
|
|
|
|
|
void recv_vec4_pv(vvp_net_ptr_t port, const vvp_vector4_t&bit,
|
2025-07-22 08:30:57 +02:00
|
|
|
unsigned base, unsigned vwid, vvp_context_t context) override;
|
2008-10-28 18:52:39 +01:00
|
|
|
|
|
|
|
|
private:
|
2015-12-27 22:07:42 +01:00
|
|
|
__vpiScope*context_scope_;
|
2008-10-28 18:52:39 +01:00
|
|
|
unsigned context_idx_;
|
|
|
|
|
};
|
|
|
|
|
|
2005-09-20 02:51:53 +02:00
|
|
|
/* vvp_fun_part_pv
|
|
|
|
|
* This node takes a vector input and turns it into the part select of
|
|
|
|
|
* a wider output network. It used the recv_vec4_pv methods of the
|
2008-10-28 18:52:39 +01:00
|
|
|
* destination nodes to propagate the part select. It can be used in
|
|
|
|
|
* both statically and automatically allocated scopes, as it has no
|
|
|
|
|
* dynamic state.
|
2005-09-20 02:51:53 +02:00
|
|
|
*/
|
|
|
|
|
class vvp_fun_part_pv : public vvp_net_fun_t {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
vvp_fun_part_pv(unsigned base, unsigned wid, unsigned vec_wid);
|
|
|
|
|
~vvp_fun_part_pv();
|
|
|
|
|
|
|
|
|
|
public:
|
2008-10-28 18:52:39 +01:00
|
|
|
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
|
2025-07-22 08:30:57 +02:00
|
|
|
vvp_context_t context) override;
|
2008-10-28 18:52:39 +01:00
|
|
|
|
2016-02-24 16:34:18 +01:00
|
|
|
void recv_vec4_pv(vvp_net_ptr_t port, const vvp_vector4_t&bit,
|
2025-07-22 08:30:57 +02:00
|
|
|
unsigned base, unsigned vwid, vvp_context_t) override;
|
2016-02-24 16:34:18 +01:00
|
|
|
|
2025-07-22 08:30:57 +02:00
|
|
|
void recv_vec8(vvp_net_ptr_t port, const vvp_vector8_t&bit) override;
|
2005-09-20 02:51:53 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
unsigned base_;
|
|
|
|
|
unsigned wid_;
|
|
|
|
|
unsigned vwid_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This part select is more flexible in that it takes the vector to
|
|
|
|
|
* part in port 0, and the base of the part in port 1. The width of
|
|
|
|
|
* the part to take out is fixed.
|
|
|
|
|
*/
|
|
|
|
|
class vvp_fun_part_var : public vvp_net_fun_t {
|
|
|
|
|
|
|
|
|
|
public:
|
2009-09-19 02:32:39 +02:00
|
|
|
explicit vvp_fun_part_var(unsigned wid, bool is_signed);
|
2005-09-20 02:51:53 +02:00
|
|
|
~vvp_fun_part_var();
|
|
|
|
|
|
2008-10-28 18:52:39 +01:00
|
|
|
protected:
|
|
|
|
|
bool recv_vec4_(vvp_net_ptr_t port, const vvp_vector4_t&bit,
|
2009-09-09 02:50:47 +02:00
|
|
|
int&base, vvp_vector4_t&source,
|
2008-10-28 18:52:39 +01:00
|
|
|
vvp_vector4_t&ref);
|
|
|
|
|
|
|
|
|
|
unsigned wid_;
|
2009-09-19 02:32:39 +02:00
|
|
|
bool is_signed_;
|
2008-10-28 18:52:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Statically allocated vvp_fun_part_var.
|
|
|
|
|
*/
|
|
|
|
|
class vvp_fun_part_var_sa : public vvp_fun_part_var {
|
|
|
|
|
|
|
|
|
|
public:
|
2009-09-19 02:32:39 +02:00
|
|
|
explicit vvp_fun_part_var_sa(unsigned wid, bool is_signed);
|
2008-10-28 18:52:39 +01:00
|
|
|
~vvp_fun_part_var_sa();
|
|
|
|
|
|
2005-09-20 02:51:53 +02:00
|
|
|
public:
|
2008-10-28 18:52:39 +01:00
|
|
|
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
|
2025-07-22 08:30:57 +02:00
|
|
|
vvp_context_t) override;
|
2005-09-20 02:51:53 +02:00
|
|
|
|
2008-02-28 03:42:21 +01:00
|
|
|
void recv_vec4_pv(vvp_net_ptr_t port, const vvp_vector4_t&bit,
|
2025-07-22 08:30:57 +02:00
|
|
|
unsigned base, unsigned vwid, vvp_context_t) override;
|
2008-02-28 03:42:21 +01:00
|
|
|
|
2005-09-20 02:51:53 +02:00
|
|
|
private:
|
2009-09-09 02:50:47 +02:00
|
|
|
int base_;
|
2005-09-20 02:51:53 +02:00
|
|
|
vvp_vector4_t source_;
|
|
|
|
|
// Save the last output, for detecting change.
|
|
|
|
|
vvp_vector4_t ref_;
|
|
|
|
|
};
|
|
|
|
|
|
2008-10-28 18:52:39 +01:00
|
|
|
/*
|
|
|
|
|
* Automatically allocated vvp_fun_part_var.
|
|
|
|
|
*/
|
|
|
|
|
class vvp_fun_part_var_aa : public vvp_fun_part_var, public automatic_hooks_s {
|
|
|
|
|
|
|
|
|
|
public:
|
2009-09-19 02:32:39 +02:00
|
|
|
explicit vvp_fun_part_var_aa(unsigned wid, bool is_signed);
|
2008-10-28 18:52:39 +01:00
|
|
|
~vvp_fun_part_var_aa();
|
|
|
|
|
|
|
|
|
|
public:
|
2025-07-22 08:30:57 +02:00
|
|
|
void alloc_instance(vvp_context_t context) override;
|
|
|
|
|
void reset_instance(vvp_context_t context) override;
|
2009-01-30 02:23:09 +01:00
|
|
|
#ifdef CHECK_WITH_VALGRIND
|
2025-07-22 08:30:57 +02:00
|
|
|
void free_instance(vvp_context_t context) override;
|
2009-01-30 02:23:09 +01:00
|
|
|
#endif
|
2008-10-28 18:52:39 +01:00
|
|
|
|
|
|
|
|
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
|
2025-07-22 08:30:57 +02:00
|
|
|
vvp_context_t context) override;
|
2008-10-28 18:52:39 +01:00
|
|
|
|
|
|
|
|
void recv_vec4_pv(vvp_net_ptr_t port, const vvp_vector4_t&bit,
|
2025-07-22 08:30:57 +02:00
|
|
|
unsigned base, unsigned vwid, vvp_context_t context) override;
|
2008-10-28 18:52:39 +01:00
|
|
|
|
|
|
|
|
private:
|
2015-12-27 22:07:42 +01:00
|
|
|
__vpiScope*context_scope_;
|
2008-10-28 18:52:39 +01:00
|
|
|
unsigned context_idx_;
|
|
|
|
|
};
|
|
|
|
|
|
2014-07-23 22:39:29 +02:00
|
|
|
#endif /* IVL_part_H */
|