2012-11-14 02:12:23 +01:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
// DESCRIPTION: Verilator: Language code class
|
|
|
|
|
//
|
2019-11-08 04:33:59 +01:00
|
|
|
// Code available from: https://verilator.org
|
2012-11-14 02:12:23 +01: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
|
2012-11-14 02:12:23 +01: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
|
2012-11-14 02:12:23 +01:00
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
2019-10-05 02:17:11 +02:00
|
|
|
|
2021-03-04 03:57:07 +01:00
|
|
|
#ifndef VERILATOR_V3LANGCODE_H_
|
|
|
|
|
#define VERILATOR_V3LANGCODE_H_
|
2012-11-14 02:12:23 +01:00
|
|
|
|
|
|
|
|
#include "config_build.h"
|
|
|
|
|
#include "verilatedos.h"
|
2018-10-14 17:10:11 +02:00
|
|
|
|
2012-11-14 02:12:23 +01:00
|
|
|
#include <map>
|
|
|
|
|
#include <set>
|
2022-08-05 11:56:57 +02:00
|
|
|
#include <vector>
|
2012-11-14 02:12:23 +01:00
|
|
|
|
|
|
|
|
//######################################################################
|
|
|
|
|
//! Class for the different languages supported.
|
|
|
|
|
//! A separate file, since used both in V3Options (globally) and FileLine 9per
|
|
|
|
|
//! file).
|
2020-11-19 03:32:16 +01:00
|
|
|
class V3LangCode final {
|
2012-11-14 02:12:23 +01:00
|
|
|
public:
|
2020-08-16 18:05:35 +02:00
|
|
|
enum en : uint8_t {
|
2019-05-19 22:13:13 +02:00
|
|
|
L_ERROR, // Must be first.
|
|
|
|
|
L1364_1995,
|
|
|
|
|
L1364_2001,
|
|
|
|
|
L1364_2005,
|
|
|
|
|
L1800_2005,
|
|
|
|
|
L1800_2009,
|
|
|
|
|
L1800_2012,
|
|
|
|
|
L1800_2017,
|
2024-03-02 15:01:37 +01:00
|
|
|
L1800_2023,
|
2019-05-19 22:13:13 +02:00
|
|
|
// ***Add new elements below also***
|
|
|
|
|
_ENUM_END
|
2012-11-14 02:12:23 +01:00
|
|
|
};
|
|
|
|
|
const char* ascii() const {
|
2024-03-02 15:01:37 +01:00
|
|
|
const char* const names[]
|
|
|
|
|
= {// These must match the `begin_keywords values
|
|
|
|
|
" ERROR", "1364-1995", "1364-2001", "1364-2005", "1800-2005",
|
|
|
|
|
"1800-2009", "1800-2012", "1800-2017", "1800-2023"};
|
2019-05-19 22:13:13 +02:00
|
|
|
return names[m_e];
|
2020-02-04 04:10:29 +01:00
|
|
|
}
|
2024-03-02 15:01:37 +01:00
|
|
|
static V3LangCode mostRecent() VL_MT_SAFE { return V3LangCode{L1800_2023}; }
|
2020-04-14 04:51:35 +02:00
|
|
|
bool systemVerilog() const {
|
2024-03-02 15:01:37 +01:00
|
|
|
return m_e == L1800_2005 || m_e == L1800_2009 || m_e == L1800_2012 || m_e == L1800_2017
|
|
|
|
|
|| m_e == L1800_2023;
|
2020-04-14 04:51:35 +02:00
|
|
|
}
|
2012-11-14 02:12:23 +01:00
|
|
|
bool legal() const { return m_e != L_ERROR; }
|
|
|
|
|
//
|
|
|
|
|
enum en m_e;
|
2022-09-16 14:17:38 +02:00
|
|
|
V3LangCode()
|
2020-08-16 17:40:42 +02:00
|
|
|
: m_e{L_ERROR} {}
|
2015-10-04 04:33:06 +02:00
|
|
|
// cppcheck-suppress noExplicitConstructor
|
2022-09-23 11:57:01 +02:00
|
|
|
constexpr V3LangCode(en _e)
|
2020-08-16 17:40:42 +02:00
|
|
|
: m_e{_e} {}
|
2018-08-25 15:52:45 +02:00
|
|
|
explicit V3LangCode(const char* textp);
|
2022-09-16 14:17:38 +02:00
|
|
|
explicit V3LangCode(int _e)
|
2020-08-18 14:10:44 +02:00
|
|
|
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
|
2022-09-23 11:57:01 +02:00
|
|
|
constexpr operator en() const { return m_e; }
|
2012-11-14 02:12:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//######################################################################
|
|
|
|
|
|
2019-05-19 22:13:13 +02:00
|
|
|
#endif // guard
|