1 /*
2 * Copyright (c) 2012-2013 Stephen Williams (steve@icarus.com)
3 *
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 # include "netvector.h"
21 # include <iostream>
22
23 using namespace std;
24
25 netvector_t netvector_t::atom2s64 (IVL_VT_BOOL, 63, 0, true);
26 netvector_t netvector_t::atom2u64 (IVL_VT_BOOL, 63, 0, false);
27 netvector_t netvector_t::atom2s32 (IVL_VT_BOOL, 31, 0, true);
28 netvector_t netvector_t::atom2u32 (IVL_VT_BOOL, 31, 0, false);
29 netvector_t netvector_t::atom2s16 (IVL_VT_BOOL, 15, 0, true);
30 netvector_t netvector_t::atom2u16 (IVL_VT_BOOL, 15, 0, false);
31 netvector_t netvector_t::atom2s8 (IVL_VT_BOOL, 7, 0, true);
32 netvector_t netvector_t::atom2u8 (IVL_VT_BOOL, 7, 0, false);
33
34 //netvector_t netvector_t::scalar_bool (IVL_VT_BOOL);
35 netvector_t netvector_t::scalar_logic (IVL_VT_LOGIC);
36
netvector_t(ivl_variable_type_t type,long msb,long lsb,bool flag)37 netvector_t::netvector_t(ivl_variable_type_t type, long msb, long lsb, bool flag)
38 : type_(type), signed_(flag), isint_(false), is_scalar_(false)
39 {
40 packed_dims_.push_back(netrange_t(msb,lsb));
41 }
42
netvector_t(ivl_variable_type_t type)43 netvector_t::netvector_t(ivl_variable_type_t type)
44 : type_(type), signed_(false), isint_(false), is_scalar_(false)
45 {
46 }
47
~netvector_t()48 netvector_t::~netvector_t()
49 {
50 }
51
base_type() const52 ivl_variable_type_t netvector_t::base_type() const
53 {
54 return type_;
55 }
56
57 /*
58 * vectors are by definition packed.
59 */
packed(void) const60 bool netvector_t::packed(void) const
61 {
62 return true;
63 }
64
packed_width() const65 long netvector_t::packed_width() const
66 {
67 return netrange_width(packed_dims_);
68 }
69
slice_dimensions() const70 vector<netrange_t> netvector_t::slice_dimensions() const
71 {
72 return packed_dims_;
73 }
74
test_compatibility(ivl_type_t that) const75 bool netvector_t::test_compatibility(ivl_type_t that) const
76 {
77 const netvector_t*that_st = dynamic_cast<const netvector_t*>(that);
78 if (that_st == 0)
79 return false;
80
81 if (type_ != that_st->type_)
82 return false;
83 if (packed_dims_.size() != that_st->packed_dims_.size())
84 return false;
85
86 for (size_t idx = 0 ; idx < packed_dims_.size() ; idx += 1) {
87 if (packed_dims_[idx] != that_st->packed_dims_[idx])
88 return false;
89 }
90
91 return true;
92 }
93