Compare commits

...

29 Commits

Author SHA1 Message Date
أحمد المحمودي 0219413eef
Merge 8de5e68e83 into a7502173d3 2025-10-29 22:36:56 +01:00
Cary R a7502173d3 Fix MSYS2 builds after cleanup 2025-10-25 11:09:39 -07:00
Cary R d697312cf8 Cleanup ivt casting for cppcheck 2025-10-25 10:54:12 -07:00
Martin Whitaker efb0ea2ec7 Try a different way to disable PLI1 in MSYS2 CLANG CI. 2025-10-25 15:54:50 +01:00
Martin Whitaker 70094ce564 Disable PLI1 support in MSYS2/CLANG CI. 2025-10-25 15:49:11 +01:00
Martin Whitaker e32584f228 Remove spurious space in MSYS2 PKGBUILD. 2025-10-25 15:23:12 +01:00
Martin Whitaker 9bf45a85e2 Fix errors in MSYS2 PKGBUILD. 2025-10-25 15:15:51 +01:00
Martin Whitaker 97da696b5a Add missing gperf dependency in MSYS2 PKGBUILD. 2025-10-25 14:33:22 +01:00
Martin Whitaker d392dcf07f Fix syntax error in github workflow. 2025-10-25 14:22:51 +01:00
Martin Whitaker e4b3f1bc69 Make MSYS2 build instructions more prominent in the documentation. 2025-10-25 14:16:00 +01:00
Martin Whitaker b69cb8efda Update documentation to describe the --enable-libveriuser config option.
Also fix a typo in the --with-valgrind description.
2025-10-25 14:16:00 +01:00
Martin Whitaker d766248bc1 Update CI to also test ucrt64 and clang64 builds in MSYS2. 2025-10-25 14:16:00 +01:00
Martin Whitaker 587d87bb96 Update MSYS2 PKGBUILD to support ucrt64 and clang64 as well as mingw64.
Also allow extra configuration options to be passed via the
IVL_CONFIG_OPTIONS environment variable and add some missing
dependencies. Don't include --enable-libveriuser by default.
Update the README accordingly, with sensible line wrapping.
2025-10-25 14:16:00 +01:00
Martin Whitaker da853622e9 Don't delete vvp/libvvp.h when running 'make clean'. 2025-10-25 14:16:00 +01:00
Cary R cc496c3cf3 More ivl cppcheck cleanup 2025-10-23 10:01:06 -07:00
Martin Whitaker 3d4f1eb94b Improved run_program() in Perl regression test scripts.
This version works with the native Windows (mingw64 and clang64)
versions of Perl in MSYS2.

Note that warnings are disabled in the Environment.pm module because
Perl fails to notice that OLDOUT and OLDERR are used when restoring
the STDOUT and STDERR file handles.
2025-10-21 21:47:45 +01:00
Cary R 702189a948 Add correct C++ cast for the vpi_modules 2025-10-21 00:44:23 -07:00
Cary R b7292e0179 Another fix for msys CI 2025-10-21 00:27:35 -07:00
Cary R 0b7bd36960 Fix msys2 compile issue in CI 2025-10-21 00:16:35 -07:00
Cary R 860761f9c6 More cppcheck fixes - part 2 2025-10-20 23:54:15 -07:00
Cary R 08c8ee081a More cppcheck updates 2025-10-20 23:54:15 -07:00
Cary R. 929fbf3507
Merge pull request #1282 from steveicarus/msys2-clang-support
MSYS2 clang support
2025-10-20 19:42:30 -07:00
Martin Whitaker 5f651d944b Check that pointers returned by tf_getp are valid.
When the argument is a literal string, tf_getp returns a pointer to
the string. But the return type is a PLI_INT32, so on machines where
pointers are larger than 32 bits, the pointer value may get truncated.
Check for this at run time, and if it occurs, print a warning and
return 0.
2025-10-18 22:31:07 +01:00
Martin Whitaker 6210c307fa Update CI scripts to continue testing PLI 1 support. 2025-10-18 20:07:23 +01:00
Martin Whitaker 935910c3c9 Modify VPI test suite to make PLI 1 tests optional. 2025-10-18 20:05:58 +01:00
Martin Whitaker cf66c64e32 Make support for PLI 1 (libveriuser and cadpli) a config option.
PLI 1 was deprecated in 1364-2005, so disable by default and note that
it is deprecated in the help text.

This works round the problem that the clang linker (lld) in MSYS2 does
not support the -r option, so cannot be used to build libveriuser.a.
2025-10-18 20:02:48 +01:00
Martin Whitaker 8e2d543304 Rework makefiles to eliminate the use of dlltool in Windows builds.
The clang dlltool is not compatible with the binutils dlltool. However
both the clang and binutils linkers support reading the .def file and
creating the import library directly, so we no longer need to perform
the link in two stages.
2025-10-18 20:00:19 +01:00
Martin Whitaker 10770c9129 Optimise Perl regression test scripts.
When redirection operators are included in a command string passed to
the system() subroutine, it spawns an intermediate shell to handle the
redirection. This is particularly inefficient when running the tests
in MSYS2. Creating our own version of system() based on fork() and
exec() allows us to handle the redirection directly.
2025-10-17 20:58:05 +01:00
أحمد المحمودي (Ahmed El-Mahmoudy) 8de5e68e83 Add CPPFLAGS & LDFLAGS for building version.exe & draw_tt build targets
Those are needed to be able to add security hardening buold flags by
downstream package maintainers
2025-09-28 17:23:40 +02:00
136 changed files with 2156 additions and 1843 deletions

6
.github/test.sh vendored
View File

@ -9,7 +9,11 @@ status=0
perl vvp_reg.pl || status=1
perl vpi_reg.pl || status=1
if [ "x$1" = "xno-pli1" ] ; then
perl vpi_reg.pl || status=1
else
perl vpi_reg.pl --with-pli1 || status=1
fi
python3 vvp_reg.py || status=1

View File

@ -29,7 +29,7 @@ jobs:
run: |
export PATH="/usr/local/opt/bison/bin:$PATH"
autoconf
./configure
./configure --enable-libveriuser
make -j$(nproc) check
sudo make install
@ -59,7 +59,7 @@ jobs:
- name: Build, check and install
run: |
autoconf
./configure
./configure --enable-libveriuser
make -j$(nproc) check
sudo make install
@ -76,10 +76,11 @@ jobs:
strategy:
fail-fast: false
matrix:
include: [
{ msystem: MINGW64, arch: x86_64 }
]
name: 🟪 ${{ matrix.msystem}} · ${{ matrix.arch }}
include:
- { msystem: MINGW64, env: x86_64 }
- { msystem: UCRT64, env: ucrt-x86_64 }
- { msystem: CLANG64, env: clang-x86_64 }
name: 🟪 ${{ matrix.msystem}}
defaults:
run:
shell: msys2 {0}
@ -99,9 +100,8 @@ jobs:
install: >
git
base-devel
gperf
python-pip
mingw-w64-${{ matrix.arch }}-toolchain
mingw-w64-${{ matrix.env }}-perl
- uses: actions/setup-python@v5
with:
@ -110,6 +110,9 @@ jobs:
- name: Build and check
run: |
cd msys2
if [ ${{ matrix.msystem }} != "CLANG64" ] ; then
export IVL_CONFIG_OPTIONS="--enable-libveriuser"
fi
makepkg-mingw --noconfirm --noprogressbar -sCLf
- name: Install
@ -117,9 +120,13 @@ jobs:
- name: Test
run: |
./.github/test.sh
if [ ${{ matrix.msystem }} = "CLANG64" ] ; then
./.github/test.sh no-pli1
else
./.github/test.sh
fi
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.msystem }}-${{ matrix.arch }}
name: ${{ matrix.msystem }}
path: msys2/*.zst

View File

@ -1,7 +1,7 @@
#ifndef IVL_AStatement_H
#define IVL_AStatement_H
/*
* Copyright (c) 2008-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2008-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -40,10 +40,10 @@ class AContrib : public Statement {
public:
AContrib(PExpr*lval, PExpr*rval);
~AContrib();
~AContrib() override;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
private:
PExpr*lval_;
@ -61,7 +61,7 @@ class AProcess : public LineInfo {
AProcess(ivl_process_type_t t, Statement*st)
: type_(t), statement_(st) { }
~AProcess();
~AProcess() override;
bool elaborate(Design*des, NetScope*scope) const;

View File

@ -103,6 +103,22 @@ reference the correct run time files and directories. The run time will check
that it is running a file with a compatible version e.g.(you can not run a
V0.9 file with the V0.8 run time).
.. code-block:: none
--enable-libvvp
The vvp progam is built as a small stub linked to a shared library,
libvvp.so, that may be linked with other programs so that they can host
a vvp simulation.
.. code-block:: none
--enable-libveriuser
PLI version 1 (the ACC and TF routines) were deprecated in IEEE 1364-2005.
These are supported in Icarus Verilog by the libveriuser library and cadpli
module. Starting with v13, these will only be built if this option is used.
A debug options is:
.. code-block:: none
@ -111,7 +127,7 @@ A debug options is:
This option adds extra memory cleanup code and pool management code to allow
better memory leak checking when valgrind is available. This option is not
need when checking for basic errors with valgrind.
needed when checking for basic errors with valgrind.
Compiling on Linux
------------------
@ -222,4 +238,3 @@ or the version branch that you are working on. Your pull request will be run
through continuous integration, and reviewed by one of the main
authors. Feedback may be offered to your PR, and once accepted, an approved
individual will merge it for you. Then you are done.

View File

@ -99,13 +99,19 @@ time). ::
This option adds extra memory cleanup code and pool management code to allow
better memory leak checking when valgrind is available. This option is not
need when checking for basic errors with valgrind. ::
needed when checking for basic errors with valgrind. ::
--enable-libvvp
The vvp progam is built as a small stub linked to a shared library,
libvvp.so, that may be linked with other programs so that they can host
a vvp simulation.
a vvp simulation. ::
--enable-libveriuser
PLI version 1 (the ACC and TF routines) were deprecated in IEEE 1364-2005.
These are supported in Icarus Verilog by the libveriuser library and cadpli
module. Starting with v13, these will only be built if this option is used.
Compiling on Linux/Unix
-----------------------
@ -151,8 +157,8 @@ be updated to version 3. ::
Icarus Verilog is also available through the Homebrew package manager: "brew
install icarus-verilog".
Compiling for Windows
---------------------
Cross-Compiling for Windows
---------------------------
These are instructions for building Icarus Verilog binaries for
Windows using mingw cross compiler tools on Linux.
@ -180,4 +186,8 @@ bits that need to be compiled with the native compiler. (version.exe
for example is used by the build process but is not installed.) The
configure script should have gotten all that right.
There is also a MSYS2 build recipe which you can find under `msys2/` in the repository.
Compiling for Windows using MSYS2
---------------------------------
There is a MSYS2 build recipe which you can find under `msys2/` in the
repository. The accompanying README file provides further details.

View File

@ -37,11 +37,17 @@ exec_prefix = @exec_prefix@
srcdir = @srcdir@
datarootdir = @datarootdir@
SUBDIRS = ivlpp vhdlpp vvp vpi libveriuser cadpli tgt-null tgt-stub tgt-vvp \
SUBDIRS = ivlpp vhdlpp vvp vpi tgt-null tgt-stub tgt-vvp \
tgt-vhdl tgt-vlog95 tgt-pcb tgt-blif tgt-sizer driver
# Only run distclean for these directories.
NOTUSED = tgt-fpga tgt-pal tgt-verilog
ifeq (@LIBVERIUSER@,yes)
SUBDIRS += libveriuser cadpli
else
NOTUSED += libveriuser cadpli
endif
ifeq (@MINGW32@,yes)
SUBDIRS += driver-vpi
else
@ -75,7 +81,6 @@ BUILDCC = @CC_FOR_BUILD@
BUILDEXT = @BUILD_EXEEXT@
CC = @CC@
CXX = @CXX@
DLLTOOL = @DLLTOOL@
INSTALL = @INSTALL@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@ -179,6 +184,8 @@ endif
cppcheck: $(O:.o=.cc) $(srcdir)/dosify.c $(srcdir)/version.c
cppcheck --enable=all --std=c99 --std=c++11 -f \
--check-level=exhaustive \
--suppressions-list=$(srcdir)/cppcheck-global.sup \
--suppressions-list=$(srcdir)/cppcheck.sup \
-UYYPARSE_PARAM -UYYPRINT -Ushort -Usize_t -Uyyoverflow \
-UYYTYPE_INT8 -UYYTYPE_INT16 -UYYTYPE_UINT8 -UYYTYPE_UINT16 \
@ -214,15 +221,11 @@ config.status: $(srcdir)/configure
./config.status
ifeq (@WIN32@,yes)
# Under Windows (mingw) I need to make the ivl.exe in two steps.
# The first step makes an ivl.exe that dlltool can use to make an
# export and import library, and the last link makes a, ivl.exe
# that really exports the things that the import library imports.
# Under Windows we need to create an import library to allow the target code
# generators to access the items exported by ivl.exe. The .def file controls
# what is visible in the import library.
ivl@EXEEXT@: $O $(srcdir)/ivl.def
$(CXX) -o ivl@EXEEXT@ $O $(dllib) @EXTRALIBS@
$(DLLTOOL) --dllname ivl@EXEEXT@ --def $(srcdir)/ivl.def \
--output-lib libivl.a --output-exp ivl.exp
$(CXX) $(LDFLAGS) -o ivl@EXEEXT@ ivl.exp $O $(dllib) @EXTRALIBS@
$(CXX) $(LDFLAGS) -o ivl@EXEEXT@ -Wl,--out-implib=libivl.a $(srcdir)/ivl.def $O $(dllib) @EXTRALIBS@
else
ivl@EXEEXT@: $O
$(CXX) $(LDFLAGS) -o ivl@EXEEXT@ $O $(dllib)
@ -233,6 +236,7 @@ all: iverilog-vpi
iverilog-vpi: $(srcdir)/iverilog-vpi.sh Makefile
sed -e 's;@SHARED@;@shared@;' -e 's;@PIC@;@PICFLAG@;' \
-e 's;@ENABLE_PLI1@;@LIBVERIUSER@;' \
-e 's;@SUFFIX@;$(suffix);' \
-e 's;@IVCC@;$(CC);' \
-e 's;@IVCXX@;$(CXX);' \
@ -245,7 +249,7 @@ iverilog-vpi: $(srcdir)/iverilog-vpi.sh Makefile
endif
version.exe: $(srcdir)/version.c $(srcdir)/version_base.h version_tag.h
$(BUILDCC) $(CFLAGS) -o version.exe -I. -I$(srcdir) $(srcdir)/version.c
$(BUILDCC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o version.exe -I. -I$(srcdir) $(srcdir)/version.c
%.o: %.cc config.h
$(CXX) $(CPPFLAGS) $(CXXFLAGS) @DEPENDENCY_FLAG@ -c $< -o $*.o

View File

@ -1,7 +1,7 @@
#ifndef IVL_Module_H
#define IVL_Module_H
/*
* Copyright (c) 1998-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -74,7 +74,7 @@ class Module : public PScopeExtra, public PNamedItem {
/* The name passed here is the module name, not the instance
name. This name must be a permallocated string. */
explicit Module(LexicalScope*parent, perm_string name);
~Module();
~Module() override;
/* Initially false. This is set to true if the module has been
declared as a library module. This makes the module
@ -167,7 +167,7 @@ class Module : public PScopeExtra, public PNamedItem {
bool elaborate_sig(Design*, NetScope*scope) const;
SymbolType symbol_type() const;
SymbolType symbol_type() const override;
bool can_be_toplevel() const;

View File

@ -1,7 +1,7 @@
#ifndef IVL_PClass_H
#define IVL_PClass_H
/*
* Copyright (c) 2012-2019 Stephen Williams (steve@icarus.com)
* Copyright (c) 2012-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -36,11 +36,11 @@ class PClass : public PScopeExtra, public PNamedItem {
public:
explicit PClass (perm_string name, LexicalScope*parent);
~PClass();
~PClass() override;
void dump(std::ostream&out, unsigned indent) const;
SymbolType symbol_type() const;
SymbolType symbol_type() const override;
public:
class_type_t*type;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -132,8 +132,8 @@ static NetExpr* make_delay_nets(Design*des, NetScope*scope, NetExpr*expr)
static NetExpr* calc_decay_time(NetExpr *rise, NetExpr *fall)
{
NetEConst *c_rise = dynamic_cast<NetEConst*>(rise);
NetEConst *c_fall = dynamic_cast<NetEConst*>(fall);
const NetEConst *c_rise = dynamic_cast<NetEConst*>(rise);
const NetEConst *c_fall = dynamic_cast<NetEConst*>(fall);
if (c_rise && c_fall) {
if (c_rise->value() < c_fall->value()) return rise;
else return fall;

View File

@ -1,7 +1,7 @@
#ifndef IVL_PEvent_H
#define IVL_PEvent_H
/*
* Copyright (c) 2000-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -37,7 +37,7 @@ class PEvent : public PNamedItem {
// The name is a perm-allocated string. It is the simple name
// of the event, without any scope.
explicit PEvent(perm_string name, unsigned lexical_pos);
~PEvent();
~PEvent() override;
perm_string name() const;
@ -45,7 +45,7 @@ class PEvent : public PNamedItem {
void elaborate_scope(Design*des, NetScope*scope) const;
SymbolType symbol_type() const;
SymbolType symbol_type() const override;
private:
perm_string name_;

268
PExpr.h
View File

@ -60,7 +60,7 @@ class PExpr : public LineInfo {
static const char*width_mode_name(width_mode_t mode);
PExpr();
virtual ~PExpr();
virtual ~PExpr() override;
virtual void dump(std::ostream&) const;
@ -204,17 +204,17 @@ class PEAssignPattern : public PExpr {
public:
explicit PEAssignPattern();
explicit PEAssignPattern(const std::list<PExpr*>&p);
~PEAssignPattern();
~PEAssignPattern() override;
void dump(std::ostream&) const;
void dump(std::ostream&) const override;
virtual unsigned test_width(Design*des, NetScope*scope, width_mode_t&mode);
virtual unsigned test_width(Design*des, NetScope*scope, width_mode_t&mode) override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
ivl_type_t type, unsigned flags) const override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
unsigned expr_wid,
unsigned flags) const;
unsigned flags) const override;
private:
NetExpr* elaborate_expr_packed_(Design *des, NetScope *scope,
ivl_variable_type_t base_type,
@ -242,35 +242,35 @@ class PEConcat : public PExpr {
public:
explicit PEConcat(const std::list<PExpr*>&p, PExpr*r =0);
~PEConcat();
~PEConcat() override;
virtual void dump(std::ostream&) const;
virtual void dump(std::ostream&) const override;
virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type);
virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type) override;
virtual bool has_aa_term(Design*des, NetScope*scope) const;
virtual bool has_aa_term(Design*des, NetScope*scope) const override;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
virtual NetNet* elaborate_lnet(Design*des, NetScope*scope,
bool var_allowed_in_sv) const;
bool var_allowed_in_sv) const override;
virtual NetNet* elaborate_bi_net(Design*des, NetScope*scope,
bool var_allowed_in_sv) const;
bool var_allowed_in_sv) const override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
ivl_type_t type, unsigned flags) const override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
unsigned expr_wid,
unsigned flags) const;
unsigned flags) const override;
virtual NetAssign_* elaborate_lval(Design*des,
NetScope*scope,
bool is_cassign,
bool is_force,
bool is_init = false) const;
bool is_init = false) const override;
virtual bool is_collapsible_net(Design*des, NetScope*scope,
NetNet::PortType port_type) const;
NetNet::PortType port_type) const override;
private:
NetNet* elaborate_lnet_common_(Design*des, NetScope*scope,
bool bidirectional_flag,
@ -299,14 +299,14 @@ class PEEvent : public PExpr {
// Use this constructor to create events based on edges or levels.
PEEvent(edge_t t, PExpr*e);
~PEEvent();
~PEEvent() override;
edge_t type() const;
PExpr* expr() const;
virtual void dump(std::ostream&) const;
virtual void dump(std::ostream&) const override;
virtual bool has_aa_term(Design*des, NetScope*scope) const;
virtual bool has_aa_term(Design*des, NetScope*scope) const override;
private:
edge_t type_;
@ -320,19 +320,19 @@ class PEFNumber : public PExpr {
public:
explicit PEFNumber(verireal*vp);
~PEFNumber();
~PEFNumber() override;
const verireal& value() const;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
ivl_type_t type, unsigned flags) const;
ivl_type_t type, unsigned flags) const override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
unsigned expr_wid,
unsigned flags) const;
unsigned flags) const override;
virtual void dump(std::ostream&) const;
virtual void dump(std::ostream&) const override;
private:
verireal*value_;
@ -344,38 +344,38 @@ class PEIdent : public PExpr {
explicit PEIdent(perm_string, unsigned lexical_pos, bool no_implicit_sig=false);
explicit PEIdent(PPackage*pkg, const pform_name_t&name, unsigned lexical_pos);
explicit PEIdent(const pform_name_t&, unsigned lexical_pos);
~PEIdent();
~PEIdent() override;
// Add another name to the string of hierarchy that is the
// current identifier.
void append_name(perm_string);
virtual void dump(std::ostream&) const;
virtual void dump(std::ostream&) const override;
virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type);
virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type) override;
virtual bool has_aa_term(Design*des, NetScope*scope) const;
virtual bool has_aa_term(Design*des, NetScope*scope) const override;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
// Identifiers are allowed (with restrictions) is assign l-values.
virtual NetNet* elaborate_lnet(Design*des, NetScope*scope, bool var_allowed_in_sv) const;
virtual NetNet* elaborate_lnet(Design*des, NetScope*scope, bool var_allowed_in_sv) const override;
virtual NetNet* elaborate_bi_net(Design*des, NetScope*scope, bool var_allowed_in_sv) const;
virtual NetNet* elaborate_bi_net(Design*des, NetScope*scope, bool var_allowed_in_sv) const override;
// Identifiers are also allowed as procedural assignment l-values.
virtual NetAssign_* elaborate_lval(Design*des,
NetScope*scope,
bool is_cassign,
bool is_force,
bool is_init = false) const;
bool is_init = false) const override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
ivl_type_t type, unsigned flags) const override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
unsigned expr_wid,
unsigned flags) const;
unsigned flags) const override;
// Elaborate the PEIdent as a port to a module. This method
// only applies to Ident expressions.
@ -387,7 +387,7 @@ class PEIdent : public PExpr {
NetNet* elaborate_unpacked_net(Design*des, NetScope*sc) const;
virtual bool is_collapsible_net(Design*des, NetScope*scope,
NetNet::PortType port_type) const;
NetNet::PortType port_type) const override;
const pform_scoped_name_t& path() const { return path_; }
@ -412,7 +412,7 @@ class PEIdent : public PExpr {
// the values written to the msb/lsb arguments. If there are
// invalid bits (xz) in either expression, then the defined
// flag is set to *false*.
bool calculate_parts_(Design*, NetScope*, long&msb, long&lsb, bool&defined) const;
void calculate_parts_(Design*, NetScope*, long&msb, long&lsb, bool&defined) const;
NetExpr* calculate_up_do_base_(Design*, NetScope*, bool need_const) const;
bool calculate_up_do_width_(Design*, NetScope*, unsigned long&wid) const;
@ -426,7 +426,7 @@ class PEIdent : public PExpr {
// [2:0][x] - BAD
// [y][x] - BAD
// Leave the last index for special handling.
bool calculate_packed_indices_(Design*des, NetScope*scope, NetNet*net,
bool calculate_packed_indices_(Design*des, NetScope*scope, const NetNet*net,
std::list<long>&prefix_indices) const;
private:
@ -554,7 +554,7 @@ class PEIdent : public PExpr {
bool var_allowed_in_sv) const;
bool eval_part_select_(Design*des, NetScope*scope, NetNet*sig,
bool eval_part_select_(Design*des, NetScope*scope, const NetNet*sig,
long&midx, long&lidx) const;
};
@ -562,16 +562,16 @@ class PENewArray : public PExpr {
public:
explicit PENewArray (PExpr*s, PExpr*i);
~PENewArray();
~PENewArray() override;
virtual void dump(std::ostream&) const;
virtual void dump(std::ostream&) const override;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
ivl_type_t type, unsigned flags) const override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
unsigned expr_wid,
unsigned flags) const;
unsigned flags) const override;
private:
PExpr*size_;
@ -587,18 +587,18 @@ class PENewClass : public PExpr {
explicit PENewClass (const std::list<named_pexpr_t> &p,
data_type_t *class_type = nullptr);
~PENewClass();
~PENewClass() override;
virtual void dump(std::ostream&) const;
virtual void dump(std::ostream&) const override;
// Class objects don't have a useful width, but the expression
// is IVL_VT_CLASS.
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
// Note that class (new) expressions only appear in context
// that uses this form of the elaborate_expr method. In fact,
// the type argument is going to be a netclass_t object.
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
ivl_type_t type, unsigned flags) const override;
private:
NetExpr* elaborate_expr_constructor_(Design*des, NetScope*scope,
@ -613,18 +613,18 @@ class PENewClass : public PExpr {
class PENewCopy : public PExpr {
public:
explicit PENewCopy(PExpr*src);
~PENewCopy();
~PENewCopy() override;
virtual void dump(std::ostream&) const;
virtual void dump(std::ostream&) const override;
// Class objects don't have a useful width, but the expression
// is IVL_VT_CLASS.
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
// Note that class (new) expressions only appear in context
// that uses this form of the elaborate_expr method. In fact,
// the type argument is going to be a netclass_t object.
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
ivl_type_t type, unsigned flags) const override;
private:
PExpr*src_;
@ -633,39 +633,39 @@ class PENewCopy : public PExpr {
class PENull : public PExpr {
public:
explicit PENull();
~PENull();
~PENull() override;
virtual void dump(std::ostream&) const;
virtual void dump(std::ostream&) const override;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
ivl_type_t type, unsigned flags) const override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
unsigned expr_wid,
unsigned flags) const;
unsigned flags) const override;
};
class PENumber : public PExpr {
public:
explicit PENumber(verinum*vp);
~PENumber();
~PENumber() override;
const verinum& value() const;
virtual void dump(std::ostream&) const;
virtual void dump(std::ostream&) const override;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
virtual NetExpr *elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
ivl_type_t type, unsigned flags) const override;
virtual NetEConst*elaborate_expr(Design*des, NetScope*,
unsigned expr_wid, unsigned) const;
unsigned expr_wid, unsigned) const override;
virtual NetAssign_* elaborate_lval(Design*des,
NetScope*scope,
bool is_cassign,
bool is_force,
bool is_init = false) const;
bool is_init = false) const override;
private:
verinum*const value_;
@ -682,19 +682,19 @@ class PEString : public PExpr {
public:
explicit PEString(char*s);
~PEString();
~PEString() override;
std::string value() const;
virtual void dump(std::ostream&) const;
virtual void dump(std::ostream&) const override;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
virtual NetEConst*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
ivl_type_t type, unsigned flags) const override;
virtual NetEConst*elaborate_expr(Design*des, NetScope*,
unsigned expr_wid, unsigned) const;
unsigned expr_wid, unsigned) const override;
private:
char*text_;
@ -703,13 +703,13 @@ class PEString : public PExpr {
class PETypename : public PExpr {
public:
explicit PETypename(data_type_t*data_type);
~PETypename();
~PETypename() override;
virtual void dump(std::ostream&) const;
virtual void dump(std::ostream&) const override;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
ivl_type_t type, unsigned flags) const override;
inline data_type_t* get_type() const { return data_type_; }
@ -721,20 +721,20 @@ class PEUnary : public PExpr {
public:
explicit PEUnary(char op, PExpr*ex);
~PEUnary();
~PEUnary() override;
virtual void dump(std::ostream&out) const;
virtual void dump(std::ostream&out) const override;
virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type);
virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type) override;
virtual bool has_aa_term(Design*des, NetScope*scope) const;
virtual bool has_aa_term(Design*des, NetScope*scope) const override;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
unsigned expr_wid,
unsigned flags) const;
unsigned flags) const override;
public:
inline char get_op() const { return op_; }
@ -752,20 +752,20 @@ class PEBinary : public PExpr {
public:
explicit PEBinary(char op, PExpr*l, PExpr*r);
~PEBinary();
~PEBinary() override;
virtual void dump(std::ostream&out) const;
virtual void dump(std::ostream&out) const override;
virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type);
virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type) override;
virtual bool has_aa_term(Design*des, NetScope*scope) const;
virtual bool has_aa_term(Design*des, NetScope*scope) const override;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
unsigned expr_wid,
unsigned flags) const;
unsigned flags) const override;
protected:
char op_;
@ -796,13 +796,13 @@ class PEBComp : public PEBinary {
public:
explicit PEBComp(char op, PExpr*l, PExpr*r);
~PEBComp();
~PEBComp() override;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
NetExpr* elaborate_expr(Design*des, NetScope*scope,
unsigned expr_wid, unsigned flags) const;
unsigned expr_wid, unsigned flags) const override;
private:
unsigned l_width_;
@ -816,13 +816,13 @@ class PEBLogic : public PEBinary {
public:
explicit PEBLogic(char op, PExpr*l, PExpr*r);
~PEBLogic();
~PEBLogic() override;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
NetExpr* elaborate_expr(Design*des, NetScope*scope,
unsigned expr_wid, unsigned flags) const;
unsigned expr_wid, unsigned flags) const override;
};
/*
@ -834,38 +834,38 @@ class PEBLeftWidth : public PEBinary {
public:
explicit PEBLeftWidth(char op, PExpr*l, PExpr*r);
~PEBLeftWidth() =0;
~PEBLeftWidth() override =0;
virtual NetExpr*elaborate_expr_leaf(Design*des, NetExpr*lp, NetExpr*rp,
unsigned expr_wid) const =0;
protected:
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
unsigned expr_wid,
unsigned flags) const;
unsigned flags) const override;
};
class PEBPower : public PEBLeftWidth {
public:
explicit PEBPower(char op, PExpr*l, PExpr*r);
~PEBPower();
~PEBPower() override;
NetExpr*elaborate_expr_leaf(Design*des, NetExpr*lp, NetExpr*rp,
unsigned expr_wid) const;
unsigned expr_wid) const override;
};
class PEBShift : public PEBLeftWidth {
public:
explicit PEBShift(char op, PExpr*l, PExpr*r);
~PEBShift();
~PEBShift() override;
NetExpr*elaborate_expr_leaf(Design*des, NetExpr*lp, NetExpr*rp,
unsigned expr_wid) const;
unsigned expr_wid) const override;
};
/*
@ -876,20 +876,20 @@ class PETernary : public PExpr {
public:
explicit PETernary(PExpr*e, PExpr*t, PExpr*f);
~PETernary();
~PETernary() override;
virtual void dump(std::ostream&out) const;
virtual void dump(std::ostream&out) const override;
virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type);
virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type) override;
virtual bool has_aa_term(Design*des, NetScope*scope) const;
virtual bool has_aa_term(Design*des, NetScope*scope) const override;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
unsigned expr_wid,
unsigned flags) const;
unsigned flags) const override;
private:
NetExpr* elab_and_eval_alternative_(Design*des, NetScope*scope,
@ -924,22 +924,22 @@ class PECallFunction : public PExpr {
explicit PECallFunction(const pform_name_t &n, const std::list<named_pexpr_t> &parms);
explicit PECallFunction(perm_string n, const std::list<named_pexpr_t> &parms);
~PECallFunction();
~PECallFunction() override;
virtual void dump(std::ostream &) const;
virtual void dump(std::ostream &) const override;
virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type);
virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type) override;
virtual bool has_aa_term(Design*des, NetScope*scope) const;
virtual bool has_aa_term(Design*des, NetScope*scope) const override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
ivl_type_t type, unsigned flags) const override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
unsigned expr_wid, unsigned flags) const;
unsigned expr_wid, unsigned flags) const override;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
private:
pform_scoped_name_t path_;
@ -959,8 +959,8 @@ class PECallFunction : public PExpr {
NetExpr* elaborate_expr_method_(Design*des, NetScope*scope,
symbol_search_results&search_results)
const;
NetExpr* elaborate_expr_method_par_(Design*des, NetScope*scope,
symbol_search_results&search_results)
NetExpr* elaborate_expr_method_par_(Design*des, const NetScope*scope,
const symbol_search_results&search_results)
const;
@ -972,16 +972,16 @@ class PECallFunction : public PExpr {
unsigned test_width_sfunc_(Design*des, NetScope*scope,
width_mode_t&mode);
unsigned test_width_method_(Design*des, NetScope*scope,
symbol_search_results&search_results,
const symbol_search_results&search_results,
width_mode_t&mode);
NetExpr*elaborate_base_(Design*des, NetScope*scope, NetScope*dscope,
unsigned flags) const;
unsigned elaborate_arguments_(Design*des, NetScope*scope,
NetFuncDef*def, bool need_const,
std::vector<NetExpr*>&parms,
unsigned parm_off) const;
const NetFuncDef*def, bool need_const,
std::vector<NetExpr*>&parms,
unsigned parm_off) const;
};
/*
@ -991,18 +991,18 @@ class PECastSize : public PExpr {
public:
explicit PECastSize(PExpr*size, PExpr*base);
~PECastSize();
~PECastSize() override;
void dump(std::ostream &out) const;
void dump(std::ostream &out) const override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
unsigned expr_wid,
unsigned flags) const;
unsigned flags) const override;
virtual bool has_aa_term(Design *des, NetScope *scope) const;
virtual bool has_aa_term(Design *des, NetScope *scope) const override;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
private:
PExpr* size_;
@ -1016,20 +1016,20 @@ class PECastType : public PExpr {
public:
explicit PECastType(data_type_t*target, PExpr*base);
~PECastType();
~PECastType() override;
void dump(std::ostream &out) const;
void dump(std::ostream &out) const override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
ivl_type_t type, unsigned flags) const override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
unsigned expr_wid, unsigned flags) const;
unsigned expr_wid, unsigned flags) const override;
virtual bool has_aa_term(Design *des, NetScope *scope) const;
virtual bool has_aa_term(Design *des, NetScope *scope) const override;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
width_mode_t&mode) override;
private:
data_type_t* target_;
@ -1044,16 +1044,16 @@ class PECastSign : public PExpr {
public:
explicit PECastSign(bool signed_flag, PExpr *base);
~PECastSign() = default;
~PECastSign() override = default;
void dump(std::ostream &out) const;
void dump(std::ostream &out) const override;
NetExpr* elaborate_expr(Design *des, NetScope *scope,
unsigned expr_wid, unsigned flags) const;
unsigned expr_wid, unsigned flags) const override;
virtual bool has_aa_term(Design *des, NetScope *scope) const;
virtual bool has_aa_term(Design *des, NetScope *scope) const override;
unsigned test_width(Design *des, NetScope *scope, width_mode_t &mode);
unsigned test_width(Design *des, NetScope *scope, width_mode_t &mode) override;
private:
std::unique_ptr<PExpr> base_;
@ -1067,11 +1067,11 @@ class PEVoid : public PExpr {
public:
explicit PEVoid();
~PEVoid();
~PEVoid() override;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
unsigned expr_wid,
unsigned flags) const;
unsigned flags) const override;
};
#endif /* IVL_PExpr_H */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -148,7 +148,7 @@ PGAssign::~PGAssign()
PGBuiltin::PGBuiltin(Type t, perm_string name,
list<PExpr*>*pins,
list<PExpr*>*del)
const list<PExpr*>*del)
: PGate(name, pins, del), type_(t)
{
}

36
PGate.h
View File

@ -1,7 +1,7 @@
#ifndef IVL_PGate_H
#define IVL_PGate_H
/*
* Copyright (c) 1998-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -57,7 +57,7 @@ class PGate : public PNamedItem {
explicit PGate(perm_string name, std::list<PExpr*>*pins);
virtual ~PGate();
virtual ~PGate() override;
void set_ranges(std::list<pform_range_t>*ranges);
bool is_array() const { return ranges_ != 0; }
@ -90,7 +90,7 @@ class PGate : public PNamedItem {
virtual void elaborate_scope(Design*des, NetScope*sc) const;
virtual bool elaborate_sig(Design*des, NetScope*scope) const;
SymbolType symbol_type() const;
SymbolType symbol_type() const override;
protected:
const std::vector<PExpr*>& get_pins() const { return pins_; }
@ -127,11 +127,11 @@ class PGAssign : public PGate {
public:
explicit PGAssign(std::list<PExpr*>*pins);
explicit PGAssign(std::list<PExpr*>*pins, std::list<PExpr*>*dels);
~PGAssign();
~PGAssign() override;
void dump(std::ostream&out, unsigned ind =4) const;
virtual void elaborate(Design*des, NetScope*scope) const;
virtual bool elaborate_sig(Design*des, NetScope*scope) const;
void dump(std::ostream&out, unsigned ind =4) const override;
virtual void elaborate(Design*des, NetScope*scope) const override;
virtual bool elaborate_sig(Design*des, NetScope*scope) const override;
private:
void elaborate_unpacked_array_(Design*des, NetScope*scope, NetNet*lval) const;
@ -159,18 +159,18 @@ class PGBuiltin : public PGate {
public:
explicit PGBuiltin(Type t, perm_string name,
std::list<PExpr*>*pins,
std::list<PExpr*>*del);
const std::list<PExpr*>*del);
explicit PGBuiltin(Type t, perm_string name,
std::list<PExpr*>*pins,
PExpr*del);
~PGBuiltin();
~PGBuiltin() override;
Type type() const { return type_; }
const char * gate_name() const;
virtual void dump(std::ostream&out, unsigned ind =4) const;
virtual void elaborate(Design*, NetScope*scope) const;
virtual bool elaborate_sig(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind =4) const override;
virtual void elaborate(Design*, NetScope*scope) const override;
virtual bool elaborate_sig(Design*des, NetScope*scope) const override;
private:
void calculate_gate_and_lval_count_(unsigned&gate_count,
@ -210,7 +210,7 @@ class PGModule : public PGate {
// constructor.
explicit PGModule(Module*type, perm_string name);
~PGModule();
~PGModule() override;
// Parameter overrides can come as an ordered list, or a set
// of named expressions.
@ -219,10 +219,10 @@ class PGModule : public PGate {
std::map<perm_string,PExpr*> attributes;
virtual void dump(std::ostream&out, unsigned ind =4) const;
virtual void elaborate(Design*, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*sc) const;
virtual bool elaborate_sig(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind =4) const override;
virtual void elaborate(Design*, NetScope*scope) const override;
virtual void elaborate_scope(Design*des, NetScope*sc) const override;
virtual bool elaborate_sig(Design*des, NetScope*scope) const override;
// This returns the module name of this module. It is a
// permallocated string.
@ -244,7 +244,7 @@ class PGModule : public PGate {
void elaborate_udp_(Design*, PUdp *udp, NetScope*scope) const;
void elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const;
void elaborate_scope_mod_instances_(Design*des, Module*mod, NetScope*sc) const;
bool elaborate_sig_mod_(Design*des, NetScope*scope, Module*mod) const;
bool elaborate_sig_mod_(Design*des, NetScope*scope, const Module*mod) const;
// Not currently used.
#if 0
bool elaborate_sig_udp_(Design*des, NetScope*scope, PUdp*udp) const;

View File

@ -1,7 +1,7 @@
#ifndef IVL_PGenerate_H
#define IVL_PGenerate_H
/*
* Copyright (c) 2006-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2006-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -54,7 +54,7 @@ class PGenerate : public PNamedItem, public LexicalScope {
public:
explicit PGenerate(LexicalScope*parent, unsigned id_number);
~PGenerate();
~PGenerate() override;
// Generate schemes have an ID number, for when the scope is
// implicit.
@ -112,7 +112,7 @@ class PGenerate : public PNamedItem, public LexicalScope {
void dump(std::ostream&out, unsigned indent) const;
SymbolType symbol_type() const;
SymbolType symbol_type() const override;
private:
void check_for_valid_genvar_value_(long value);

View File

@ -1,7 +1,7 @@
#ifndef IVL_PModport_H
#define IVL_PModport_H
/*
* Copyright (c) 2015-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2015-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -34,14 +34,14 @@ class PModport : public PNamedItem {
// The name is a perm-allocated string. It is the simple name
// of the modport, without any scope.
explicit PModport(perm_string name);
~PModport();
~PModport() override;
perm_string name() const { return name_; }
typedef std::pair <NetNet::PortType,PExpr*> simple_port_t;
std::map<perm_string,simple_port_t> simple_ports;
SymbolType symbol_type() const;
SymbolType symbol_type() const override;
private:
perm_string name_;

View File

@ -1,7 +1,7 @@
#ifndef IVL_PNamedItem_H
#define IVL_PNamedItem_H
/*
* Copyright (c) 2019 Martin Whitaker (icarus@martin-whitaker.me.uk)
* Copyright (c) 2019-2025 Martin Whitaker (icarus@martin-whitaker.me.uk)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -34,7 +34,7 @@ class PNamedItem : virtual public LineInfo {
INSTANCE };
explicit PNamedItem();
virtual ~PNamedItem();
virtual ~PNamedItem() override;
virtual SymbolType symbol_type() const;
};
@ -49,9 +49,9 @@ class PGenvar : public PNamedItem {
public:
explicit PGenvar();
virtual ~PGenvar();
virtual ~PGenvar() override;
SymbolType symbol_type() const;
SymbolType symbol_type() const override;
};
#endif /* IVL_PNamedItem_H */

View File

@ -1,7 +1,7 @@
#ifndef IVL_PPackage_H
#define IVL_PPackage_H
/*
* Copyright (c) 2012-2014 Stephen Williams (steve@icarus.com)
* Copyright (c) 2012-2025 Stephen Williams (steve@icarus.com)
* Copyright CERN 2013 / Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
@ -36,7 +36,7 @@ class PPackage : public PScopeExtra, public LineInfo {
public:
explicit PPackage (perm_string name, LexicalScope*parent);
~PPackage();
~PPackage() override;
bool elaborate_scope(Design*des, NetScope*scope);
bool elaborate_sig(Design*des, NetScope*scope) const;

View File

@ -1,7 +1,7 @@
#ifndef IVL_PScope_H
#define IVL_PScope_H
/*
* Copyright (c) 2008-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 2008-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -198,7 +198,7 @@ class PScope : public LexicalScope {
// modules. Scopes for tasks and functions point to their
// containing module.
explicit PScope(perm_string name, LexicalScope*parent =0);
virtual ~PScope();
virtual ~PScope() override;
perm_string pscope_name() const { return name_; }
@ -233,7 +233,7 @@ class PScopeExtra : public PScope {
public:
explicit PScopeExtra(perm_string, LexicalScope*parent =0);
~PScopeExtra();
~PScopeExtra() override;
/* Task definitions within this module */
std::map<perm_string,PTask*> tasks;

View File

@ -1,7 +1,7 @@
#ifndef IVL_PSpec_H
#define IVL_PSpec_H
/*
* Copyright (c) 2006-2014 Stephen Williams <steve@icarus.com>
* Copyright (c) 2006-2025 Stephen Williams <steve@icarus.com>
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -60,7 +60,7 @@ class PSpecPath : public LineInfo {
PSpecPath(const std::list<perm_string> &src_list,
const std::list<perm_string> &dst_list,
char polarity, bool full_flag);
~PSpecPath();
~PSpecPath() override;
void elaborate(class Design*des, class NetScope*scope) const;

34
PTask.h
View File

@ -1,7 +1,7 @@
#ifndef IVL_PTask_H
#define IVL_PTask_H
/*
* Copyright (c) 1999-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -39,9 +39,9 @@ class PTaskFunc : public PScope, public PNamedItem {
public:
PTaskFunc(perm_string name, LexicalScope*parent);
~PTaskFunc();
~PTaskFunc() override;
bool var_init_needs_explicit_lifetime() const;
bool var_init_needs_explicit_lifetime() const override;
void set_ports(std::vector<pform_tf_port_t>*p);
@ -80,7 +80,7 @@ class PTask : public PTaskFunc {
public:
explicit PTask(perm_string name, LexicalScope*parent, bool is_auto);
~PTask();
~PTask() override;
void set_statement(Statement *s);
@ -91,16 +91,16 @@ class PTask : public PTaskFunc {
void elaborate_scope(Design*des, NetScope*scope) const;
// Bind the ports to the regs that are the ports.
void elaborate_sig(Design*des, NetScope*scope) const;
void elaborate_sig(Design*des, NetScope*scope) const override;
// Elaborate the statement to finish off the task definition.
void elaborate(Design*des, NetScope*scope) const;
void elaborate(Design*des, NetScope*scope) const override;
bool is_auto() const { return is_auto_; };
void dump(std::ostream&, unsigned) const;
void dump(std::ostream&, unsigned) const override;
SymbolType symbol_type() const;
SymbolType symbol_type() const override;
private:
Statement*statement_;
@ -122,7 +122,7 @@ class PFunction : public PTaskFunc {
public:
explicit PFunction(perm_string name, LexicalScope*parent, bool is_auto);
~PFunction();
~PFunction() override;
void set_statement(Statement *s);
void set_return(data_type_t*t);
@ -142,16 +142,16 @@ class PFunction : public PTaskFunc {
void elaborate_scope(Design*des, NetScope*scope) const;
/* elaborate the ports and return value. */
void elaborate_sig(Design *des, NetScope*) const;
void elaborate_sig(Design *des, NetScope*) const override;
/* Elaborate the behavioral statement. */
void elaborate(Design *des, NetScope*) const;
void elaborate(Design *des, NetScope*) const override;
bool is_auto() const { return is_auto_; };
void dump(std::ostream&, unsigned) const;
void dump(std::ostream&, unsigned) const override;
SymbolType symbol_type() const;
SymbolType symbol_type() const override;
private:
data_type_t* return_type_;
@ -174,12 +174,12 @@ class PLet : public PTaskFunc {
// FIXME: Should the port list be a vector. Check once implemented completely
explicit PLet(perm_string name, LexicalScope*parent,
std::list<let_port_t*>*ports, PExpr*expr);
~PLet();
~PLet() override;
void elaborate_sig(Design*des, NetScope*scope) const { (void)des; (void)scope; }
void elaborate(Design*des, NetScope*scope) const { (void)des; (void)scope; }
void elaborate_sig(Design*des, NetScope*scope) const override { (void)des; (void)scope; }
void elaborate(Design*des, NetScope*scope) const override { (void)des; (void)scope; }
void dump(std::ostream&, unsigned) const;
void dump(std::ostream&, unsigned) const override;
private:
std::list<let_port_t*>*ports_;

View File

@ -1,7 +1,7 @@
#ifndef IVL_PTimingCheck_H
#define IVL_PTimingCheck_H
/*
* Copyright (c) 2006-2023 Stephen Williams <steve@icarus.com>
* Copyright (c) 2006-2025 Stephen Williams <steve@icarus.com>
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -52,7 +52,7 @@ class PTimingCheck : public LineInfo {
};
PTimingCheck() { }
virtual ~PTimingCheck() { }
virtual ~PTimingCheck() override { }
virtual void elaborate(class Design*des, class NetScope*scope) const = 0;
@ -76,7 +76,7 @@ class PRecRem : public PTimingCheck {
pform_name_t* delayed_reference,
pform_name_t* delayed_data);
~PRecRem();
~PRecRem() override;
void elaborate(class Design*des, class NetScope*scope) const override;
@ -114,7 +114,7 @@ class PSetupHold : public PTimingCheck {
pform_name_t* delayed_reference,
pform_name_t* delayed_data);
~PSetupHold();
~PSetupHold() override;
void elaborate(class Design*des, class NetScope*scope) const override;

View File

@ -1,7 +1,7 @@
#ifndef IVL_PWire_H
#define IVL_PWire_H
/*
* Copyright (c) 1998-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -93,7 +93,7 @@ class PWire : public PNamedItem {
NetNet* elaborate_sig(Design*, NetScope*scope);
SymbolType symbol_type() const;
SymbolType symbol_type() const override;
bool is_net() const { return net_set_; };
bool is_port() const { return port_set_; };

View File

@ -1,7 +1,7 @@
#ifndef IVL_Statement_H
#define IVL_Statement_H
/*
* Copyright (c) 1998-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -53,7 +53,7 @@ class PProcess : public LineInfo {
PProcess(ivl_process_type_t t, Statement*st)
: type_(t), statement_(st) { }
virtual ~PProcess();
virtual ~PProcess() override;
bool elaborate(Design*des, NetScope*scope) const;
@ -78,7 +78,7 @@ class Statement : virtual public LineInfo {
public:
Statement() { }
virtual ~Statement() =0;
virtual ~Statement() override =0;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
@ -99,7 +99,7 @@ class PAssign_ : public Statement {
bool is_init = false);
explicit PAssign_(PExpr*lval, PExpr*de, PExpr*ex);
explicit PAssign_(PExpr*lval, PExpr*cnt, PEventStatement*de, PExpr*ex);
virtual ~PAssign_() =0;
virtual ~PAssign_() override =0;
const PExpr* lval() const { return lval_; }
PExpr* rval() const { return rval_; }
@ -139,10 +139,10 @@ class PAssign : public PAssign_ {
explicit PAssign(PExpr*lval, PExpr*de, PExpr*ex);
explicit PAssign(PExpr*lval, PExpr*cnt, PEventStatement*de, PExpr*ex);
explicit PAssign(PExpr*lval, PExpr*ex, bool is_constant, bool is_init);
~PAssign();
~PAssign() override;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
private:
NetProc* elaborate_compressed_(Design*des, NetScope*scope) const;
@ -155,10 +155,10 @@ class PAssignNB : public PAssign_ {
explicit PAssignNB(PExpr*lval, PExpr*ex);
explicit PAssignNB(PExpr*lval, PExpr*de, PExpr*ex);
explicit PAssignNB(PExpr*lval, PExpr*cnt, PEventStatement*de, PExpr*ex);
~PAssignNB();
~PAssignNB() override;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
private:
NetProc*assign_to_memory_(class NetMemory*, PExpr*,
@ -181,11 +181,11 @@ class PBlock : public PScope, public Statement, public PNamedItem {
explicit PBlock(perm_string n, LexicalScope*parent, BL_TYPE t);
// If it doesn't have a name, it's not a scope
explicit PBlock(BL_TYPE t);
~PBlock();
~PBlock() override;
BL_TYPE bl_type() const { return bl_type_; }
bool var_init_needs_explicit_lifetime() const;
bool var_init_needs_explicit_lifetime() const override;
// This is only used if this block is the statement list for a
// constructor. We look for a PChainConstructor as the first
@ -202,12 +202,12 @@ class PBlock : public PScope, public Statement, public PNamedItem {
// block.
void push_statement_front(Statement*that);
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void elaborate_sig(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
virtual void elaborate_scope(Design*des, NetScope*scope) const override;
virtual void elaborate_sig(Design*des, NetScope*scope) const override;
SymbolType symbol_type() const;
SymbolType symbol_type() const override;
private:
BL_TYPE bl_type_;
@ -216,8 +216,8 @@ class PBlock : public PScope, public Statement, public PNamedItem {
class PBreak : public Statement {
public:
void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
void dump(std::ostream&out, unsigned ind) const override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
};
class PCallTask : public Statement {
@ -226,12 +226,12 @@ class PCallTask : public Statement {
explicit PCallTask(PPackage *pkg, const pform_name_t &n, const std::list<named_pexpr_t> &parms);
explicit PCallTask(const pform_name_t &n, const std::list<named_pexpr_t> &parms);
explicit PCallTask(perm_string n, const std::list<named_pexpr_t> &parms);
~PCallTask();
~PCallTask() override;
const pform_name_t& path() const;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
bool elaborate_elab(Design*des, NetScope*scope) const;
@ -265,7 +265,7 @@ class PCallTask : public Statement {
ivl_type_t type,
perm_string method_name,
const char*sys_task_name) const;
bool test_task_calls_ok_(Design*des, NetScope*scope) const;
bool test_task_calls_ok_(Design*des, const NetScope*scope) const;
PPackage*package_;
pform_name_t path_;
@ -282,12 +282,12 @@ class PCase : public Statement {
};
PCase(ivl_case_quality_t, NetCase::TYPE, PExpr*ex, std::vector<Item*>*);
~PCase();
~PCase() override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void elaborate_sig(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
virtual void elaborate_scope(Design*des, NetScope*scope) const override;
virtual void elaborate_sig(Design*des, NetScope*scope) const override;
virtual void dump(std::ostream&out, unsigned ind) const override;
private:
ivl_case_quality_t quality_;
@ -305,10 +305,10 @@ class PCAssign : public Statement {
public:
explicit PCAssign(PExpr*l, PExpr*r);
~PCAssign();
~PCAssign() override;
virtual NetCAssign* elaborate(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetCAssign* elaborate(Design*des, NetScope*scope) const override;
virtual void dump(std::ostream&out, unsigned ind) const override;
private:
PExpr*lval_;
@ -324,10 +324,10 @@ class PChainConstructor : public Statement {
public:
explicit PChainConstructor(const std::list<named_pexpr_t> &parms);
explicit PChainConstructor(const std::vector<named_pexpr_t> &parms);
~PChainConstructor();
~PChainConstructor() override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
virtual void dump(std::ostream&out, unsigned ind) const override;
inline const std::vector<named_pexpr_t>& chain_args(void) const
{ return parms_; }
@ -340,12 +340,12 @@ class PCondit : public Statement {
public:
PCondit(PExpr*ex, Statement*i, Statement*e);
~PCondit();
~PCondit() override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void elaborate_sig(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
virtual void elaborate_scope(Design*des, NetScope*scope) const override;
virtual void elaborate_sig(Design*des, NetScope*scope) const override;
virtual void dump(std::ostream&out, unsigned ind) const override;
private:
PExpr*expr_;
@ -360,18 +360,18 @@ class PCondit : public Statement {
class PContinue : public Statement {
public:
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
};
class PDeassign : public Statement {
public:
explicit PDeassign(PExpr*l);
~PDeassign();
~PDeassign() override;
virtual NetDeassign* elaborate(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetDeassign* elaborate(Design*des, NetScope*scope) const override;
virtual void dump(std::ostream&out, unsigned ind) const override;
private:
PExpr*lval_;
@ -381,12 +381,12 @@ class PDelayStatement : public Statement {
public:
PDelayStatement(PExpr*d, Statement*st);
~PDelayStatement();
~PDelayStatement() override;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void elaborate_sig(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
virtual void elaborate_scope(Design*des, NetScope*scope) const override;
virtual void elaborate_sig(Design*des, NetScope*scope) const override;
private:
PExpr*delay_;
@ -401,10 +401,10 @@ class PDisable : public Statement {
public:
explicit PDisable(const pform_name_t&sc);
~PDisable();
~PDisable() override;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
private:
pform_name_t scope_;
@ -414,12 +414,12 @@ class PDoWhile : public Statement {
public:
PDoWhile(PExpr*ex, Statement*st);
~PDoWhile();
~PDoWhile() override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void elaborate_sig(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
virtual void elaborate_scope(Design*des, NetScope*scope) const override;
virtual void elaborate_sig(Design*des, NetScope*scope) const override;
virtual void dump(std::ostream&out, unsigned ind) const override;
private:
PExpr*cond_;
@ -444,17 +444,17 @@ class PEventStatement : public Statement {
// from functions added and outputs removed for always_comb/latch.
explicit PEventStatement(bool always_sens = false);
~PEventStatement();
~PEventStatement() override;
void set_statement(Statement*st);
virtual void dump(std::ostream&out, unsigned ind) const;
virtual void dump(std::ostream&out, unsigned ind) const override;
// Call this with a NULL statement only. It is used to print
// the event expression for inter-assignment event controls.
virtual void dump_inline(std::ostream&out) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void elaborate_sig(Design*des, NetScope*scope) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
virtual void elaborate_scope(Design*des, NetScope*scope) const override;
virtual void elaborate_sig(Design*des, NetScope*scope) const override;
bool has_aa_term(Design*des, NetScope*scope);
@ -463,7 +463,7 @@ class PEventStatement : public Statement {
NetProc* elaborate_st(Design*des, NetScope*scope, NetProc*st) const;
NetProc* elaborate_wait(Design*des, NetScope*scope, NetProc*st) const;
NetProc* elaborate_wait_fork(Design*des, NetScope*scope) const;
NetProc* elaborate_wait_fork(Design*des, const NetScope*scope) const;
private:
std::vector<PEEvent*>expr_;
@ -477,10 +477,10 @@ class PForce : public Statement {
public:
explicit PForce(PExpr*l, PExpr*r);
~PForce();
~PForce() override;
virtual NetForce* elaborate(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetForce* elaborate(Design*des, NetScope*scope) const override;
virtual void dump(std::ostream&out, unsigned ind) const override;
private:
PExpr*lval_;
@ -490,12 +490,12 @@ class PForce : public Statement {
class PForeach : public Statement {
public:
explicit PForeach(perm_string var, const std::list<perm_string>&ix, Statement*stmt);
~PForeach();
~PForeach() override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void elaborate_sig(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
virtual void elaborate_scope(Design*des, NetScope*scope) const override;
virtual void elaborate_sig(Design*des, NetScope*scope) const override;
virtual void dump(std::ostream&out, unsigned ind) const override;
private:
NetProc* elaborate_static_array_(Design*des, NetScope*scope,
@ -510,12 +510,12 @@ class PForeach : public Statement {
class PForever : public Statement {
public:
explicit PForever(Statement*s);
~PForever();
~PForever() override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void elaborate_sig(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
virtual void elaborate_scope(Design*des, NetScope*scope) const override;
virtual void elaborate_sig(Design*des, NetScope*scope) const override;
virtual void dump(std::ostream&out, unsigned ind) const override;
private:
Statement*statement_;
@ -526,12 +526,12 @@ class PForStatement : public Statement {
public:
PForStatement(PExpr*n1, PExpr*e1, PExpr*cond,
Statement*step, Statement*body);
~PForStatement();
~PForStatement() override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void elaborate_sig(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
virtual void elaborate_scope(Design*des, NetScope*scope) const override;
virtual void elaborate_sig(Design*des, NetScope*scope) const override;
virtual void dump(std::ostream&out, unsigned ind) const override;
private:
PExpr* name1_;
@ -548,18 +548,18 @@ class PNoop : public Statement {
public:
PNoop() { }
~PNoop() { }
~PNoop() override { }
};
class PRepeat : public Statement {
public:
explicit PRepeat(PExpr*expr, Statement*s);
~PRepeat();
~PRepeat() override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void elaborate_sig(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
virtual void elaborate_scope(Design*des, NetScope*scope) const override;
virtual void elaborate_sig(Design*des, NetScope*scope) const override;
virtual void dump(std::ostream&out, unsigned ind) const override;
private:
PExpr*expr_;
@ -570,10 +570,10 @@ class PRelease : public Statement {
public:
explicit PRelease(PExpr*l);
~PRelease();
~PRelease() override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
virtual void dump(std::ostream&out, unsigned ind) const override;
private:
PExpr*lval_;
@ -583,10 +583,10 @@ class PReturn : public Statement {
public:
explicit PReturn(PExpr*e);
~PReturn();
~PReturn() override;
NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const;
NetProc* elaborate(Design*des, NetScope*scope) const override;
virtual void dump(std::ostream&out, unsigned ind) const override;
private:
PExpr*expr_;
@ -600,10 +600,10 @@ class PTrigger : public Statement {
public:
explicit PTrigger(PPackage*pkg, const pform_name_t&ev, unsigned lexical_pos);
~PTrigger();
~PTrigger() override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
virtual void dump(std::ostream&out, unsigned ind) const override;
private:
pform_scoped_name_t event_;
@ -613,10 +613,10 @@ class PTrigger : public Statement {
class PNBTrigger : public Statement {
public:
explicit PNBTrigger(const pform_name_t&ev, unsigned lexical_pos, PExpr*dly);
~PNBTrigger();
~PNBTrigger() override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
virtual void dump(std::ostream&out, unsigned ind) const override;
private:
pform_name_t event_;
@ -628,12 +628,12 @@ class PWhile : public Statement {
public:
PWhile(PExpr*ex, Statement*st);
~PWhile();
~PWhile() override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void elaborate_sig(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
virtual void elaborate_scope(Design*des, NetScope*scope) const override;
virtual void elaborate_sig(Design*des, NetScope*scope) const override;
virtual void dump(std::ostream&out, unsigned ind) const override;
private:
PExpr*cond_;

View File

@ -59,7 +59,11 @@ distclean: clean
rm -f Makefile config.log
cppcheck: $(O:.o=.c)
cppcheck --enable=all --std=c99 --std=c++11 -f $(INCLUDE_PATH) $^
cppcheck --enable=all --std=c99 --std=c++11 -f \
--check-level=exhaustive \
--suppressions-list=$(srcdir)/../cppcheck-global.sup \
--suppressions-list=$(srcdir)/cppcheck.sup \
$(INCLUDE_PATH) $^
Makefile: $(srcdir)/Makefile.in ../config.status
cd ..; ./config.status --file=cadpli/$@

7
cadpli/cppcheck.sup Normal file
View File

@ -0,0 +1,7 @@
// We use guarded memory allocation routines, but cppcheck is not
// noticing this so it is complaining we could return a NULL value.
nullPointerOutOfMemory:cadpli.c:53
nullPointerOutOfMemory:cadpli.c:54
// Unused function
unusedFunction:ivl_dlfcn.h:73

View File

@ -21,7 +21,6 @@ AC_PROG_CXX
AC_PROG_RANLIB
AC_CHECK_TOOL(LD, ld, false)
AC_CHECK_TOOL(AR, ar, false)
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(STRIP, strip, true)
AC_CHECK_TOOL(WINDRES,windres,false)
AC_CHECK_PROGS(XGPERF,gperf,none)
@ -178,7 +177,7 @@ AC_SUBST(HAVE_LIBBZ2)
AC_FUNC_ALLOCA
AC_FUNC_FSEEKO
# Package Options
# Feature Options
# ---------------
# Build VVP as a library and stub
@ -186,6 +185,14 @@ AC_ARG_ENABLE([libvvp],
[AS_HELP_STRING([--enable-libvvp], [build VVP as a shared library])],
[AC_SUBST(LIBVVP, yes)],[])
AC_ARG_ENABLE([libveriuser],
[AS_HELP_STRING([--enable-libveriuser], [include support for PLI 1 (deprecated)])],
[AC_SUBST(LIBVERIUSER, yes)],
[AC_SUBST(LIBVERIUSER, no)])
# Package Options
# ---------------
# valgrind checks
AC_ARG_WITH([valgrind], [AS_HELP_STRING([--with-valgrind],[Add valgrind hooks])],
[], [check_valgrind=yes])

View File

@ -1,10 +1,10 @@
// These are correct and are used to find the base (zero) pin.
thisSubtraction:netlist.h:5244
thisSubtraction:netlist.h:5253
thisSubtraction:netlist.h:5311
thisSubtraction:netlist.h:5320
// This is used when running a debugger
// debugger_release
knownConditionTrueFalse:main.cc:921
knownConditionTrueFalse:main.cc:931
// This are just stubs
// vpi_control()

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -41,14 +41,14 @@ struct cprop_functor : public functor_t {
unsigned count;
virtual void signal(Design*des, NetNet*obj);
virtual void lpm_add_sub(Design*des, NetAddSub*obj);
virtual void lpm_compare(Design*des, const NetCompare*obj);
virtual void lpm_concat(Design*des, NetConcat*obj);
virtual void lpm_ff(Design*des, NetFF*obj);
virtual void lpm_logic(Design*des, NetLogic*obj);
virtual void lpm_mux(Design*des, NetMux*obj);
virtual void lpm_part_select(Design*des, NetPartSelect*obj);
virtual void signal(Design*des, NetNet*obj) override;
virtual void lpm_add_sub(Design*des, NetAddSub*obj) override;
virtual void lpm_compare(Design*des, const NetCompare*obj) override;
virtual void lpm_concat(Design*des, NetConcat*obj) override;
virtual void lpm_ff(Design*des, NetFF*obj) override;
virtual void lpm_logic(Design*des, NetLogic*obj) override;
virtual void lpm_mux(Design*des, NetMux*obj) override;
virtual void lpm_part_select(Design*des, NetPartSelect*obj) override;
void lpm_compare_eq_(Design*des, const NetCompare*obj);
};
@ -90,7 +90,7 @@ void cprop_functor::lpm_concat(Design*des, NetConcat*obj)
unsigned off = 0;
for (unsigned idx = 1 ; idx < obj->pin_count() ; idx += 1) {
Nexus*nex = obj->pin(idx).nexus();
const Nexus*nex = obj->pin(idx).nexus();
// If there are non-constant drivers, then give up.
if (! nex->drivers_constant())
return;
@ -156,7 +156,7 @@ void cprop_functor::lpm_mux(Design*des, NetMux*obj)
if (obj->sel_width() != 1)
return;
Nexus*sel_nex = obj->pin_Sel().nexus();
const Nexus*sel_nex = obj->pin_Sel().nexus();
/* If the select input is constant, then replace with a BUFZ */
@ -226,7 +226,7 @@ void cprop_functor::lpm_part_select(Design*des, NetPartSelect*obj)
NetPins*tmp_obj = cur->get_obj();
// Record if we are driving a 2-state net.
NetNet*net_obj = dynamic_cast<NetNet*> (tmp_obj);
const NetNet*net_obj = dynamic_cast<NetNet*> (tmp_obj);
if (net_obj && (net_obj->data_type() == IVL_VT_BOOL))
output_2_state = true;
@ -355,7 +355,7 @@ void cprop_functor::lpm_part_select(Design*des, NetPartSelect*obj)
*/
struct cprop_dc_functor : public functor_t {
virtual void lpm_const(Design*des, NetConst*obj);
virtual void lpm_const(Design*des, NetConst*obj) override;
};
struct nexus_info_s {

View File

@ -1,7 +1,7 @@
#ifndef IVL_discipline_H
#define IVL_discipline_H
/*
* Copyright (c) 2008-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2008-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -36,7 +36,7 @@ extern std::ostream& operator << (std::ostream&, ivl_dis_domain_t);
class ivl_nature_s : public LineInfo {
public:
explicit ivl_nature_s(perm_string name, perm_string access);
~ivl_nature_s();
~ivl_nature_s() override;
perm_string name() const { return name_; }
// Identifier for the access function for this nature
@ -51,12 +51,12 @@ class ivl_discipline_s : public LineInfo {
public:
explicit ivl_discipline_s (perm_string name, ivl_dis_domain_t dom,
ivl_nature_t pot, ivl_nature_t flow);
~ivl_discipline_s();
~ivl_discipline_s() override;
perm_string name() const { return name_; }
ivl_dis_domain_t domain() const { return domain_; }
ivl_nature_t potential() const { return potential_; }
ivl_nature_t flow() const { return flow_; }
perm_string name() const { return name_; }
ivl_dis_domain_t domain() const { return domain_; }
ivl_nature_t potential() const { return potential_; }
ivl_nature_t flow() const { return flow_; }
private:
perm_string name_;

View File

@ -66,7 +66,10 @@ distclean: clean
rm -f Makefile config.log
cppcheck: main.c
cppcheck --enable=all --std=c99 --std=c++11 -f $(INCLUDE_PATH) $^
cppcheck --enable=all --std=c99 --std=c++11 -f \
--check-level=exhaustive \
--suppressions-list=$(srcdir)/../cppcheck-global.sup \
$(INCLUDE_PATH) $^
Makefile: $(srcdir)/Makefile.in ../config.status
cd ..; ./config.status --file=driver-vpi/$@
@ -84,6 +87,11 @@ config.h: $(srcdir)/config.h.in Makefile
-e 's;@IVLCFLAGS@;$(CFLAGS);' \
-e 's;@IVLCXXFLAGS@;$(CXXFLAGS);' \
-e 's;@SHARED@;@shared@;' $< > $@
ifeq (@LIBVERIUSER@,yes)
sed -i 's;@VPILIBS@;-lveriuser$(suffix) -lvpi$(suffix);' $@
else
sed -i 's;@VPILIBS@;-lvpi$(suffix);' $@
endif
# Windows specific...
res.rc: $(srcdir)/res.rc.in ../version.exe

View File

@ -6,5 +6,5 @@
#define IVERILOG_VPI_CFLAGS " @IVLCFLAGS@"
#define IVERILOG_VPI_CXXFLAGS " @IVLCXXFLAGS@"
#define IVERILOG_VPI_LDFLAGS "@SHARED@"
#define IVERILOG_VPI_LDLIBS "-lveriuser@SUFFIX@ -lvpi@SUFFIX@"
#define IVERILOG_VPI_LDLIBS "@VPILIBS@"
#define IVERILOG_SUFFIX "@SUFFIX@"

View File

@ -341,7 +341,7 @@ NetExpr* PEAssignPattern::elaborate_expr_uarray_(Design *des, NetScope *scope,
// have a good way of passing the inner dimensions through the
// generic elaborate_expr() API and assigment patterns is the only
// place where we need it.
if (auto ap = dynamic_cast<PEAssignPattern*>(parms_[idx])) {
if (const auto ap = dynamic_cast<PEAssignPattern*>(parms_[idx])) {
expr = ap->elaborate_expr_uarray_(des, scope, uarray_type,
dims, cur_dim, need_const);
} else if (dynamic_cast<PEConcat*>(parms_[idx])) {
@ -410,7 +410,7 @@ NetExpr* PEAssignPattern::elaborate_expr_packed_(Design *des, NetScope *scope,
// have a good way of passing the inner dimensions through the
// generic elaborate_expr() API and assigment patterns is the only
// place where we need it.
auto ap = dynamic_cast<PEAssignPattern*>(parms_[idx]);
const auto ap = dynamic_cast<PEAssignPattern*>(parms_[idx]);
if (ap)
expr = ap->elaborate_expr_packed_(des, scope, base_type,
width, dims, cur_dim, need_const);
@ -755,7 +755,7 @@ NetExpr* PEBinary::elaborate_expr_base_mult_(Design*,
}
// Handle a few special case multiplies against constants.
if (NetEConst*rp_const = dynamic_cast<NetEConst*> (rp)) {
if (const NetEConst*rp_const = dynamic_cast<NetEConst*> (rp)) {
verinum rp_val = rp_const->value();
if (!rp_val.is_defined() && (lp->expr_type() == IVL_VT_LOGIC)) {
@ -1062,7 +1062,7 @@ unsigned PEBLeftWidth::test_width(Design*des, NetScope*scope, width_mode_t&mode)
delete right_;
right_ = tmp;
}
NetEConst*rc = dynamic_cast<NetEConst*> (rp);
const NetEConst*rc = dynamic_cast<NetEConst*> (rp);
// Adjust the expression width that can be converter depending
// on if the R-value is signed or not.
unsigned c_width = sizeof(long)*8;
@ -1086,7 +1086,7 @@ unsigned PEBLeftWidth::test_width(Design*des, NetScope*scope, width_mode_t&mode)
// If the left operand is a simple unsized number, we
// can calculate the actual width required for the power
// operator.
PENumber*lc = dynamic_cast<PENumber*> (left_);
const PENumber*lc = dynamic_cast<PENumber*> (left_);
// Now calculate the lossless width.
unsigned use_width = expr_width_;
@ -1259,7 +1259,7 @@ NetExpr*PEBShift::elaborate_expr_leaf(Design*des, NetExpr*lp, NetExpr*rp,
// there are some other interesting cases. But if neither are
// constant, then there is the general case.
if (NetEConst*lpc = dynamic_cast<NetEConst*> (lp)) {
if (const NetEConst*lpc = dynamic_cast<NetEConst*> (lp)) {
// Special case: The left expression is zero. If the
// shift value contains no 'x' or 'z' bits, the result
@ -1279,7 +1279,7 @@ NetExpr*PEBShift::elaborate_expr_leaf(Design*des, NetExpr*lp, NetExpr*rp,
return tmp;
}
} else if (NetEConst*rpc = dynamic_cast<NetEConst*> (rp)) {
} else if (const NetEConst*rpc = dynamic_cast<NetEConst*> (rp)) {
// Special case: The shift value contains 'x' or 'z' bits.
// Elaborate as a constant-x.
@ -1382,7 +1382,7 @@ unsigned PECallFunction::test_width_sfunc_(Design*des, NetScope*scope,
return 0;
}
NetExpr*nexpr = elab_and_eval(des, scope, pexpr, -1, true);
const NetExpr*nexpr = elab_and_eval(des, scope, pexpr, -1, true);
if (nexpr == 0) {
cerr << get_fileline() << ": error: "
<< "Unable to evaluate " << name
@ -1519,7 +1519,7 @@ static NetFuncDef* find_function_definition(Design*des, NetScope*,
}
unsigned PECallFunction::test_width_method_(Design*, NetScope*,
symbol_search_results&search_results,
const symbol_search_results&search_results,
width_mode_t&)
{
if (!gn_system_verilog())
@ -1560,7 +1560,7 @@ unsigned PECallFunction::test_width_method_(Design*, NetScope*,
if (search_results.net && search_results.net->data_type()==IVL_VT_DARRAY
&& search_results.path_head.back().index.empty()) {
NetNet*net = search_results.net;
const NetNet*net = search_results.net;
const netdarray_t*darray = net->darray_type();
ivl_assert(*this, darray);
@ -1583,7 +1583,7 @@ unsigned PECallFunction::test_width_method_(Design*, NetScope*,
if (search_results.net && search_results.net->data_type()==IVL_VT_QUEUE
&& search_results.path_head.back().index.empty()) {
NetNet*net = search_results.net;
const NetNet*net = search_results.net;
const netdarray_t*darray = net->darray_type();
ivl_assert(*this, darray);
@ -1616,7 +1616,7 @@ unsigned PECallFunction::test_width_method_(Design*, NetScope*,
&& (search_results.net->data_type()==IVL_VT_QUEUE || search_results.net->data_type()==IVL_VT_DARRAY)
&& search_results.path_head.back().index.size()) {
NetNet*net = search_results.net;
const NetNet*net = search_results.net;
const netdarray_t*darray = net->darray_type();
ivl_assert(*this, darray);
@ -1646,7 +1646,7 @@ unsigned PECallFunction::test_width_method_(Design*, NetScope*,
// Enumeration variable. Check for the various enumeration methods.
if (search_results.net && search_results.net->enumeration()) {
NetNet*net = search_results.net;
const NetNet*net = search_results.net;
const netenum_t*enum_type = net->enumeration();
if (method_name=="first" || method_name=="last"
@ -1692,7 +1692,7 @@ unsigned PECallFunction::test_width_method_(Design*, NetScope*,
}
// Get the return value of the method function.
if (NetNet*res = method->find_signal(method->basename())) {
if (const NetNet*res = method->find_signal(method->basename())) {
expr_type_ = res->data_type();
expr_width_ = res->vector_width();
min_width_ = expr_width_;
@ -1786,7 +1786,7 @@ unsigned PECallFunction::test_width(Design*des, NetScope*scope,
<< "." << endl;
}
NetNet*res = search_results.net;
const NetNet*res = search_results.net;
expr_type_ = res->data_type();
expr_width_ = res->vector_width();
min_width_ = expr_width_;
@ -1845,7 +1845,7 @@ unsigned PECallFunction::test_width(Design*des, NetScope*scope,
NetScope*dscope = def->scope();
ivl_assert(*this, dscope);
if (NetNet*res = dscope->find_signal(dscope->basename())) {
if (const NetNet*res = dscope->find_signal(dscope->basename())) {
expr_type_ = res->data_type();
expr_width_ = res->vector_width();
min_width_ = expr_width_;
@ -1906,7 +1906,7 @@ NetExpr* PECallFunction::elaborate_sfunc_(Design*des, NetScope*scope,
if (name=="$ivlh_to_unsigned") {
ivl_assert(*this, parms_.size()==2);
PExpr *expr = parms_[0].parm;
const PExpr *expr = parms_[0].parm;
ivl_assert(*this, expr);
NetExpr*sub = expr->elaborate_expr(des, scope, expr->expr_width(), flags);
return cast_to_width_(sub, expr_wid);
@ -1934,7 +1934,7 @@ NetExpr* PECallFunction::elaborate_sfunc_(Design*des, NetScope*scope,
cerr << get_fileline() << ": PECallFunction::elaborate_sfunc_: "
<< name << " expression is the argument cast to expr_wid=" << expr_wid << endl;
}
PExpr *expr = parms_[0].parm;
const PExpr *expr = parms_[0].parm;
NetExpr*sub = expr->elaborate_expr(des, scope, expr_width_, flags);
return cast_to_width_(sub, expr_wid);
@ -1959,7 +1959,7 @@ NetExpr* PECallFunction::elaborate_sfunc_(Design*des, NetScope*scope,
PExpr *expr = parms_[0].parm;
uint64_t use_width = 0;
if (PETypename*type_expr = dynamic_cast<PETypename*>(expr)) {
if (const PETypename*type_expr = dynamic_cast<PETypename*>(expr)) {
ivl_type_t data_type = type_expr->get_type()->elaborate_type(des, scope);
ivl_assert(*this, data_type);
use_width = 1;
@ -2009,7 +2009,7 @@ NetExpr* PECallFunction::elaborate_sfunc_(Design*des, NetScope*scope,
return 0;
}
PExpr *expr = parms_[0].parm;
const PExpr *expr = parms_[0].parm;
verinum val (expr->has_sign() ? verinum::V1 : verinum::V0, 1);
NetEConst*sub = new NetEConst(val);
@ -2104,7 +2104,7 @@ NetExpr* PECallFunction::elaborate_access_func_(Design*des, NetScope*scope,
if (parms_.size() == 1) {
PExpr *arg1 = parms_[0].parm;
PEIdent*arg_ident = dynamic_cast<PEIdent*> (arg1);
const PEIdent*arg_ident = dynamic_cast<PEIdent*> (arg1);
ivl_assert(*this, arg_ident);
const pform_name_t&path = arg_ident->path().name;
@ -2264,7 +2264,7 @@ static NetExpr* check_for_enum_methods(const LineInfo*li,
"enumeration method argument " << use_path << "."
<< method_name << "(" << args[0] << ")." << endl;
des->errors++;
} else if (NetEEvent *evt = dynamic_cast<NetEEvent*> (count)) {
} else if (const NetEEvent *evt = dynamic_cast<NetEEvent*> (count)) {
cerr << evt->get_fileline() << ": error: An event '"
<< evt->event()->name() << "' cannot be an enumeration "
"method argument." << endl;
@ -3024,7 +3024,7 @@ NetExpr* PECallFunction::elaborate_base_(Design*des, NetScope*scope, NetScope*ds
if (! check_call_matches_definition_(des, dscope))
return 0;
NetFuncDef*def = dscope->func_def();
const NetFuncDef*def = dscope->func_def();
bool need_const = NEED_CONST & flags;
@ -3124,7 +3124,7 @@ NetExpr* PECallFunction::elaborate_base_(Design*des, NetScope*scope, NetScope*ds
* def->port(0) will be the "this" argument and should be skipped.
*/
unsigned PECallFunction::elaborate_arguments_(Design*des, NetScope*scope,
NetFuncDef*def, bool need_const,
const NetFuncDef*def, bool need_const,
vector<NetExpr*>&parms,
unsigned parm_off) const
{
@ -3160,7 +3160,7 @@ unsigned PECallFunction::elaborate_arguments_(Design*des, NetScope*scope,
continue;
}
if (NetEEvent*evt = dynamic_cast<NetEEvent*> (parms[pidx])) {
if (const NetEEvent*evt = dynamic_cast<NetEEvent*> (parms[pidx])) {
cerr << evt->get_fileline() << ": error: An event '"
<< evt->event()->name() << "' can not be a user "
"function argument." << endl;
@ -3272,7 +3272,7 @@ NetExpr* PECallFunction::elaborate_expr_method_(Design*des, NetScope*scope,
if (search_results.net && search_results.net->data_type()==IVL_VT_QUEUE
&& search_results.path_head.back().index.size()==1) {
NetNet*net = search_results.net;
const NetNet*net = search_results.net;
const netdarray_t*darray = net->darray_type();
const index_component_t&use_index = search_results.path_head.back().index.back();
ivl_assert(*this, use_index.msb != 0);
@ -3378,7 +3378,7 @@ NetExpr* PECallFunction::elaborate_expr_method_(Design*des, NetScope*scope,
// Enumeration methods.
if (search_results.net && search_results.net->enumeration()) {
NetNet*net = search_results.net;
const NetNet*net = search_results.net;
const netenum_t*netenum = net->enumeration();
// Get the method name that we are looking for.
@ -3408,7 +3408,7 @@ NetExpr* PECallFunction::elaborate_expr_method_(Design*des, NetScope*scope,
return 0;
}
NetFuncDef*def = method->func_def();
const NetFuncDef*def = method->func_def();
ivl_assert(*this, def);
NetNet*res = method->find_signal(method->basename());
@ -3509,8 +3509,8 @@ NetExpr* PECallFunction::elaborate_expr_method_(Design*des, NetScope*scope,
* expression of some sort (it's a parameter value) and most methods are
* stable in the sense that they generate a constant value for a constant input.
*/
NetExpr* PECallFunction::elaborate_expr_method_par_(Design*des, NetScope*scope,
symbol_search_results&search_results)
NetExpr* PECallFunction::elaborate_expr_method_par_(Design*des, const NetScope*scope,
const symbol_search_results&search_results)
const
{
ivl_assert(*this, search_results.par_val);
@ -3581,7 +3581,7 @@ unsigned PECastSize::test_width(Design*des, NetScope*scope, width_mode_t&)
expr_width_ = 0;
NetExpr*size_ex = elab_and_eval(des, scope, size_, -1, true);
NetEConst*size_ce = dynamic_cast<NetEConst*>(size_ex);
const NetEConst*size_ce = dynamic_cast<NetEConst*>(size_ex);
if (size_ce && !size_ce->value().is_negative())
expr_width_ = size_ce->value().as_ulong();
delete size_ex;
@ -3837,7 +3837,7 @@ unsigned PEConcat::test_width(Design*des, NetScope*scope, width_mode_t&)
return 0;
}
NetEConst*rep = dynamic_cast<NetEConst*>(tmp);
const NetEConst*rep = dynamic_cast<NetEConst*>(tmp);
if (rep == 0) {
cerr << get_fileline() << ": error: "
@ -4047,7 +4047,7 @@ NetExpr* PEFNumber::elaborate_expr(Design*, NetScope*, unsigned, unsigned) const
return tmp;
}
bool PEIdent::calculate_packed_indices_(Design*des, NetScope*scope, NetNet*net,
bool PEIdent::calculate_packed_indices_(Design*des, NetScope*scope, const NetNet*net,
list<long>&prefix_indices) const
{
unsigned dimensions = net->unpacked_dimensions() + net->packed_dimensions();
@ -4094,7 +4094,7 @@ bool PEIdent::calculate_bits_(Design*des, NetScope*scope,
bit select expressions which must be constant. */
NetExpr*msb_ex = elab_and_eval(des, scope, index_tail.msb, -1, true);
NetEConst*msb_c = dynamic_cast<NetEConst*>(msb_ex);
const NetEConst*msb_c = dynamic_cast<NetEConst*>(msb_ex);
if (msb_c == 0) {
cerr << index_tail.msb->get_fileline() << ": error: "
"Bit select expressions must be a constant integral value."
@ -4120,7 +4120,7 @@ bool PEIdent::calculate_bits_(Design*des, NetScope*scope,
* function calculates their values. Note that this method does *not*
* convert the values to canonical form.
*/
bool PEIdent::calculate_parts_(Design*des, NetScope*scope,
void PEIdent::calculate_parts_(Design*des, NetScope*scope,
long&msb, long&lsb, bool&defined) const
{
defined = true;
@ -4136,7 +4136,7 @@ bool PEIdent::calculate_parts_(Design*des, NetScope*scope,
constant. Evaluate them and pass the results back to
the caller. */
NetExpr*lsb_ex = elab_and_eval(des, scope, index_tail.lsb, -1, true);
NetEConst*lsb_c = dynamic_cast<NetEConst*>(lsb_ex);
const NetEConst*lsb_c = dynamic_cast<NetEConst*>(lsb_ex);
if (lsb_c == 0) {
cerr << index_tail.lsb->get_fileline() << ": error: "
"Part select expressions must be constant integral values."
@ -4154,7 +4154,7 @@ bool PEIdent::calculate_parts_(Design*des, NetScope*scope,
}
NetExpr*msb_ex = elab_and_eval(des, scope, index_tail.msb, -1, true);
NetEConst*msb_c = dynamic_cast<NetEConst*>(msb_ex);
const NetEConst*msb_c = dynamic_cast<NetEConst*>(msb_ex);
if (msb_c == 0) {
cerr << index_tail.msb->get_fileline() << ": error: "
"Part select expressions must be constant integral values."
@ -4173,7 +4173,6 @@ bool PEIdent::calculate_parts_(Design*des, NetScope*scope,
delete msb_ex;
delete lsb_ex;
return true;
}
bool PEIdent::calculate_up_do_width_(Design*des, NetScope*scope,
@ -4191,7 +4190,7 @@ bool PEIdent::calculate_up_do_width_(Design*des, NetScope*scope,
first. If the expression is not constant, error but guess 1
so we can keep going and find more errors. */
NetExpr*wid_ex = elab_and_eval(des, scope, index_tail.lsb, -1, true);
NetEConst*wid_c = dynamic_cast<NetEConst*>(wid_ex);
const NetEConst*wid_c = dynamic_cast<NetEConst*>(wid_ex);
wid = wid_c ? wid_c->value().as_ulong() : 0;
if (wid == 0) {
@ -5204,7 +5203,7 @@ NetExpr* PEIdent::elaborate_expr_param_bit_(Design*des, NetScope*scope,
// Handle the special case that the selection is constant. In this
// case, just precalculate the entire constant result.
if (NetEConst*sel_c = dynamic_cast<NetEConst*> (sel)) {
if (const NetEConst*sel_c = dynamic_cast<NetEConst*> (sel)) {
// Special case: If the bit select is constant and not fully
// defined, then we know that the result must be 1'bx.
if (! sel_c->value().is_defined()) {
@ -5274,9 +5273,7 @@ NetExpr* PEIdent::elaborate_expr_param_part_(Design*des, NetScope*scope,
{
long msv, lsv;
bool parts_defined_flag;
bool flag = calculate_parts_(des, scope, msv, lsv, parts_defined_flag);
if (!flag)
return 0;
calculate_parts_(des, scope, msv, lsv, parts_defined_flag);
const NetEConst*par_ex = dynamic_cast<const NetEConst*> (par);
ivl_assert(*this, par_ex);
@ -5428,7 +5425,7 @@ NetExpr* PEIdent::elaborate_expr_param_idx_up_(Design*des, NetScope*scope,
// Handle the special case that the base is constant. In this
// case, just precalculate the entire constant result.
if (NetEConst*base_c = dynamic_cast<NetEConst*> (base)) {
if (const NetEConst*base_c = dynamic_cast<NetEConst*> (base)) {
if (! base_c->value().is_defined()) {
NetEConst *ex;
ex = new NetEConst(verinum(verinum::Vx, wid, true));
@ -5516,7 +5513,7 @@ NetExpr* PEIdent::elaborate_expr_param_idx_do_(Design*des, NetScope*scope,
// Handle the special case that the base is constant. In this
// case, just precalculate the entire constant result.
if (NetEConst*base_c = dynamic_cast<NetEConst*> (base)) {
if (const NetEConst*base_c = dynamic_cast<NetEConst*> (base)) {
if (! base_c->value().is_defined()) {
NetEConst *ex;
ex = new NetEConst(verinum(verinum::Vx, wid, true));
@ -5851,9 +5848,7 @@ NetExpr* PEIdent::elaborate_expr_net_part_(Design*des, NetScope*scope,
long msv, lsv;
bool parts_defined_flag;
bool flag = calculate_parts_(des, scope, msv, lsv, parts_defined_flag);
if (!flag)
return 0;
calculate_parts_(des, scope, msv, lsv, parts_defined_flag);
/* But wait... if the part select expressions are not fully
defined, then fall back on the tested width. */
@ -6011,7 +6006,7 @@ NetExpr* PEIdent::elaborate_expr_net_idx_up_(Design*des, NetScope*scope,
// Handle the special case that the base is constant as
// well. In this case it can be converted to a conventional
// part select.
if (NetEConst*base_c = dynamic_cast<NetEConst*> (base)) {
if (const NetEConst*base_c = dynamic_cast<NetEConst*> (base)) {
NetExpr*ex;
if (base_c->value().is_defined()) {
long lsv = base_c->value().as_long();
@ -6178,7 +6173,7 @@ NetExpr* PEIdent::elaborate_expr_net_idx_do_(Design*des, NetScope*scope,
// Handle the special case that the base is constant as
// well. In this case it can be converted to a conventional
// part select.
if (NetEConst*base_c = dynamic_cast<NetEConst*> (base)) {
if (const NetEConst*base_c = dynamic_cast<NetEConst*> (base)) {
NetExpr*ex;
if (base_c->value().is_defined()) {
long lsv = base_c->value().as_long();
@ -6352,7 +6347,7 @@ NetExpr* PEIdent::elaborate_expr_net_bit_(Design*des, NetScope*scope,
// If the bit select is constant, then treat it similar
// to the part select, so that I save the effort of
// making a mux part in the netlist.
if (NetEConst*msc = dynamic_cast<NetEConst*> (mux)) {
if (const NetEConst*msc = dynamic_cast<NetEConst*> (mux)) {
if (debug_elaborate) {
cerr << get_fileline() << ": PEIdent::elaborate_expr_net_bit_: "
@ -6722,7 +6717,7 @@ NetExpr* PENewClass::elaborate_expr_constructor_(Design*des, NetScope*scope,
}
NetFuncDef*def = new_scope->func_def();
const NetFuncDef*def = new_scope->func_def();
if (def == 0) {
cerr << get_fileline() << ": internal error: "
<< "Scope " << scope_path(new_scope)
@ -6763,7 +6758,7 @@ NetExpr* PENewClass::elaborate_expr_constructor_(Design*des, NetScope*scope,
// Ran out of explicit arguments. Is there a default
// argument we can use?
if (NetExpr*tmp = def->port_defe(idx)) {
if (const NetExpr*tmp = def->port_defe(idx)) {
parms[idx] = tmp->dup_expr();
continue;
}
@ -7120,7 +7115,7 @@ NetExpr*PETernary::elaborate_expr(Design*des, NetScope*scope,
// Verilog doesn't say that we must do short circuit evaluation
// of ternary expressions, but it doesn't disallow it.
if (NetEConst*tmp = dynamic_cast<NetEConst*> (con)) {
if (const NetEConst*tmp = dynamic_cast<NetEConst*> (con)) {
verinum cval = tmp->value();
ivl_assert(*this, cval.len()==1);
@ -7386,7 +7381,7 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope,
break;
case '-':
if (NetEConst*ipc = dynamic_cast<NetEConst*>(ip)) {
if (const NetEConst*ipc = dynamic_cast<NetEConst*>(ip)) {
verinum val = - ipc->value();
tmp = new NetEConst(val);
@ -7394,7 +7389,7 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope,
tmp->set_line(*this);
delete ip;
} else if (NetECReal*ipr = dynamic_cast<NetECReal*>(ip)) {
} else if (const NetECReal*ipr = dynamic_cast<NetECReal*>(ip)) {
/* When taking the - of a real, fold this into the
constant value. */
@ -7417,7 +7412,7 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope,
/* If the operand to unary ! is a constant, then I can
evaluate this expression here and return a logical
constant in its place. */
if (NetEConst*ipc = dynamic_cast<NetEConst*>(ip)) {
if (const NetEConst*ipc = dynamic_cast<NetEConst*>(ip)) {
verinum val = ipc->value();
unsigned v1 = 0;
unsigned vx = 0;
@ -7445,7 +7440,7 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope,
tmp = new NetEConst(vres);
tmp->set_line(*this);
delete ip;
} else if (NetECReal*ipr = dynamic_cast<NetECReal*>(ip)) {
} else if (const NetECReal*ipr = dynamic_cast<NetECReal*>(ip)) {
verinum::V res;
if (ipr->value().as_double() == 0.0) res = verinum::V1;
else res = verinum::V0;
@ -7527,7 +7522,7 @@ NetNet* Design::find_discipline_reference(ivl_discipline_t dis, NetScope*scope)
if (gnd) return gnd;
string name = string(dis->name()) + "$gnd";
netvector_t*gnd_vec = new netvector_t(IVL_VT_REAL,0,0);
const netvector_t*gnd_vec = new netvector_t(IVL_VT_REAL,0,0);
gnd = new NetNet(scope, lex_strings.make(name), NetNet::WIRE, gnd_vec);
gnd->set_discipline(dis);
discipline_references_[dis->name()] = gnd;

View File

@ -177,7 +177,7 @@ NetAssign_* PEIdent::elaborate_lval(Design*des,
symbol_search(this, des, scope, path_, lexical_pos_, &sr);
NetNet *reg = sr.net;
pform_name_t &member_path = sr.path_tail;
const pform_name_t &member_path = sr.path_tail;
/* The l-value must be a variable. If not, then give up and
print a useful error message. */
@ -254,7 +254,7 @@ NetAssign_* PEIdent::elaborate_lval(Design*des,
NetAssign_*PEIdent::elaborate_lval_var_(Design *des, NetScope *scope,
bool is_force, bool is_cassign,
NetNet *reg, ivl_type_t data_type,
pform_name_t tail_path) const
const pform_name_t tail_path) const
{
// We are processing the tail of a string of names. For
// example, the Verilog may be "a.b.c", so we are processing
@ -475,7 +475,7 @@ NetAssign_* PEIdent::elaborate_lval_net_word_(Design*des,
if ((reg->type()==NetNet::UNRESOLVED_WIRE) && !is_force) {
ivl_assert(*this, reg->coerced_to_uwire());
NetEConst*canon_const = dynamic_cast<NetEConst*>(canon_index);
const NetEConst*canon_const = dynamic_cast<NetEConst*>(canon_index);
if (!canon_const || reg->test_part_driven(reg->vector_width() - 1, 0,
canon_const->value().as_long())) {
report_mixed_assignment_conflict_("array word");
@ -556,7 +556,7 @@ bool PEIdent::elaborate_lval_net_bit_(Design*des,
return false;
}
if (NetEConst*index_con = dynamic_cast<NetEConst*> (mux)) {
if (const NetEConst*index_con = dynamic_cast<NetEConst*> (mux)) {
// The index has a constant defined value.
if (index_con->value().is_defined()) {
lsb = index_con->value().as_long();
@ -761,8 +761,7 @@ bool PEIdent::elaborate_lval_net_part_(Design*des,
// values into msb and lsb.
long msb, lsb;
bool parts_defined_flag;
bool flag = calculate_parts_(des, scope, msb, lsb, parts_defined_flag);
if (!flag) return false;
calculate_parts_(des, scope, msb, lsb, parts_defined_flag);
NetNet*reg = lv->sig();
ivl_assert(*this, reg);
@ -901,7 +900,7 @@ bool PEIdent::elaborate_lval_net_idx_(Design*des,
// Handle the special case that the base is constant. For this
// case we can reduce the expression.
if (NetEConst*base_c = dynamic_cast<NetEConst*> (base)) {
if (const NetEConst*base_c = dynamic_cast<NetEConst*> (base)) {
// For the undefined case just let the constant pass and
// we will handle it in the code generator.
if (base_c->value().is_defined()) {

View File

@ -105,7 +105,7 @@ NetNet* PEConcat::elaborate_lnet_common_(Design*des, NetScope*scope,
concat operator from most significant to least significant,
which is the order they are given in the concat list. */
netvector_t*tmp2_vec = new netvector_t(nets[0]->data_type(),width-1,0);
const netvector_t*tmp2_vec = new netvector_t(nets[0]->data_type(),width-1,0);
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, tmp2_vec);
@ -206,7 +206,7 @@ bool PEConcat::is_collapsible_net(Design*des, NetScope*scope,
* results, which may be the whole vector, or a single bit, or
* anything in between. The values are in canonical indices.
*/
bool PEIdent::eval_part_select_(Design*des, NetScope*scope, NetNet*sig,
bool PEIdent::eval_part_select_(Design*des, NetScope*scope, const NetNet*sig,
long&midx, long&lidx) const
{
list<long> prefix_indices;
@ -237,7 +237,7 @@ bool PEIdent::eval_part_select_(Design*des, NetScope*scope, NetNet*sig,
case index_component_t::SEL_IDX_DO:
case index_component_t::SEL_IDX_UP: {
NetExpr*tmp_ex = elab_and_eval(des, scope, index_tail.msb, -1, true);
NetEConst*tmp = dynamic_cast<NetEConst*>(tmp_ex);
const NetEConst*tmp = dynamic_cast<NetEConst*>(tmp_ex);
if (!tmp) {
cerr << get_fileline() << ": error: Indexed part select "
"base expression must be a constant integral value "
@ -743,7 +743,7 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
member_select.sel = index_component_t::SEL_BIT;
member_select.msb = new PENumber(new verinum(member_off));
tmp_index.push_back(member_select);
NetExpr*packed_base = collapse_array_indices(des, scope, sig, tmp_index);
const NetExpr*packed_base = collapse_array_indices(des, scope, sig, tmp_index);
if (debug_elaborate) {
cerr << get_fileline() << ": PEIdent::elaborate_lnet_common_: "
@ -825,7 +825,7 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
widx_flag = true;
} else {
NetEConst*canon_const = dynamic_cast<NetEConst*>(canon_index);
const NetEConst*canon_const = dynamic_cast<NetEConst*>(canon_index);
ivl_assert(*this, canon_const);
widx = canon_const->value().as_long();
@ -967,8 +967,8 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
<< " wid=" << subnet_wid <<"]"
<< endl;
netvector_t*tmp2_vec = new netvector_t(sig->data_type(),
subnet_wid-1,0);
const netvector_t*tmp2_vec = new netvector_t(sig->data_type(),
subnet_wid-1,0);
NetNet*subsig = new NetNet(sig->scope(),
sig->scope()->local_symbol(),
NetNet::WIRE, tmp2_vec);
@ -1114,7 +1114,7 @@ NetNet* PEIdent::elaborate_subport(Design*des, NetScope*scope) const
unsigned swid = abs(midx - lidx) + 1;
ivl_assert(*this, swid > 0 && swid < sig->vector_width());
netvector_t*tmp2_vec = new netvector_t(sig->data_type(),swid-1,0);
const netvector_t*tmp2_vec = new netvector_t(sig->data_type(),swid-1,0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, tmp2_vec);
tmp->port_type(sig->port_type());

View File

@ -58,7 +58,7 @@
using namespace std;
void set_scope_timescale(Design*des, NetScope*scope, PScope*pscope)
void set_scope_timescale(Design*des, NetScope*scope, const PScope*pscope)
{
scope->time_unit(pscope->time_unit);
scope->time_precision(pscope->time_precision);
@ -218,7 +218,7 @@ static void elaborate_scope_enumeration(Design*des, NetScope*scope,
// There is an explicit value. elaborate/evaluate
// the value and assign it to the enumeration name.
NetExpr*val = elab_and_eval(des, scope, cur->parm, -1);
NetEConst*val_const = dynamic_cast<NetEConst*> (val);
const NetEConst*val_const = dynamic_cast<NetEConst*> (val);
if (val_const == 0) {
cerr << use_enum->get_fileline()
<< ": error: Enumeration expression for "
@ -241,7 +241,7 @@ static void elaborate_scope_enumeration(Design*des, NetScope*scope,
}
// If this is a literal constant and it has a defined
// width then the width must match the enumeration width.
if (PENumber *tmp = dynamic_cast<PENumber*>(cur->parm)) {
if (const PENumber *tmp = dynamic_cast<PENumber*>(cur->parm)) {
if (tmp->value().has_len() &&
(tmp->value().len() != enum_width)) {
cerr << use_enum->get_fileline()
@ -706,7 +706,7 @@ class generate_schemes_work_item_t : public elaborator_work_item_t {
: elaborator_work_item_t(des__), scope_(scope), mod_(mod)
{ }
void elaborate_runrun()
void elaborate_runrun() override
{
if (debug_scopes)
cerr << mod_->get_fileline() << ": debug: "
@ -965,7 +965,7 @@ bool PGenerate::generate_scope_loop_(Design*des, NetScope*container)
// use) the genvar itself, so we can evaluate this expression
// the same way any other parameter value is evaluated.
NetExpr*init_ex = elab_and_eval(des, container, loop_init, -1, true);
NetEConst*init = dynamic_cast<NetEConst*> (init_ex);
const NetEConst*init = dynamic_cast<NetEConst*> (init_ex);
if (init == 0) {
cerr << get_fileline() << ": error: "
"Cannot evaluate generate \"loop\" initialization "
@ -991,7 +991,7 @@ bool PGenerate::generate_scope_loop_(Design*des, NetScope*container)
container->genvar_tmp = loop_index;
container->genvar_tmp_val = genvar;
NetExpr*test_ex = elab_and_eval(des, container, loop_test, -1, true);
NetEConst*test = dynamic_cast<NetEConst*>(test_ex);
const NetEConst*test = dynamic_cast<NetEConst*>(test_ex);
if (test == 0) {
cerr << get_fileline() << ": error: Cannot evaluate generate \"loop\" "
"conditional expression: " << *loop_test << endl;
@ -1123,7 +1123,7 @@ bool PGenerate::generate_scope_loop_(Design*des, NetScope*container)
bool PGenerate::generate_scope_condit_(Design*des, NetScope*container, bool else_flag)
{
NetExpr*test_ex = elab_and_eval(des, container, loop_test, -1, true);
NetEConst*test = dynamic_cast<NetEConst*> (test_ex);
const NetEConst*test = dynamic_cast<NetEConst*> (test_ex);
if (test == 0) {
cerr << get_fileline() << ": error: Cannot evaluate genvar"
<< " conditional expression: " << *loop_test << endl;
@ -1380,9 +1380,9 @@ class delayed_elaborate_scope_mod_instances : public elaborator_work_item_t {
NetScope*sc)
: elaborator_work_item_t(des__), obj_(obj), mod_(mod), sc_(sc)
{ }
~delayed_elaborate_scope_mod_instances() { }
~delayed_elaborate_scope_mod_instances() override { }
virtual void elaborate_runrun();
virtual void elaborate_runrun() override;
private:
const PGModule*obj_;
@ -1751,7 +1751,7 @@ void PCase::elaborate_scope(Design*des, NetScope*scope) const
for (unsigned idx = 0 ; idx < (*items_).size() ; idx += 1) {
ivl_assert(*this, (*items_)[idx]);
if (Statement*sp = (*items_)[idx]->stat)
if (const Statement*sp = (*items_)[idx]->stat)
sp -> elaborate_scope(des, scope);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2025 Stephen Williams (steve@icarus.com)
* Copyright CERN 2012 / Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
@ -90,8 +90,8 @@ void Statement::elaborate_sig(Design*, NetScope*) const
{
}
static void sig_check_data_type(Design*des, NetScope*scope,
PWire *wire, NetNet *sig)
static void sig_check_data_type(Design*des, const NetScope*scope,
const PWire *wire, NetNet *sig)
{
ivl_type_t type = sig->net_type();
@ -141,8 +141,8 @@ static void sig_check_data_type(Design*des, NetScope*scope,
}
}
static void sig_check_port_type(Design*des, NetScope*scope,
PWire *wire, NetNet *sig)
static void sig_check_port_type(Design*des, const NetScope*scope,
const PWire *wire, const NetNet *sig)
{
if (sig->port_type() == NetNet::PREF) {
cerr << wire->get_fileline() << ": sorry: "
@ -460,7 +460,7 @@ bool PGAssign::elaborate_sig(Design*, NetScope*) const
}
bool PGModule::elaborate_sig_mod_(Design*des, NetScope*scope,
Module*rmod) const
const Module*rmod) const
{
bool flag = true;
@ -538,7 +538,7 @@ bool PGenerate::elaborate_sig(Design*des, NetScope*container) const
cerr << get_fileline() << ": debug: Elaborate nets in "
<< "scope " << scope_path(*cur)
<< " in generate " << id_number << endl;
flag = elaborate_sig_(des, *cur) & flag;
flag = elaborate_sig_(des, *cur) && flag;
}
return flag;
@ -671,7 +671,7 @@ void PFunction::elaborate_sig(Design*des, NetScope*scope) const
ivl_assert(*this, ret_type);
}
} else {
netvector_t*tmp = new netvector_t(IVL_VT_LOGIC);
const netvector_t*tmp = new netvector_t(IVL_VT_LOGIC);
ret_type = tmp;
}
@ -970,7 +970,7 @@ bool test_ranges_eeq(const netranges_t&lef, const netranges_t&rig)
ivl_type_t PWire::elaborate_type(Design*des, NetScope*scope,
const netranges_t &packed_dimensions) const
{
vector_type_t *vec_type = dynamic_cast<vector_type_t*>(set_data_type_.get());
const vector_type_t *vec_type = dynamic_cast<vector_type_t*>(set_data_type_.get());
if (set_data_type_ && !vec_type) {
ivl_assert(*this, packed_dimensions.empty());
return set_data_type_->elaborate_type(des, scope);
@ -1156,8 +1156,8 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope)
}
unsigned nattrib = 0;
attrib_list_t*attrib_list = evaluate_attributes(attributes, nattrib,
des, scope);
const attrib_list_t*attrib_list = evaluate_attributes(attributes, nattrib,
des, scope);
/* If the net type is supply0 or supply1, replace it
with a simple wire with a pulldown/pullup with supply

View File

@ -60,7 +60,7 @@
using namespace std;
// Implemented in elab_scope.cc
extern void set_scope_timescale(Design*des, NetScope*scope, PScope*pscope);
extern void set_scope_timescale(Design*des, NetScope*scope, const PScope*pscope);
void PGate::elaborate(Design*, NetScope*) const
{
@ -199,8 +199,8 @@ void PGAssign::elaborate(Design*des, NetScope*scope) const
NetPartSelect::VP);
des->add_node(tmp);
tmp->set_line(*this);
netvector_t*osig_vec = new netvector_t(rval->data_type(),
lval->vector_width()-1,0);
const netvector_t*osig_vec = new netvector_t(rval->data_type(),
lval->vector_width()-1,0);
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::TRI, osig_vec);
osig->set_line(*this);
@ -227,8 +227,8 @@ void PGAssign::elaborate(Design*des, NetScope*scope) const
connect(rval->pin(0), driver->pin(1));
netvector_t*tmp_vec = new netvector_t(rval->data_type(),
rval->vector_width()-1,0);
const netvector_t*tmp_vec = new netvector_t(rval->data_type(),
rval->vector_width()-1,0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, tmp_vec);
tmp->set_line(*this);
@ -258,7 +258,7 @@ NetNet *elaborate_unpacked_array(Design *des, NetScope *scope, const LineInfo &l
const NetNet *lval, PExpr *expr)
{
NetNet *expr_net;
PEIdent* ident = dynamic_cast<PEIdent*> (expr);
const PEIdent* ident = dynamic_cast<PEIdent*> (expr);
if (!ident) {
if (dynamic_cast<PEConcat*> (expr)) {
cout << loc.get_fileline() << ": sorry: Continuous assignment"
@ -923,8 +923,8 @@ void PGBuiltin::elaborate(Design*des, NetScope*scope) const
des->add_node(rep);
connect(rep->pin(1), sig->pin(0));
netvector_t*osig_vec = new netvector_t(IVL_VT_LOGIC,
instance_width-1,0);
const netvector_t*osig_vec = new netvector_t(IVL_VT_LOGIC,
instance_width-1,0);
sig = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, osig_vec);
sig->set_line(*this);
@ -1004,7 +1004,7 @@ void PGBuiltin::elaborate(Design*des, NetScope*scope) const
unsigned dev = gdx*gate_count;
connect(cur[dev+idx]->pin(0), cc->pin(gdx+1));
netvector_t*tmp2_vec = new netvector_t(IVL_VT_LOGIC);
const netvector_t*tmp2_vec = new netvector_t(IVL_VT_LOGIC);
NetNet*tmp2 = new NetNet(scope,
scope->local_symbol(),
NetNet::WIRE, tmp2_vec);
@ -1021,7 +1021,7 @@ void PGBuiltin::elaborate(Design*des, NetScope*scope) const
tmp1->set_line(*this);
des->add_node(tmp1);
connect(tmp1->pin(1), sig->pin(0));
netvector_t*tmp2_vec = new netvector_t(sig->data_type());
const netvector_t*tmp2_vec = new netvector_t(sig->data_type());
NetNet*tmp2 = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, tmp2_vec);
tmp2->set_line(*this);
@ -1052,7 +1052,7 @@ NetNet*PGModule::resize_net_to_port_(Design*des, NetScope*scope,
ivl_assert(*this, dir != NetNet::NOT_A_PORT);
ivl_assert(*this, dir != NetNet::PIMPLICIT);
netvector_t*tmp_type = new netvector_t(IVL_VT_LOGIC, port_wid-1, 0);
const netvector_t*tmp_type = new netvector_t(IVL_VT_LOGIC, port_wid-1, 0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, tmp_type);
tmp->local_flag(true);
@ -1203,7 +1203,7 @@ static void isolate_and_connect(Design*des, NetScope*scope, const PGModule*mod,
void elaborate_unpacked_port(Design *des, NetScope *scope, NetNet *port_net,
PExpr *expr, NetNet::PortType port_type,
Module *mod, unsigned int port_idx)
const Module *mod, unsigned int port_idx)
{
NetNet *expr_net = elaborate_unpacked_array(des, scope, *expr, port_net,
expr);
@ -1508,7 +1508,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
// commonly used feature.)
for (unsigned ldx = 0 ; ldx < mport.size() ; ldx += 1) {
unsigned lbase = inst * mport.size();
PEIdent*pport = mport[ldx];
const PEIdent*pport = mport[ldx];
ivl_assert(*this, pport);
NetNet *netnet = pport->elaborate_subport(des, inst_scope);
prts[lbase + ldx] = netnet;
@ -1592,7 +1592,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
in that case that the port is input. */
int context_width = -1;
if (PENumber*literal = dynamic_cast<PENumber*>(pins[idx])) {
if (const PENumber*literal = dynamic_cast<PENumber*>(pins[idx])) {
if (literal->value().is_single())
context_width = prts_vector_width;
}
@ -1664,8 +1664,8 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
des->add_node(tmp);
connect(tmp->pin(1), sig->pin(0));
netvector_t*tmp2_vec = new netvector_t(sig->data_type(),
sig->vector_width()-1,0);
const netvector_t*tmp2_vec = new netvector_t(sig->data_type(),
sig->vector_width()-1,0);
NetNet*tmp2 = new NetNet(inner_scope, inner_scope->local_symbol(),
NetNet::WIRE, tmp2_vec);
tmp2->local_flag(true);
@ -2420,12 +2420,12 @@ NetAssign_* PAssign_::elaborate_lval(Design*des, NetScope*scope) const
rval_->test_width(des, scope, mode);
// Create a L-value that matches the function return type.
NetNet*tmp;
netvector_t*tmp_vec = new netvector_t(rval_->expr_type(),
rval_->expr_width()-1, 0,
rval_->has_sign());
const netvector_t*tmp_vec = new netvector_t(rval_->expr_type(),
rval_->expr_width()-1, 0,
rval_->has_sign());
if(rval_->expr_type() == IVL_VT_DARRAY) {
netdarray_t*darray = new netdarray_t(tmp_vec);
const netdarray_t*darray = new netdarray_t(tmp_vec);
tmp = new NetNet(scope, scope->local_symbol(), NetNet::REG, darray);
} else {
tmp = new NetNet(scope, scope->local_symbol(), NetNet::REG, tmp_vec);
@ -2636,7 +2636,7 @@ NetProc* PAssign::elaborate_compressed_(Design*des, NetScope*scope) const
static bool lval_not_program_variable(const NetAssign_*lv)
{
while (lv) {
NetScope*sig_scope = lv->scope();
const NetScope*sig_scope = lv->scope();
if (! sig_scope->program_block()) return true;
lv = lv->more;
}
@ -2752,7 +2752,7 @@ NetProc* PAssign::elaborate(Design*des, NetScope*scope) const
if (delay || event_) {
unsigned wid = count_lval_width(lv);
netvector_t*tmp2_vec = new netvector_t(rv->expr_type(),wid-1,0);
const netvector_t*tmp2_vec = new netvector_t(rv->expr_type(),wid-1,0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::REG, tmp2_vec);
tmp->local_flag(true);
@ -2797,7 +2797,7 @@ NetProc* PAssign::elaborate(Design*des, NetScope*scope) const
// If the expression is a constant, handle
// certain special iteration counts.
if (NetEConst*ce = dynamic_cast<NetEConst*>(count)) {
if (const NetEConst*ce = dynamic_cast<NetEConst*>(count)) {
long val = ce->value().as_long();
// We only need the real statement.
if (val <= 0) {
@ -2946,7 +2946,7 @@ NetProc* PAssignNB::elaborate(Design*des, NetScope*scope) const
ivl_assert(*this, event);
// Some constant values are special.
if (NetEConst*ce = dynamic_cast<NetEConst*>(count)) {
if (const NetEConst*ce = dynamic_cast<NetEConst*>(count)) {
long val = ce->value().as_long();
// We only need the assignment statement.
if (val <= 0) {
@ -3056,7 +3056,7 @@ NetProc* PBlock::elaborate(Design*des, NetScope*scope) const
// Detect the error that a super.new() statement is in the
// midst of a block. Report the error. Continue on with the
// elaboration so that other errors might be found.
if (PChainConstructor*supernew = dynamic_cast<PChainConstructor*> (list_[idx])) {
if (const PChainConstructor*supernew = dynamic_cast<PChainConstructor*> (list_[idx])) {
if (debug_elaborate) {
cerr << get_fileline() << ": PBlock::elaborate: "
<< "Found super.new statement, idx=" << idx << ", "
@ -3335,7 +3335,7 @@ NetProc* PChainConstructor::elaborate(Design*des, NetScope*scope) const
// The scope is the <class>.new function, so scope->parent()
// is the class. Use that to get the class type that we are
// constructing.
NetScope*scope_class = scope->parent();
const NetScope*scope_class = scope->parent();
const netclass_t*class_this = scope_class->class_def();
ivl_assert(*this, class_this);
@ -3360,7 +3360,7 @@ NetProc* PChainConstructor::elaborate(Design*des, NetScope*scope) const
if (NetScope*new_scope = class_super->get_constructor()) {
int missing_parms = 0;
NetFuncDef*def = new_scope->func_def();
const NetFuncDef*def = new_scope->func_def();
ivl_assert(*this, def);
NetESignal*eres = new NetESignal(var_this);
@ -3376,7 +3376,7 @@ NetProc* PChainConstructor::elaborate(Design*des, NetScope*scope) const
continue;
}
if (NetExpr*tmp = def->port_defe(idx)) {
if (const NetExpr*tmp = def->port_defe(idx)) {
parms[idx] = tmp->dup_expr();
continue;
}
@ -3429,7 +3429,7 @@ NetProc* PCondit::elaborate(Design*des, NetScope*scope) const
// then look at the value and elaborate either the if statement
// or the else statement. I don't need both. If there is no
// else_ statement, then use an empty block as a noop.
if (NetEConst*ce = dynamic_cast<NetEConst*>(expr)) {
if (const NetEConst*ce = dynamic_cast<NetEConst*>(expr)) {
verinum val = ce->value();
if (debug_elaborate) {
cerr << get_fileline() << ": debug: Condition expression "
@ -3476,14 +3476,14 @@ NetProc* PCondit::elaborate(Design*des, NetScope*scope) const
// Detect the special cases that the if or else statements are
// empty blocks. If this is the case, remove the blocks as
// null statements.
if (NetBlock*tmp = dynamic_cast<NetBlock*>(i)) {
if (const NetBlock*tmp = dynamic_cast<NetBlock*>(i)) {
if (tmp->proc_first() == 0) {
delete i;
i = 0;
}
}
if (NetBlock*tmp = dynamic_cast<NetBlock*>(e)) {
if (const NetBlock*tmp = dynamic_cast<NetBlock*>(e)) {
if (tmp->proc_first() == 0) {
delete e;
e = 0;
@ -3642,7 +3642,7 @@ NetProc* PCallTask::elaborate_usr(Design*des, NetScope*scope) const
ivl_assert(*this, task);
ivl_assert(*this, task->type() == NetScope::TASK);
NetTaskDef*def = task->task_def();
const NetTaskDef*def = task->task_def();
if (def == 0) {
cerr << get_fileline() << ": internal error: task " << path_
<< " doesn't have a definition in " << scope_path(scope)
@ -4052,7 +4052,7 @@ NetProc* PCallTask::elaborate_method_(Design*des, NetScope*scope,
* task call is allowed in the current context. If so, return true. If
* not, print an error message and return false;
*/
bool PCallTask::test_task_calls_ok_(Design*des, NetScope*scope) const
bool PCallTask::test_task_calls_ok_(Design*des, const NetScope*scope) const
{
if (scope->in_func()) {
cerr << get_fileline() << ": error: Functions cannot enable/call "
@ -4130,7 +4130,7 @@ NetProc* PCallTask::elaborate_void_function_(Design*des, NetScope*scope,
NetProc* PCallTask::elaborate_build_call_(Design*des, NetScope*scope,
NetScope*task, NetExpr*use_this) const
{
NetBaseDef*def = 0;
const NetBaseDef*def = 0;
if (task->type() == NetScope::TASK) {
def = task->task_def();
@ -4147,7 +4147,7 @@ NetProc* PCallTask::elaborate_build_call_(Design*des, NetScope*scope,
}
} else if (task->type() == NetScope::FUNC) {
NetFuncDef*tmp = task->func_def();
const NetFuncDef*tmp = task->func_def();
if (!tmp->is_void())
return elaborate_non_void_function_(des, scope);
def = tmp;
@ -4241,7 +4241,7 @@ NetProc* PCallTask::elaborate_build_call_(Design*des, NetScope*scope,
if (args[parms_idx]) {
rv = elaborate_rval_expr(des, scope, port->net_type(),
args[parms_idx]);
if (NetEEvent*evt = dynamic_cast<NetEEvent*> (rv)) {
if (const NetEEvent*evt = dynamic_cast<NetEEvent*> (rv)) {
cerr << evt->get_fileline() << ": error: An event '"
<< evt->event()->name() << "' can not be a user "
"task argument." << endl;
@ -4651,7 +4651,7 @@ NetProc* PDelayStatement::elaborate(Design*des, NetScope*scope) const
NetExpr*dex = elaborate_delay_expr(delay_, des, scope);
NetPDelay *obj;
if (NetEConst*tmp = dynamic_cast<NetEConst*>(dex)) {
if (const NetEConst*tmp = dynamic_cast<NetEConst*>(dex)) {
if (statement_)
obj = new NetPDelay(tmp->value().as_ulong64(),
statement_->elaborate(des, scope));
@ -4951,7 +4951,7 @@ cerr << endl;
named event, then handle this case all at once and
skip the rest of the expression handling. */
if (PEIdent*id = dynamic_cast<PEIdent*>(expr_[idx]->expr())) {
if (const PEIdent*id = dynamic_cast<PEIdent*>(expr_[idx]->expr())) {
symbol_search_results sr;
symbol_search(this, des, scope, id->path(), id->lexical_pos(), &sr);
@ -5168,7 +5168,7 @@ NetProc* PEventStatement::elaborate_wait(Design*des, NetScope*scope,
constant. Constant true is OK (it becomes transparent) but
constant false is almost certainly not what is intended. */
ivl_assert(*this, expr->expr_width() == 1);
if (NetEConst*ce = dynamic_cast<NetEConst*>(expr)) {
if (const NetEConst*ce = dynamic_cast<NetEConst*>(expr)) {
verinum val = ce->value();
ivl_assert(*this, val.len() == 1);
@ -5271,7 +5271,7 @@ NetProc* PEventStatement::elaborate_wait(Design*des, NetScope*scope,
*
* @(0) <noop>;
*/
NetProc* PEventStatement::elaborate_wait_fork(Design*des, NetScope*scope) const
NetProc* PEventStatement::elaborate_wait_fork(Design*des, const NetScope*scope) const
{
ivl_assert(*this, scope);
ivl_assert(*this, expr_.size() == 1);
@ -5896,7 +5896,7 @@ NetProc* PRepeat::elaborate(Design*des, NetScope*scope) const
// If the expression is a constant, handle certain special
// iteration counts.
if (NetEConst*ce = dynamic_cast<NetEConst*>(expr)) {
if (const NetEConst*ce = dynamic_cast<NetEConst*>(expr)) {
long val = ce->value().as_long();
if (val <= 0) {
delete expr;
@ -6254,12 +6254,12 @@ void PSpecPath::elaborate(Design*des, NetScope*scope) const
PExpr*exp = delays[idx];
NetExpr*cur = elab_and_eval(des, scope, exp, -1);
if (NetEConst*con = dynamic_cast<NetEConst*> (cur)) {
if (const NetEConst*con = dynamic_cast<NetEConst*> (cur)) {
verinum fn = con->value();
delay_value[idx] = des->scale_to_precision(fn.as_ulong64(),
scope);
} else if (NetECReal*rcon = dynamic_cast<NetECReal*>(cur)) {
} else if (const NetECReal*rcon = dynamic_cast<NetECReal*>(cur)) {
delay_value[idx] = get_scaled_time_from_real(des, scope,
rcon);
@ -6310,7 +6310,7 @@ void PSpecPath::elaborate(Design*des, NetScope*scope) const
typedef std::vector<perm_string>::const_iterator str_vec_iter;
for (str_vec_iter cur = src.begin();
( cur != src.end() && all_single); ++ cur) {
NetNet *psig = scope->find_signal(*cur);
const NetNet *psig = scope->find_signal(*cur);
/* We will report a missing signal as invalid later. For
* now assume it's a single bit. */
if (psig == 0) continue;
@ -6318,7 +6318,7 @@ void PSpecPath::elaborate(Design*des, NetScope*scope) const
}
for (str_vec_iter cur = dst.begin();
( cur != dst.end() && all_single); ++ cur) {
NetNet *psig = scope->find_signal(*cur);
const NetNet *psig = scope->find_signal(*cur);
/* The same as above for source paths. */
if (psig == 0) continue;
if (psig->vector_width() != 1) all_single = false;
@ -6723,7 +6723,7 @@ bool Module::elaborate(Design*des, NetScope*scope) const
void netclass_t::elaborate(Design*des, PClass*pclass)
{
if (! pclass->type->initialize_static.empty()) {
std::vector<Statement*>&stmt_list = pclass->type->initialize_static;
const std::vector<Statement*>&stmt_list = pclass->type->initialize_static;
NetBlock*stmt = new NetBlock(NetBlock::SEQU, 0);
for (size_t idx = 0 ; idx < stmt_list.size() ; idx += 1) {
NetProc*tmp = stmt_list[idx]->elaborate(des, class_scope_);
@ -6822,7 +6822,7 @@ bool PGenerate::elaborate(Design*des, NetScope*container) const
cerr << get_fileline() << ": debug: Elaborate in "
<< "scope " << scope_path(scope) << endl;
flag = elaborate_(des, scope) & flag;
flag = elaborate_(des, scope) && flag;
}
return flag;
@ -6972,9 +6972,9 @@ class elaborate_package_t : public elaborator_work_item_t {
: elaborator_work_item_t(d), scope_(scope), package_(p)
{ }
~elaborate_package_t() { }
~elaborate_package_t() override { }
virtual void elaborate_runrun()
virtual void elaborate_runrun() override
{
if (! package_->elaborate_scope(des, scope_))
des->errors += 1;
@ -6991,9 +6991,9 @@ class elaborate_root_scope_t : public elaborator_work_item_t {
: elaborator_work_item_t(des__), scope_(scope), rmod_(rmod)
{ }
~elaborate_root_scope_t() { }
~elaborate_root_scope_t() override { }
virtual void elaborate_runrun()
virtual void elaborate_runrun() override
{
Module::replace_t root_repl;
for (list<Module::named_expr_t>::iterator cur = Module::user_defparms.begin()
@ -7025,9 +7025,9 @@ class top_defparams : public elaborator_work_item_t {
: elaborator_work_item_t(des__)
{ }
~top_defparams() { }
~top_defparams() override { }
virtual void elaborate_runrun()
virtual void elaborate_runrun() override
{
if (debug_scopes) {
cerr << "debug: top_defparams::elaborate_runrun()" << endl;
@ -7056,9 +7056,9 @@ class later_defparams : public elaborator_work_item_t {
: elaborator_work_item_t(des__)
{ }
~later_defparams() { }
~later_defparams() override { }
virtual void elaborate_runrun()
virtual void elaborate_runrun() override
{
if (debug_scopes) {
cerr << "debug: later_defparams::elaborate_runrun()" << endl;
@ -7434,7 +7434,7 @@ static void check_timescales()
}
for (mod = pform_modules.begin(); mod != pform_modules.end(); ++mod) {
Module*mp = (*mod).second;
const Module*mp = (*mod).second;
if (mp->has_explicit_timescale())
continue;
cerr << " : -- module " << (*mod).first
@ -7445,7 +7445,7 @@ static void check_timescales()
return;
for (pkg = pform_packages.begin(); pkg != pform_packages.end(); ++pkg) {
PPackage*pp = *pkg;
const PPackage*pp = *pkg;
if (pp->has_explicit_timescale())
continue;
cerr << " : -- package " << pp->pscope_name()
@ -7656,7 +7656,7 @@ Design* elaborate(list<perm_string>roots)
// creates all the NetNet and NetMemory objects for declared
// objects.
for (i = 0; i < pack_elems.size(); i += 1) {
PPackage*pack = pack_elems[i].pack;
const PPackage*pack = pack_elems[i].pack;
NetScope*scope= pack_elems[i].scope;
if (! pack->elaborate_sig(des, scope)) {
@ -7680,7 +7680,7 @@ Design* elaborate(list<perm_string>roots)
}
for (i = 0; i < root_elems.size(); i++) {
Module *rmod = root_elems[i].mod;
const Module *rmod = root_elems[i].mod;
NetScope *scope = root_elems[i].scope;
scope->set_num_ports( rmod->port_count() );
@ -7708,7 +7708,7 @@ Design* elaborate(list<perm_string>roots)
for (unsigned pin = 0; pin < mport.size(); pin += 1) {
// This really does more than we need and adds extra
// stuff to the design that should be cleaned later.
NetNet *netnet = mport[pin]->elaborate_subport(des, scope);
const NetNet *netnet = mport[pin]->elaborate_subport(des, scope);
if (netnet != 0) {
// Elaboration may actually fail with
// erroneous input source
@ -7729,13 +7729,13 @@ Design* elaborate(list<perm_string>roots)
// run through the pform again and generate the full netlist.
for (i = 0; i < pack_elems.size(); i += 1) {
PPackage*pkg = pack_elems[i].pack;
const PPackage*pkg = pack_elems[i].pack;
NetScope*scope = pack_elems[i].scope;
rc &= pkg->elaborate(des, scope);
}
for (i = 0; i < root_elems.size(); i++) {
Module *rmod = root_elems[i].mod;
const Module *rmod = root_elems[i].mod;
NetScope *scope = root_elems[i].scope;
rc &= rmod->elaborate(des, scope);
}

10
emit.cc
View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -391,7 +391,7 @@ void NetBlock::emit_recurse(struct target_t*tgt) const
if (last_ == 0)
return;
NetProc*cur = last_;
const NetProc*cur = last_;
do {
cur = cur->next_;
cur->emit_proc(tgt);
@ -467,7 +467,7 @@ void NetScope::emit_scope(struct target_t*tgt) const
tgt->scope(this);
for (NetEvent*cur = events_ ; cur ; cur = cur->snext_)
for (const NetEvent*cur = events_ ; cur ; cur = cur->snext_)
tgt->event(cur);
for (map<perm_string,netclass_t*>::const_iterator cur = classes_.begin()
@ -566,7 +566,7 @@ int Design::emit(struct target_t*tgt) const
// emit nodes
bool nodes_rc = true;
if (nodes_) {
NetNode*cur = nodes_->node_next_;
const NetNode*cur = nodes_->node_next_;
do {
nodes_rc = nodes_rc && cur->emit_node(tgt);
cur = cur->node_next_;
@ -575,7 +575,7 @@ int Design::emit(struct target_t*tgt) const
bool branches_rc = true;
for (NetBranch*cur = branches_ ; cur ; cur = cur->next_) {
for (const NetBranch*cur = branches_ ; cur ; cur = cur->next_) {
branches_rc = tgt->branch(cur) && branches_rc;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2002-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -58,9 +58,9 @@ attrib_list_t* evaluate_attributes(const map<perm_string,PExpr*>&att,
if (!tmp)
continue;
if (NetEConst *ce = dynamic_cast<NetEConst*>(tmp)) {
if (const NetEConst *ce = dynamic_cast<NetEConst*>(tmp)) {
table[idx].val = ce->value();
} else if (NetECReal *cer = dynamic_cast<NetECReal*>(tmp)) {
} else if (const NetECReal *cer = dynamic_cast<NetECReal*>(tmp)) {
table[idx].val = verinum(cer->value().as_long());
} else {
cerr << exp->get_fileline() << ": error: ``"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2022 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -153,8 +153,8 @@ NetExpr* NetEBAdd::eval_tree()
// example, the expression (a + 2) - 1 can be rewritten as a + 1.
NetEBAdd*se = dynamic_cast<NetEBAdd*>(left_);
NetEConst*lc = se? dynamic_cast<NetEConst*>(se->right_) : NULL;
NetEConst*rc = dynamic_cast<NetEConst*>(right_);
const NetEConst*lc = se? dynamic_cast<NetEConst*>(se->right_) : NULL;
const NetEConst*rc = dynamic_cast<NetEConst*>(right_);
if (lc != 0 && rc != 0) {
ivl_assert(*this, se != 0);
@ -1194,12 +1194,12 @@ NetEConst* NetEConcat::eval_arguments_(const vector<NetExpr*>&vals,
NetEConst* NetESelect::eval_tree()
{
eval_expr(expr_);
NetEConst*expr = dynamic_cast<NetEConst*>(expr_);
const NetEConst*expr = dynamic_cast<NetEConst*>(expr_);
long bval = 0;
if (base_) {
eval_expr(base_);
NetEConst*base = dynamic_cast<NetEConst*>(base_);
const NetEConst*base = dynamic_cast<NetEConst*>(base_);
if (base == 0) return 0;
@ -1242,11 +1242,11 @@ NetEConst* NetESelect::eval_tree()
static void print_ternary_cond(NetExpr*expr)
{
if (NetEConst*c = dynamic_cast<NetEConst*>(expr)) {
if (const NetEConst*c = dynamic_cast<NetEConst*>(expr)) {
cerr << c->value() << endl;
return;
}
if (NetECReal*c = dynamic_cast<NetECReal*>(expr)) {
if (const NetECReal*c = dynamic_cast<NetECReal*>(expr)) {
cerr << c->value() << endl;
return;
}
@ -2499,7 +2499,7 @@ NetExpr* NetEUFunc::eval_tree()
return 0;
}
NetFuncDef*def = func_->func_def();
const NetFuncDef*def = func_->func_def();
ivl_assert(*this, def);
vector<NetExpr*>args(parms_.size());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2021 Martin Whitaker (icarus@martin-whitaker.me.uk)
* Copyright (c) 2016-2025 Martin Whitaker (icarus@martin-whitaker.me.uk)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -47,9 +47,9 @@ struct exposenodes_functor : public functor_t {
unsigned count;
virtual void lpm_mux(Design*des, NetMux*obj);
virtual void lpm_part_select(Design*des, NetPartSelect*obj);
virtual void lpm_substitute(Design*des, NetSubstitute*obj);
virtual void lpm_mux(Design*des, NetMux*obj) override;
virtual void lpm_part_select(Design*des, NetPartSelect*obj) override;
virtual void lpm_substitute(Design*des, NetSubstitute*obj) override;
};
static bool expose_nexus(Nexus*nex)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -31,7 +31,7 @@
using namespace std;
static NetNet* convert_to_real_const(Design*des, NetScope*scope, NetEConst*expr)
static NetNet* convert_to_real_const(Design*des, NetScope*scope, const NetEConst*expr)
{
verireal vrl(expr->value().as_double());
NetECReal rlval(vrl);
@ -53,7 +53,7 @@ static bool process_binary_args(Design*des, NetScope*scope, NetExpr*root,
cases of constants, which can be converted more directly. */
if (left->expr_type() == IVL_VT_REAL) {
lsig = left->synthesize(des, scope, root);
} else if (NetEConst*tmpc = dynamic_cast<NetEConst*> (left)) {
} else if (const NetEConst*tmpc = dynamic_cast<NetEConst*> (left)) {
lsig = convert_to_real_const(des, scope, tmpc);
} else {
NetNet*tmp = left->synthesize(des, scope, root);
@ -62,7 +62,7 @@ static bool process_binary_args(Design*des, NetScope*scope, NetExpr*root,
if (right->expr_type() == IVL_VT_REAL) {
rsig = right->synthesize(des, scope, root);
} else if (NetEConst*tmpc = dynamic_cast<NetEConst*> (right)) {
} else if (const NetEConst*tmpc = dynamic_cast<NetEConst*> (right)) {
rsig = convert_to_real_const(des, scope, tmpc);
} else {
NetNet*tmp = right->synthesize(des, scope, root);
@ -177,7 +177,7 @@ NetNet* NetEBBits::synthesize(Design*des, NetScope*scope, NetExpr*root)
rsig = pad_to_width(des, rsig, width, *this);
ivl_assert(*this, lsig->vector_width() == rsig->vector_width());
netvector_t*osig_vec = new netvector_t(expr_type(), width-1, 0);
const netvector_t*osig_vec = new netvector_t(expr_type(), width-1, 0);
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
@ -247,7 +247,7 @@ NetNet* NetEBComp::synthesize(Design*des, NetScope*scope, NetExpr*root)
rsig = pad_to_width(des, rsig, width, *this);
}
netvector_t*osig_vec = new netvector_t(IVL_VT_LOGIC);
const netvector_t*osig_vec = new netvector_t(IVL_VT_LOGIC);
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
@ -576,7 +576,7 @@ NetNet* NetEBLogic::synthesize(Design*des, NetScope*scope, NetExpr*root)
olog->set_line(*this);
des->add_node(olog);
netvector_t*osig_tmp = new netvector_t(expr_type());
const netvector_t*osig_tmp = new netvector_t(expr_type());
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, osig_tmp);
osig->set_line(*this);
@ -618,7 +618,7 @@ NetNet* NetEBShift::synthesize(Design*des, NetScope*scope, NetExpr*root)
/* Detect the special case where the shift amount is
constant. Evaluate the shift amount, and simply reconnect
the left operand to the output, but shifted. */
if (NetEConst*rcon = dynamic_cast<NetEConst*>(right_)) {
if (const NetEConst*rcon = dynamic_cast<NetEConst*>(right_)) {
verinum shift_v = rcon->value();
long shift = shift_v.as_long();
@ -628,7 +628,7 @@ NetNet* NetEBShift::synthesize(Design*des, NetScope*scope, NetExpr*root)
if (shift == 0)
return lsig;
netvector_t*osig_vec = new netvector_t(expr_type(), expr_width()-1,0);
const netvector_t*osig_vec = new netvector_t(expr_type(), expr_width()-1,0);
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
@ -650,7 +650,7 @@ NetNet* NetEBShift::synthesize(Design*des, NetScope*scope, NetExpr*root)
psel->set_line(*this);
des->add_node(psel);
netvector_t*psig_vec = new netvector_t(expr_type(), part_width-1, 0);
const netvector_t*psig_vec = new netvector_t(expr_type(), part_width-1, 0);
NetNet*psig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, psig_vec);
psig->set_line(*this);
@ -678,8 +678,8 @@ NetNet* NetEBShift::synthesize(Design*des, NetScope*scope, NetExpr*root)
znum);
des->add_node(zcon);
netvector_t*zsig_vec = new netvector_t(osig->data_type(),
znum.len()-1, 0);
const netvector_t*zsig_vec = new netvector_t(osig->data_type(),
znum.len()-1, 0);
NetNet*zsig = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, zsig_vec);
zsig->set_line(*this);
@ -709,7 +709,7 @@ NetNet* NetEBShift::synthesize(Design*des, NetScope*scope, NetExpr*root)
if (rsig == 0) return 0;
netvector_t*osig_vec = new netvector_t(expr_type(), expr_width()-1, 0);
const netvector_t*osig_vec = new netvector_t(expr_type(), expr_width()-1, 0);
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
@ -966,7 +966,7 @@ NetNet* NetEUBits::synthesize(Design*des, NetScope*scope, NetExpr*root)
}
unsigned width = isig->vector_width();
netvector_t*osig_vec = new netvector_t(expr_type(), width-1, 0);
const netvector_t*osig_vec = new netvector_t(expr_type(), width-1, 0);
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
@ -1009,8 +1009,8 @@ NetNet* NetEUnary::synthesize(Design*des, NetScope*scope, NetExpr*root)
if (expr_->has_sign() == false)
return sub;
netvector_t*sig_vec = new netvector_t(sub->data_type(),
sub->vector_width()-1, 0);
const netvector_t*sig_vec = new netvector_t(sub->data_type(),
sub->vector_width()-1, 0);
NetNet*sig = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, sig_vec);
sig->set_line(*this);
@ -1084,7 +1084,7 @@ NetNet* NetEUReduce::synthesize(Design*des, NetScope*scope, NetExpr*root)
gate->set_line(*this);
des->add_node(gate);
netvector_t*osig_vec = new netvector_t(expr_type());
const netvector_t*osig_vec = new netvector_t(expr_type());
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
@ -1139,7 +1139,7 @@ NetNet* NetESelect::synthesize(Design *des, NetScope*scope, NetExpr*root)
// Detect the special case that there is a base expression and
// it is constant. In this case we can generate fixed part selects.
if (NetEConst*base_const = dynamic_cast<NetEConst*>(base_)) {
if (const NetEConst*base_const = dynamic_cast<NetEConst*>(base_)) {
verinum base_tmp = base_const->value();
unsigned select_width = expr_width();
@ -1194,8 +1194,8 @@ NetNet* NetESelect::synthesize(Design *des, NetScope*scope, NetExpr*root)
des->add_node(sel);
ivl_assert(*this, select_width > 0);
netvector_t*tmp_vec = new netvector_t(sub->data_type(),
select_width-1, 0);
const netvector_t*tmp_vec = new netvector_t(sub->data_type(),
select_width-1, 0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, tmp_vec);
tmp->set_line(*this);
@ -1243,8 +1243,8 @@ NetNet* NetESelect::synthesize(Design *des, NetScope*scope, NetExpr*root)
sel->set_line(*this);
des->add_node(sel);
netvector_t*tmp_vec = new netvector_t(sub->data_type(),
expr_width()-1, 0);
const netvector_t*tmp_vec = new netvector_t(sub->data_type(),
expr_width()-1, 0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, tmp_vec);
tmp->local_flag(true);
@ -1321,7 +1321,7 @@ NetNet* NetESelect::synthesize(Design *des, NetScope*scope, NetExpr*root)
con->set_line(*this);
des->add_node(con);
netvector_t*tmp_vec = new netvector_t(expr_type(), pad_width-1, 0);
const netvector_t*tmp_vec = new netvector_t(expr_type(), pad_width-1, 0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, tmp_vec);
tmp->set_line(*this);
@ -1376,7 +1376,7 @@ NetNet* NetETernary::synthesize(Design *des, NetScope*scope, NetExpr*root)
ivl_assert(*this, csig->vector_width() == 1);
unsigned width=expr_width();
netvector_t*osig_vec = new netvector_t(expr_type(), width-1, 0);
const netvector_t*osig_vec = new netvector_t(expr_type(), width-1, 0);
NetNet*osig = new NetNet(csig->scope(), path, NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
osig->local_flag(true);
@ -1421,8 +1421,8 @@ NetNet* NetESignal::synthesize(Design*des, NetScope*scope, NetExpr*root)
// If this is a synthesis with a specific value for the
// signal, then replace it (here) with a constant value.
if (net_->scope()==scope && net_->name()==scope->genvar_tmp) {
netvector_t*tmp_vec = new netvector_t(net_->data_type(),
net_->vector_width()-1, 0);
const netvector_t*tmp_vec = new netvector_t(net_->data_type(),
net_->vector_width()-1, 0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, tmp_vec);
tmp->set_line(*this);
@ -1452,8 +1452,8 @@ NetNet* NetESignal::synthesize(Design*des, NetScope*scope, NetExpr*root)
return tmp;
}
netvector_t*tmp_vec = new netvector_t(net_->data_type(),
net_->vector_width()-1, 0);
const netvector_t*tmp_vec = new netvector_t(net_->data_type(),
net_->vector_width()-1, 0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, tmp_vec);
tmp->set_line(*this);
@ -1462,7 +1462,7 @@ NetNet* NetESignal::synthesize(Design*des, NetScope*scope, NetExpr*root)
// For NetExpr objects, the word index is already converted to
// a canonical (lsb==0) address. Just use the index directly.
if (NetEConst*index_co = dynamic_cast<NetEConst*> (word_)) {
if (const NetEConst*index_co = dynamic_cast<NetEConst*> (word_)) {
long index = index_co->value().as_long();
connect(tmp->pin(0), net_->pin(index));
@ -1483,7 +1483,7 @@ NetNet* NetESignal::synthesize(Design*des, NetScope*scope, NetExpr*root)
return tmp;
}
static NetEvWait* make_func_trigger(Design*des, NetScope*scope, NetExpr*root)
static NetEvWait* make_func_trigger(Design*des, NetScope*scope, const NetExpr*root)
{
NetEvWait*trigger = 0;
@ -1611,8 +1611,8 @@ NetNet* NetEUFunc::synthesize(Design*des, NetScope*scope, NetExpr*root)
des->add_node(net);
/* Create an output signal and connect it to the function. */
netvector_t*osig_vec = new netvector_t(result_sig_->expr_type(),
result_sig_->vector_width()-1, 0);
const netvector_t*osig_vec = new netvector_t(result_sig_->expr_type(),
result_sig_->vector_width()-1, 0);
NetNet*osig = new NetNet(scope_, scope_->local_symbol(), NetNet::WIRE,
osig_vec);
osig->set_line(*this);
@ -1626,7 +1626,7 @@ NetNet* NetEUFunc::synthesize(Design*des, NetScope*scope, NetExpr*root)
}
/* Connect the pins to the arguments. */
NetFuncDef*def = func_->func_def();
const NetFuncDef*def = func_->func_def();
for (unsigned idx = 0; idx < eparms.size(); idx += 1) {
unsigned width = def->port(idx)->vector_width();
NetNet*tmp;

View File

@ -29,7 +29,11 @@ SUFFIX=@SUFFIX@
# These are used for linking...
LD=$CC
LDFLAGS="@IVCTARGETFLAGS@ @SHARED@ -L@LIBDIR@"
LDLIBS="-lveriuser$SUFFIX -lvpi$SUFFIX"
if [ x@ENABLE_PLI1@ = xyes ] ; then
LDLIBS="-lveriuser$SUFFIX -lvpi$SUFFIX"
else
LDLIBS="-lvpi$SUFFIX"
fi
CCSRC=
CXSRC=

View File

@ -1,7 +1,7 @@
#ifndef IVL_ivl_alloc_H
#define IVL_ivl_alloc_H
/*
* Copyright (C) 2010-2014 Cary R. (cygcary@yahoo.com)
* Copyright (C) 2010-2025 Cary R. (cygcary@yahoo.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -21,12 +21,30 @@
#ifdef __cplusplus
# include <cstdlib>
# include <cstdio>
# include <cstring>
#else
# include <stdlib.h>
# include <stdio.h>
# include <string.h>
#endif
#if defined(__GNUC__)
/*
* Define a safer version of strdup().
*/
#define strdup(__ivl_str) \
({ \
char *__ivl_rtn = strdup(__ivl_str); \
/* If we run out of memory then exit with a message. */ \
if (__ivl_rtn == NULL) { \
fprintf(stderr, "%s:%d: Error: strdup() ran out of memory.\n", \
__FILE__, __LINE__); \
exit(1); \
} \
__ivl_rtn; \
})
/*
* Define a safer version of malloc().
*/

View File

@ -60,7 +60,10 @@ distclean: clean
rm -f Makefile config.log
cppcheck: $(O:.o=.c)
cppcheck --enable=all --std=c99 --std=c++11 -f $(INCLUDE_PATH) $^
cppcheck --enable=all --std=c99 --std=c++11 -f \
--check-level=exhaustive \
--suppressions-list=$(srcdir)/../cppcheck-global.sup \
$(INCLUDE_PATH) $^
Makefile: $(srcdir)/Makefile.in ../config.status
cd ..; ./config.status --file=ivlpp/$@

View File

@ -73,7 +73,7 @@ unsigned vhdlpp_libdir_cnt = 0;
static char**source_list = 0;
static unsigned source_cnt = 0;
void add_source_file(const char*name)
static void add_source_file(const char*name)
{
if (source_list == 0) {
source_list = calloc(2, sizeof(char*));

View File

@ -5,13 +5,13 @@
package Environment;
use strict;
use warnings;
#use warnings;
our $VERSION = '1.03';
use base 'Exporter';
our @EXPORT = qw(get_args get_regress_fn get_ivl_version);
our @EXPORT = qw(get_args get_regress_fn get_ivl_version run_program);
use constant DEF_REGRESS_FN => './regress.list'; # Default regression list.
use constant DEF_SUFFIX => ''; # Default suffix.
@ -102,4 +102,26 @@ sub get_ivl_version {
}
}
#
# Run a subprogram. This avoids spawing an intermediate shell when output
# is redirected to a log file.
#
sub run_program {
my ($cmd, $log_mode, $log_file) = @_;
my $ret;
if ($log_mode) {
open(OLDOUT, '>&STDOUT');
open(OLDERR, '>&STDERR');
open(STDOUT, $log_mode, $log_file) or die("couldn't open log file '$log_file'\n");
open(STDERR, '>&STDOUT');
$ret = system($cmd);
open(STDOUT, '>&OLDOUT');
open(STDERR, '>&OLDERR');
} else {
$ret = system($cmd);
}
$ret;
}
1; # Module loaded OK

View File

@ -4,7 +4,7 @@
#
# This script is based on code with the following Copyright.
#
# Copyright (c) 1999-2024 Guy Hutchison (ghutchis@pacbell.net)
# Copyright (c) 1999-2025 Guy Hutchison (ghutchis@pacbell.net)
#
# This source code is free software; you can redistribute it
# and/or modify it in source code form under the terms of the GNU
@ -126,9 +126,9 @@ sub execute_regression {
$cmd .= $testtype{$tname} eq "CN" ? " -t null" : " -t vlog95";
$cmd .= " -pfileline=1 -pspacing=4" if ($testtype{$tname} ne "CN");
$cmd .= " -D__ICARUS_UNSIZED__ $args{$tname}";
$cmd .= " ./$srcpath{$tname}/$tname.v > log/$tname.log 2>&1";
$cmd .= " ./$srcpath{$tname}/$tname.v";
# print "$cmd\n";
if (system("$cmd")) {
if (run_program($cmd, '>', "log/$tname.log")) {
if ($testtype{$tname} eq "CE") {
# Check if the system command core dumped!
if ($? >> 8 & 128) {
@ -186,9 +186,9 @@ sub execute_regression {
$args{$tname} =~ s/-gverilog-ams//g;
$cmd = "iverilog$sfx -o vsim $gen_flag $args{$tname}";
$cmd .= " -s $testmod{$tname}" if ($testmod{$tname} ne "");
$cmd .= " vlog95.v >> log/$tname.log 2>&1";
$cmd .= " vlog95.v";
# print "$cmd\n";
if ($pass_type == 0 and system("$cmd")) {
if ($pass_type == 0 and run_program($cmd, '>>', "log/$tname.log")) {
if ($testtype{$tname} eq "TE") {
# Check if the system command core dumped!
if ($? >> 8 & 128) {
@ -205,9 +205,9 @@ sub execute_regression {
}
}
$cmd = "vvp$sfx vsim $plargs{$tname} >> log/$tname.log 2>&1";
$cmd = "vvp$sfx vsim $plargs{$tname}";
# print "$cmd\n";
if ($pass_type == 0 and system("$cmd")) {
if ($pass_type == 0 and run_program($cmd, '>>', "log/$tname.log")) {
if ($testtype{$tname} eq "RE") {
# Check if the system command core dumped!
if ($? >> 8 & 128) {
@ -275,7 +275,7 @@ sub execute_regression {
} continue {
if ($tname ne "") {
system("rm -f ./vlog95.v ./vsim") and
run_program("rm -f ./vlog95.v ./vsim") and
die "Error: failed to remove temporary file.\n";
}
}

View File

@ -11,8 +11,10 @@ $| = 1; # This turns off buffered I/O
# We support a --suffix= and --with-valgrind flags.
use Getopt::Long;
$sfx = ""; # Default suffix.
$with_pli1 = 0; # Default PLI 1 support (keep this off).
$with_valg = 0; # Default valgrind usage (keep this off).
if (!GetOptions("suffix=s" => \$sfx,
"with-pli1" => \$with_pli1,
"with-valgrind" => \$with_valg,
"help" => \&usage)) {
die "Error: Invalid argument(s).\n";
@ -22,6 +24,8 @@ sub usage {
warn "$0 usage:\n\n" .
" --suffix=<suffix> # The Icarus executables suffix, " .
"default \"\".\n" .
" --with-pli1 # Include the PLI 1 tests, " .
"default \"off\".\n" .
" --with-valgrind # Run the test suite with valgrind, " .
"default \"off\".\n" .
" <regression file> # The regression file, " .
@ -104,6 +108,7 @@ sub read_regression_list {
$testtype = $fields[1];
$args{$tname} = "";
}
next if ($testtype eq "PLI1" && !$with_pli1); # Skip PLI 1 tests if not enabled.
# This version of the program does not implement something
# required to run this test.
if ($testtype eq "NI") {
@ -128,8 +133,10 @@ sub read_regression_list {
$args{$tname} = join(' ', split(',', $args{$tname}));
}
} else {
$testtype = $fields[1];
$args{$tname} = "";
}
next if ($testtype eq "PLI1" && !$with_pli1); # Skip PLI 1 tests if not enabled.
$ccode{$tname} = $fields[2];
$goldfile{$tname} = $fields[3];
$cargs{$tname} = $fields[4];
@ -189,17 +196,16 @@ sub execute_regression {
}
$cmd = "iverilog-vpi$sfx --name=$tname $cargs{$tname} " .
"vpi/$ccode{$tname} > vpi_log/$tname.log 2>&1";
if (system("$cmd")) {
"vpi/$ccode{$tname}";
if (run_program($cmd, '>', "vpi_log/$tname.log")) {
print "==> Failed - running iverilog-vpi.\n";
$failed++;
next;
}
$cmd = $with_valg ? "valgrind --trace-children=yes " : "";
$cmd .= "iverilog$sfx $args{$tname} -L . -m $tname -o vsim vpi/$tname.v >> " .
"vpi_log/$tname.log 2>&1";
if (system("$cmd")) {
$cmd .= "iverilog$sfx $args{$tname} -L . -m $tname -o vsim vpi/$tname.v";
if (run_program($cmd, '>>', "vpi_log/$tname.log")) {
print "==> Failed - running iverilog.\n";
$failed++;
next;
@ -207,8 +213,8 @@ sub execute_regression {
$cmd = $with_valg ? "valgrind --leak-check=full " .
"--show-reachable=yes " : "";
$cmd .= "vvp$sfx vsim >> vpi_log/$tname.log 2>&1";
if (system("$cmd")) {
$cmd .= "vvp$sfx vsim";
if (run_program($cmd, '>>', "vpi_log/$tname.log")) {
print "==> Failed - running vvp.\n";
$failed++;
next;
@ -230,7 +236,7 @@ sub execute_regression {
if ($tname ne "" and $ccode{$tname} ne "") {
my $doto = $ccode{$tname};
$doto =~ s/\.(c|cc|cpp)$/.o/;
system("rm -f $doto $tname.vpi vsim") and
run_program("rm -f $doto $tname.vpi vsim") and
die "Error: failed to remove temporary files.\n";
}
}

View File

@ -62,7 +62,7 @@ br_gh59 normal br_gh59.c br_gh59.gold
br_gh73a normal force.c br_gh73a.gold
br_gh73b normal force.c br_gh73b.gold
br_gh117 normal br_gh117.c br_gh117.gold
br_gh141 normal br_gh141.c br_gh141.gold
br_gh141 PLI1 br_gh141.c br_gh141.gold
br_gh169a normal br_gh169.c br_gh169a.gold
br_gh169b normal,-g2009 br_gh169.c br_gh169b.gold
br_gh184 normal start_of_simtime1.c br_gh184.gold
@ -93,9 +93,9 @@ force_wire_real normal force_real.c force_wire_real.gold
genblk_named normal genblk_names.c genblk_named.gold
genblk_unnamed normal genblk_names.c genblk_unnamed.gold
genblk_direct normal,-g2009 genblk_names.c genblk_direct.gold
getp normal getp.c getp.log
getp PLI1 getp.c getp.log
hello_poke normal hello_poke.c hello_poke.log
hello_tf normal hello_tf.c hello_tf.log
hello_tf PLI1 hello_tf.c hello_tf.log
hello_vpi normal hello_vpi.c hello.log
hello_vpi2 normal hello_vpi2.c hello2.log vpi/hello_vpi1.c
listparams normal listparams.c listparams.log
@ -105,15 +105,15 @@ nextsimtime_cb3 normal nextsimtime_cb3.c nextsimtime_cb3.gold
nextsimtime_cb4 normal nextsimtime_cb4.c nextsimtime_cb4.gold
memmon normal,-g1995 memmon.c memmon.log
memwide normal memwide.cc memwide.log
mipname normal mipname.c mipname.log
mipname PLI1 mipname.c mipname.log
myscope normal myscope.c myscope.gold
myscope2 normal myscope2.c myscope2.gold
myscope2 PLI1 myscope2.c myscope2.gold
nulls1 normal nulls1.c nulls1.log
poke_escaped normal poke_escaped.c poke_escaped.gold
pokevent normal pokevent.cc pokevent.log
pokereg normal pokereg.cc pokereg.log
ports_params normal ports_params.c ports_params.gold
pr521 normal pr521.c pr521.log
pr521 PLI1 pr521.c pr521.log
pr686 normal pr686.c pr686.log
pr723 normal pr723.c pr723.log
pr1693971 normal pr1693971.c pr1693971.log
@ -121,8 +121,8 @@ pr2048463 normal pr2048463.c pr2048463.log
pr2314742 normal pr2314742.c pr2314742.gold
pr2966059 normal pr2966059.c pr2966059.gold
pr2971220 normal pr2971220.c pr2971220.gold
putp normal putp.c putp.log
putp2 normal putp2.c putp2.log
putp PLI1 putp.c putp.log
putp2 PLI1 putp2.c putp2.log
putvalue normal putvalue.c putvalue.log
range1 normal range1.c range1.gold
realcb normal realcb.c realcb.log
@ -137,7 +137,7 @@ sim_time_cb1 normal sim_time_cb1.c sim_time_cb1.gold
sim_time_cb2 normal sim_time_cb2.c sim_time_cb2.gold
spec_delays normal,-gspecify spec_delays.c spec_delays.log
start_of_simtime1 normal start_of_simtime1.c start_of_simtime1.log
timescale normal timescale.c timescale.log
timescale PLI1 timescale.c timescale.log
value_change_cb1 normal,-g2009 value_change_cb1.c value_change_cb1.gold
value_change_cb2 normal,-g2009 value_change_cb2.c value_change_cb2.gold
value_change_cb3 normal,-g2009 value_change_cb3.c value_change_cb3.gold

View File

@ -4,7 +4,7 @@
#
# This script is based on code with the following Copyright.
#
# Copyright (c) 1999-2024 Guy Hutchison (ghutchis@pacbell.net)
# Copyright (c) 1999-2025 Guy Hutchison (ghutchis@pacbell.net)
#
# This source code is free software; you can redistribute it
# and/or modify it in source code form under the terms of the GNU
@ -136,9 +136,9 @@ sub execute_regression {
$cmd .= "iverilog$sfx -o vsim $ivl_args $args{$tname}";
$cmd .= " -s $testmod{$tname}" if ($testmod{$tname} ne "");
$cmd .= " -t null" if ($testtype{$tname} eq "CN");
$cmd .= " ./$srcpath{$tname}/$tname.v > log/$tname.log 2>&1";
$cmd .= " ./$srcpath{$tname}/$tname.v";
# print "$cmd\n";
if (system("$cmd")) {
if (run_program($cmd, '>', "log/$tname.log")) {
if ($testtype{$tname} eq "CE") {
# Check if the system command core dumped!
if ($? >> 8 & 128) {
@ -174,9 +174,9 @@ sub execute_regression {
$cmd = $with_valg ? "valgrind --leak-check=full " .
"--show-reachable=yes " : "";
$cmd .= "vvp$sfx vsim $vvp_args $plargs{$tname} >> log/$tname.log 2>&1";
$cmd .= "vvp$sfx vsim $vvp_args $plargs{$tname}";
# print "$cmd\n";
if ($pass_type == 0 and system("$cmd")) {
if ($pass_type == 0 and run_program($cmd, '>>', "log/$tname.log")) {
if ($testtype{$tname} eq "RE") {
# Check if the system command core dumped!
if ($? >> 8 & 128) {
@ -242,7 +242,7 @@ sub execute_regression {
} continue {
if ($tname ne "") {
system("rm -f ./vsim && rm -rf ivl_vhdl_work") and
run_program("rm -rf ./vsim ivl_vhdl_work") and
die "Error: failed to remove temporary file.\n";
}
}
@ -252,7 +252,7 @@ sub execute_regression {
" Not Implemented=$not_impl, Expected Fail=$expected_fail\n");
# Remove remaining temporary files
system("rm -f *.tmp ivltests/*.tmp");
run_program("rm -f *.tmp ivltests/*.tmp");
return $failed;
}

View File

@ -920,7 +920,7 @@ void lex_end_table()
BEGIN(INITIAL);
}
static unsigned truncate_to_integer_width(verinum::V*bits, unsigned size)
static unsigned truncate_to_integer_width(const verinum::V*bits, unsigned size)
{
if (size <= integer_width) return size;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2002-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -56,8 +56,8 @@ const char* StringHeap::add(const char*text)
char*buf = strdup(text);
#ifdef CHECK_WITH_VALGRIND
string_pool_count += 1;
string_pool = (char**)realloc(string_pool,
string_pool_count*sizeof(char**));
string_pool = static_cast<char**>(realloc(string_pool,
string_pool_count*sizeof(char**)));
string_pool[string_pool_count-1] = buf;
#endif
return buf;
@ -72,19 +72,19 @@ const char* StringHeap::add(const char*text)
// same pointer.
if (rem > 0) {
char*old = cell_base_;
cell_base_ = (char*)realloc(cell_base_, cell_ptr_);
cell_base_ = static_cast<char*>(realloc(cell_base_, cell_ptr_));
assert(cell_base_ != 0);
assert(cell_base_ == old);
}
// start new cell
cell_base_ = (char*)malloc(DEFAULT_CELL_SIZE);
cell_base_ = static_cast<char*>(malloc(DEFAULT_CELL_SIZE));
cell_ptr_ = 0;
rem = DEFAULT_CELL_SIZE;
assert(cell_base_ != 0);
#ifdef CHECK_WITH_VALGRIND
string_pool_count += 1;
string_pool = (char **) realloc(string_pool,
string_pool_count*sizeof(char **));
string_pool = static_cast<char **>(realloc(string_pool,
string_pool_count*sizeof(char **)));
string_pool[string_pool_count-1] = cell_base_;
#endif
}

View File

@ -77,6 +77,8 @@ distclean: clean
cppcheck: $(O:.o=.c)
cppcheck --enable=all --std=c99 --std=c++11 -f \
--check-level=exhaustive \
--suppressions-list=$(srcdir)/../cppcheck-global.sup \
--suppressions-list=$(srcdir)/cppcheck.sup \
--relative-paths=$(srcdir) $(INCLUDE_PATH) $^

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003-2020 Stephen Williams (steve@icarus.com)
* Copyright (c) 2003-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -38,7 +38,7 @@ handle acc_handle_object(const char*name)
char* acc_set_scope(handle ref, ...)
{
char*name;
const char*name;
search_scope = ref;
name = acc_fetch_fullname(search_scope);

View File

@ -1,3 +1,19 @@
// We use guarded memory allocation routines, but cppcheck is not
// noticing this so it is complaining we could return a NULL value.
nullPointerOutOfMemory:workarea.c:53 // calloc @ 52
nullPointerOutOfMemory:workarea.c:54 // calloc @ 52
nullPointerOutOfMemory:workarea.c:55 // calloc @ 52
nullPointerOutOfMemory:veriusertfs.c:61 // calloc @ 70
nullPointerOutOfMemory:veriusertfs.c:62 // calloc @ 70
nullPointerOutOfMemory:veriusertfs.c:63 // calloc @ 70
nullPointerOutOfMemory:a_vcl.c:167 // strdup @ 166
nullPointerOutOfMemory:a_vcl.c:168 // strdup @ 166
nullPointerOutOfMemory:a_vcl.c:169 // strdup @ 166
nullPointerOutOfMemory:a_vcl.c:170 // strdup @ 166
nullPointerOutOfMemory:a_vcl.c:171 // strdup @ 166
nullPointerOutOfMemory:a_vcl.c:180 // strdup @ 166
memleakOnRealloc:veriusertfs.c:66
// These are the functions that the runtime exports.
// The ACC functions.

View File

@ -53,7 +53,13 @@ PLI_INT32 tf_igetp(PLI_INT32 n, void *obj)
vpi_get_value(arg_h, &value);
/* The following may generate a compilation warning, but this
* functionality is required by some versions of the standard. */
rtn = (int)(intptr_t)value.value.str; /* Oh my */
rtn = (PLI_INT32)(intptr_t)value.value.str; /* Oh my */
if ((intptr_t)rtn != (intptr_t)value.value.str) {
fprintf(stderr, "warning: tf_getp returning string pointer. "
"Pointer value doesn't fit in 32 bits, "
"returning 0.\n");
rtn = 0;
}
} else {
value.format = vpiIntVal;
vpi_get_value(arg_h, &value);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2013 Michael Ruff (mruff at chiaro.com)
* Copyright (c) 2002-2025 Michael Ruff (mruff at chiaro.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -24,7 +24,7 @@
/*
* mc_scan_plusargs implemented using VPI interface
*/
char *mc_scan_plusargs(char *plusarg)
char *mc_scan_plusargs(const char *plusarg)
{
int argc, diff;
char **argv;
@ -37,7 +37,8 @@ char *mc_scan_plusargs(char *plusarg)
/* for each argument */
argv = vpi_vlog_info.argv;
for (argc = 0; argc < vpi_vlog_info.argc; argc++, argv++) {
char *a, *p;
char *a;
const char *p;
a = *argv;
p = plusarg;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -122,7 +122,7 @@ int build_library_index(const char*path, bool key_case_sensitive)
/* Scan the director for files. check each file name to see if
it has one of the configured suffixes. If it does, then use
the root of the name as the key and index the file name. */
while (struct dirent*de = readdir(dir)) {
while (const struct dirent*de = readdir(dir)) {
unsigned namsiz = strlen(de->d_name);
char*key = 0;

27
main.cc
View File

@ -95,7 +95,10 @@ static void signals_handler(int sig)
unsigned flag_errors = 0;
static unsigned long pre_process_fail_count = 0;
const char*basedir = strdup(".");
// We have to wrap the strdup() so that the define expands correctly.
static char* init_basedir(void)
{ return strdup("."); }
const char*basedir = init_basedir();
/*
* These are the language support control flags. These support which
@ -130,10 +133,10 @@ void add_vpi_module(const char*name)
vpi_module_list = strdup(name);
} else {
char*tmp = (char*)realloc(vpi_module_list,
strlen(vpi_module_list)
+ strlen(name)
+ 2);
char*tmp = static_cast<char*>(realloc(vpi_module_list,
strlen(vpi_module_list)
+ strlen(name)
+ 2));
strcat(tmp, ",");
strcat(tmp, name);
vpi_module_list = tmp;
@ -647,7 +650,7 @@ static void read_iconfig_file(const char*ipath)
}
if (strcmp(buf, "basedir") == 0) {
free((void *)basedir);
free(static_cast<void*>(const_cast<char *>(basedir)));
basedir = strdup(cp);
} else if (strcmp(buf, "debug") == 0) {
@ -715,7 +718,7 @@ static void read_iconfig_file(const char*ipath)
add_vpi_module(cp);
} else if (strcmp(buf, "out") == 0) {
free((void *)flags["-o"]);
free(reinterpret_cast<void*>(const_cast<char*>(flags["-o"])));
flags["-o"] = strdup(cp);
} else if (strcmp(buf, "sys_func") == 0) {
@ -861,7 +864,7 @@ static void read_sources_file(const char*path)
extern Design* elaborate(list <perm_string> root);
#if defined(HAVE_TIMES)
static double cycles_diff(struct tms *a, struct tms *b)
static double cycles_diff(const struct tms *a, const struct tms *b)
{
clock_t aa = a->tms_utime
+ a->tms_stime
@ -892,13 +895,13 @@ static void EOC_cleanup(void)
}
library_suff.clear();
free((void *) basedir);
free(reinterpret_cast<void*>(const_cast<char*>(basedir)));
free(ivlpp_string);
free(depfile_name);
for (map<string, const char*>::iterator flg = flags.begin() ;
flg != flags.end() ; ++ flg ) {
free((void *)flg->second);
free(reinterpret_cast<void*>(const_cast<char*>(flg->second)));
}
flags.clear();
@ -1397,7 +1400,7 @@ static void find_module_mention(map<perm_string,bool>&check_map, Module*mod)
list<PGate*> gates = mod->get_gates();
list<PGate*>::const_iterator gate;
for (gate = gates.begin(); gate != gates.end(); ++ gate ) {
PGModule*tmp = dynamic_cast<PGModule*>(*gate);
const PGModule*tmp = dynamic_cast<PGModule*>(*gate);
if (tmp) {
// Note that this module has been instantiated
check_map[tmp->get_type()] = true;
@ -1415,7 +1418,7 @@ static void find_module_mention(map<perm_string,bool>&check_map, PGenerate*schm)
{
list<PGate*>::const_iterator gate;
for (gate = schm->gates.begin(); gate != schm->gates.end(); ++ gate ) {
PGModule*tmp = dynamic_cast<PGModule*>(*gate);
const PGModule*tmp = dynamic_cast<PGModule*>(*gate);
if (tmp) {
// Note that this module has been instantiated
check_map[tmp->get_type()] = true;

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 Lars-Peter Clausen <lars@metafoo.de>
// SPDX-FileCopyrightText: 2023-2025 Lars-Peter Clausen <lars@metafoo.de>
// SPDX-License-Identifier: GPL-2.0-or-later
#include "PExpr.h"
@ -62,7 +62,7 @@ std::vector<PExpr*> map_named_args(Design *des,
return args;
}
std::vector<PExpr*> map_named_args(Design *des, NetBaseDef *def,
std::vector<PExpr*> map_named_args(Design *des, const NetBaseDef *def,
const std::vector<named_pexpr_t> &parms,
unsigned int off)
{

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 Lars-Peter Clausen <lars@metafoo.de>
// SPDX-FileCopyrightText: 2023-2025 Lars-Peter Clausen <lars@metafoo.de>
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef MAP_NAMED_ARGS_H
@ -15,7 +15,7 @@ std::vector<PExpr*> map_named_args(Design *des,
const std::vector<perm_string> &names,
const std::vector<named_pexpr_t> &parms);
std::vector<PExpr*> map_named_args(Design *des, NetBaseDef *def,
std::vector<PExpr*> map_named_args(Design *des, const NetBaseDef *def,
const std::vector<named_pexpr_t> &parms,
unsigned int off);

View File

@ -1,17 +1,21 @@
_realname=iverilog
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=ci
pkgver=devel
pkgrel=1
pkgdesc="Icarus Verilog, a Verilog simulation and synthesis tool (mingw-w64)"
pkgdesc="Icarus Verilog, a Verilog simulation tool (mingw-w64)"
arch=('any')
mingw_arch=('mingw64', 'ucrt64', 'clang64')
url="https://steveicarus.github.io/iverilog/"
license=('GPLv2+')
depends=("${MINGW_PACKAGE_PREFIX}-readline"
"${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("autoconf"
license=('spdx:GPL-2.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs"
"${MINGW_PACKAGE_PREFIX}-readline"
"${MINGW_PACKAGE_PREFIX}-bzip2"
"${MINGW_PACKAGE_PREFIX}-zlib")
makedepends=("gperf"
"man-db"
"${MINGW_PACKAGE_PREFIX}-gcc"
"${MINGW_PACKAGE_PREFIX}-cc"
"${MINGW_PACKAGE_PREFIX}-autotools"
"${MINGW_PACKAGE_PREFIX}-ghostscript")
source=()
@ -22,16 +26,16 @@ build() {
sh autoconf.sh
./configure \
--prefix="${MINGW_PREFIX}" \
--host="$CARCH"-w64-mingw32
mingw32-make
${IVL_CONFIG_OPTIONS}
make
}
check() {
cd "${srcdir}"/../..
mingw32-make check
make check
}
package() {
cd "${srcdir}"/../..
mingw32-make DESTDIR="${pkgdir}" PACKAGE="${_realname}" install
make DESTDIR="${pkgdir}" PACKAGE="${_realname}" install
}

View File

@ -1,29 +1,53 @@
# MSYS2 build recipe
This subdir contains a [PKGBUILD](https://wiki.archlinux.org/index.php/PKGBUILD) recipe for building iverilog on [MSYS2](https://www.msys2.org/). MSYS2 is a collection of tools and libraries for Windows, which is closely based on the packaging approach in [Arch Linux](https://www.archlinux.org/). Precisely, the package manager in MSYS2 is a port of [pacman](https://wiki.archlinux.org/index.php/pacman). Therefore, the structure of PKGBUILD recipes in MSYS2 is very similar to packages in Arch Linux and the build script (`makepkg-mingw`) is a port of [makepkg](https://wiki.archlinux.org/index.php/makepkg).
This directory contains a [PKGBUILD](https://wiki.archlinux.org/index.php/PKGBUILD)
recipe for building Icarus Verilog in [MSYS2](https://www.msys2.org/). MSYS2
is a collection of tools and libraries for Windows that is closely based on
the packaging approach in [Arch Linux](https://www.archlinux.org/). The package
manager in MSYS2 is a port of [pacman](https://wiki.archlinux.org/index.php/pacman).
Therefore the structure of PKGBUILD recipes in MSYS2 is very similar to that in
Arch Linux and the build script (`makepkg-mingw`) is a port of
[makepkg](https://wiki.archlinux.org/index.php/makepkg).
Other than that, PKGBUILD files are shell scripts containing some specific functions (build, package, check, etc.) and metadata (variables). The build system takes care of dependencies, creating temporary directories, generating a tarball, etc. Therefore, the recommended approach for building iverilog on Windows is the following:
Other than that, PKGBUILD files are shell scripts containing some specific
functions (build, package, check, etc.) and metadata (variables). The build
system takes care of dependencies, creating temporary directories, generating
a tarball, etc. Therefore, the recommended approach for building Icarus Verilog
on Windows is the following:
```sh
# Install the toolchain
pacman -S mingw-w64-x86_64-toolchain
# and/or mingw-w64-i686-toolchain
# Install the base development tools
pacman -S base-devel
# Retrieve iverilog sources. Optionally, retrieve a tarball, or an specific branch/version.
# Retrieve the Icarus Verilog sources. Optionally, retrieve a tarball, or a
# specific branch/version.
git clone https://github.com/steveicarus/iverilog
cd iverilog
# Call makepkg-mingw from subdir 'msys2'. It will build, check and package iverilog.
# Call makepkg-mingw from the directory 'msys2'. It will install dependencies,
# build, check, and package Icarus Verilog.
cd msys2
MINGW_INSTALLS=mingw64 makepkg-mingw --noconfirm --noprogressbar -sCLf
# or, set the envvar to 'mingw32', or unset it for building both packages at the same time
makepkg-mingw --noconfirm --noprogressbar -sCLf
# Optionally, install the tarball(s)/package(s). Or just distribute it/them.
pacman -U --noconfirm *.zst
```
NOTE: the continuous integration workflow in [github.com/steveicarus](https://github.com/steveicarus) uses the procedure above for building iverilog on MINGW32 and MINGW64 each time a commit is pushed or a Pull Request is updated. The two generated packages are uploaded as artifacts. Hence, users willing to test *nightly* builds or specific features, can download and install the tarballs from the corresponding CI run.
Additional configuration options can be passed to the configuration step
by setting the environment variable `IVL_CONFIG_OPTIONS` before calling
`makepkg-mingw`, e.g.
```sh
export IVL_CONFIG_OPTIONS=-"-enable-suffix=-devel --enable-libvvp"
```
Nevertheless, the content of functions `build` and `check` in the PKGBUILD file should be familiar for any user willing to build iverilog *manually*. Those can be executed in a shell (ignoring makepkg), as long as the few envvars are properly defined.
NOTE: the continuous integration workflow in [github.com/steveicarus/iverilog]
(https://github.com/steveicarus/iverilog) uses the above procedure for building
Icarus Verilog for Windows each time a commit is pushed or a pull request is
updated. The generated packages are uploaded as artifacts. Hence, users willing
to test *development* builds or specific features, can download and install the
tarballs from the corresponding CI run.
HINT: this document explains the most straightforward and automatec solution for building iverilog on Windows. However, intermediate and advanced users might want to check [iverilog.fandom.com/wiki/Installation_using_MSYS2](https://iverilog.fandom.com/wiki/Installation_using_MSYS2) for some specific tweaks, such as using a custom prefix for iverilog executables, or using MSYS2 packages/tarballs outside of MSYS2.
Nevertheless, the content of functions `build` and `check` in the PKGBUILD file
should be familiar to any user willing to build iverilog *manually*. Those can
be executed in a shell (ignoring makepkg), as long as the few environment
variables are properly defined.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -290,7 +290,7 @@ unsigned NetAssignBase::l_val_count() const
unsigned NetAssignBase::lwidth() const
{
unsigned sum = 0;
for (NetAssign_*cur = lval_ ; cur ; cur = cur->more)
for (const NetAssign_*cur = lval_ ; cur ; cur = cur->more)
sum += cur->lwidth();
return sum;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2022 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -214,7 +214,7 @@ NetScope* Design::find_scope(const hname_t&path) const
return 0;
}
static bool is_design_unit(NetScope*scope)
static bool is_design_unit(const NetScope*scope)
{
return (scope->type() == NetScope::MODULE && !scope->nested_module())
|| (scope->type() == NetScope::PACKAGE);
@ -643,7 +643,7 @@ void NetScope::evaluate_parameter_logic_(Design*des, param_ref_t cur)
if ((*cur).second.range == 0)
return;
NetEConst*val = dynamic_cast<NetEConst*>((*cur).second.val);
const NetEConst*val = dynamic_cast<NetEConst*>((*cur).second.val);
ivl_assert(*expr, val);
verinum value = val->value();
@ -659,7 +659,7 @@ void NetScope::evaluate_parameter_logic_(Design*des, param_ref_t cur)
continue;
if (value_range->low_expr) {
NetEConst*tmp = dynamic_cast<NetEConst*>(value_range->low_expr);
const NetEConst*tmp = dynamic_cast<NetEConst*>(value_range->low_expr);
ivl_assert(*value_range->low_expr, tmp);
if (value_range->low_open_flag && value <= tmp->value())
continue;
@ -668,7 +668,7 @@ void NetScope::evaluate_parameter_logic_(Design*des, param_ref_t cur)
}
if (value_range->high_expr) {
NetEConst*tmp = dynamic_cast<NetEConst*>(value_range->high_expr);
const NetEConst*tmp = dynamic_cast<NetEConst*>(value_range->high_expr);
ivl_assert(*value_range->high_expr, tmp);
if (value_range->high_open_flag && value >= tmp->value())
continue;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2022 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -73,7 +73,7 @@ const NetScope* NetEvent::scope() const
unsigned NetEvent::nprobe() const
{
unsigned cnt = 0;
NetEvProbe*cur = probes_;
const NetEvProbe*cur = probes_;
while (cur) {
cnt += 1;
cur = cur->enext_;
@ -105,7 +105,7 @@ const NetEvProbe* NetEvent::probe(unsigned idx) const
unsigned NetEvent::ntrig() const
{
unsigned cnt = 0;
NetEvTrig*cur = trig_;
const NetEvTrig*cur = trig_;
while (cur) {
cnt += 1;
cur = cur->enext_;
@ -198,7 +198,7 @@ void NetEvent::find_similar_event(list<NetEvent*>&event_list)
continue;
unsigned tcnt = 0;
for (NetEvProbe*cur = tmp->probes_ ; cur ; cur = cur->enext_)
for (const NetEvProbe*cur = tmp->probes_ ; cur ; cur = cur->enext_)
tcnt += 1;
if (tcnt == probe_count)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2002-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -52,7 +52,7 @@ NetUserFunc::~NetUserFunc()
unsigned NetUserFunc::port_width(unsigned port) const
{
NetFuncDef*fdef = def_->func_def();
const NetFuncDef*fdef = def_->func_def();
/* Port 0 is the return port. */
if (port == 0) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 2012-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -242,7 +242,7 @@ void NetAssign::eval_func_lval_op_real_(const LineInfo&loc,
}
void NetAssign::eval_func_lval_op_(const LineInfo&loc,
verinum&lv, verinum&rv) const
verinum&lv, const verinum&rv) const
{
unsigned lv_width = lv.len();
bool lv_sign = lv.has_sign();
@ -329,7 +329,7 @@ bool NetAssign::eval_func_lval_(const LineInfo&loc,
return false;
}
NetEConst*word_const = dynamic_cast<NetEConst*>(word_result);
const NetEConst*word_const = dynamic_cast<NetEConst*>(word_result);
ivl_assert(loc, word_const);
if (!word_const->value().is_defined())
@ -353,7 +353,7 @@ bool NetAssign::eval_func_lval_(const LineInfo&loc,
return false;
}
NetEConst*base_const = dynamic_cast<NetEConst*>(base_result);
const NetEConst*base_const = dynamic_cast<NetEConst*>(base_result);
ivl_assert(loc, base_const);
long base = base_const->value().as_long();
@ -361,10 +361,10 @@ bool NetAssign::eval_func_lval_(const LineInfo&loc,
if (old_lval == 0)
old_lval = make_const_x(lval->sig()->vector_width());
NetEConst*lval_const = dynamic_cast<NetEConst*>(old_lval);
const NetEConst*lval_const = dynamic_cast<NetEConst*>(old_lval);
ivl_assert(loc, lval_const);
verinum lval_v = lval_const->value();
NetEConst*rval_const = dynamic_cast<NetEConst*>(rval_result);
const NetEConst*rval_const = dynamic_cast<NetEConst*>(rval_result);
ivl_assert(loc, rval_const);
verinum rval_v = rval_const->value();
@ -392,10 +392,10 @@ bool NetAssign::eval_func_lval_(const LineInfo&loc,
if (op_ == 0) {
rval_result = fix_assign_value(lval->sig(), rval_result);
} else if (dynamic_cast<NetECReal*>(rval_result)) {
NetECReal*lval_const = dynamic_cast<NetECReal*>(old_lval);
const NetECReal*lval_const = dynamic_cast<NetECReal*>(old_lval);
ivl_assert(loc, lval_const);
verireal lval_r = lval_const->value();
NetECReal*rval_const = dynamic_cast<NetECReal*>(rval_result);
const NetECReal*rval_const = dynamic_cast<NetECReal*>(rval_result);
ivl_assert(loc, rval_const);
verireal rval_r = rval_const->value();
@ -404,10 +404,10 @@ bool NetAssign::eval_func_lval_(const LineInfo&loc,
delete rval_result;
rval_result = new NetECReal(lval_r);
} else {
NetEConst*lval_const = dynamic_cast<NetEConst*>(old_lval);
const NetEConst*lval_const = dynamic_cast<NetEConst*>(old_lval);
ivl_assert(loc, lval_const);
verinum lval_v = lval_const->value();
NetEConst*rval_const = dynamic_cast<NetEConst*>(rval_result);
const NetEConst*rval_const = dynamic_cast<NetEConst*>(rval_result);
ivl_assert(loc, rval_const);
verinum rval_v = rval_const->value();
@ -453,7 +453,7 @@ bool NetAssign::evaluate_function(const LineInfo&loc,
// If we get here, the LHS must be a concatenation, so we
// expect the RHS to be a vector value.
NetEConst*rval_const = dynamic_cast<NetEConst*>(rval_result);
const NetEConst*rval_const = dynamic_cast<NetEConst*>(rval_result);
ivl_assert(*this, rval_const);
if (op_) {
@ -557,13 +557,13 @@ bool NetCase::evaluate_function_vect_(const LineInfo&loc,
if (case_expr == 0)
return false;
NetEConst*case_const = dynamic_cast<NetEConst*> (case_expr);
const NetEConst*case_const = dynamic_cast<NetEConst*> (case_expr);
ivl_assert(loc, case_const);
verinum case_val = case_const->value();
delete case_expr;
NetProc*default_statement = 0;
const NetProc*default_statement = 0;
for (unsigned cnt = 0 ; cnt < items_.size() ; cnt += 1) {
const Item*item = &items_[cnt];
@ -577,7 +577,7 @@ bool NetCase::evaluate_function_vect_(const LineInfo&loc,
if (item_expr == 0)
return false;
NetEConst*item_const = dynamic_cast<NetEConst*> (item_expr);
const NetEConst*item_const = dynamic_cast<NetEConst*> (item_expr);
ivl_assert(loc, item_const);
verinum item_val = item_const->value();
@ -619,13 +619,13 @@ bool NetCase::evaluate_function_real_(const LineInfo&loc,
if (case_expr == 0)
return false;
NetECReal*case_const = dynamic_cast<NetECReal*> (case_expr);
const NetECReal*case_const = dynamic_cast<NetECReal*> (case_expr);
ivl_assert(loc, case_const);
double case_val = case_const->value().as_double();
delete case_expr;
NetProc*default_statement = 0;
const NetProc*default_statement = 0;
for (unsigned cnt = 0 ; cnt < items_.size() ; cnt += 1) {
const Item*item = &items_[cnt];
@ -639,7 +639,7 @@ bool NetCase::evaluate_function_real_(const LineInfo&loc,
if (item_expr == 0)
return false;
NetECReal*item_const = dynamic_cast<NetECReal*> (item_expr);
const NetECReal*item_const = dynamic_cast<NetECReal*> (item_expr);
ivl_assert(loc, item_const);
double item_val = item_const->value().as_double();
@ -677,7 +677,7 @@ bool NetCondit::evaluate_function(const LineInfo&loc,
return false;
}
NetEConst*cond_const = dynamic_cast<NetEConst*> (cond);
const NetEConst*cond_const = dynamic_cast<NetEConst*> (cond);
ivl_assert(loc, cond_const);
long val = cond_const->value().as_long();
@ -767,7 +767,7 @@ bool NetDoWhile::evaluate_function(const LineInfo&loc,
break;
}
NetEConst*cond_const = dynamic_cast<NetEConst*> (cond);
const NetEConst*cond_const = dynamic_cast<NetEConst*> (cond);
ivl_assert(loc, cond_const);
long val = cond_const->value().as_long();
@ -843,7 +843,7 @@ bool NetForLoop::evaluate_function(const LineInfo&loc,
break;
}
NetEConst*cond_const = dynamic_cast<NetEConst*> (cond);
const NetEConst*cond_const = dynamic_cast<NetEConst*> (cond);
ivl_assert(loc, cond_const);
long val = cond_const->value().as_long();
@ -891,7 +891,7 @@ bool NetRepeat::evaluate_function(const LineInfo&loc,
NetExpr*count_expr = expr_->evaluate_function(loc, context_map);
if (count_expr == 0) return false;
NetEConst*count_const = dynamic_cast<NetEConst*> (count_expr);
const NetEConst*count_const = dynamic_cast<NetEConst*> (count_expr);
ivl_assert(loc, count_const);
long count = count_const->value().as_long();
@ -948,7 +948,7 @@ bool NetWhile::evaluate_function(const LineInfo&loc,
break;
}
NetEConst*cond_const = dynamic_cast<NetEConst*> (cond);
const NetEConst*cond_const = dynamic_cast<NetEConst*> (cond);
ivl_assert(loc, cond_const);
long val = cond_const->value().as_long();
@ -1047,7 +1047,7 @@ NetExpr* NetESelect::evaluate_function(const LineInfo&loc,
NetExpr*sub_exp = expr_->evaluate_function(loc, context_map);
ivl_assert(loc, sub_exp);
NetEConst*sub_const = dynamic_cast<NetEConst*> (sub_exp);
const NetEConst*sub_const = dynamic_cast<NetEConst*> (sub_exp);
ivl_assert(loc, sub_exp);
verinum sub = sub_const->value();
@ -1058,7 +1058,7 @@ NetExpr* NetESelect::evaluate_function(const LineInfo&loc,
NetExpr*base_val = base_->evaluate_function(loc, context_map);
ivl_assert(loc, base_val);
NetEConst*base_const = dynamic_cast<NetEConst*>(base_val);
const NetEConst*base_const = dynamic_cast<NetEConst*>(base_val);
ivl_assert(loc, base_const);
base = base_const->value().as_long();
@ -1096,14 +1096,14 @@ NetExpr* NetESignal::evaluate_function(const LineInfo&loc,
var = var->ref;
}
NetExpr*value = 0;
const NetExpr*value = 0;
if (var->nwords > 0) {
ivl_assert(loc, word_);
NetExpr*word_result = word_->evaluate_function(loc, context_map);
if (word_result == 0)
return 0;
NetEConst*word_const = dynamic_cast<NetEConst*>(word_result);
const NetEConst*word_const = dynamic_cast<NetEConst*>(word_result);
ivl_assert(loc, word_const);
int word = word_const->value().as_long();
@ -1202,7 +1202,7 @@ NetExpr* NetESFunc::evaluate_function(const LineInfo&loc,
NetExpr* NetEUFunc::evaluate_function(const LineInfo&loc,
map<perm_string,LocalVar>&context_map) const
{
NetFuncDef*def = func_->func_def();
const NetFuncDef*def = func_->func_def();
ivl_assert(*this, def);
vector<NetExpr*>args(parms_.size());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2022 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -164,7 +164,7 @@ Link::DIR Link::get_dir() const
return dir_;
}
void Link::drivers_delays(NetExpr*rise, NetExpr*fall, NetExpr*decay)
void Link::drivers_delays(const NetExpr*rise, const NetExpr*fall, const NetExpr*decay)
{
find_nexus_()->drivers_delays(rise, fall, decay);
}
@ -358,7 +358,7 @@ bool Nexus::drivers_present() const
return false;
}
void Nexus::drivers_delays(NetExpr*rise, NetExpr*fall, NetExpr*decay)
void Nexus::drivers_delays(const NetExpr*rise, const NetExpr*fall, const NetExpr*decay)
{
for (Link*cur = first_nlink() ; cur ; cur = cur->next_nlink()) {
if (cur->get_dir() != Link::OUTPUT)
@ -600,7 +600,7 @@ void NexusSet::add(Nexus*that, unsigned base, unsigned wid)
items_.push_back(cur);
}
void NexusSet::add(NexusSet&that)
void NexusSet::add(const NexusSet&that)
{
for (size_t idx = 0 ; idx < that.items_.size() ; idx += 1)
add(that.items_[idx]->lnk.nexus(), that.items_[idx]->base, that.items_[idx]->wid);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2002-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -144,9 +144,9 @@ NexusSet* NetESelect::nex_input(bool rem_out, bool always_sens, bool nested_func
NexusSet*tmp = expr_->nex_input(rem_out, always_sens, nested_func);
bool const_select = result->size() == 0;
if (always_sens && const_select) {
if (NetEConst *val = dynamic_cast <NetEConst*> (base_)) {
if (const NetEConst *val = dynamic_cast <NetEConst*> (base_)) {
assert(select_type() == IVL_SEL_OTHER);
if (NetESignal *sig = dynamic_cast<NetESignal*> (expr_)) {
if (const NetESignal *sig = dynamic_cast<NetESignal*> (expr_)) {
delete tmp;
tmp = sig->nex_input_base(rem_out, always_sens, nested_func,
val->value().as_unsigned(), expr_width());
@ -221,7 +221,7 @@ NexusSet* NetESignal::nex_input_base(bool rem_out, bool always_sens, bool nested
<< net_->unpacked_count() << " words in array '"
<< name() << "'." << endl;
}
if (always_sens) if (NetEConst *val = dynamic_cast <NetEConst*> (word_)) {
if (always_sens) if (const NetEConst *val = dynamic_cast <NetEConst*> (word_)) {
const_select = true;
const_word = val->value().as_unsigned();
}
@ -337,7 +337,7 @@ NexusSet* NetAssignBase::nex_input(bool rem_out, bool always_sens, bool nested_f
/* It is possible that the lval_ can have nex_input values. In
particular, index expressions are statement inputs as well,
so should be addressed here. */
for (NetAssign_*cur = lval_ ; cur ; cur = cur->more) {
for (const NetAssign_*cur = lval_ ; cur ; cur = cur->more) {
NexusSet*tmp = cur->nex_input(rem_out, always_sens, nested_func);
result->add(*tmp);
delete tmp;

View File

@ -133,7 +133,7 @@ void NetCase::prune()
// If the guard expression is not constant, assume
// all bits are needed, so no pruning can be done.
NetEConst*gc = dynamic_cast<NetEConst*>(items_[idx].guard);
const NetEConst*gc = dynamic_cast<NetEConst*>(items_[idx].guard);
if (gc == 0)
return;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2025 Stephen Williams (steve@icarus.com)
* Copyright (c) 2016 CERN Michele Castellana (michele.castellana@cern.ch)
*
* This source code is free software; you can redistribute it
@ -52,7 +52,7 @@ void Definitions::add_enumeration_set(const enum_type_t*key, netenum_t*enum_set)
tmp = enum_set;
}
bool Definitions::add_enumeration_name(netenum_t*enum_set, perm_string name)
bool Definitions::add_enumeration_name(const netenum_t*enum_set, perm_string name)
{
netenum_t::iterator enum_val = enum_set->find_name(name);
assert(enum_val != enum_set->end_name());
@ -708,7 +708,7 @@ void NetScope::add_signal_placeholder(PWire*wire)
signal_placeholders_[wire->basename()] = wire;
}
void NetScope::rem_signal_placeholder(PWire*wire)
void NetScope::rem_signal_placeholder(const PWire*wire)
{
signal_placeholders_.erase(wire->basename());
}

View File

@ -1,7 +1,7 @@
#ifndef IVL_netclass_H
#define IVL_netclass_H
/*
* Copyright (c) 2012-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2012-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -36,7 +36,7 @@ class PExpr;
class netclass_t : public ivl_type_s {
public:
netclass_t(perm_string class_name, const netclass_t*super);
~netclass_t();
~netclass_t() override;
// Set the property of the class during elaboration. Set the
// name and type, and return true. If the name is already
@ -61,7 +61,7 @@ class netclass_t : public ivl_type_s {
// As an ivl_type_s object, the netclass is always an
// ivl_VT_CLASS object.
ivl_variable_type_t base_type() const;
ivl_variable_type_t base_type() const override;
// This is the name of the class type
inline perm_string get_name() const { return name_; }
@ -114,7 +114,7 @@ class netclass_t : public ivl_type_s {
void emit_scope(struct target_t*tgt) const;
bool emit_defs(struct target_t*tgt) const;
std::ostream& debug_dump(std::ostream&fd) const;
std::ostream& debug_dump(std::ostream&fd) const override;
void dump_scope(std::ostream&fd) const;
const NetExpr* get_parameter(Design *des, perm_string name,
@ -124,7 +124,7 @@ class netclass_t : public ivl_type_s {
bool is_virtual() const { return virtual_class_; }
protected:
bool test_compatibility(ivl_type_t that) const;
bool test_compatibility(ivl_type_t that) const override;
private:
perm_string name_;

View File

@ -1,7 +1,7 @@
#ifndef IVL_netdarray_H
#define IVL_netdarray_H
/*
* Copyright (c) 2012-2015 Stephen Williams (steve@icarus.com)
* Copyright (c) 2012-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -26,15 +26,15 @@ class netdarray_t : public netarray_t {
public:
explicit netdarray_t(ivl_type_t vec);
~netdarray_t();
~netdarray_t() override;
// This is the "base_type()" virtual method of the
// nettype_base_t. The ivl_target api expects this to return
// IVL_VT_DARRAY for dynamic arrays?
ivl_variable_type_t base_type() const;
ivl_variable_type_t base_type() const override;
// A dynamic array may have a type that is signed.
inline bool get_signed() const { return element_type()->get_signed(); }
inline bool get_signed() const override { return element_type()->get_signed(); }
// This is the base_type() of the element of the array. We
// need this in some cases in order to get the base type of
@ -45,11 +45,11 @@ class netdarray_t : public netarray_t {
// element. Strictly speaking it's not necessary.
inline unsigned long element_width(void) const { return element_type()->packed_width(); }
std::ostream& debug_dump(std::ostream&) const;
std::ostream& debug_dump(std::ostream&) const override;
private:
bool test_compatibility(ivl_type_t that) const;
bool test_equivalence(ivl_type_t that) const;
bool test_compatibility(ivl_type_t that) const override;
bool test_equivalence(ivl_type_t that) const override;
};
#endif /* IVL_netdarray_H */

View File

@ -1,7 +1,7 @@
#ifndef IVL_netenum_H
#define IVL_netenum_H
/*
* Copyright (c) 2010-2014 Stephen Williams (steve@icarus.com)
* Copyright (c) 2010-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -34,13 +34,13 @@ class netenum_t : public LineInfo, public ivl_type_s {
public:
explicit netenum_t(ivl_type_t base_type, size_t name_count,
bool integer_flag);
~netenum_t();
~netenum_t() override;
virtual ivl_variable_type_t base_type() const;
virtual bool packed() const;
virtual long packed_width() const;
netranges_t slice_dimensions() const;
bool get_signed() const;
virtual ivl_variable_type_t base_type() const override;
virtual bool packed() const override;
virtual long packed_width() const override;
netranges_t slice_dimensions() const override;
bool get_signed() const override;
bool get_isint() const;
// The size() is the number of enumeration literals.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -1013,7 +1013,7 @@ NetProcTop::~NetProcTop()
bool flag = false;
for (unsigned idx = 0 ; idx < nex_set.size() ; idx += 1) {
NetNet*net = nex_set[idx].lnk.nexus()->pick_any_net();
const NetNet*net = nex_set[idx].lnk.nexus()->pick_any_net();
if (net->peek_lref() > 0) {
cerr << get_fileline() << ": warning: '" << net->name()
<< "' is driven by more than one process." << endl;
@ -3070,7 +3070,7 @@ static void check_if_logic_l_value(const NetAssignBase *base,
const NetAssign_*lval = base->l_val(0);
if (! lval) return;
NetNet*sig = lval->sig();
const NetNet*sig = lval->sig();
if (! sig) return;
if ((sig->data_type() != IVL_VT_BOOL) &&
@ -3271,7 +3271,7 @@ bool NetForever::check_synth(ivl_process_type_t pr_type,
* structure for synthesis.
*/
static void print_for_idx_warning(const NetProc*proc, const char*check,
ivl_process_type_t pr_type, NetNet*idx)
ivl_process_type_t pr_type, const NetNet*idx)
{
cerr << proc->get_fileline() << ": warning: A for statement must use "
"the index (" << idx->name() << ") in the " << check
@ -3293,7 +3293,7 @@ static void check_for_const_synth(const NetExpr*expr, const NetProc*proc,
static void check_for_bin_synth(const NetExpr*left,const NetExpr*right,
const char*str, const char*check,
const NetProc*proc,
ivl_process_type_t pr_type, NetNet*index)
ivl_process_type_t pr_type, const NetNet*index)
{
const NetESignal*lsig = dynamic_cast<const NetESignal*>(left);
const NetESignal*rsig = dynamic_cast<const NetESignal*>(right);
@ -3327,7 +3327,7 @@ static void print_for_step_warning(const NetProc*proc,
}
static void print_for_step_warning(const NetProc*proc,
ivl_process_type_t pr_type, NetNet*idx)
ivl_process_type_t pr_type, const NetNet*idx)
{
cerr << proc->get_fileline() << ": warning: A for statement step must "
"be an assignment to the index variable ("
@ -3336,7 +3336,7 @@ static void print_for_step_warning(const NetProc*proc,
}
static void check_for_bstep_synth(const NetExpr*expr, const NetProc*proc,
ivl_process_type_t pr_type, NetNet*index)
ivl_process_type_t pr_type, const NetNet*index)
{
if (const NetECast*tmp = dynamic_cast<const NetECast*>(expr)) {
expr = tmp->expr();
@ -3355,7 +3355,7 @@ static void check_for_bstep_synth(const NetExpr*expr, const NetProc*proc,
}
static void check_for_step_synth(const NetAssign*assign, const NetProc*proc,
ivl_process_type_t pr_type, NetNet*index)
ivl_process_type_t pr_type, const NetNet*index)
{
if (assign->l_val_count() != 1) {
print_for_step_warning(proc, pr_type);
@ -3451,7 +3451,7 @@ bool NetScope::check_synth(ivl_process_type_t pr_type,
{
bool result = false;
// Skip local events/signals
for (NetEvent*cur = events_ ; cur ; cur = cur->snext_) {
for (const NetEvent*cur = events_ ; cur ; cur = cur->snext_) {
if (cur->local_flag()) continue;
cerr << cur->get_fileline() << ": warning: An event ("
<< cur->name() << ") cannot be synthesized "

1036
netlist.h

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -34,8 +34,8 @@ using namespace std;
NetNet* sub_net_from(Design*des, NetScope*scope, long val, NetNet*sig)
{
netvector_t*zero_vec = new netvector_t(sig->data_type(),
sig->vector_width()-1, 0);
const netvector_t*zero_vec = new netvector_t(sig->data_type(),
sig->vector_width()-1, 0);
NetNet*zero_net = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, zero_vec);
zero_net->set_line(*sig);
@ -68,8 +68,8 @@ NetNet* sub_net_from(Design*des, NetScope*scope, long val, NetNet*sig)
connect(zero_net->pin(0), adder->pin_DataA());
connect(adder->pin_DataB(), sig->pin(0));
netvector_t*tmp_vec = new netvector_t(sig->data_type(),
sig->vector_width()-1, 0);
const netvector_t*tmp_vec = new netvector_t(sig->data_type(),
sig->vector_width()-1, 0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, tmp_vec);
tmp->set_line(*sig);
@ -85,8 +85,8 @@ NetNet* cast_to_int2(Design*des, NetScope*scope, NetNet*src, unsigned wid)
if (src->data_type() == IVL_VT_BOOL)
return src;
netvector_t*tmp_vec = new netvector_t(IVL_VT_BOOL, wid-1, 0,
src->get_signed());
const netvector_t*tmp_vec = new netvector_t(IVL_VT_BOOL, wid-1, 0,
src->get_signed());
NetNet*tmp = new NetNet(scope, scope->local_symbol(), NetNet::WIRE, tmp_vec);
tmp->set_line(*src);
tmp->local_flag(true);
@ -106,7 +106,7 @@ NetNet* cast_to_int4(Design*des, NetScope*scope, NetNet*src, unsigned wid)
if (src->data_type() != IVL_VT_REAL)
return src;
netvector_t*tmp_vec = new netvector_t(IVL_VT_LOGIC, wid-1, 0);
const netvector_t*tmp_vec = new netvector_t(IVL_VT_LOGIC, wid-1, 0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(), NetNet::WIRE, tmp_vec);
tmp->set_line(*src);
tmp->local_flag(true);
@ -126,7 +126,7 @@ NetNet* cast_to_real(Design*des, NetScope*scope, NetNet*src)
if (src->data_type() == IVL_VT_REAL)
return src;
netvector_t*tmp_vec = new netvector_t(IVL_VT_REAL);
const netvector_t*tmp_vec = new netvector_t(IVL_VT_REAL);
NetNet*tmp = new NetNet(scope, scope->local_symbol(), NetNet::WIRE, tmp_vec);
tmp->set_line(*src);
tmp->local_flag(true);
@ -514,7 +514,7 @@ void indices_to_expressions(Design*des, NetScope*scope,
// Track if we detect any non-constant expressions
// here. This may allow for a special case.
NetEConst*word_const = dynamic_cast<NetEConst*> (word_index);
const NetEConst*word_const = dynamic_cast<NetEConst*> (word_index);
if (word_const == 0)
flags.variable = true;
else if (!word_const->value().is_defined())
@ -543,7 +543,7 @@ static void make_strides(const netranges_t&dims, vector<long>&stride)
* word. If any of the indices are out of bounds, return nil instead
* of an expression.
*/
static NetExpr* normalize_variable_unpacked(const netranges_t&dims, list<long>&indices)
static NetExpr* normalize_variable_unpacked(const netranges_t&dims, const list<long>&indices)
{
// Make strides for each index. The stride is the distance (in
// words) to the next element in the canonical array.
@ -574,19 +574,19 @@ static NetExpr* normalize_variable_unpacked(const netranges_t&dims, list<long>&i
return canonical_expr;
}
NetExpr* normalize_variable_unpacked(const NetNet*net, list<long>&indices)
NetExpr* normalize_variable_unpacked(const NetNet*net, const list<long>&indices)
{
const netranges_t&dims = net->unpacked_dims();
return normalize_variable_unpacked(dims, indices);
}
NetExpr* normalize_variable_unpacked(const netsarray_t*stype, list<long>&indices)
NetExpr* normalize_variable_unpacked(const netsarray_t*stype, const list<long>&indices)
{
const netranges_t&dims = stype->static_dimensions();
return normalize_variable_unpacked(dims, indices);
}
NetExpr* normalize_variable_unpacked(const LineInfo&loc, const netranges_t&dims, list<NetExpr*>&indices)
NetExpr* normalize_variable_unpacked(const LineInfo&loc, const netranges_t&dims, const list<NetExpr*>&indices)
{
// Make strides for each index. The stride is the distance (in
// words) to the next element in the canonical array.
@ -631,7 +631,7 @@ NetExpr* normalize_variable_unpacked(const LineInfo&loc, const netranges_t&dims,
// Now generate the math to calculate the canonical address.
NetExpr*tmp_scaled = 0;
if (NetEConst*tmp_const = dynamic_cast<NetEConst*> (tmp)) {
if (const NetEConst*tmp_const = dynamic_cast<NetEConst*> (tmp)) {
// Special case: the index is constant, so this
// iteration can be replaced with a constant
// expression.
@ -671,13 +671,13 @@ NetExpr* normalize_variable_unpacked(const LineInfo&loc, const netranges_t&dims,
return canonical_expr;
}
NetExpr* normalize_variable_unpacked(const NetNet*net, list<NetExpr*>&indices)
NetExpr* normalize_variable_unpacked(const NetNet*net, const list<NetExpr*>&indices)
{
const netranges_t&dims = net->unpacked_dims();
return normalize_variable_unpacked(*net, dims, indices);
}
NetExpr* normalize_variable_unpacked(const LineInfo&loc, const netsarray_t*stype, list<NetExpr*>&indices)
NetExpr* normalize_variable_unpacked(const LineInfo&loc, const netsarray_t*stype, const list<NetExpr*>&indices)
{
const netranges_t&dims = stype->static_dimensions();
return normalize_variable_unpacked(loc, dims, indices);
@ -748,7 +748,7 @@ static NetNet* make_const_net(Design*des, NetScope*scope, verinum val)
NetConst*res = new NetConst(scope, scope->local_symbol(), val);
des->add_node(res);
netvector_t*sig_vec = new netvector_t(IVL_VT_LOGIC, val.len() - 1, 0);
const netvector_t*sig_vec = new netvector_t(IVL_VT_LOGIC, val.len() - 1, 0);
NetNet*sig = new NetNet(scope, scope->local_symbol(), NetNet::WIRE, sig_vec);
sig->local_flag(true);
@ -774,7 +774,7 @@ NetNet* make_const_z(Design*des, NetScope*scope, unsigned long wid)
NetExpr* condition_reduce(NetExpr*expr)
{
if (expr->expr_type() == IVL_VT_REAL) {
if (NetECReal *tmp = dynamic_cast<NetECReal*>(expr)) {
if (const NetECReal *tmp = dynamic_cast<NetECReal*>(expr)) {
verinum::V res;
if (tmp->value().as_double() == 0.0) res = verinum::V0;
else res = verinum::V1;
@ -1181,12 +1181,12 @@ bool eval_as_long(long&value, const NetExpr*expr)
bool eval_as_double(double&value, NetExpr*expr)
{
if (NetEConst*tmp = dynamic_cast<NetEConst*>(expr) ) {
if (const NetEConst*tmp = dynamic_cast<NetEConst*>(expr) ) {
value = tmp->value().as_double();
return true;
}
if (NetECReal*rtmp = dynamic_cast<NetECReal*>(expr)) {
if (const NetECReal*rtmp = dynamic_cast<NetECReal*>(expr)) {
value = rtmp->value().as_double();
return true;
}
@ -1375,7 +1375,7 @@ const_bool const_logical(const NetExpr*expr)
return C_NON;
}
uint64_t get_scaled_time_from_real(Design*des, NetScope*scope, NetECReal*val)
uint64_t get_scaled_time_from_real(const Design*des, NetScope*scope, const NetECReal*val)
{
verireal fn = val->value();
@ -1431,7 +1431,7 @@ void collapse_partselect_pv_to_concat(Design*des, NetNet*sig)
unsigned idx = 0;
unsigned device_count = 0;
while (idx < ps_map.size()) {
NetPartSelect*ps_obj = ps_map[idx];
const NetPartSelect*ps_obj = ps_map[idx];
if (ps_obj == 0)
return;
@ -1530,7 +1530,7 @@ bool evaluate_index_prefix(Design*des, NetScope*scope,
* replace the exprs.
*/
NetExpr*collapse_array_exprs(Design*des, NetScope*scope,
const LineInfo*loc, NetNet*net,
const LineInfo*loc, const NetNet*net,
const list<index_component_t>&indices)
{
// First elaborate all the expressions as far as possible.
@ -1589,7 +1589,7 @@ NetExpr*collapse_array_exprs(Design*des, NetScope*scope,
* them to an expression that normalizes the list to a single index
* expression over a canonical equivalent 1-dimensional array.
*/
NetExpr*collapse_array_indices(Design*des, NetScope*scope, NetNet*net,
NetExpr*collapse_array_indices(Design*des, NetScope*scope, const NetNet*net,
const list<index_component_t>&indices)
{
list<long>prefix_indices;
@ -1787,7 +1787,7 @@ NetScope* find_method_containing_scope(const LineInfo&, NetScope*scope)
* Print a warning if we find a mixture of default and explicit timescale
* based delays in the design, since this is likely an error.
*/
void check_for_inconsistent_delays(NetScope*scope)
void check_for_inconsistent_delays(const NetScope*scope)
{
static bool used_implicit_timescale = false;
static bool used_explicit_timescale = false;

View File

@ -271,11 +271,11 @@ extern void indices_to_expressions(Design*des, NetScope*scope,
indices_flags&flags,
std::list<NetExpr*>&indices,std::list<long>&indices_const);
extern NetExpr*normalize_variable_unpacked(const NetNet*net, std::list<long>&indices);
extern NetExpr*normalize_variable_unpacked(const netsarray_t*net, std::list<long>&indices);
extern NetExpr*normalize_variable_unpacked(const NetNet*net, const std::list<long>&indices);
extern NetExpr*normalize_variable_unpacked(const netsarray_t*net, const std::list<long>&indices);
extern NetExpr*normalize_variable_unpacked(const NetNet*net, std::list<NetExpr*>&indices);
extern NetExpr*normalize_variable_unpacked(const LineInfo&loc, const netsarray_t*net, std::list<NetExpr*>&indices);
extern NetExpr*normalize_variable_unpacked(const NetNet*net, const std::list<NetExpr*>&indices);
extern NetExpr*normalize_variable_unpacked(const LineInfo&loc, const netsarray_t*net, const std::list<NetExpr*>&indices);
extern NetExpr*make_canonical_index(Design*des, NetScope*scope,
// loc for error messages
@ -454,9 +454,9 @@ const_bool const_logical(const NetExpr*expr);
* When scaling a real value to a time we need to do some standard
* processing.
*/
extern uint64_t get_scaled_time_from_real(Design*des,
extern uint64_t get_scaled_time_from_real(const Design*des,
NetScope*scope,
NetECReal*val);
const NetECReal*val);
extern void collapse_partselect_pv_to_concat(Design*des, NetNet*sig);
@ -464,11 +464,11 @@ extern bool evaluate_index_prefix(Design*des, NetScope*scope,
std::list<long>&prefix_indices,
const std::list<index_component_t>&indices);
extern NetExpr*collapse_array_indices(Design*des, NetScope*scope, NetNet*net,
extern NetExpr*collapse_array_indices(Design*des, NetScope*scope, const NetNet*net,
const std::list<index_component_t>&indices);
extern NetExpr*collapse_array_exprs(Design*des, NetScope*scope,
const LineInfo*loc, NetNet*net,
const LineInfo*loc, const NetNet*net,
const std::list<index_component_t>&indices);
extern void assign_unpacked_with_bufz(Design*des, NetScope*scope,
@ -481,6 +481,6 @@ extern NetPartSelect* detect_partselect_lval(Link&pin);
* Print a warning if we find a mixture of default and explicit timescale
* based delays in the design, since this is likely an error.
*/
extern void check_for_inconsistent_delays(NetScope*scope);
extern void check_for_inconsistent_delays(const NetScope*scope);
#endif /* IVL_netmisc_H */

View File

@ -1,7 +1,7 @@
#ifndef IVL_netarray_H
#define IVL_netarray_H
/*
* Copyright (c) 2012-2014 Stephen Williams (steve@icarus.com)
* Copyright (c) 2012-2025 Stephen Williams (steve@icarus.com)
* Copyright CERN 2012 / Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
@ -31,7 +31,7 @@ class netsarray_t : public netarray_t {
public:
explicit netsarray_t(const netranges_t&packed, ivl_type_t etype);
~netsarray_t();
~netsarray_t() override;
public:
// Virtual methods from the ivl_type_s type...
@ -57,17 +57,17 @@ class netparray_t : public netsarray_t {
public:
explicit netparray_t(const netranges_t&packed, ivl_type_t etype);
~netparray_t();
~netparray_t() override;
public:
// Virtual methods from the ivl_type_s type...
bool packed(void) const;
long packed_width(void) const;
netranges_t slice_dimensions() const;
bool packed(void) const override;
long packed_width(void) const override;
netranges_t slice_dimensions() const override;
private:
bool test_compatibility(ivl_type_t that) const;
bool test_equivalence(ivl_type_t that) const;
bool test_compatibility(ivl_type_t that) const override;
bool test_equivalence(ivl_type_t that) const override;
};
inline netparray_t::netparray_t(const netranges_t&pd, ivl_type_t etype)
@ -82,14 +82,14 @@ class netuarray_t : public netsarray_t {
public:
explicit netuarray_t(const netranges_t&packed, ivl_type_t etype);
~netuarray_t();
~netuarray_t() override;
public:
// Virtual methods from the ivl_type_s type...
netranges_t slice_dimensions() const;
netranges_t slice_dimensions() const override;
private:
bool test_equivalence(ivl_type_t that) const;
bool test_equivalence(ivl_type_t that) const override;
};
inline netuarray_t::netuarray_t(const netranges_t&pd, ivl_type_t etype)

View File

@ -1,7 +1,7 @@
#ifndef IVL__netqueue_H
#define IVL__netqueue_H
/*
* Copyright (c) 2014-2020 Stephen Williams (steve@icarus.com)
* Copyright (c) 2014-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -31,16 +31,16 @@ class netqueue_t : public netdarray_t {
public:
explicit netqueue_t(ivl_type_t vec, long max_idx);
~netqueue_t();
~netqueue_t() override;
// This is the "base_type()" virtual method of the
// nettype_base_t. The ivl_target api expects this to return
// IVL_VT_QUEUE for queues.
ivl_variable_type_t base_type() const;
ivl_variable_type_t base_type() const override;
long max_idx(void) const { return max_idx_; }
std::ostream& debug_dump(std::ostream&) const;
std::ostream& debug_dump(std::ostream&) const override;
private:
long max_idx_;

View File

@ -1,7 +1,7 @@
#ifndef IVL_netscalar_H
#define IVL_netscalar_H
/*
* Copyright (c) 2013-2014 Stephen Williams (steve@icarus.com)
* Copyright (c) 2013-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -25,13 +25,13 @@ class netreal_t : public ivl_type_s {
public:
inline explicit netreal_t() { }
~netreal_t();
~netreal_t() override;
ivl_variable_type_t base_type() const;
bool get_signed() const { return true; }
bool get_scalar() const { return true; }
ivl_variable_type_t base_type() const override;
bool get_signed() const override { return true; }
bool get_scalar() const override { return true; }
std::ostream& debug_dump(std::ostream&) const;
std::ostream& debug_dump(std::ostream&) const override;
public:
static netreal_t type_real;
@ -42,11 +42,11 @@ class netstring_t : public ivl_type_s {
public:
inline explicit netstring_t() { }
~netstring_t();
~netstring_t() override;
ivl_variable_type_t base_type() const;
ivl_variable_type_t base_type() const override;
std::ostream& debug_dump(std::ostream&) const;
std::ostream& debug_dump(std::ostream&) const override;
public:
static netstring_t type_string;

View File

@ -1,7 +1,7 @@
#ifndef IVL_netstruct_H
#define IVL_netstruct_H
/*
* Copyright (c) 2011-2014 Stephen Williams (steve@icarus.com)
* Copyright (c) 2011-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -40,7 +40,7 @@ class netstruct_t : public LineInfo, public ivl_type_s {
public:
netstruct_t();
~netstruct_t();
~netstruct_t() override;
// If this is a union (instead of struct) then this flag is
// set. We handle union and struct together because they are
@ -49,11 +49,11 @@ class netstruct_t : public LineInfo, public ivl_type_s {
bool union_flag(void) const;
void packed(bool flag);
bool packed(void) const;
bool packed(void) const override;
// When the struct is accessed as a primary it can be signed or unsigned
void set_signed(bool flag) { signed_ = flag; }
bool get_signed(void) const { return signed_; }
bool get_signed(void) const override { return signed_; }
// Append a new member to the struct/union. This must be done
// after the union_flag and packed settings are set. This
@ -69,16 +69,16 @@ class netstruct_t : public LineInfo, public ivl_type_s {
// Return the width (in bits) of the packed record, or -1 if
// the record is not packed.
long packed_width() const;
netranges_t slice_dimensions() const;
long packed_width() const override;
netranges_t slice_dimensions() const override;
// Return the base type of the packed record, or
// IVL_VT_NO_TYPE if the record is not packed.
ivl_variable_type_t base_type() const;
ivl_variable_type_t base_type() const override;
private:
bool test_compatibility(ivl_type_t that) const;
bool test_equivalence(ivl_type_t that) const;
bool test_compatibility(ivl_type_t that) const override;
bool test_equivalence(ivl_type_t that) const override;
private:
bool union_;

View File

@ -1,7 +1,7 @@
#ifndef IVL_nettypes_H
#define IVL_nettypes_H
/*
* Copyright (c) 2012-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2012-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -80,13 +80,13 @@ class netarray_t : public ivl_type_s {
public:
inline explicit netarray_t(ivl_type_t etype) : element_type_(etype) { }
~netarray_t();
~netarray_t() override;
public:
// Some virtual methods have a common implementation for arrays.
// The base_type() for arrays is the base_Typeof the element.
ivl_variable_type_t base_type() const;
ivl_variable_type_t base_type() const override;
public:
inline ivl_type_t element_type() const { return element_type_; }

View File

@ -1,7 +1,7 @@
#ifndef IVL_netvector_H
#define IVL_netvector_H
/*
* Copyright (c) 2012-2014 Stephen Williams (steve@icarus.com)
* Copyright (c) 2012-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -37,29 +37,29 @@ class netvector_t : public ivl_type_s {
// Special case: scalar object--no packed dimensions at all.
explicit netvector_t(ivl_variable_type_t type);
~netvector_t();
~netvector_t() override;
// Vectors can be interpreted as signed or unsigned when
// handled as vectors.
inline void set_signed(bool flag) { signed_ = flag; }
inline bool get_signed(void) const { return signed_; }
inline bool get_signed(void) const override { return signed_; }
inline void set_isint(bool flag) { isint_ = flag; }
inline bool get_isint(void) const { return isint_; }
inline bool get_scalar(void) const { return packed_dims_.empty(); }
inline bool get_scalar(void) const override { return packed_dims_.empty(); }
void set_implicit(bool implicit) { implicit_ = implicit; }
bool get_implicit() const { return implicit_; }
ivl_variable_type_t base_type() const;
ivl_variable_type_t base_type() const override;
const netranges_t&packed_dims() const;
bool packed(void) const;
long packed_width() const;
netranges_t slice_dimensions() const;
bool packed(void) const override;
long packed_width() const override;
netranges_t slice_dimensions() const override;
std::ostream& debug_dump(std::ostream&) const;
std::ostream& debug_dump(std::ostream&) const override;
public:
// Some commonly used predefined types
@ -78,8 +78,8 @@ class netvector_t : public ivl_type_s {
static const netvector_t*integer_type(bool is_signed = true);
private:
bool test_compatibility(ivl_type_t that) const;
bool test_equivalence(ivl_type_t that) const;
bool test_compatibility(ivl_type_t that) const override;
bool test_equivalence(ivl_type_t that) const override;
private:
netranges_t packed_dims_;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -33,8 +33,8 @@ using namespace std;
class nodangle_f : public functor_t {
public:
void event(Design*des, NetEvent*ev);
void signal(Design*des, NetNet*sig);
void event(Design*des, NetEvent*ev) override;
void signal(Design*des, NetNet*sig) override;
unsigned iteration;
unsigned stotal, etotal;
@ -230,7 +230,7 @@ void nodangle_f::signal(Design*, NetNet*sig)
if (cur == &sig->pin(idx))
continue;
NetNet*cursig = dynamic_cast<NetNet*>(cur->get_obj());
const NetNet*cursig = dynamic_cast<NetNet*>(cur->get_obj());
if (cursig == 0)
continue;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2016 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -106,8 +106,8 @@ NetNet*pad_to_width(Design*des, NetNet*net, unsigned wid, const LineInfo&info)
connect(cc->pin(2), con->pin(0));
// Make a NetNet for the NetConst to NetConcat link.
netvector_t*tmp_vec = new netvector_t(net->data_type(),
wid - net->vector_width() - 1, 0);
const netvector_t*tmp_vec = new netvector_t(net->data_type(),
wid - net->vector_width() - 1, 0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, tmp_vec);
tmp->set_line(info);
@ -162,7 +162,7 @@ NetNet*crop_to_width(Design*des, NetNet*net, unsigned wid)
ps->set_line(*net);
des->add_node(ps);
netvector_t*tmp_vec = new netvector_t(net->data_type(), wid-1, 0);
const netvector_t*tmp_vec = new netvector_t(net->data_type(), wid-1, 0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, tmp_vec);
tmp->set_line(*net);

14
parse.y
View File

@ -268,7 +268,7 @@ static std::list<named_pexpr_t>* make_named_number(const struct vlltype &loc,
return lst;
}
static long check_enum_seq_value(const YYLTYPE&loc, verinum *arg, bool zero_ok)
static long check_enum_seq_value(const YYLTYPE&loc, const verinum *arg, bool zero_ok)
{
long value = 1;
// We can never have an undefined value in an enumeration name
@ -308,8 +308,8 @@ static void check_end_label(const struct vlltype&loc, const char *type,
delete[] end;
}
static void check_for_loop(const struct vlltype&loc, PExpr*init,
PExpr*cond, Statement*step)
static void check_for_loop(const struct vlltype&loc, const PExpr*init,
const PExpr*cond, const Statement*step)
{
if (generation_flag >= GN_VER2012)
return;
@ -439,7 +439,7 @@ Module::port_t *module_declare_port(const YYLTYPE&loc, char *id,
// are variables. Unlike the other port types, which are nets in
// that case.
if (net_type == NetNet::IMPLICIT) {
if (vector_type_t*dtype = dynamic_cast<vector_type_t*> (data_type)) {
if (const vector_type_t*dtype = dynamic_cast<vector_type_t*> (data_type)) {
if (!dtype->implicit_flag)
net_type = NetNet::IMPLICIT_REG;
} else if (data_type) {
@ -4998,7 +4998,7 @@ module_item
*/
| attribute_list_opt K_inout data_type_or_implicit list_of_port_identifiers ';'
{ NetNet::Type use_type = $3 ? NetNet::IMPLICIT : NetNet::NONE;
if (vector_type_t*dtype = dynamic_cast<vector_type_t*> ($3)) {
if (const vector_type_t*dtype = dynamic_cast<vector_type_t*> ($3)) {
if (dtype->implicit_flag)
use_type = NetNet::NONE;
}
@ -5010,7 +5010,7 @@ module_item
| attribute_list_opt K_input data_type_or_implicit list_of_port_identifiers ';'
{ NetNet::Type use_type = $3 ? NetNet::IMPLICIT : NetNet::NONE;
if (vector_type_t*dtype = dynamic_cast<vector_type_t*> ($3)) {
if (const vector_type_t*dtype = dynamic_cast<vector_type_t*> ($3)) {
if (dtype->implicit_flag)
use_type = NetNet::NONE;
}
@ -5022,7 +5022,7 @@ module_item
| attribute_list_opt K_output data_type_or_implicit list_of_variable_port_identifiers ';'
{ NetNet::Type use_type = $3 ? NetNet::IMPLICIT : NetNet::NONE;
if (vector_type_t*dtype = dynamic_cast<vector_type_t*> ($3)) {
if (const vector_type_t*dtype = dynamic_cast<vector_type_t*> ($3)) {
if (dtype->implicit_flag)
use_type = NetNet::NONE;
else

View File

@ -138,7 +138,7 @@ void parm_to_defparam_list(const string&param)
unsigned off = param.find('=');
if (off > param.size()) {
key = strdup(param.c_str());
value = (char*)malloc(1);
value = static_cast<char*>(malloc(1));
*value = '\0';
} else {
@ -606,7 +606,7 @@ PPackage* pform_push_package_scope(const struct vlltype&loc, perm_string name,
return pkg_scope;
}
PTask* pform_push_task_scope(const struct vlltype&loc, char*name,
PTask* pform_push_task_scope(const struct vlltype&loc, const char*name,
LexicalScope::lifetime_t lifetime)
{
perm_string task_name = lex_strings.make(name);
@ -677,7 +677,7 @@ PFunction* pform_push_function_scope(const struct vlltype&loc, const char*name,
return func;
}
PBlock* pform_push_block_scope(const struct vlltype&loc, char*name,
PBlock* pform_push_block_scope(const struct vlltype&loc, const char*name,
PBlock::BL_TYPE bt)
{
perm_string block_name;
@ -1678,7 +1678,7 @@ void pform_generate_case_item(const struct vlltype&li, list<PExpr*>*expr_list)
}
}
void pform_generate_block_name(char*name)
void pform_generate_block_name(const char*name)
{
assert(pform_cur_generate != 0);
assert(pform_cur_generate->scope_name == 0);
@ -2007,7 +2007,7 @@ void pform_make_udp(const struct vlltype&loc, perm_string name,
// XXXX
ivl_assert(loc, pins[0]->get_wire_type() == NetNet::REG);
PAssign*pa = dynamic_cast<PAssign*>(init_expr);
const PAssign*pa = dynamic_cast<PAssign*>(init_expr);
ivl_assert(*init_expr, pa);
const PEIdent*id = dynamic_cast<const PEIdent*>(pa->lval());
@ -2088,7 +2088,7 @@ void pform_make_udp(const struct vlltype&loc, perm_string name,
// XXXX
ivl_assert(*init_expr, pins[0]->get_wire_type() == NetNet::REG);
PAssign*pa = dynamic_cast<PAssign*>(init_expr);
const PAssign*pa = dynamic_cast<PAssign*>(init_expr);
ivl_assert(*init_expr, pa);
const PEIdent*id = dynamic_cast<const PEIdent*>(pa->lval());
@ -2157,7 +2157,7 @@ static void pform_set_net_range(PWire *wire,
if (!vec_type)
return;
list<pform_range_t> *range = vec_type->pdims.get();
const list<pform_range_t> *range = vec_type->pdims.get();
if (range)
wire->set_range(*range, rt);
wire->set_signed(vec_type->signed_flag);
@ -2638,7 +2638,7 @@ void pform_module_define_port(const struct vlltype&li,
* this one to create the wire and stash it.
*/
PWire *pform_makewire(const vlltype&li, const pform_ident_t&name,
NetNet::Type type, std::list<pform_range_t> *indices)
NetNet::Type type, const std::list<pform_range_t> *indices)
{
PWire*cur = pform_get_or_make_wire(li, name, type, NetNet::NOT_A_PORT, SR_NET);
ivl_assert(li, cur);
@ -2745,7 +2745,7 @@ vector<pform_tf_port_t>*pform_make_task_ports(const struct vlltype&loc,
// If this is a non-ansi port declaration and the type is an implicit type
// this is only a port declaration.
vector_type_t*vec_type = dynamic_cast<vector_type_t*>(vtype);
const vector_type_t*vec_type = dynamic_cast<vector_type_t*>(vtype);
if (allow_implicit && (!vtype || (vec_type && vec_type->implicit_flag)))
rt = SR_PORT;
@ -2911,7 +2911,7 @@ static void pform_set_type_parameter(const struct vlltype&loc, perm_string name,
void pform_set_parameter(const struct vlltype&loc,
perm_string name, bool is_local, bool is_type,
data_type_t*data_type, list<pform_range_t>*udims,
data_type_t*data_type, const list<pform_range_t>*udims,
PExpr*expr, LexicalScope::range_t*value_range)
{
LexicalScope*scope = lexical_scope;
@ -3193,7 +3193,7 @@ void pform_set_port_type(const struct vlltype&li,
{
ivl_assert(li, pt != NetNet::PIMPLICIT && pt != NetNet::NOT_A_PORT);
vector_type_t *vt = dynamic_cast<vector_type_t*> (dt);
const vector_type_t *vt = dynamic_cast<vector_type_t*> (dt);
bool have_init_expr = false;
for (list<pform_port_t>::iterator cur = ports->begin()
@ -3242,7 +3242,7 @@ void pform_set_data_type(const struct vlltype&li, data_type_t*data_type,
ivl_assert(li, 0);
}
vector_type_t*vec_type = dynamic_cast<vector_type_t*> (data_type);
const vector_type_t*vec_type = dynamic_cast<vector_type_t*> (data_type);
for (std::vector<PWire*>::iterator it= wires->begin();
it != wires->end() ; ++it) {
@ -3428,8 +3428,8 @@ int pform_parse(const char*path)
if (strcmp(path, "-") == 0) {
vl_input = stdin;
} else if (ivlpp_string) {
char*cmdline = (char*)malloc(strlen(ivlpp_string) +
strlen(path) + 4);
char*cmdline = static_cast<char*>(malloc(strlen(ivlpp_string) +
strlen(path) + 4));
strcpy(cmdline, ivlpp_string);
strcat(cmdline, " \"");
strcat(cmdline, path);

26
pform.h
View File

@ -1,7 +1,7 @@
#ifndef IVL_pform_H
#define IVL_pform_H
/*
* Copyright (c) 1998-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -212,7 +212,7 @@ PPackage *pform_find_potential_import(const struct vlltype&loc, LexicalScope*sco
extern PExpr* pform_package_ident(const struct vlltype&loc,
PPackage*pkg, pform_name_t*ident);
PPackage*pkg, const pform_name_t*ident);
/*
* Interface related functions.
@ -255,13 +255,13 @@ extern PFunction*pform_push_constructor_scope(const struct vlltype&loc);
extern PPackage* pform_push_package_scope(const struct vlltype&loc, perm_string name,
LexicalScope::lifetime_t lifetime);
extern PTask*pform_push_task_scope(const struct vlltype&loc, char*name,
extern PTask*pform_push_task_scope(const struct vlltype&loc, const char*name,
LexicalScope::lifetime_t lifetime);
extern PFunction*pform_push_function_scope(const struct vlltype&loc, const char*name,
LexicalScope::lifetime_t lifetime);
extern PBlock*pform_push_block_scope(const struct vlltype&loc, char*name,
extern PBlock*pform_push_block_scope(const struct vlltype&loc, const char*name,
PBlock::BL_TYPE tt);
extern void pform_put_behavior_in_scope(AProcess*proc);
@ -294,7 +294,7 @@ extern void pform_start_generate_else(const struct vlltype&li);
extern void pform_start_generate_case(const struct vlltype&lp, PExpr*test);
extern void pform_start_generate_nblock(const struct vlltype&lp, char*name);
extern void pform_generate_case_item(const struct vlltype&lp, std::list<PExpr*>*test);
extern void pform_generate_block_name(char*name);
extern void pform_generate_block_name(const char*name);
extern void pform_endgenerate(bool end_conditional);
/*
@ -342,7 +342,7 @@ extern PForeach* pform_make_foreach(const struct vlltype&loc,
extern PWire *pform_makewire(const struct vlltype&li,
const pform_ident_t&name,
NetNet::Type type,
std::list<pform_range_t> *indices);
const std::list<pform_range_t> *indices);
/* This form handles assignment declarations. */
@ -401,10 +401,10 @@ extern LexicalScope::range_t* pform_parameter_value_range(bool exclude_flag,
bool hig_open, PExpr*hig_expr);
extern void pform_set_parameter(const struct vlltype&loc,
perm_string name,
bool is_local, bool is_type,
data_type_t*data_type, std::list<pform_range_t>*udims,
PExpr*expr, LexicalScope::range_t*value_range);
perm_string name,
bool is_local, bool is_type,
data_type_t*data_type, const std::list<pform_range_t>*udims,
PExpr*expr, LexicalScope::range_t*value_range);
extern void pform_set_specparam(const struct vlltype&loc,
perm_string name,
std::list<pform_range_t>*range,
@ -520,7 +520,7 @@ extern PExpr* pform_genvar_compressed(const struct vlltype &loc,
* parses the source file and places all the modules it finds into the
* mod list. The dump function dumps a module to the output stream.
*/
extern void pform_dump(std::ostream&out, Module*mod);
extern void pform_dump(std::ostream&out, const Module*mod);
/* ** pform_discipline.cc
* Functions for handling the parse of natures and disciplines. These
@ -554,10 +554,10 @@ extern AContrib*pform_contribution_statement(const struct vlltype&loc,
PExpr*lval, PExpr*rval);
extern PExpr* pform_make_branch_probe_expression(const struct vlltype&loc,
char*name, char*n1, char*n2);
const char*name, const char*n1, const char*n2);
extern PExpr* pform_make_branch_probe_expression(const struct vlltype&loc,
char*name, char*branch);
const char*name, const char*branch);
/*
* Parse configuration file with format <key>=<value>, where key

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 2008-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -44,7 +44,7 @@ void pform_make_analog_behavior(const struct vlltype&loc, ivl_process_type_t pt,
}
PExpr* pform_make_branch_probe_expression(const struct vlltype&loc,
char*name, char*n1, char*n2)
const char*name, const char*n1, const char*n2)
{
vector<named_pexpr_t> parms (2);
parms[0].parm = new PEIdent(lex_strings.make(n1), loc.lexical_pos);
@ -59,7 +59,7 @@ PExpr* pform_make_branch_probe_expression(const struct vlltype&loc,
}
PExpr* pform_make_branch_probe_expression(const struct vlltype&loc,
char*name, char*branch_name)
const char*name, const char*branch_name)
{
vector<named_pexpr_t> parms (1);
parms[0].parm = new PEIdent(lex_strings.make(branch_name), loc.lexical_pos);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -1811,7 +1811,7 @@ void Module::dump(ostream&out) const
out << "endmodule" << endl;
}
void pform_dump(ostream&out, Module*mod)
void pform_dump(ostream&out, const Module*mod)
{
mod->dump(out);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 2012-2025 Stephen Williams (steve@icarus.com)
* Copyright CERN 2013 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
@ -118,7 +118,7 @@ PPackage *pform_package_importable(PPackage *pkg, perm_string name)
if (import_pkg == pkg->explicit_imports.end())
return nullptr;
for (auto &exp : pkg->exports) {
for (const auto &exp : pkg->exports) {
// *::* will match all imports, P::* will match all imports
// from a package and P::ID will match a specific identifier
// from a package.
@ -229,7 +229,7 @@ void pform_package_export(const struct vlltype &loc, PPackage *pkg, const char *
}
PExpr* pform_package_ident(const struct vlltype&loc,
PPackage*pkg, pform_name_t*ident_name)
PPackage*pkg, const pform_name_t*ident_name)
{
ivl_assert(loc, ident_name);
PEIdent*tmp = new PEIdent(pkg, *ident_name, loc.lexical_pos);

View File

@ -1,7 +1,7 @@
#ifndef IVL_pform_types_H
#define IVL_pform_types_H
/*
* Copyright (c) 2007-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2007-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -157,7 +157,7 @@ struct pform_tf_port_t {
class data_type_t : public PNamedItem {
public:
inline explicit data_type_t() { }
virtual ~data_type_t() = 0;
virtual ~data_type_t() override = 0;
// This method is used by the pform dumper to diagnostic dump. The
// pform_dump dumps type type in pform format, and the debug_dump
// prints the output in a linear form.
@ -166,7 +166,7 @@ class data_type_t : public PNamedItem {
ivl_type_t elaborate_type(Design*des, NetScope*scope);
virtual SymbolType symbol_type() const;
virtual SymbolType symbol_type() const override;
private:
// Elaborate the type to an ivl_type_s type.
@ -208,10 +208,10 @@ public:
struct typeref_t : public data_type_t {
explicit typeref_t(typedef_t *t, PScope *s = 0) : scope(s), type(t) {}
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const;
NetScope *find_scope(Design* des, NetScope *scope) const;
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const override;
NetScope *find_scope(Design* des, NetScope *scope) const override;
std::ostream& debug_dump(std::ostream&out) const;
std::ostream& debug_dump(std::ostream&out) const override;
private:
PScope *scope;
@ -220,13 +220,13 @@ private:
struct type_parameter_t : data_type_t {
explicit type_parameter_t(perm_string n) : name(n) { }
ivl_type_t elaborate_type_raw(Design *des, NetScope *scope) const;
ivl_type_t elaborate_type_raw(Design *des, NetScope *scope) const override;
perm_string name;
};
struct void_type_t : public data_type_t {
virtual void pform_dump(std::ostream&out, unsigned indent) const;
virtual void pform_dump(std::ostream&out, unsigned indent) const override;
};
/*
@ -239,9 +239,9 @@ struct enum_type_t : public data_type_t {
explicit enum_type_t(data_type_t *btype) : base_type(btype) { }
// Return the elaborated version of the type.
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const;
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const override;
SymbolType symbol_type() const;
SymbolType symbol_type() const override;
std::unique_ptr<data_type_t> base_type;
std::unique_ptr< std::list<named_pexpr_t> > names;
@ -254,8 +254,8 @@ struct struct_member_t : public LineInfo {
};
struct struct_type_t : public data_type_t {
virtual void pform_dump(std::ostream&out, unsigned indent) const;
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const;
virtual void pform_dump(std::ostream&out, unsigned indent) const override;
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const override;
bool packed_flag;
bool union_flag;
@ -279,9 +279,9 @@ struct atom_type_t : public data_type_t {
enum type_code type_code;
bool signed_flag;
virtual std::ostream& debug_dump(std::ostream&out) const;
virtual std::ostream& debug_dump(std::ostream&out) const override;
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const;
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const override;
};
extern atom_type_t size_type;
@ -304,9 +304,9 @@ struct vector_type_t : public data_type_t {
inline explicit vector_type_t(ivl_variable_type_t bt, bool sf,
std::list<pform_range_t>*pd)
: base_type(bt), signed_flag(sf), integer_flag(false), implicit_flag(false), pdims(pd) { }
virtual void pform_dump(std::ostream&out, unsigned indent) const;
virtual std::ostream& debug_dump(std::ostream&out) const;
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const;
virtual void pform_dump(std::ostream&out, unsigned indent) const override;
virtual std::ostream& debug_dump(std::ostream&out) const override;
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const override;
ivl_variable_type_t base_type;
bool signed_flag;
@ -334,8 +334,8 @@ struct parray_type_t : public array_base_t {
inline explicit parray_type_t(data_type_t*btype, std::list<pform_range_t>*pd)
: array_base_t(btype, pd) { }
virtual void pform_dump(std::ostream&out, unsigned indent) const;
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const;
virtual void pform_dump(std::ostream&out, unsigned indent) const override;
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const override;
};
/*
@ -346,17 +346,17 @@ struct uarray_type_t : public array_base_t {
: array_base_t(btype, pd) { }
public:
virtual void pform_dump(std::ostream&out, unsigned indent) const;
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const;
virtual void pform_dump(std::ostream&out, unsigned indent) const override;
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const override;
};
struct real_type_t : public data_type_t {
public:
enum type_t { REAL, SHORTREAL };
inline explicit real_type_t(type_t tc) : type_code_(tc) { }
virtual std::ostream& debug_dump(std::ostream&out) const;
virtual std::ostream& debug_dump(std::ostream&out) const override;
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const;
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const override;
inline type_t type_code() const { return type_code_; }
@ -366,16 +366,16 @@ struct real_type_t : public data_type_t {
struct string_type_t : public data_type_t {
inline explicit string_type_t() { }
~string_type_t();
~string_type_t() override;
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const;
ivl_type_t elaborate_type_raw(Design*des, NetScope*scope) const override;
};
struct class_type_t : public data_type_t {
inline explicit class_type_t(perm_string n) : name(n) { }
void pform_dump(std::ostream&out, unsigned indent) const;
void pform_dump(std::ostream&out, unsigned indent) const override;
void pform_dump_init(std::ostream&out, unsigned indent) const;
// This is the named type that is supposed to be the base
@ -408,11 +408,11 @@ struct class_type_t : public data_type_t {
// without waiting for any constructor.
std::vector<Statement*> initialize_static;
ivl_type_t elaborate_type_raw(Design*, NetScope*) const;
ivl_type_t elaborate_type_raw(Design*, NetScope*) const override;
perm_string name;
virtual SymbolType symbol_type() const;
virtual SymbolType symbol_type() const override;
};
ivl_type_t elaborate_array_type(Design *des, NetScope *scope,

View File

@ -1,7 +1,7 @@
%{
/*
* Copyright (c) 2000-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -185,9 +185,9 @@ static syn_token_t*ptr_ = 0;
*/
struct tokenize : public proc_match_t {
tokenize() { }
~tokenize() { }
~tokenize() override { }
int assign(NetAssign*dev)
int assign(NetAssign*dev) override
{
syn_token_t*cur;
cur = new syn_token_t;
@ -202,7 +202,7 @@ struct tokenize : public proc_match_t {
return 0;
}
int assign_nb(NetAssignNB*dev)
int assign_nb(NetAssignNB*dev) override
{
syn_token_t*cur;
cur = new syn_token_t;
@ -217,7 +217,7 @@ struct tokenize : public proc_match_t {
return 0;
}
int condit(NetCondit*dev)
int condit(NetCondit*dev) override
{
syn_token_t*cur;
@ -257,7 +257,7 @@ struct tokenize : public proc_match_t {
return 0;
}
int event_wait(NetEvWait*dev)
int event_wait(NetEvWait*dev) override
{
syn_token_t*cur;
@ -345,9 +345,9 @@ static int yylex()
}
struct syn_rules_f : public functor_t {
~syn_rules_f() { }
~syn_rules_f() override { }
void process(class Design*, class NetProcTop*top)
void process(class Design*, class NetProcTop*top) override
{
/* If the scope that contains this process as a cell
attribute attached to it, then skip synthesis. */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 2002-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -40,7 +40,7 @@ bool NetEvWait::is_synchronous()
return false;
for (unsigned pdx = 0 ; pdx < ev->nprobe() ; pdx += 1) {
NetEvProbe*pr = ev->probe(pdx);
const NetEvProbe*pr = ev->probe(pdx);
/* No level sensitive clocks. */
if (pr->edge() == NetEvProbe::ANYEDGE)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2017 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -41,10 +41,10 @@ class do_expr : public proc_match_t {
Design*des_;
NetScope*scope_;
virtual int assign(NetAssign*);
virtual int assign_nb(NetAssignNB*);
virtual int event_wait(NetEvWait*);
virtual int condit(NetCondit*);
virtual int assign(NetAssign*) override;
virtual int assign_nb(NetAssignNB*) override;
virtual int event_wait(NetEvWait*) override;
virtual int condit(NetCondit*) override;
};
@ -114,7 +114,7 @@ class synth_f : public functor_t {
public:
synth_f() { top_ = NULL; }
void process(Design*, NetProcTop*);
void process(Design*, NetProcTop*) override;
private:
void proc_always_(Design*);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2022 Stephen Williams (steve@icarus.com)
* Copyright (c) 2002-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -261,7 +261,7 @@ bool NetProcTop::tie_off_floating_inputs_(Design*des,
continue;
ivl_variable_type_t data_type = IVL_VT_LOGIC;
netvector_t*tmp_vec = new netvector_t(data_type, width-1,0);
const netvector_t*tmp_vec = new netvector_t(data_type, width-1,0);
NetNet*sig = new NetNet(scope(), scope()->local_symbol(),
NetNet::WIRE, tmp_vec);
sig->local_flag(true);
@ -421,14 +421,14 @@ bool NetAssignBase::synth_async(Design*des, NetScope*scope,
// Evaluate the index expression to a constant.
const NetExpr*base_expr_raw = lval_->get_base();
ivl_assert(*this, base_expr_raw);
NetExpr*base_expr = base_expr_raw->evaluate_function(*this, scope->loop_index_tmp);
const NetExpr*base_expr = base_expr_raw->evaluate_function(*this, scope->loop_index_tmp);
if (! eval_as_long(base_off, base_expr)) {
ivl_assert(*this, 0);
}
ivl_assert(*this, base_off >= 0);
ivl_variable_type_t tmp_data_type = rsig->data_type();
netvector_t*tmp_type = new netvector_t(tmp_data_type, lsig_width-1,0);
const netvector_t*tmp_type = new netvector_t(tmp_data_type, lsig_width-1,0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, tmp_type);
@ -451,7 +451,7 @@ bool NetAssignBase::synth_async(Design*des, NetScope*scope,
const NetExpr*base_expr_raw = lval_->get_base();
ivl_assert(*this, base_expr_raw);
NetExpr*base_expr = base_expr_raw->evaluate_function(*this, scope->loop_index_tmp);
const NetExpr*base_expr = base_expr_raw->evaluate_function(*this, scope->loop_index_tmp);
if (! eval_as_long(base_off, base_expr)) {
cerr << get_fileline() << ": sorry: assignment to variable "
"bit location is not currently supported in "
@ -462,7 +462,7 @@ bool NetAssignBase::synth_async(Design*des, NetScope*scope,
ivl_assert(*this, base_off >= 0);
ivl_variable_type_t tmp_data_type = rsig->data_type();
netvector_t*tmp_type = new netvector_t(tmp_data_type, lsig_width-1,0);
const netvector_t*tmp_type = new netvector_t(tmp_data_type, lsig_width-1,0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, tmp_type);
@ -679,7 +679,7 @@ static NetNet* mux_selector_reduce_width(Design*des, NetScope*scope,
// This is the output signal, osig.
ivl_variable_type_t osig_data_type = IVL_VT_LOGIC;
netvector_t*osig_vec = new netvector_t(osig_data_type, sel_need-1, 0);
const netvector_t*osig_vec = new netvector_t(osig_data_type, sel_need-1, 0);
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::TRI, osig_vec);
osig->local_flag(true);
@ -699,7 +699,7 @@ static NetNet* mux_selector_reduce_width(Design*des, NetScope*scope,
des->add_node(ps0);
connect(ps0->pin(1), esig->pin(0));
netvector_t*ps0_vec = new netvector_t(osig_data_type, sel_need-2, 0);
const netvector_t*ps0_vec = new netvector_t(osig_data_type, sel_need-2, 0);
NetNet*ps0_sig = new NetNet(scope, scope->local_symbol(),
NetNet::TRI, ps0_vec);
ps0_sig->local_flag(true);
@ -717,7 +717,7 @@ static NetNet* mux_selector_reduce_width(Design*des, NetScope*scope,
des->add_node(ps1);
connect(ps1->pin(1), esig->pin(0));
netvector_t*ps1_vec = new netvector_t(osig_data_type, sel_got-sel_need, 0);
const netvector_t*ps1_vec = new netvector_t(osig_data_type, sel_got-sel_need, 0);
NetNet*ps1_sig = new NetNet(scope, scope->local_symbol(),
NetNet::TRI, ps1_vec);
ps1_sig->local_flag(true);
@ -819,7 +819,7 @@ bool NetCase::synth_async(Design*des, NetScope*scope,
continue;
}
NetEConst*ge = dynamic_cast<NetEConst*>(items_[item].guard);
const NetEConst*ge = dynamic_cast<NetEConst*>(items_[item].guard);
if (ge == 0) {
cerr << items_[item].guard->get_fileline() << ": sorry: "
<< "variable case item expressions with a variable "
@ -939,7 +939,7 @@ bool NetCase::synth_async(Design*des, NetScope*scope,
// the pin.
if (out_mux[mdx]->pin_Result().nexus()->pick_any_net() == 0) {
ivl_variable_type_t mux_data_type = IVL_VT_LOGIC;
netvector_t*tmp_vec = new netvector_t(mux_data_type, mux_width[mdx]-1,0);
const netvector_t*tmp_vec = new netvector_t(mux_data_type, mux_width[mdx]-1,0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, tmp_vec);
tmp->local_flag(true);
@ -1105,7 +1105,7 @@ bool NetCase::synth_async_casez_(Design*des, NetScope*scope,
}
}
netvector_t*condit_type = new netvector_t(IVL_VT_LOGIC, 0, 0);
const netvector_t*condit_type = new netvector_t(IVL_VT_LOGIC, 0, 0);
NetCaseCmp::kind_t case_kind = NetCaseCmp::EEQ;
switch (type()) {
@ -1185,7 +1185,7 @@ bool NetCase::synth_async_casez_(Design*des, NetScope*scope,
// Make a NetNet for the result.
ivl_variable_type_t mux_data_type = IVL_VT_LOGIC;
netvector_t*tmp_vec = new netvector_t(mux_data_type, mux_width[mdx]-1,0);
const netvector_t*tmp_vec = new netvector_t(mux_data_type, mux_width[mdx]-1,0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, tmp_vec);
tmp->local_flag(true);
@ -1335,7 +1335,7 @@ bool NetCondit::synth_async(Design*des, NetScope*scope,
// Guess the mux type from the type of the output.
ivl_variable_type_t mux_data_type = IVL_VT_LOGIC;
if (NetNet*tmp = nex_out.pin(idx).nexus()->pick_any_net()) {
if (const NetNet*tmp = nex_out.pin(idx).nexus()->pick_any_net()) {
mux_data_type = tmp->data_type();
}
@ -1389,7 +1389,7 @@ bool NetCondit::synth_async(Design*des, NetScope*scope,
mux->set_line(*this);
des->add_node(mux);
netvector_t*tmp_type = 0;
const netvector_t*tmp_type = 0;
if (mux_width==1)
tmp_type = new netvector_t(mux_data_type);
else
@ -1477,7 +1477,7 @@ bool NetForLoop::synth_async(Design*des, NetScope*scope,
NetAssign*step_assign = dynamic_cast<NetAssign*> (step_statement_);
char assign_operator = step_assign->assign_operator();
ivl_assert(*this, step_assign);
NetExpr*step_expr = step_assign->rval();
const NetExpr*step_expr = step_assign->rval();
// Tell the scope that this index value is like a genvar.
LocalVar index_var;
@ -1814,11 +1814,11 @@ bool NetCondit::synth_sync(Design*des, NetScope*scope,
case NetEvProbe::NEGEDGE: {
bool is_inverter = false;
NetNode*node = rst->pin(0).nexus()->pick_any_node();
if (NetLogic*gate = dynamic_cast<NetLogic*>(node)) {
if (const NetLogic*gate = dynamic_cast<NetLogic*>(node)) {
if (gate->type() == NetLogic::NOT)
is_inverter = true;
}
if (NetUReduce*gate = dynamic_cast<NetUReduce*>(node)) {
if (const NetUReduce*gate = dynamic_cast<NetUReduce*>(node)) {
if (gate->type() == NetUReduce::NOR)
is_inverter = true;
}
@ -1854,7 +1854,7 @@ bool NetCondit::synth_sync(Design*des, NetScope*scope,
ivl_assert(*this, tmp_out.pin_count() == ff_aset.pin_count());
for (unsigned pin = 0 ; pin < tmp_out.pin_count() ; pin += 1) {
Nexus*rst_nex = tmp_out.pin(pin).nexus();
const Nexus*rst_nex = tmp_out.pin(pin).nexus();
if (!all_bits_driven(tmp_masks[pin])) {
cerr << get_fileline() << ": sorry: Not all bits of '"
@ -2034,7 +2034,7 @@ bool NetEvWait::synth_sync(Design*des, NetScope*scope,
/* Get the input set from the substatement. This will be used
to figure out which of the probes is the clock. */
NexusSet*statement_input = statement_ -> nex_input();
const NexusSet*statement_input = statement_ -> nex_input();
/* Search for a clock input. The clock input is the edge event
that is not also an input to the substatement. */
@ -2209,7 +2209,7 @@ bool NetProcTop::synth_sync(Design*des)
class synth2_f : public functor_t {
public:
void process(Design*, NetProcTop*);
void process(Design*, NetProcTop*) override;
private:
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008-2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 2008-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -34,8 +34,8 @@ bool dll_target::process(const NetAnalogTop*net)
{
bool rc_flag = true;
ivl_process_t obj = (struct ivl_process_s*)
calloc(1, sizeof(struct ivl_process_s));
ivl_process_t obj = static_cast<struct ivl_process_s*>
(calloc(1, sizeof(struct ivl_process_s)));
obj->type_ = net->type();
obj->analog_flag = 1;
@ -49,7 +49,7 @@ bool dll_target::process(const NetAnalogTop*net)
obj->attr = fill_in_attributes(net);
assert(stmt_cur_ == 0);
stmt_cur_ = (struct ivl_statement_s*)calloc(1, sizeof*stmt_cur_);
stmt_cur_ = static_cast<struct ivl_statement_s*>(calloc(1, sizeof*stmt_cur_));
rc_flag = net->statement()->emit_proc(this) && rc_flag;
assert(stmt_cur_);

Some files were not shown because too many files have changed in this diff Show More