2012-11-14 01:12:23 +00:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
|
|
|
//*************************************************************************
|
|
|
|
// DESCRIPTION: Verilator: Language code class
|
|
|
|
//
|
2019-11-08 03:33:59 +00:00
|
|
|
// Code available from: https://verilator.org
|
2012-11-14 01:12:23 +00:00
|
|
|
//
|
|
|
|
//*************************************************************************
|
|
|
|
//
|
2021-01-01 15:29:54 +00:00
|
|
|
// Copyright 2003-2021 by Wilson Snyder. This program is free software; you
|
2020-03-21 15:24:24 +00:00
|
|
|
// can redistribute it and/or modify it under the terms of either the GNU
|
2012-11-14 01:12:23 +00:00
|
|
|
// Lesser General Public License Version 3 or the Perl Artistic License
|
|
|
|
// Version 2.0.
|
2020-03-21 15:24:24 +00:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2012-11-14 01:12:23 +00:00
|
|
|
//
|
|
|
|
//*************************************************************************
|
2019-10-05 00:17:11 +00:00
|
|
|
|
2021-03-04 02:57:07 +00:00
|
|
|
#ifndef VERILATOR_V3LANGCODE_H_
|
|
|
|
#define VERILATOR_V3LANGCODE_H_
|
2012-11-14 01:12:23 +00:00
|
|
|
|
|
|
|
#include "config_build.h"
|
|
|
|
#include "verilatedos.h"
|
2018-10-14 15:10:11 +00:00
|
|
|
|
2012-11-14 01:12:23 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
//######################################################################
|
|
|
|
//! Class for the different languages supported.
|
|
|
|
//! A separate file, since used both in V3Options (globally) and FileLine 9per
|
|
|
|
//! file).
|
2020-11-19 02:32:16 +00:00
|
|
|
class V3LangCode final {
|
2012-11-14 01:12:23 +00:00
|
|
|
public:
|
2020-08-16 16:05:35 +00:00
|
|
|
enum en : uint8_t {
|
2019-05-19 20:13:13 +00:00
|
|
|
L_ERROR, // Must be first.
|
|
|
|
L1364_1995,
|
|
|
|
L1364_2001,
|
|
|
|
L1364_2005,
|
|
|
|
L1800_2005,
|
|
|
|
L1800_2009,
|
|
|
|
L1800_2012,
|
|
|
|
L1800_2017,
|
|
|
|
// ***Add new elements below also***
|
|
|
|
_ENUM_END
|
2012-11-14 01:12:23 +00:00
|
|
|
};
|
|
|
|
const char* ascii() const {
|
2020-04-14 02:51:35 +00: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"};
|
2019-05-19 20:13:13 +00:00
|
|
|
return names[m_e];
|
2020-02-04 03:10:29 +00:00
|
|
|
}
|
2018-03-13 02:26:34 +00:00
|
|
|
static V3LangCode mostRecent() { return V3LangCode(L1800_2017); }
|
2020-04-14 02:51:35 +00:00
|
|
|
bool systemVerilog() const {
|
|
|
|
return m_e == L1800_2005 || m_e == L1800_2009 || m_e == L1800_2012 || m_e == L1800_2017;
|
|
|
|
}
|
2012-11-14 01:12:23 +00:00
|
|
|
bool legal() const { return m_e != L_ERROR; }
|
|
|
|
//
|
|
|
|
enum en m_e;
|
2020-04-14 02:51:35 +00:00
|
|
|
inline V3LangCode()
|
2020-08-16 15:40:42 +00:00
|
|
|
: m_e{L_ERROR} {}
|
2015-10-04 02:33:06 +00:00
|
|
|
// cppcheck-suppress noExplicitConstructor
|
2020-04-14 02:51:35 +00:00
|
|
|
inline V3LangCode(en _e)
|
2020-08-16 15:40:42 +00:00
|
|
|
: m_e{_e} {}
|
2018-08-25 13:52:45 +00:00
|
|
|
explicit V3LangCode(const char* textp);
|
2020-04-14 02:51:35 +00:00
|
|
|
explicit inline V3LangCode(int _e)
|
2020-08-18 12:10:44 +00:00
|
|
|
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
|
2018-08-25 13:52:45 +00:00
|
|
|
operator en() const { return m_e; }
|
2012-11-14 01:12:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//######################################################################
|
|
|
|
|
2019-05-19 20:13:13 +00:00
|
|
|
#endif // guard
|