1 // -*- mode: C++; c-file-style: "cc-mode" -*- 2 //************************************************************************* 3 // DESCRIPTION: Verilator: Language code class 4 // 5 // Code available from: https://verilator.org 6 // 7 //************************************************************************* 8 // 9 // Copyright 2003-2021 by Wilson Snyder. This program is free software; you 10 // can redistribute it and/or modify it under the terms of either the GNU 11 // Lesser General Public License Version 3 or the Perl Artistic License 12 // Version 2.0. 13 // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 14 // 15 //************************************************************************* 16 17 #ifndef VERILATOR_V3LANGCODE_H_ 18 #define VERILATOR_V3LANGCODE_H_ 19 20 #include "config_build.h" 21 #include "verilatedos.h" 22 23 #include <vector> 24 #include <map> 25 #include <set> 26 27 //###################################################################### 28 //! Class for the different languages supported. 29 //! A separate file, since used both in V3Options (globally) and FileLine 9per 30 //! file). 31 class V3LangCode final { 32 public: 33 enum en : uint8_t { 34 L_ERROR, // Must be first. 35 L1364_1995, 36 L1364_2001, 37 L1364_2005, 38 L1800_2005, 39 L1800_2009, 40 L1800_2012, 41 L1800_2017, 42 // ***Add new elements below also*** 43 _ENUM_END 44 }; ascii()45 const char* ascii() const { 46 const char* const names[] = {// These must match the `begin_keywords values. 47 " ERROR", "1364-1995", "1364-2001", "1364-2005", 48 "1800-2005", "1800-2009", "1800-2012", "1800-2017"}; 49 return names[m_e]; 50 } mostRecent()51 static V3LangCode mostRecent() { return V3LangCode(L1800_2017); } systemVerilog()52 bool systemVerilog() const { 53 return m_e == L1800_2005 || m_e == L1800_2009 || m_e == L1800_2012 || m_e == L1800_2017; 54 } legal()55 bool legal() const { return m_e != L_ERROR; } 56 // 57 enum en m_e; V3LangCode()58 inline V3LangCode() 59 : m_e{L_ERROR} {} 60 // cppcheck-suppress noExplicitConstructor V3LangCode(en _e)61 inline V3LangCode(en _e) 62 : m_e{_e} {} 63 explicit V3LangCode(const char* textp); V3LangCode(int _e)64 explicit inline V3LangCode(int _e) 65 : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning en()66 operator en() const { return m_e; } 67 }; 68 69 //###################################################################### 70 71 #endif // guard 72