2012-04-13 03:08:20 +02:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
2011-07-07 01:03:40 +02:00
|
|
|
//*************************************************************************
|
|
|
|
|
// DESCRIPTION: Verilator: Cleanup stage in V3Width
|
|
|
|
|
//
|
2019-11-08 04:33:59 +01:00
|
|
|
// Code available from: https://verilator.org
|
2011-07-07 01:03:40 +02:00
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
//
|
2025-01-01 14:30:25 +01:00
|
|
|
// Copyright 2003-2025 by Wilson Snyder. This program is free software; you
|
2020-03-21 16:24:24 +01:00
|
|
|
// can redistribute it and/or modify it under the terms of either the GNU
|
2011-07-07 01:03:40 +02:00
|
|
|
// Lesser General Public License Version 3 or the Perl Artistic License
|
|
|
|
|
// Version 2.0.
|
2020-03-21 16:24:24 +01:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2011-07-07 01:03:40 +02:00
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
2019-10-05 02:17:11 +02:00
|
|
|
|
2021-03-04 03:57:07 +01:00
|
|
|
#ifndef VERILATOR_V3WIDTHCOMMIT_H_
|
|
|
|
|
#define VERILATOR_V3WIDTHCOMMIT_H_
|
2018-10-14 19:43:24 +02:00
|
|
|
|
2011-07-07 01:03:40 +02:00
|
|
|
#include "config_build.h"
|
|
|
|
|
#include "verilatedos.h"
|
2018-10-14 19:43:24 +02:00
|
|
|
|
2011-07-07 01:03:40 +02:00
|
|
|
#include "V3Ast.h"
|
2022-08-05 11:56:57 +02:00
|
|
|
#include "V3Error.h"
|
2011-07-07 01:03:40 +02:00
|
|
|
|
2023-10-07 05:18:26 +02:00
|
|
|
//============================================================================
|
2020-11-25 13:03:01 +01:00
|
|
|
|
2023-10-07 05:18:26 +02:00
|
|
|
class V3WidthCommit final {
|
2014-04-02 05:16:16 +02:00
|
|
|
public:
|
2018-08-25 15:52:45 +02:00
|
|
|
static AstConst* newIfConstCommitSize(AstConst* nodep) {
|
2020-04-14 04:51:35 +02:00
|
|
|
if (((nodep->dtypep()->width() != nodep->num().width()) || !nodep->num().sized())
|
2019-05-10 02:03:19 +02:00
|
|
|
&& !nodep->num().isString()) { // Need to force the number from unsized to sized
|
2025-04-30 14:08:44 +02:00
|
|
|
V3Number num{nodep, nodep->dtypep()->width(), nodep->num()};
|
2019-05-19 22:13:13 +02:00
|
|
|
num.isSigned(nodep->isSigned());
|
2022-11-11 04:58:27 +01:00
|
|
|
AstConst* const newp = new AstConst{nodep->fileline(), num};
|
2019-05-19 22:13:13 +02:00
|
|
|
newp->dtypeFrom(nodep);
|
2022-11-19 19:30:23 +01:00
|
|
|
newp->user1(true);
|
2019-05-19 22:13:13 +02:00
|
|
|
return newp;
|
|
|
|
|
} else {
|
2020-08-15 16:12:55 +02:00
|
|
|
return nullptr;
|
2019-05-19 22:13:13 +02:00
|
|
|
}
|
2014-04-02 05:16:16 +02:00
|
|
|
}
|
|
|
|
|
|
2023-10-07 05:18:26 +02:00
|
|
|
// Final step... Mark all widths as equal
|
|
|
|
|
static void widthCommit(AstNetlist* nodep) VL_MT_DISABLED;
|
2011-07-07 01:03:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//######################################################################
|
|
|
|
|
|
2019-05-19 22:13:13 +02:00
|
|
|
#endif // Guard
|