diff --git a/.gitignore b/.gitignore index e6e7d24a..333edc16 100644 --- a/.gitignore +++ b/.gitignore @@ -126,3 +126,5 @@ scan_vcd.cpp tokens_vcd.h *~ +*build* +CMakeLists.txt.user diff --git a/CMakeLists.txt b/CMakeLists.txt index 86d30a70..f9dcec53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,8 +29,8 @@ # ~~~ -project(qucs-core CXX) -cmake_minimum_required(VERSION 2.6) +project(qucsator CXX) +cmake_minimum_required(VERSION 3.16) # ignore the project() managed VERSION (new in CMake 3.0) if(POLICY CMP0048) @@ -38,10 +38,10 @@ if(POLICY CMP0048) endif(POLICY CMP0048) -# otherwise qucsator cannot generate qucsdefs.h -add_definitions(-DDEBUG) +## otherwise qucsator cannot generate qucsdefs.h +#add_definitions(-DDEBUG) -# defines nr_double_t +## defines nr_double_t add_definitions(-DHAVE_CONFIG_H) # ~~~ @@ -49,42 +49,41 @@ add_definitions(-DHAVE_CONFIG_H) # OPTION(ENABLE_QUCSLIB "enable qucslib build, default: OFF") # OPTION(ENABLE_DOUBLE " type of double representation, default=double") -# TODO configure debug/release flags - -# TODO check flags used on Autotools are needed: -# -# -pipe : Use pipes rather than temporary files for communication between the -# various stages of compilation. -# -# https://blog.mozilla.org/nnethercote/2011/01/18/the-dangers-of-fno-exceptions/ -# -fno-exceptions option is used, which means that exception-handling is -# disabled. -# -# -fno-rtti : Disable generation of information about every class with virtual -# functions. -# -# -fno-check-new : specific to GCC -# -# -Wmissing-prototypes : Warn if a global function is defined without a previous -# prototype declaration. -# -# ~~~ +## TODO configure debug/release flags + +## TODO check flags used on Autotools are needed: +## +## -pipe : Use pipes rather than temporary files for communication between the +## various stages of compilation. +## +## https://blog.mozilla.org/nnethercote/2011/01/18/the-dangers-of-fno-exceptions/ +## -fno-exceptions option is used, which means that exception-handling is +## disabled. +## +## -fno-rtti : Disable generation of information about every class with virtual +## functions. +## +## -fno-check-new : specific to GCC +## +## -Wmissing-prototypes : Warn if a global function is defined without a previous +## prototype declaration. +## +## ~~~ # use top VERSION file -file(STRINGS ${qucs-core_SOURCE_DIR}/VERSION QUCS_VERSION) +file(STRINGS ${qucsator_SOURCE_DIR}/VERSION QUCS_VERSION) message(STATUS "Configuring ${PROJECT_NAME}: VERSION ${QUCS_VERSION}") +# directed to config.h, so these definitions are available in the code set(PROJECT_VERSION "${QUCS_VERSION}") - set(PROJECT_VENDOR "Qucs team. This program is licensed under the GNU GPL") - set(QUCS_URL "https://sf.net/p/qucs") set(QUCS_BUGREPORT "qucs-bugs@lists.sourceforge.net") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/qucsconv.1.cmake.in - ${CMAKE_CURRENT_SOURCE_DIR}/doc/qucsconv.1) + ${CMAKE_CURRENT_SOURCE_DIR}/doc/qucsconv.1) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/qucsator.1.cmake.in - ${CMAKE_CURRENT_SOURCE_DIR}/doc/qucsator.1) + ${CMAKE_CURRENT_SOURCE_DIR}/doc/qucsator.1) # use last git commit hash along the version set(GIT unknown) @@ -92,20 +91,18 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/../.git) find_package(Git) # Get the latest abbreviated commit hash of the working branch execute_process( - COMMAND ${GIT_EXECUTABLE} log --pretty=format:%h -n 1u - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE GIT_COMMIT_HASH) - set(GIT ${GIT_COMMIT_HASH}) - message(STATUS "Found Git repository, last commit hash: ${GIT}") + COMMAND ${GIT_EXECUTABLE} log --pretty=format:%h -n 1u + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_HASH) +set(GIT ${GIT_COMMIT_HASH}) +message(STATUS "Found Git repository, last commit hash: ${GIT}") endif() -# TODO rename the above variables? Project/Package? - # Define to the address where bug reports for this package should be sent. set(PACKAGE_BUGREPORT "qucs-bugs@lists.sourceforge.net") # Define to the full name of this package. -set(PACKAGE_NAME "qucs-core") +set(PACKAGE_NAME "qucsator") # Define to the full name and version of this package. set(PACKAGE_STRING "${PACKAGE_NAME} ${PROJECT_VERSION}") @@ -118,19 +115,8 @@ set(PACKAGE_URL "http://sourceforge.net/projects/qucs/") # Define to the version of this package. set(PACKAGE_VERSION ${PROJECT_VERSION}) - -# -# Avoid source tree pollution -# -if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) - message( - FATAL_ERROR - "\nIn-source builds are not permitted. - Make a separate folder for building: - $ mkdir build; cd build; cmake .. - Before that, remove the files already created: - $ rm -rf CMakeCache.txt CMakeFiles") -endif() +# add compiler definitions/symbols +add_compile_definitions(PACKAGE_VERSION="${PACKAGE_VERSION}") # # Set locations of CMake modules, used on tests, find,... @@ -138,72 +124,16 @@ endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") # -# Need Flex -# -find_package(FLEX 2.5.9 REQUIRED) -if(FLEX_FOUND) -endif() - -# ~~~ -# Need Bison -# -# This is a HACK to get arround a PATH issue with Qt Creator on OSX. -# It seams impossible to pass a custom PATH to Qt Creator on OSX, ie, cannot prepend `/usr/local/bin/` for intance. -# The FIND_PACKAGE fails. For now we provide a fallback with a custom FIND_PROGRAM. -# The variable BISON_DIR is also available. -# ~~~ -if(WIN32) - find_package(BISON 2.4 REQUIRED) -else() # Linux, OSX - # use -DBISON_DIR=/path/ to provide the path to bison - find_program( - BISON_EXECUTABLE bison - PATHS /usr/local/bin/ /opt/local/bin/ /usr/bin ${BISON_DIR} - DOC "bison path" - NO_DEFAULT_PATH) - if(BISON_EXECUTABLE) - message(STATUS "Found bison: " ${BISON_EXECUTABLE}) - else() - message( - FATAL_ERROR "Unable to find bison. Try to provide -DBISON_DIR=[path]") - endif() -endif() - -# -# Check for sed -# -find_program(SED_TOOL NAMES sed) -if(NOT SED_TOOL) - message(FATAL_ERROR "Unable to find sed") -else() - message(STATUS "Found sed: " ${SED_TOOL}) -endif() - -# -# Check for gperf -# -find_program(GPERF_TOOL NAMES gperf) -if(NOT GPERF_TOOL) - message(FATAL_ERROR "gperf required in PATH") -else() - message(STATUS "Found gperf: " ${GPERF_TOOL}) -endif() - -# -# Check if admsXml is available -# -# * Use -DADMSXML_DIR=[path] to give the path containing admsXml -# * Try a few othe locations +# Avoid source tree pollution # -find_program( - ADMSXML admsXml - HINTS ${ADMSXML_DIR} - PATHS /usr/local/bin/ /opt/local/bin/ /usr/bin - DOC "admsXml application") -if(NOT ADMSXML) - message(FATAL_ERROR "admsXml required in PATH") -else() - message(STATUS "Found admsXml: " ${ADMSXML}) +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) + message( + FATAL_ERROR + "\nIn-source builds are not permitted. + Make a separate folder for building: + $ mkdir build; cd build; cmake .. + Before that, remove the files already created: + $ rm -rf CMakeCache.txt CMakeFiles") endif() # @@ -262,10 +192,10 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") # Compiler-specific C++11 activation. if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion - OUTPUT_VARIABLE GCC_VERSION) + OUTPUT_VARIABLE GCC_VERSION) if(NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7)) - message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.7 or greater.") - endif() + message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.7 or greater.") +endif() elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") else() @@ -277,7 +207,7 @@ endif() # if(UNIX AND NOT APPLE) if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") - set(CMAKE_POSITION_INDEPENDENT_CODE ON) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() endif() @@ -291,11 +221,11 @@ add_subdirectory(doc) # Custom uninstall target # configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake" IMMEDIATE @ONLY) + "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake" IMMEDIATE @ONLY) add_custom_target( - uninstall-core COMMAND ${CMAKE_COMMAND} -P - ${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake) + uninstall-qucsator COMMAND ${CMAKE_COMMAND} -P + ${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake) # TODO install distributables EXTRA_DIST = BUGS bootstrap depcomp RELEASE @@ -309,3 +239,33 @@ set(CPACK_GENERATOR "TGZ") set(CPACK_PACKAGE_VERSION_MAJOR 0) set(CPACK_PACKAGE_VERSION_MINOR 18) include(CPack) + +# everything related to install the qucs application +# any dependencies are installed here +if(UNIX AND NOT APPLE) + set(DESKTOP ${CMAKE_CURRENT_SOURCE_DIR}/contrib/qucsator.desktop) + install(FILES ${DESKTOP} + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications) + + set(BITMAPS_HICOLOR_PATH ${CMAKE_CURRENT_SOURCE_DIR}/contrib/hicolor) + set(BITMAPS_HICOLOR_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor) + + install(FILES ${BITMAPS_HICOLOR_PATH}/16x16/apps/qucsator.png + DESTINATION ${BITMAPS_HICOLOR_DESTINATION}/16x16/apps) + install(FILES ${BITMAPS_HICOLOR_PATH}/22x22/apps/qucsator.png + DESTINATION ${BITMAPS_HICOLOR_DESTINATION}/22x22/apps) + install(FILES ${BITMAPS_HICOLOR_PATH}/32x32/apps/qucsator.png + DESTINATION ${BITMAPS_HICOLOR_DESTINATION}/32x32/apps) + install(FILES ${BITMAPS_HICOLOR_PATH}/48x48/apps/qucsator.png + DESTINATION ${BITMAPS_HICOLOR_DESTINATION}/48x48/apps) + install(FILES ${BITMAPS_HICOLOR_PATH}/64x64/apps/qucsator.png + DESTINATION ${BITMAPS_HICOLOR_DESTINATION}/64x64/apps) + install(FILES ${BITMAPS_HICOLOR_PATH}/128x128/apps/qucsator.png + DESTINATION ${BITMAPS_HICOLOR_DESTINATION}/128x128/apps) + install(FILES ${BITMAPS_HICOLOR_PATH}/256x256/apps/qucsator.png + DESTINATION ${BITMAPS_HICOLOR_DESTINATION}/256x256/apps) + install(FILES ${BITMAPS_HICOLOR_PATH}/512x512/apps/qucsator.png + DESTINATION ${BITMAPS_HICOLOR_DESTINATION}/512x512/apps) + install(FILES ${BITMAPS_HICOLOR_PATH}/scalable/apps/qucsator.svg + DESTINATION ${BITMAPS_HICOLOR_DESTINATION}/scalable/apps) +endif() diff --git a/FAQ.md b/FAQ.md new file mode 100644 index 00000000..70872f53 --- /dev/null +++ b/FAQ.md @@ -0,0 +1,98 @@ +## WINDOWS: Could NOT find BISON (missing: BISON_EXECUTABLE) +install BISON from: http://gnuwin32.sourceforge.net/packages/bison.htm + +## WINDOWS: Could NOT find FLEX (missing: FLEX_EXECUTABLE) +install FLEX from: http://gnuwin32.sourceforge.net/packages/flex.htm + +## In file included from C:\Users\mmarmsoler\Documents\Personal\GIT\qucs\qucsator\src\ucs.cpp:39: C:\Users\mmarmsoler\Documents\Personal\GIT\qucs\qucsator\src\components/component.h:35:10: fatal error: compat.h: No such file or directory #include "compat.h" +problem commit: adcda63f7cfd11f398b5cfed5110764a04e7f6f8 + +seems to be a problem in qucsator, because when commenting out qucsator target in src/CMakeLists.txt the compiler error does not occur anymore +#add_executable(qucsator ucs.cpp ${PUBLIC_HEADERS} ${TEMPLATES}) +#target_include_directories(qucsator PRIVATE ${qucsator_SOURCE_DIR}) + +## C:/Users/mmarmsoler/Documents/Personal/GIT/qucs/qucsator/src/logging.h:32:1: error: '__BEGIN_DECLS' does not name a type __BEGIN_DECLS +occured during build of coreMath: Scanning dependencies of target coreMath +defined in the config file config.h in the qucsator folder +include config.h, how it should no about it? +#include "config.h" + +## C:/Users/mmarmsoler/Documents/Personal/GIT/qucs/qucsator/src/compat.h:33:18: error: 'index' was not declared in this scope # define strchr index +index is a deprecated posix function: https://stackoverflow.com/questions/4091864/c-differences-between-strchr-and-index +strchr is a standard c function. +solution commit: 87719aa0b7a2c185bdb531cae508836edfc66769 + +## windows: flex.exe: unknown flag '-'. +solution: 15c6aba89bc03e5c94f37bdc00cec813f68565b2 + +## windows: m4: cannot open `Files': No such file or directory +m4: cannot open `(x86)\GnuWin32/share/bison': No such file or directory +m4: cannot open `C:\Program': No such file or directory +m4: cannot open `Files': No such file or directory +m4: cannot open `(x86)\GnuWin32/share/bison/m4sugar/m4sugar.m4': No such file or directory +Problem during execution of bison.exe +https://stackoverflow.com/questions/16442556/m4-no-such-file-or-directory-bison + +## C:\Users\mmarmsoler\Documents\Personal\GIT\qucs\qucsator\src\eqnsys.cpp:55: Fehler: redefinition of 'qucs::eqnsys::eqnsys()' eqnsys::eqnsys () { +solution: 9046e62088c1060d354916fafdd988c3c99e29a2 + +## windows: By not providing "FindSED.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "SED", but + CMake did not find one. + + 1) http://gnuwin32.sourceforge.net/packages/sed.htm + 2) find_program(SED_TOOL NAMES sed) + +## windows: sed.exe: -e expression #1, char 1: unknown command: `'' +replace '' by "" + +## windows: add_custom_command( + OUTPUT gperfapphash.gph + COMMAND gperfappgen > ${CMAKE_CURRENT_BINARY_DIR}/gperfapphash.gph + DEPENDS gperfappgen + COMMENT "Gperfappgen gets executed" + VERBATIM +Solution: It gets not executed, because gperfapphash is not needed anywhere. +add_custom_command( + OUTPUT gperfapphash.cpp + COMMAND ${GPERF_TOOL} -I -m 8 ${CMAKE_CURRENT_BINARY_DIR}/gperfapphash.gph > + temp.gperf + COMMAND ${SED_TOOL} -e "s/{''},/{'',0},/g" < temp.gperf > + ${CMAKE_CURRENT_BINARY_DIR}/gperfapphash.cpp + DEPENDS gperfapphash.gph) +Seeing here, gperfapphash.gph is only needed if gperfapphash.cpp is needed. +So gperfapphash.cpp must be added as source to the libqucsator library. Then it is needed and so also the Command gets executed. +Solution commit: d4e6b0d0d8bf5eda6ebdf689407b5af09910c87f + +## /usr/bin/ld: CMakeFiles/libqucsator.dir/gperfappgen.cpp.o:(.data.rel.local+0x0): multiple definition of `qucs::eqn::applications'; CMakeFiles/libqucsator.dir/evaluate.cpp.o:(.data.rel+0x0): first defined here +/usr/bin/ld: CMakeFiles/libqucsator.dir/gperfappgen.cpp.o: in function `qucs::eqn::checker::tag2key(int)': +solution: some source files from the headers removed + +## [ 52%] Linking CXX shared library libqucsator.dll +CMakeFiles\libqucsator.dir/objects.a(acsolver.cpp.obj): In function `qucs::acsolver::acsolver()': +C:/Users/mmarmsoler/Documents/Personal/GIT/qucs/qucsator/src/acsolver.cpp:50: undefined reference to `qucs::nasolver >::nasolver()' + +## Header missing from a target included with add_subdirectory +Do not do: add_library(libqucsator SHARED $), because it adds only the source files. So the headers must also be included into libqucsator. +Better: add_library(libqucsator SHARED ) +target_link_libraries(libqucsator includedObject) + +## /usr/bin/ld: /usr/bin/ld: DWARF error: could not find variable specification at offset a43a components/CMakeFiles/coreComponents.dir/biastee.cpp.o: in function `biastee::calcTR(double)': +at commit: c75f49c12e9c6656134f28dad0b3207a4719e574 +removed coreMath, coreComponents and so on from the link libraries command for the qucsator and added the include paths to the headers +DO NOT add object targets to a target when they are already included into the shared library. Makes no sense + +## :-1: error: libqucsator.so: undefined reference to `qucs::nasolver::nasolver(qucs::nasolver&)' +During link of the libqucsator to the qucsator application +problem commit: 1c2e56d5ac05cdea1adbd2fdc5612af489f1e187 +The problem was that the source files of the template definitions are compiled by it self. But this is not correct. Do not compile template definitions. So they where included again (as it was before) into the header and not compiled. +solution commit: a0b92f912525602e495fdbd9176dbfc918ff58b7 + +## [fatal..] Template not found: vtype [fatal..] see: [/home/martin/GITProjekte/qucs/qucsator/src/components/verilog/qucsMODULEcore.xml:871] +order in components/verilog/Makelist.txt, VERILOG_XML, is important, because vtype needed by qucsMODULEcore.xml is defined in qucsVersion.xml + + + + + + diff --git a/cmake/dependencides.cmake b/cmake/dependencides.cmake new file mode 100644 index 00000000..e69de29b diff --git a/cmake/modules/AC_HEADER_STDC.cmake b/cmake/modules/AC_HEADER_STDC.cmake index cf4fff83..53305d8c 100644 --- a/cmake/modules/AC_HEADER_STDC.cmake +++ b/cmake/modules/AC_HEADER_STDC.cmake @@ -1,7 +1,6 @@ message(STATUS "Checking whether system has ANSI C header files") include(CheckPrototypeExists) -include(CheckPrototypeExists) check_include_files("dlfcn.h;stdint.h;stddef.h;inttypes.h;stdlib.h;strings.h;string.h;float.h" StandardHeadersExist) if(StandardHeadersExist) check_prototype_exists(memchr string.h memchrExists) @@ -30,7 +29,6 @@ endif(NOT STDC_HEADERS) check_include_files(unistd.h HAVE_UNISTD_H) - include(CheckDIRSymbolExists) check_dirsymbol_exists("sys/stat.h;sys/types.h;dirent.h" HAVE_DIRENT_H) if (HAVE_DIRENT_H) diff --git a/config.h.cmake b/config.h.cmake index 30f08d26..63fe37dd 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -18,6 +18,9 @@ #define _GNU_SOURCE 1 #endif +#ifndef CONFIG_H +#define CONFIG_H + /* Define if debug output should be supported. */ #cmakedefine DEBUG @@ -287,3 +290,7 @@ /* Git last commit short hash */ #cmakedefine GIT "@GIT@" +/* If verilog models should be used or not */ +#cmakedefine USE_VERILOG + +#endif /* CONFIG_H */ diff --git a/contrib/hicolor/128x128/apps/qucsator.png b/contrib/hicolor/128x128/apps/qucsator.png new file mode 100644 index 00000000..6c18bd4f Binary files /dev/null and b/contrib/hicolor/128x128/apps/qucsator.png differ diff --git a/contrib/hicolor/16x16/apps/qucsator.png b/contrib/hicolor/16x16/apps/qucsator.png new file mode 100644 index 00000000..158cdc42 Binary files /dev/null and b/contrib/hicolor/16x16/apps/qucsator.png differ diff --git a/contrib/hicolor/22x22/apps/qucsator.png b/contrib/hicolor/22x22/apps/qucsator.png new file mode 100644 index 00000000..2c86241e Binary files /dev/null and b/contrib/hicolor/22x22/apps/qucsator.png differ diff --git a/contrib/hicolor/256x256/apps/qucsator.png b/contrib/hicolor/256x256/apps/qucsator.png new file mode 100644 index 00000000..1c8d8ddb Binary files /dev/null and b/contrib/hicolor/256x256/apps/qucsator.png differ diff --git a/contrib/hicolor/32x32/apps/qucsator.png b/contrib/hicolor/32x32/apps/qucsator.png new file mode 100644 index 00000000..5d3a5f04 Binary files /dev/null and b/contrib/hicolor/32x32/apps/qucsator.png differ diff --git a/contrib/hicolor/48x48/apps/qucsator.png b/contrib/hicolor/48x48/apps/qucsator.png new file mode 100644 index 00000000..77429cde Binary files /dev/null and b/contrib/hicolor/48x48/apps/qucsator.png differ diff --git a/contrib/hicolor/512x512/apps/qucsator.png b/contrib/hicolor/512x512/apps/qucsator.png new file mode 100644 index 00000000..db8d3c32 Binary files /dev/null and b/contrib/hicolor/512x512/apps/qucsator.png differ diff --git a/contrib/hicolor/64x64/apps/qucsator.png b/contrib/hicolor/64x64/apps/qucsator.png new file mode 100644 index 00000000..efc81921 Binary files /dev/null and b/contrib/hicolor/64x64/apps/qucsator.png differ diff --git a/contrib/hicolor/scalable/apps/qucsator.svg b/contrib/hicolor/scalable/apps/qucsator.svg new file mode 100644 index 00000000..b4f56394 --- /dev/null +++ b/contrib/hicolor/scalable/apps/qucsator.svg @@ -0,0 +1,114 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/contrib/net.sourceforge.qucs.qucsator.desktop b/contrib/net.sourceforge.qucs.qucsator.desktop new file mode 100644 index 00000000..f0be0acf --- /dev/null +++ b/contrib/net.sourceforge.qucs.qucsator.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=Qucsator +Exec=qucsator %U +Icon=qucsator +Terminal=false + +Type=Application +Categories=Education;Electronics; +StartupNotify=false diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 72a3bb92..804fc26d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,493 +1,110 @@ -project(qucsator CXX C) -cmake_policy(VERSION 2.6) +project(qucsator_app CXX C) +cmake_minimum_required(VERSION 3.16) -# -# Checks for libraries. -# -# AC_CHECK_LIB(m, sin) need to check for sin? -if(NOT WIN32) - find_library(MATH_LIB NAMES m) - if(NOT MATH_LIB) - message(SEND_ERROR "Math lib not found: ${MATH_LIB}") - else() - message(STATUS "Math lib found at: ${MATH_LIB}") - endif() -endif() - -# -# Checks for header files. AC_HEADER_STDC !! obsolete, need to check? Define -# STDC_HEADERS if the system has ANSI C header files. Specifically, this macro -# checks for `stdlib.h', `stdarg.h', `string.h', and `float.h'; Lifted the cmake -# checks from gd-libdg, Lua https://bitbucket.org/libgd/gd-libgd -# https://github.com/LuaDist/libgd/tree/master/cmake/modules -include(CheckIncludeFiles) -set(CMAKE_REQUIRED_INCLUDES "/usr/include" "/usr/local/include") -set(CMAKE_MODULE_PATH "${qucs-core_SOURCE_DIR}/cmake/modules") -include(AC_HEADER_STDC) - -# -# Further header checks -# -include(CheckIncludeFile) - -# list of headers to be checked -set(INCLUDES ieeefp.h memory.h stddef.h stdlib.h string.h unistd.h) - -# -# Check if header can be included. * Define HAVE_[basename]_H to 1 if you have -# the header. -# -foreach(header ${INCLUDES}) - get_filename_component(base ${header} NAME_WE) - string(TOUPPER ${base} base) - check_include_file(${header} HAVE_${base}_H) - # MESSAGE(STATUS "${header} --> ${HAVE_${base}_H}") -endforeach() - -# Checks for typedefs, structures, and compiler characteristics. AC_C_CONST -# !!obsolete AC_C_CONST "This macro is obsolescent, as current C compilers -# support `const'. New programs need not use this macro." - -# -# Check for type sizes. -# -include(CheckTypeSize) -check_type_size("short" SIZEOF_SHORT) -check_type_size("int" SIZEOF_INT) -check_type_size("long" SIZEOF_LONG) -check_type_size("double" SIZEOF_DOUBLE) -check_type_size("long double" SIZEOF_LONG_DOUBLE) -# MESSAGE(STATUS "short ${SIZEOF_SHORT}" ) MESSAGE(STATUS "int ${SIZEOF_INT}" -# ) MESSAGE(STATUS "long ${SIZEOF_LONG}" ) MESSAGE(STATUS "double -# ${SIZEOF_DOUBLE}" ) MESSAGE(STATUS "long double ${SIZEOF_LONG_DOUBLE}" ) - -# -# Check for double type. * valid types are: double, float and long double. * -# defines: nr_double_t, The global type of double representation. * defines: -# NR_DOUBLE_SIZE, The size of the double representation. * Use -DENABLE- -# DOUBLE="[float,double, long double]" -if(ENABLE-DOUBLE) - # User defined - set(DoubleType ${ENABLE-DOUBLE}) - - # valid types - set(ValidTypes "float" "double" "long double") - - list(FIND ValidTypes ${DoubleType} HasType) - if(HasType EQUAL -1) - message(FATAL_ERROR "Valid types are: ${ValidTypes}") - endif() - - # The global type of double representation. - set(nr_double_t DoubleType) - check_type_size(${DoubleType} DoubleSize) +include(${PROJECT_SOURCE_DIR}/../../cmake/readMakeList.txt) - # The size of the double representation. - set(NR_DOUBLE_SIZE ${DoubleSize}) -else() - # Default double - set(DoubleType "double") - # The global type of double representation. - set(nr_double_t ${DoubleType}) - check_type_size(${DoubleType} DoubleSize) - - # The size of the double representation. - set(NR_DOUBLE_SIZE ${DoubleSize}) +# qucsator_SOURCE_DIR is set when the project qucsator exists. +# If this project is build by it self, this variable is not set +if (NOT qucsator_SOURCE_DIR) + set(qucsator_SOURCE_DIR ${PROJECT_SOURCE_DIR}/..) + set(qucsator_BINARY_DIR ${qucsator_app_BINARY_DIR}) endif() -message(STATUS "using double type: ${DoubleType}; size: ${DoubleSize}") -# defines used in qucs_typedefs.h -set(QUCS_INT32_TYPE ${nr_int32_t}) -set(QUCS_INT16_TYPE ${nr_int16_t}) -set(QUCS_DOUBLE_TYPE ${DoubleType}) -set(QUCS_DOUBLE_SIZE ${DoubleSize}) -# -# Configure the header qucs_typedefs.h, interpolate above definitions. -# -configure_file("${qucs-core_SOURCE_DIR}/qucs_typedefs.h.cmake" - "${qucs-core_BINARY_DIR}/qucs_typedefs.h") +OPTION(ENABLE_CHECKS "enable checks of functions, default: OFF" OFF) -# -# Check for library functions * not all functons seem to be used after defined. -# TODO check for HAVE_{func} -# -include(CheckFunctionExists) -set(REQUIRED_FUNCTIONS - floor - pow - exp - sqrt - log10 - log - cos - sin - acos - asin # for real.cpp - tan - atan - sinh - cosh - tanh - fabs - modf - atan2 - jn - yn - erf - erfc # for fspecial.cpp - round - trunc - acosh - asinh # for real.cpp - strdup - strerror - strchr) # for compat.h, matvec.cpp, scan_*.cpp +#TODO: do that only if they are not set previously +# Define to the address where bug reports for this package should be sent. +set(PACKAGE_BUGREPORT "qucs-bugs@lists.sourceforge.net") -foreach(func ${REQUIRED_FUNCTIONS}) - string(TOUPPER ${func} FNAME) - check_function_exists(${func} HAVE_${FNAME}) - # message(STATUS "${func} --> ${HAVE_${FNAME}}") -endforeach() +# Define to the full name of this package. +set(PACKAGE_NAME "qucsator") -# -# Checks for complex classes and functions, as in the Autotools scripts. -# -# AC_CXX_NAMESPACES !!custom m4 AC_CXX_HAVE_COMPLEX !!custom m4 -# AC_CXX_HAVE_TR1_COMPLEX !!custom m4 AC_CHECK_CXX_COMPLEX_FUNCS([cos cosh exp -# log log10 sin sinh sqrt tan tanh]) !!custom m4 -# AC_CHECK_CXX_COMPLEX_FUNCS([acos acosh asin asinh atan atanh]) -# AC_CHECK_CXX_COMPLEX_FUNCS([log2 norm]) AC_CHECK_CXX_COMPLEX_POW -# AC_CHECK_CXX_COMPLEX_ATAN2 !failed, need libstdc? -# AC_CHECK_CXX_COMPLEX_FMOD !failed: AC_CHECK_CXX_COMPLEX_POLAR -# AC_CHECK_CXX_COMPLEX_POLAR_COMPLEX !failed +# Define to the full name and version of this package. +set(PACKAGE_STRING "${PACKAGE_NAME} ${PROJECT_VERSION}") -# -# Namespace -# -# Check whether the compiler implements namespaces -# -try_compile( - HAVE_NAMESPACES ${CMAKE_BINARY_DIR} - ${qucs-core_SOURCE_DIR}/cmake/namespaces.cpp OUTPUT_VARIABLE TRY_OUT) -if(NOT HAVE_NAMESPACES) - message( - SEND_ERROR - "${PROJECT_NAME} requires an c++ compiler with namespace HAVE_NAMESPACES failed" - ) # ${TRY_OUT}") -endif() +# Define to the one symbol short name of this package. +set(PACKAGE_TARNAME ${PACKAGE_NAME}) -# -# Check whether the compiler has complex -# -try_compile(HAVE_COMPLEX ${CMAKE_BINARY_DIR} - ${qucs-core_SOURCE_DIR}/cmake/complex.cpp OUTPUT_VARIABLE TRY_OUT) -if(NOT HAVE_COMPLEX) - message(SEND_ERROR "HAVE_COMPLEX failed") # ${TRY_OUT}") -endif() +# Define to the home page for this package. +set(PACKAGE_URL "http://sourceforge.net/projects/qucs/") -# -# Check std::vector::erase iterator type [const_iterator | iterator] -# -message(STATUS "Checking HAVE_ERASE_CONSTANT_ITERATOR") -try_compile( - HAVE_ERASE_CONSTANT_ITERATOR ${CMAKE_BINARY_DIR} - ${qucs-core_SOURCE_DIR}/cmake/erase_iterator_type.cpp OUTPUT_VARIABLE TRY_OUT) -if(HAVE_ERASE_CONSTANT_ITERATOR) - message(STATUS "Using std::vector:erase iterator type : const_iterator") +#Check dependencies: bison, flex, sed, gperf ... +include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependencies.cmake) +if (ADMSXML) # set in dependencies.cmake + set(USE_VERILOG true) else() - message(STATUS "Using std::vector:erase iterator type : iterator") + set(USE_VERILOG false) endif() +# Check for type sizes +include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/checkTypeSize.cmake) +## +# Configure the header qucs_typedefs.h, interpolate definitions in checkTypeSize # -# Check for list of complex functions. -# -set(COMPLEX_FUNCS_GRP1 - acos - acosh - asin - asinh - atan - atanh - cos - cosh - exp - log - log10 - sin - sinh - sqrt - tan - tanh - log2 - norm) -set(COMPLEX_FUNCS_GRP2 pow atan2 fmod polar polar_complex) +configure_file("${qucsator_SOURCE_DIR}/qucs_typedefs.h.cmake" + "${qucsator_BINARY_DIR}/qucs_typedefs.h") -# -# test complex function group 1 code inlined to easily replace '${func}' -# -foreach(func ${COMPLEX_FUNCS_GRP1}) - set(code - " #include - using namespace std\; - #ifdef log2 - #undef log2 - #endif - - int main() { - complex a\; - ${func}(a)\; - return 0\; - }") - - file(WRITE ${qucs-core_SOURCE_DIR}/cmake/test_${func}.cpp ${code}) - - string(TOUPPER ${func} FNAME) - - message(STATUS "Checking HAVE_CXX_COMPLEX_${FNAME}") - - try_compile( - HAVE_CXX_COMPLEX_${FNAME} ${CMAKE_BINARY_DIR} - ${qucs-core_SOURCE_DIR}/cmake/test_${func}.cpp OUTPUT_VARIABLE TRY_OUT) - if(NOT HAVE_CXX_COMPLEX_${FNAME}) - message(STATUS "HAVE_CXX_COMPLEX_${FNAME} failed") # ${TRY_OUT}") - endif() - - file(REMOVE ${qucs-core_SOURCE_DIR}/cmake/test_${func}.cpp ${code}) -endforeach() - -# -# test complex function group 2 use prepared source file. -# -foreach(func ${COMPLEX_FUNCS_GRP2}) - string(TOUPPER ${func} FNAME) - - message(STATUS "Checking HAVE_CXX_COMPLEX_${FNAME}") - - try_compile( - HAVE_CXX_COMPLEX_${FNAME} ${CMAKE_BINARY_DIR} - ${qucs-core_SOURCE_DIR}/cmake/complex_${func}.cpp - COMPILE_DEFINITIONS -DHAVE_NAMESPACES -DHAVE_COMPLEX -DHAVE_TR1_COMPLEX - OUTPUT_VARIABLE TRY_OUT) - if(NOT HAVE_CXX_COMPLEX_${FNAME}) - message(STATUS "HAVE_CXX_COMPLEX_${FNAME} failed") # ${TRY_OUT}") - endif() -endforeach() +if (ENABLE_CHECKS) + # Do some checks + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/checks.cmake) +endif() # # Configure the header config.h, interpolate above definitions. # -configure_file("${qucs-core_SOURCE_DIR}/config.h.cmake" - "${qucs-core_BINARY_DIR}/config.h") - -# -# List of lexer/parsers type names -# -set(ParserTypes - csv - citi - dataset - mdl - netlist - touchstone - zvr) - -set(generated_SRC) -foreach(type ${ParserTypes}) - # Create custom Bison - set(bisonIn "${CMAKE_CURRENT_SOURCE_DIR}/parse_${type}.ypp") - set(bisonOut "parse_${type}.hpp" - "parse_${type}.cpp") - add_custom_command( - OUTPUT ${bisonOut} - COMMAND - ${BISON_EXECUTABLE} - --defines=parse_${type}.hpp - --output=parse_${type}.cpp - ${bisonIn} - DEPENDS ${bisonIn}) - # Create custom Flex - set(flexIn "${CMAKE_CURRENT_SOURCE_DIR}/scan_${type}.lpp") - set(flexOut "scan_${type}.cpp") - add_custom_command( - OUTPUT ${flexOut} - COMMAND ${FLEX_EXECUTABLE} --outfile=${flexOut} ${flexIn} - DEPENDS ${flexIn}) - - list(APPEND generated_SRC ${bisonOut}) - list(APPEND generated_SRC ${flexOut}) -endforeach() +configure_file("${qucsator_SOURCE_DIR}/config.h.cmake" + "${qucsator_BINARY_DIR}/config.h") +include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/generateLexerParserFiles.cmake) # # Source code libqucs # -set(LIBQUCS_SRC - ${generated_SRC} - analysis.cpp - check_zvr.cpp - interpolator.cpp - parasweep.cpp - property.cpp - range.cpp - spline.cpp - strlist.cpp - trsolver.cpp - acsolver.cpp - check_citi.cpp - check_csv.cpp - check_dataset.cpp - check_mdl.cpp - check_netlist.cpp - check_touchstone.cpp - circuit.cpp - dataset.cpp - dcsolver.cpp - devstates.cpp - differentiate.cpp - environment.cpp - equation.cpp # <= depends on gperfapphash.cpp - evaluate.cpp - exception.cpp - exceptionstack.cpp - fourier.cpp - hbsolver.cpp - history.cpp - input.cpp - integrator.cpp - logging.c - matvec.cpp - module.cpp - net.cpp - nodelist.cpp - nodeset.cpp - object.cpp - receiver.cpp - spsolver.cpp - sweep.cpp - transient.cpp - variable.cpp - vector.cpp) +# equation.cpp # <= depends on gperfapphash.cpp +#list(LENGTH ${generated_SRC} NUMBER_ELEMENTS) +#message("NUMBER_ELEMENTS: ${NUMBER_ELEMENTS}") +#if (${NUMBER_ELEMENTS} LESS_EQUAL "0") +# message(FATAL_ERROR "No files generated") +#endif( +readVariable(MakeList SRCS LIBQUCS_SRC) +list(APPEND LIBQUCS_SRC ${generated_SRC}) # # Template classes # -set(TEMPLATES - tmatrix.h - tvector.h - eqnsys.h - nasolver.h - states.h - tvector.h - ptrlist.h - tridiag.h - hash.h - valuelist.h - nasolution.h) +readVariable(MakeList TEMPLATE_HDRS TEMPLATES) # # Include headers to be installed # -set(PUBLIC_HEADERS - ${qucs-core_BINARY_DIR}/config.h - ${qucs-core_BINARY_DIR}/qucs_typedefs.h - circuit.h - compat.h - constants.h - consts.h - integrator.h - logging.h - net.h - netdefs.h - node.h - object.h - states.h - valuelist.h - vector.h - property.h - ptrlist.h - characteristic.h - pair.h - operatingpoint.h) - -include_directories( - ${qucs-core_SOURCE_DIR} # generated config.h - ${qucs-core_SOURCE_DIR}/src/math # precision.h - ${qucs-core_SOURCE_DIR}/src/ # compat.h - ${qucs-core_SOURCE_DIR}/src/components # microstrip/substrate.h - ${qucs-core_SOURCE_DIR}/src/interface - ${qucs-core_BINARY_DIR} # cmake generated config.h - ${qucs-core_BINARY_DIR}/src # cmake generated gperfapphash.h - ${qucs-core_BINARY_DIR}/src/components # generated verilog/[].core.h -) - -# -# Replace 'evaluate::[whatever]' by NULL -# -# * evaluate.h (class evaluate): New class implementing the actual evaluation -# function (applications) for the equations in Qucs. -# -add_custom_command( - OUTPUT gperfappgen.h - COMMAND - ${SED_TOOL} -e 's/evaluate::[a-zA-Z0-9_]*/NULL/g' < - ${CMAKE_CURRENT_SOURCE_DIR}/applications.h > - ${CMAKE_CURRENT_BINARY_DIR}/gperfappgen.h - DEPENDS ${applications.h}) - -# -# Compile gperfappgen * used to generate gperf input file (used in qucsator) -# -set(gperf_SRC gperfappgen.cpp gperfappgen.h) +readVariable(MakeList HDRS PUBLIC_HEADERS) +list(APPEND PUBLIC_HEADERS + ${qucsator_BINARY_DIR}/config.h + ${qucsator_BINARY_DIR}/qucs_typedefs.h) -add_executable(gperfappgen ${gperf_SRC}) +include(${qucsator_app_SOURCE_DIR}/cmake/generateGPerfAppHashCpp.cmake) -# -# Run gperfappgen, pipe to gperf input to gperfapphash.gph -# -add_custom_command( - OUTPUT gperfapphash.gph - COMMAND gperfappgen > ${CMAKE_CURRENT_BINARY_DIR}/gperfapphash.gph - DEPENDS ${gperfappgen}) - -# -# Run gperf, create hash table. * -I, Include the necessary system include files -# at the beginning of the code. * -m, Perform multiple iterations to minimize -# generated table. * Replace '{""}' by '{"",0}; (why?) -# -add_custom_command( - OUTPUT gperfapphash.cpp - COMMAND ${GPERF_TOOL} -I -m 8 ${CMAKE_CURRENT_BINARY_DIR}/gperfapphash.gph > - temp.gperf - COMMAND ${SED_TOOL} -e 's/{""},/{"",0},/g' < temp.gperf > - ${CMAKE_CURRENT_BINARY_DIR}/gperfapphash.cpp - DEPENDS gperfapphash.gph) + #target <- source (includea) equation.cpp: gperfapphash.cpp -# target <- source (includea) equation.cpp: gperfapphash.cpp -# -# noinst_PROGRAMS = gperfappgen gperfappgen_SOURCES = gperfappgen.cpp + #noinst_PROGRAMS = gperfappgen gperfappgen_SOURCES = gperfappgen.cpp # for cleaning (autogenerated) set(gperf_FILES gperfapphash.cpp gperfapphash.gph # gperfappgen.h) -# Qucs library dependencies -add_subdirectory(interface) +## Qucs library dependencies add_subdirectory(components) add_subdirectory(components/digital) add_subdirectory(components/devices) add_subdirectory(components/microstrip) -add_subdirectory(components/verilog) +if (USE_VERILOG) + add_subdirectory(interface) + add_subdirectory(components/verilog) +endif() add_subdirectory(math) # Qucsconv application add_subdirectory(converter) -# Linux? set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-all-symbols") - -# -# Create qucsator -# -add_executable(qucsator ucs.cpp ${PUBLIC_HEADERS} ${TEMPLATES}) - # # Build libqucs as SHARED, dynamic library # @@ -497,28 +114,49 @@ add_executable(qucsator ucs.cpp ${PUBLIC_HEADERS} ${TEMPLATES}) add_library( libqucsator SHARED ${LIBQUCS_SRC} - ${TEMPLATES} - $ - $ - $ - $ - $ - $ - $) + gperfapphash.cpp + + ) +target_link_libraries(libqucsator PUBLIC + coreMath + coreComponents + coreMicrostrip + coreDevices + coreDigital + ${CMAKE_DL_LIBS} # for dlerror(), dlopen() ... +) +if (USE_VERILOG) + target_link_libraries(libqucsator PUBLIC coreInterface coreVerilog) +endif() + +target_include_directories(libqucsator + PUBLIC ${PROJECT_SOURCE_DIR} + PRIVATE + ${qucsator_BINARY_DIR} # qucs_typedefs.h + ${qucsator_app_BINARY_DIR} # generated sources by bison and flex are located here + ) -# rename the library to let it be libqucsator (not liblibqucsator) +# rename the library to let it be libqucsator (not liblibqucsator). +# The target name must be unique and qucsator is already used for the application set_target_properties(libqucsator PROPERTIES OUTPUT_NAME qucsator) # # Create target to handle gperfapp dependency # -add_custom_target(equation DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gperfapphash.cpp - equation.cpp) +add_custom_target(equation DEPENDS ${qucsator_app_BINARY_DIR}/gperfapphash.cpp + ${PROJECT_SOURCE_DIR}/equation.cpp) add_dependencies(libqucsator equation) # -# Link qucsator and libqucsator +# Create qucsator application # +add_executable(qucsator ucs.cpp) +target_include_directories(qucsator + PRIVATE + ${qucsator_SOURCE_DIR} + ${qucsator_BINARY_DIR} + ) +## DL libs needed for opening a shared library target_link_libraries(qucsator libqucsator ${CMAKE_DL_LIBS}) # @@ -534,4 +172,4 @@ install( ARCHIVE DESTINATION lib COMPONENT devel LIBRARY DESTINATION lib COMPONENT library) -install(FILES ${PUBLIC_HEADERS} DESTINATION include/qucs-core) +#install(FILES ${PUBLIC_HEADERS} DESTINATION include/qucsator) diff --git a/src/MakeList b/src/MakeList new file mode 100644 index 00000000..a4e77d2d --- /dev/null +++ b/src/MakeList @@ -0,0 +1,124 @@ +SRCS = \ + acsolver.cpp \ + analysis.cpp \ + check_citi.cpp \ + check_csv.cpp \ + check_dataset.cpp \ + check_mdl.cpp \ + check_netlist.cpp \ + check_touchstone.cpp \ + check_zvr.cpp \ + circuit.cpp \ + dataset.cpp \ + dcsolver.cpp \ + devstates.cpp \ + differentiate.cpp \ + environment.cpp \ + # eqnsys.cpp \ # do not include, because it is included in nasolver.h (Template implementation) + equation.cpp \ + evaluate.cpp \ + exception.cpp \ + exceptionstack.cpp \ + fourier.cpp \ + # gperfappgen.cpp \ # not intended to be compiled for libqucsator, but it is its own application + # hash.cpp \ # do not include, because it is included in nasolver.h (Template implementation) + hbsolver.cpp \ + history.cpp \ + input.cpp \ + integrator.cpp \ + interpolator.cpp \ + logging.c \ + matvec.cpp \ + module.cpp \ + # nasolver.cpp \ # do not include, because it is included in nasolver.h (Template implementation) + net.cpp \ + nodelist.cpp \ + nodeset.cpp \ + object.cpp \ + parasweep.cpp \ + property.cpp \ + range.cpp \ + receiver.cpp \ + spline.cpp \ + spsolver.cpp \ + # states.cpp \ # do not include, because it is included in nasolver.h (Template implementation) + strlist.cpp \ + sweep.cpp \ + # tmatrix.cpp \ # do not include, because it is included in nasolver.h (Template implementation) + transient.cpp \ + # tridiag.cpp \ # do not include, because it is included in nasolver.h (Template implementation) + trsolver.cpp \ + # tvector.cpp \ # do not include, because it is included in nasolver.h (Template implementation) + # ucs.cpp \ Not used in the lib, only in the application it self + variable.cpp \ + vector.cpp + +HDRS = \ + acsolver.h \ + analyses.h \ + analysis.h \ + applications.h \ + characteristic.h \ + check_citi.h \ + check_csv.h \ + check_dataset.h \ + check_mdl.h \ + check_netlist.h \ + check_touchstone.h \ + check_zvr.h \ + circuit.h \ + compat.h \ + constants.h \ + consts.h \ + dataset.h \ + dcsolver.h \ + devstates.h \ + differentiate.h \ + environment.h \ + equation.h \ + evaluate.h \ + exception.h \ + exceptionstack.h \ + fourier.h \ + hbsolver.h \ + history.h \ + input.h \ + integrator.h \ + interpolator.h \ + libqucsator.h \ + logging.h \ + matvec.h \ + module.h \ + net.h \ + netdefs.h \ + node.h \ + nodelist.h \ + nodeset.h \ + object.h \ + operatingpoint.h \ + pair.h \ + parasweep.h \ + poly.h \ + property.h \ + range.h \ + receiver.h \ + spline.h \ + spsolver.h \ + strlist.h \ + sweep.h \ + transient.h \ + trsolver.h \ + variable.h \ + vector.h + +TEMPLATE_HDRS = \ + eqnsys.h \ + hash.h \ + nasolution.h \ + nasolver.h \ + ptrlist.h \ + states.h \ + tmatrix.h \ + tridiag.h \ + tvector.h + valuelist.h \ diff --git a/src/acsolver.cpp b/src/acsolver.cpp index e3795c3d..023216da 100644 --- a/src/acsolver.cpp +++ b/src/acsolver.cpp @@ -27,10 +27,11 @@ #endif #include +#include #include #include "object.h" -#include "complex.h" +#include "math/complex.h" #include "circuit.h" #include "sweep.h" #include "net.h" @@ -38,6 +39,10 @@ #include "analysis.h" #include "nasolver.h" #include "acsolver.h" +#include "dataset.h" +#include "vector.h" +#include "node.h" +#include "logging.h" namespace qucs { diff --git a/src/acsolver.h b/src/acsolver.h index 2f5b577c..ce3af10f 100644 --- a/src/acsolver.h +++ b/src/acsolver.h @@ -26,6 +26,7 @@ #define __ACSOLVER_H__ #include "nasolver.h" +#include "complex.h" namespace qucs { diff --git a/src/analyses.h b/src/analyses.h index b8a519ff..4c0948cc 100644 --- a/src/analyses.h +++ b/src/analyses.h @@ -21,14 +21,14 @@ * $Id: analyses.h 1868 2013-03-06 12:47:36Z crobarcro $ * */ - -/*! \file analyses.h - * \brief global analysis header file - * - * Contains includes of all the analysis types available in - * Qucs. - * - */ + +/*! \file analyses.h + * \brief global analysis header file + * + * Contains includes of all the analysis types available in + * Qucs. + * + */ #ifndef __ANALYSES_H__ #define __ANALYSES_H__ @@ -40,6 +40,8 @@ #include "acsolver.h" #include "trsolver.h" #include "hbsolver.h" -#include "e_trsolver.h" +#ifdef USE_VERILOG +#include "interface/e_trsolver.h" +#endif #endif /* __ANALYSES_H__ */ diff --git a/src/analysis.h b/src/analysis.h index 1d0398ac..344327f3 100644 --- a/src/analysis.h +++ b/src/analysis.h @@ -33,6 +33,7 @@ #include "object.h" #include "ptrlist.h" +#include "complex.h" #define SAVE_OPS 1 // save operating points #define SAVE_ALL 2 // also save subcircuit nodes and operating points diff --git a/src/applications.h b/src/applications.h index 0b1f0f6f..e14c520e 100644 --- a/src/applications.h +++ b/src/applications.h @@ -26,8 +26,13 @@ #ifndef __APPLICATIONS_H__ #define __APPLICATIONS_H__ +#include "equation.h" +#include "evaluate.h" + // Array containing all kinds of applications. -struct application_t qucs::eqn::applications[] = { +namespace qucs { +namespace eqn { +struct application_t applications[] = { { "+", TAG_DOUBLE, evaluate::plus_d, 1, { TAG_DOUBLE } }, { "+", TAG_COMPLEX, evaluate::plus_c, 1, { TAG_COMPLEX } }, { "+", TAG_VECTOR, evaluate::plus_v, 1, { TAG_VECTOR } }, @@ -412,7 +417,7 @@ struct application_t qucs::eqn::applications[] = { { "diff", TAG_VECTOR, evaluate::diff_v_2, 2, { TAG_VECTOR, TAG_VECTOR } }, { "diff", TAG_VECTOR, evaluate::diff_v_3, 3, { TAG_VECTOR, TAG_VECTOR, - TAG_DOUBLE } }, + TAG_DOUBLE } }, { "max", TAG_DOUBLE, evaluate::max_d, 1, { TAG_DOUBLE } }, { "max", TAG_DOUBLE, evaluate::max_c, 1, { TAG_COMPLEX } }, @@ -467,48 +472,48 @@ struct application_t qucs::eqn::applications[] = { { "stos", TAG_MATRIX, evaluate::stos_m_d, 2, { TAG_MATRIX, TAG_DOUBLE } }, { "stos", TAG_MATRIX, evaluate::stos_m_d_d, 3, { TAG_MATRIX, TAG_DOUBLE, - TAG_DOUBLE } }, + TAG_DOUBLE } }, { "stos", TAG_MATRIX, evaluate::stos_m_d_c, 3, { TAG_MATRIX, TAG_DOUBLE, - TAG_COMPLEX } }, + TAG_COMPLEX } }, { "stos", TAG_MATRIX, evaluate::stos_m_d_v, 3, { TAG_MATRIX, TAG_DOUBLE, - TAG_VECTOR } }, + TAG_VECTOR } }, { "stos", TAG_MATRIX, evaluate::stos_m_c, 2, { TAG_MATRIX, TAG_COMPLEX } }, { "stos", TAG_MATRIX, evaluate::stos_m_c_d, 3, { TAG_MATRIX, TAG_COMPLEX, - TAG_DOUBLE } }, + TAG_DOUBLE } }, { "stos", TAG_MATRIX, evaluate::stos_m_c_c, 3, { TAG_MATRIX, TAG_COMPLEX, - TAG_COMPLEX } }, + TAG_COMPLEX } }, { "stos", TAG_MATRIX, evaluate::stos_m_c_v, 3, { TAG_MATRIX, TAG_COMPLEX, - TAG_VECTOR } }, + TAG_VECTOR } }, { "stos", TAG_MATRIX, evaluate::stos_m_v, 2, { TAG_MATRIX, TAG_VECTOR } }, { "stos", TAG_MATRIX, evaluate::stos_m_v_d, 3, { TAG_MATRIX, TAG_VECTOR, - TAG_DOUBLE } }, + TAG_DOUBLE } }, { "stos", TAG_MATRIX, evaluate::stos_m_v_c, 3, { TAG_MATRIX, TAG_VECTOR, - TAG_COMPLEX } }, + TAG_COMPLEX } }, { "stos", TAG_MATRIX, evaluate::stos_m_v_v, 3, { TAG_MATRIX, TAG_VECTOR, - TAG_VECTOR } }, + TAG_VECTOR } }, { "stos", TAG_MATVEC, evaluate::stos_mv_d, 2, { TAG_MATVEC, TAG_DOUBLE } }, { "stos", TAG_MATVEC, evaluate::stos_mv_d_d, 3, { TAG_MATVEC, TAG_DOUBLE, - TAG_DOUBLE } }, + TAG_DOUBLE } }, { "stos", TAG_MATVEC, evaluate::stos_mv_d_c, 3, { TAG_MATVEC, TAG_DOUBLE, - TAG_COMPLEX } }, + TAG_COMPLEX } }, { "stos", TAG_MATVEC, evaluate::stos_mv_d_v, 3, { TAG_MATVEC, TAG_DOUBLE, - TAG_VECTOR } }, + TAG_VECTOR } }, { "stos", TAG_MATVEC, evaluate::stos_mv_c, 2, { TAG_MATVEC, - TAG_COMPLEX } }, + TAG_COMPLEX } }, { "stos", TAG_MATVEC, evaluate::stos_mv_c_d, 3, { TAG_MATVEC, TAG_COMPLEX, - TAG_DOUBLE } }, + TAG_DOUBLE } }, { "stos", TAG_MATVEC, evaluate::stos_mv_c_c, 3, { TAG_MATVEC, TAG_COMPLEX, - TAG_COMPLEX } }, + TAG_COMPLEX } }, { "stos", TAG_MATVEC, evaluate::stos_mv_c_v, 3, { TAG_MATVEC, TAG_COMPLEX, - TAG_VECTOR } }, + TAG_VECTOR } }, { "stos", TAG_MATVEC, evaluate::stos_mv_v, 2, { TAG_MATVEC, TAG_VECTOR } }, { "stos", TAG_MATVEC, evaluate::stos_mv_v_d, 3, { TAG_MATVEC, TAG_VECTOR, - TAG_DOUBLE } }, + TAG_DOUBLE } }, { "stos", TAG_MATVEC, evaluate::stos_mv_v_c, 3, { TAG_MATVEC, TAG_VECTOR, - TAG_COMPLEX } }, + TAG_COMPLEX } }, { "stos", TAG_MATVEC, evaluate::stos_mv_v_v, 3, { TAG_MATVEC, TAG_VECTOR, - TAG_VECTOR } }, + TAG_VECTOR } }, { "stoy", TAG_MATRIX, evaluate::stoy_m, 1, { TAG_MATRIX } }, { "stoy", TAG_MATRIX, evaluate::stoy_m_d, 2, { TAG_MATRIX, TAG_DOUBLE } }, @@ -1089,5 +1094,8 @@ const char * checker::tag2key (int tag) { } return key; } +} /* namespace eqn */ +} /* namespace qucs */ + #endif /* __APPLICATIONS_H__ */ diff --git a/src/check_mdl.h b/src/check_mdl.h index 4cbe2464..67807bf0 100644 --- a/src/check_mdl.h +++ b/src/check_mdl.h @@ -25,6 +25,8 @@ #ifndef __CHECK_MDL_H__ #define __CHECK_MDL_H__ +#include "config.h" + namespace qucs { class dataset; } diff --git a/src/check_netlist.h b/src/check_netlist.h index ad3cb24f..4096579f 100644 --- a/src/check_netlist.h +++ b/src/check_netlist.h @@ -26,6 +26,7 @@ #define __CHECK_NETLIST_H__ #include "netdefs.h" +#include "config.h" /* Forward declarations. */ namespace qucs { diff --git a/src/check_zvr.h b/src/check_zvr.h index 86b4fddc..2d9f30b7 100644 --- a/src/check_zvr.h +++ b/src/check_zvr.h @@ -25,6 +25,8 @@ #ifndef __CHECK_ZVR_H__ #define __CHECK_ZVR_H__ +#include "config.h" + // forward declarations namespace qucs { class dataset; diff --git a/src/circuit.cpp b/src/circuit.cpp index 0c459e90..4ed9c3bd 100644 --- a/src/circuit.cpp +++ b/src/circuit.cpp @@ -41,10 +41,10 @@ #include "tvector.h" #include "history.h" #include "circuit.h" -#include "microstrip/substrate.h" +#include "components/microstrip/substrate.h" #include "operatingpoint.h" #include "characteristic.h" -#include "component_id.h" +#include "components/component_id.h" namespace qucs { diff --git a/src/cmake/checkTypeSize.cmake b/src/cmake/checkTypeSize.cmake new file mode 100644 index 00000000..0cb8655f --- /dev/null +++ b/src/cmake/checkTypeSize.cmake @@ -0,0 +1,53 @@ +# +# Check for type sizes. +# +include(CheckTypeSize) +check_type_size("short" SIZEOF_SHORT) +check_type_size("int" SIZEOF_INT) +check_type_size("long" SIZEOF_LONG) +check_type_size("double" SIZEOF_DOUBLE) +check_type_size("long double" SIZEOF_LONG_DOUBLE) +# MESSAGE(STATUS "short ${SIZEOF_SHORT}" ) MESSAGE(STATUS "int ${SIZEOF_INT}" +# ) MESSAGE(STATUS "long ${SIZEOF_LONG}" ) MESSAGE(STATUS "double +# ${SIZEOF_DOUBLE}" ) MESSAGE(STATUS "long double ${SIZEOF_LONG_DOUBLE}" ) + +# +# Check for double type. * valid types are: double, float and long double. * +# defines: nr_double_t, The global type of double representation. * defines: +# NR_DOUBLE_SIZE, The size of the double representation. * Use -DENABLE- +# DOUBLE="[float,double, long double]" +if(ENABLE-DOUBLE) + # User defined + set(DoubleType ${ENABLE-DOUBLE}) + + # valid types + set(ValidTypes "float" "double" "long double") + + list(FIND ValidTypes ${DoubleType} HasType) + if(HasType EQUAL -1) + message(FATAL_ERROR "Valid types are: ${ValidTypes}") + endif() + + # The global type of double representation. + set(nr_double_t DoubleType) + check_type_size(${DoubleType} DoubleSize) + + # The size of the double representation. + set(NR_DOUBLE_SIZE ${DoubleSize}) +else() + # Default double + set(DoubleType "double") + # The global type of double representation. + set(nr_double_t ${DoubleType}) + check_type_size(${DoubleType} DoubleSize) + + # The size of the double representation. + set(NR_DOUBLE_SIZE ${DoubleSize}) +endif() +message(STATUS "using double type: ${DoubleType}; size: ${DoubleSize}") + +# defines used in qucs_typedefs.h +set(QUCS_INT32_TYPE ${nr_int32_t}) +set(QUCS_INT16_TYPE ${nr_int16_t}) +set(QUCS_DOUBLE_TYPE ${DoubleType}) +set(QUCS_DOUBLE_SIZE ${DoubleSize}) diff --git a/src/cmake/checks.cmake b/src/cmake/checks.cmake new file mode 100644 index 00000000..2aebe9f5 --- /dev/null +++ b/src/cmake/checks.cmake @@ -0,0 +1,212 @@ +# +# Checks for libraries. +# +# AC_CHECK_LIB(m, sin) need to check for sin? +if(NOT WIN32) + find_library(MATH_LIB NAMES m) + if(NOT MATH_LIB) + message(SEND_ERROR "Math lib not found: ${MATH_LIB}") +else() + message(STATUS "Math lib found at: ${MATH_LIB}") +endif() +endif() + +# +# Checks for header files. AC_HEADER_STDC !! obsolete, need to check? Define +# STDC_HEADERS if the system has ANSI C header files. Specifically, this macro +# checks for `stdlib.h', `stdarg.h', `string.h', and `float.h'; Lifted the cmake +# checks from gd-libdg, Lua https://bitbucket.org/libgd/gd-libgd +# https://github.com/LuaDist/libgd/tree/master/cmake/modules +include(CheckIncludeFiles) +set(CMAKE_REQUIRED_INCLUDES "/usr/include" "/usr/local/include") +set(CMAKE_MODULE_PATH "${qucsator_SOURCE_DIR}/cmake/modules") +include(AC_HEADER_STDC) + +# +# Further header checks +# +include(CheckIncludeFile) + +# list of headers to be checked +set(INCLUDES ieeefp.h memory.h stddef.h stdlib.h string.h unistd.h) + +# +# Check if header can be included. * Define HAVE_[basename]_H to 1 if you have +# the header. +# +foreach(header ${INCLUDES}) + get_filename_component(base ${header} NAME_WE) + string(TOUPPER ${base} base) + check_include_file(${header} HAVE_${base}_H) + # MESSAGE(STATUS "${header} --> ${HAVE_${base}_H}") +endforeach() + +# Checks for typedefs, structures, and compiler characteristics. AC_C_CONST +# !!obsolete AC_C_CONST "This macro is obsolescent, as current C compilers +# support `const'. New programs need not use this macro." + +# +# Check for library functions * not all functons seem to be used after defined. +# TODO check for HAVE_{func} +# +include(CheckFunctionExists) +set(REQUIRED_FUNCTIONS + floor + pow + exp + sqrt + log10 + log + cos + sin + acos + asin # for real.cpp + tan + atan + sinh + cosh + tanh + fabs + modf + atan2 + jn + yn + erf + erfc # for fspecial.cpp + round + trunc + acosh + asinh # for real.cpp + strdup + strerror + strchr) # for compat.h, matvec.cpp, scan_*.cpp + +foreach(func ${REQUIRED_FUNCTIONS}) + string(TOUPPER ${func} FNAME) + check_function_exists(${func} HAVE_${FNAME}) + # message(STATUS "${func} --> ${HAVE_${FNAME}}") +endforeach() + +# +# Checks for complex classes and functions, as in the Autotools scripts. +# +# AC_CXX_NAMESPACES !!custom m4 AC_CXX_HAVE_COMPLEX !!custom m4 +# AC_CXX_HAVE_TR1_COMPLEX !!custom m4 AC_CHECK_CXX_COMPLEX_FUNCS([cos cosh exp +# log log10 sin sinh sqrt tan tanh]) !!custom m4 +# AC_CHECK_CXX_COMPLEX_FUNCS([acos acosh asin asinh atan atanh]) +# AC_CHECK_CXX_COMPLEX_FUNCS([log2 norm]) AC_CHECK_CXX_COMPLEX_POW +# AC_CHECK_CXX_COMPLEX_ATAN2 !failed, need libstdc? +# AC_CHECK_CXX_COMPLEX_FMOD !failed: AC_CHECK_CXX_COMPLEX_POLAR +# AC_CHECK_CXX_COMPLEX_POLAR_COMPLEX !failed + +# +# Namespace +# +# Check whether the compiler implements namespaces +# +try_compile( + HAVE_NAMESPACES ${CMAKE_BINARY_DIR} + ${qucsator_SOURCE_DIR}/cmake/namespaces.cpp OUTPUT_VARIABLE TRY_OUT) +if(NOT HAVE_NAMESPACES) + message( + SEND_ERROR + "${PROJECT_NAME} requires an c++ compiler with namespace HAVE_NAMESPACES failed" + ) # ${TRY_OUT}") +endif() + +# +# Check whether the compiler has complex +# +try_compile(HAVE_COMPLEX ${CMAKE_BINARY_DIR} + ${qucsator_SOURCE_DIR}/cmake/complex.cpp OUTPUT_VARIABLE TRY_OUT) +if(NOT HAVE_COMPLEX) + message(SEND_ERROR "HAVE_COMPLEX failed") # ${TRY_OUT}") +endif() + +# +# Check std::vector::erase iterator type [const_iterator | iterator] +# +message(STATUS "Checking HAVE_ERASE_CONSTANT_ITERATOR") +try_compile( + HAVE_ERASE_CONSTANT_ITERATOR ${CMAKE_BINARY_DIR} + ${qucsator_SOURCE_DIR}/cmake/erase_iterator_type.cpp OUTPUT_VARIABLE TRY_OUT) +if(HAVE_ERASE_CONSTANT_ITERATOR) + message(STATUS "Using std::vector:erase iterator type : const_iterator") +else() + message(STATUS "Using std::vector:erase iterator type : iterator") +endif() + +# +# Check for list of complex functions. +# +set(COMPLEX_FUNCS_GRP1 + acos + acosh + asin + asinh + atan + atanh + cos + cosh + exp + log + log10 + sin + sinh + sqrt + tan + tanh + log2 + norm) +set(COMPLEX_FUNCS_GRP2 pow atan2 fmod polar polar_complex) + +# +# test complex function group 1 code inlined to easily replace '${func}' +# +foreach(func ${COMPLEX_FUNCS_GRP1}) + set(code + " #include + using namespace std\; + #ifdef log2 + #undef log2 + #endif + + int main() { + complex a\; + ${func}(a)\; + return 0\; + }") + +file(WRITE ${qucsator_SOURCE_DIR}/cmake/test_${func}.cpp ${code}) + + string(TOUPPER ${func} FNAME) + + message(STATUS "Checking HAVE_CXX_COMPLEX_${FNAME}") + + try_compile( + HAVE_CXX_COMPLEX_${FNAME} ${CMAKE_BINARY_DIR} + ${qucsator_SOURCE_DIR}/cmake/test_${func}.cpp OUTPUT_VARIABLE TRY_OUT) +if(NOT HAVE_CXX_COMPLEX_${FNAME}) + message(STATUS "HAVE_CXX_COMPLEX_${FNAME} failed") # ${TRY_OUT}") +endif() + + file(REMOVE ${qucsator_SOURCE_DIR}/cmake/test_${func}.cpp ${code}) +endforeach() + +# +# test complex function group 2 use prepared source file. +# +foreach(func ${COMPLEX_FUNCS_GRP2}) + string(TOUPPER ${func} FNAME) + + message(STATUS "Checking HAVE_CXX_COMPLEX_${FNAME}") + + try_compile( + HAVE_CXX_COMPLEX_${FNAME} ${CMAKE_BINARY_DIR} + ${qucsator_SOURCE_DIR}/cmake/complex_${func}.cpp + COMPILE_DEFINITIONS -DHAVE_NAMESPACES -DHAVE_COMPLEX -DHAVE_TR1_COMPLEX + OUTPUT_VARIABLE TRY_OUT) +if(NOT HAVE_CXX_COMPLEX_${FNAME}) + message(STATUS "HAVE_CXX_COMPLEX_${FNAME} failed") # ${TRY_OUT}") +endif() +endforeach() diff --git a/src/cmake/dependencies.cmake b/src/cmake/dependencies.cmake new file mode 100644 index 00000000..98924c48 --- /dev/null +++ b/src/cmake/dependencies.cmake @@ -0,0 +1,54 @@ +# In this file all dependencies of libqucsator are listed. This file gets exectued from the libqucsator CMakeLists.txt + +find_program(SED_TOOL NAMES sed REQUIRED) +message(STATUS "Found sed: " ${SED_TOOL}) + +find_program(GPERF_TOOL NAMES gperf REQUIRED) +message(STATUS "Found gperf: " ${GPERF_TOOL}) + +# +# Need Flex +# +find_package(FLEX 2.5.4 REQUIRED) + +# ~~~ +# Need Bison +# +# This is a HACK to get arround a PATH issue with Qt Creator on OSX. +# It seams impossible to pass a custom PATH to Qt Creator on OSX, ie, cannot prepend `/usr/local/bin/` for intance. +# The FIND_PACKAGE fails. For now we provide a fallback with a custom FIND_PROGRAM. +# The variable BISON_DIR is also available. +# ~~~ +if(WIN32 OR (UNIX AND NOT APPLE)) + find_package(BISON 2.4 REQUIRED) +elseif(APPLE) # OSX. TODO: check if still relevant + # use -DBISON_DIR=/path/ to provide the path to bison + find_program( + BISON_EXECUTABLE bison + PATHS /usr/local/bin/ /opt/local/bin/ /usr/bin ${BISON_DIR} + DOC "bison path" + NO_DEFAULT_PATH) + if(BISON_EXECUTABLE) + message(STATUS "Found bison: " ${BISON_EXECUTABLE}) + else() + message( + FATAL_ERROR "Unable to find bison. Try to provide -DBISON_DIR=[path]") + endif() +endif() + +# +# Check if admsXml is available +# +# * Use -DADMSXML_DIR=[path] to give the path containing admsXml +# * Try a few other locations +# +# Needed by src/components/verlog +# https://stackoverflow.com/questions/36102809/qucs-core-configure-error-needs-admsxml +# TODO: download if not already installed +find_program( + ADMSXML admsXml + HINTS ${ADMSXML_DIR} + PATHS /usr/local/bin/ /opt/local/bin/ /usr/bin + REQUIRED + DOC "admsXml application") +message(STATUS "Found admsXml: " ${ADMSXML}) diff --git a/src/cmake/generateGPerfAppHashCpp.cmake b/src/cmake/generateGPerfAppHashCpp.cmake new file mode 100644 index 00000000..d2578616 --- /dev/null +++ b/src/cmake/generateGPerfAppHashCpp.cmake @@ -0,0 +1,65 @@ +# +# Replace 'evaluate::[whatever]' by NULL +# +# * evaluate.h (class evaluate): New class implementing the actual evaluation +# function (applications) for the equations in Qucs. +# +if (UNIX) + add_custom_command( + OUTPUT gperfappgen.h + COMMAND + ${SED_TOOL} -e 's/evaluate::[a-zA-Z0-9_]*/NULL/g' < + ${CMAKE_CURRENT_SOURCE_DIR}/applications.h > + ${CMAKE_CURRENT_BINARY_DIR}/gperfappgen.h + DEPENDS ${applications.h}) +else() +add_custom_command( + OUTPUT gperfappgen.h + COMMAND + ${SED_TOOL} -e "s/evaluate::[a-zA-Z0-9_]*/NULL/g" < + ${CMAKE_CURRENT_SOURCE_DIR}/applications.h > + ${CMAKE_CURRENT_BINARY_DIR}/gperfappgen.h + DEPENDS ${applications.h}) +endif() + +# +# Compile gperfappgen * used to generate gperf input file (used in qucsator) +# +set(gperf_SRC gperfappgen.cpp gperfappgen.h) +add_executable(gperfappgen ${gperf_SRC}) +target_include_directories(gperfappgen PRIVATE ${qucsator_BINARY_DIR} + ${qucsator_app_BINARY_DIR} + ${qucsator_app_SOURCE_DIR} + ${qucsator_app_SOURCE_DIR}/math + ) + +# +# Run gperfappgen, pipe to gperf input to gperfapphash.gph +# +add_custom_command( + OUTPUT gperfapphash.gph + COMMAND gperfappgen > ${CMAKE_CURRENT_BINARY_DIR}/gperfapphash.gph + DEPENDS gperfappgen + COMMENT "gperfappgen gets executed" + VERBATIM) + +# +# Run gperf, create hash table. * -I, Include the necessary system include files +# at the beginning of the code. * -m, Perform multiple iterations to minimize +# generated table. * Replace '{""}' by '{"",0}; (why?) +# +if (UNIX) + add_custom_command( + OUTPUT gperfapphash.cpp + COMMAND ${GPERF_TOOL} -I -m 8 ${CMAKE_CURRENT_BINARY_DIR}/gperfapphash.gph > + temp.gperf + COMMAND ${SED_TOOL} -e 's/{""},/{"",0},/g' < temp.gperf > ${CMAKE_CURRENT_BINARY_DIR}/gperfapphash.cpp + DEPENDS gperfapphash.gph) +else() +add_custom_command( + OUTPUT gperfapphash.cpp + COMMAND ${GPERF_TOOL} -I -m 8 ${CMAKE_CURRENT_BINARY_DIR}/gperfapphash.gph > + temp.gperf + COMMAND ${SED_TOOL} -e "s/{\"\"},/{\"\",0},/g" < temp.gperf > ${CMAKE_CURRENT_BINARY_DIR}/gperfapphash.cpp + DEPENDS gperfapphash.gph) +endif() diff --git a/src/cmake/generateLexerParserFiles.cmake b/src/cmake/generateLexerParserFiles.cmake new file mode 100644 index 00000000..b2f47d55 --- /dev/null +++ b/src/cmake/generateLexerParserFiles.cmake @@ -0,0 +1,39 @@ +# Generate Lexer and Parser files with Bison +# +# List of lexer/parsers type names +# +set(ParserTypes + csv + citi + dataset + mdl + netlist + touchstone + zvr) + +set(generated_SRC) +foreach(type ${ParserTypes}) + # Create custom Bison + set(bisonIn "${CMAKE_CURRENT_SOURCE_DIR}/parse_${type}.ypp") + set(bisonOut "parse_${type}.hpp" + "parse_${type}.cpp") + add_custom_command( + OUTPUT ${bisonOut} + COMMAND + ${BISON_EXECUTABLE} + --defines=parse_${type}.hpp + --output=parse_${type}.cpp + ${bisonIn} + DEPENDS ${bisonIn}) + # Create custom Flex + set(flexIn "${CMAKE_CURRENT_SOURCE_DIR}/scan_${type}.lpp") + set(flexOut "scan_${type}.cpp") + add_custom_command( + OUTPUT ${flexOut} + #COMMAND ${FLEX_EXECUTABLE} --outfile=${flexOut} ${flexIn} # not working on windows 10? + COMMAND ${FLEX_EXECUTABLE} -o"${flexOut}" ${flexIn} + DEPENDS ${flexIn}) + + list(APPEND generated_SRC ${bisonOut}) + list(APPEND generated_SRC ${flexOut}) +endforeach() diff --git a/src/compat.h b/src/compat.h index af56372b..2979cf19 100644 --- a/src/compat.h +++ b/src/compat.h @@ -29,10 +29,10 @@ # include #endif -#if !HAVE_STRCHR -# define strchr index -# define strrchr rindex -#endif +//#if !HAVE_STRCHR +//# define strchr index +//# define strrchr rindex +//#endif #if defined(_WIN32) & not defined(__MINGW32__) #define strcasecmp stricmp diff --git a/src/components/CMakeLists.txt b/src/components/CMakeLists.txt index a35e6955..8ba0632c 100644 --- a/src/components/CMakeLists.txt +++ b/src/components/CMakeLists.txt @@ -1,81 +1,17 @@ -include_directories(${qucs-core_SOURCE_DIR} ${qucs-core_CURRENT_SOURCE_DIR} - ${qucs-core_SOURCE_DIR}/src/math) +project(components) +cmake_minimum_required(VERSION 3.16) -set(COMPONENTS_SRC - amplifier.cpp - attenuator.cpp - biastee.cpp - capacitor.cpp - capq.cpp - cccs.cpp - ccvs.cpp - circline.cpp - circulator.cpp - coaxline.cpp - coupler.cpp - cross.cpp - ctline.cpp - dcblock.cpp - dcfeed.cpp - ecvs.cpp - taperedline.cpp - ground.cpp - gyrator.cpp - hybrid.cpp - iac.cpp - idc.cpp - iexp.cpp - ifile.cpp - iinoise.cpp - inductor.cpp - indq.cpp - inoise.cpp - iprobe.cpp - ipulse.cpp - irect.cpp - isolator.cpp - itrafo.cpp - ivnoise.cpp - mutual.cpp - mutual2.cpp - mutualx.cpp - opamp.cpp - open.cpp - pac.cpp - phaseshifter.cpp - rectline.cpp - relais.cpp - resistor.cpp - rfedd.cpp - rlcg.cpp - short.cpp - spfile.cpp - spembed.cpp - spdeembed.cpp - strafo.cpp - tee.cpp - tline.cpp - tline4p.cpp - trafo.cpp - tswitch.cpp - twistedpair.cpp - vac.cpp - vam.cpp - vccs.cpp - vcvs.cpp - vdc.cpp - vexp.cpp - vfile.cpp - vnoise.cpp - vpm.cpp - vprobe.cpp - vpulse.cpp - vrect.cpp - vvnoise.cpp - wprobe.cpp) +include(${PROJECT_SOURCE_DIR}/../../../cmake/readMakeList.txt) -set(HEADERS component.h component_id.h components.h) +readVariable(MakeList SRCS COMPONENTS_SRC) +readVariable(MakeList HDRS COMPONENTS_HDRS) add_library(coreComponents OBJECT ${COMPONENTS_SRC}) +target_include_directories(coreComponents + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} # This folder + PRIVATE ${qucsator_BINARY_DIR} # config.h and qucs_typedef.h + ${qucsator_app_SOURCE_DIR} + ${qucsator_app_SOURCE_DIR}/math + ) -install(FILES ${HEADERS} DESTINATION include/qucs-core) +install(FILES ${COMPONENTS_HDRS} DESTINATION include/qucsator) diff --git a/src/components/MakeList b/src/components/MakeList new file mode 100644 index 00000000..b29758fa --- /dev/null +++ b/src/components/MakeList @@ -0,0 +1,148 @@ +SRCS = \ + amplifier.cpp \ + attenuator.cpp \ + biastee.cpp \ + capacitor.cpp \ + capq.cpp \ + cccs.cpp \ + ccvs.cpp \ + circline.cpp \ + circulator.cpp \ + coaxline.cpp \ + coupler.cpp \ + cross.cpp \ + ctline.cpp \ + dcblock.cpp \ + dcfeed.cpp \ + ecvs.cpp \ + ground.cpp \ + gyrator.cpp \ + hybrid.cpp \ + iac.cpp \ + idc.cpp \ + iexp.cpp \ + ifile.cpp \ + iinoise.cpp \ + indq.cpp \ + inductor.cpp \ + inoise.cpp \ + iprobe.cpp \ + ipulse.cpp \ + irect.cpp \ + isolator.cpp \ + itrafo.cpp \ + ivnoise.cpp \ + mutual.cpp \ + mutual2.cpp \ + mutualx.cpp \ + opamp.cpp \ + open.cpp \ + pac.cpp \ + phaseshifter.cpp \ + rectline.cpp \ + relais.cpp \ + resistor.cpp \ + rfedd.cpp \ + rlcg.cpp \ + short.cpp \ + spdeembed.cpp \ + spembed.cpp \ + spfile.cpp \ + strafo.cpp \ + taperedline.cpp \ + tee.cpp \ + tline.cpp \ + tline4p.cpp \ + trafo.cpp \ + tswitch.cpp \ + twistedpair.cpp \ + vac.cpp \ + vam.cpp \ + vccs.cpp \ + vcvs.cpp \ + vdc.cpp \ + vexp.cpp \ + vfile.cpp \ + vnoise.cpp \ + vpm.cpp \ + vprobe.cpp \ + vpulse.cpp \ + vrect.cpp \ + vvnoise.cpp \ + wprobe.cpp + +HDRS = \ + amplifier.h \ + attenuator.h \ + biastee.h \ + capacitor.h \ + capq.h \ + cccs.h \ + ccvs.h \ + circline.h \ + circulator.h \ + coaxline.h \ + component.h \ + component_id.h \ + components.h \ + coupler.h \ + cross.h \ + ctline.h \ + dcblock.h \ + dcfeed.h \ + ecvs.h \ + ground.h \ + gyrator.h \ + hybrid.h \ + iac.h \ + idc.h \ + iexp.h \ + ifile.h \ + iinoise.h \ + indq.h \ + inductor.h \ + inoise.h \ + iprobe.h \ + ipulse.h \ + irect.h \ + isolator.h \ + itrafo.h \ + ivnoise.h \ + mutual.h \ + mutual2.h \ + mutualx.h \ + opamp.h \ + open.h \ + pac.h \ + phaseshifter.h \ + rectline.h \ + relais.h \ + resistor.h \ + rfedd.h \ + rlcg.h \ + short.h \ + spdeembed.h \ + spembed.h \ + spfile.h \ + strafo.h \ + taperedline.h \ + tee.h \ + tline.h \ + tline4p.h \ + trafo.h \ + tswitch.h \ + twistedpair.h \ + vac.h \ + vam.h \ + vccs.h \ + vcvs.h \ + vdc.h \ + vexp.h \ + vfile.h \ + vnoise.h \ + vpm.h \ + vprobe.h \ + vpulse.h \ + vrect.h \ + vvnoise.h \ + wprobe.h diff --git a/src/components/components.h b/src/components/components.h index 75617f88..ba0861fc 100644 --- a/src/components/components.h +++ b/src/components/components.h @@ -28,6 +28,8 @@ // BUG: include all component headers. // components should add to the kernel, not the other way around. +#include "config.h" + #include "complex.h" #include "object.h" #include "node.h" @@ -151,6 +153,8 @@ #include "digital/digisource.h" #include "digital/buffer.h" +#ifdef USE_VERILOG + #include "verilog/EKV26MOS.core.h" #include "verilog/log_amp.core.h" #include "verilog/MESFET.core.h" @@ -191,6 +195,8 @@ #include "verilog/hpribin4bit.core.h" #include "verilog/vcresistor.core.h" +#endif + #include "ecvs.h" #endif /* __COMPONENTS_H__ */ diff --git a/src/components/devices/CMakeLists.txt b/src/components/devices/CMakeLists.txt index 44ad4c99..f48fe112 100644 --- a/src/components/devices/CMakeLists.txt +++ b/src/components/devices/CMakeLists.txt @@ -1,22 +1,26 @@ -include_directories( - ${qucs-core_SOURCE_DIR} ${qucs-core_CURRENT_SOURCE_DIR} - ${qucs-core_SOURCE_DIR}/src/math ${qucs-core_SOURCE_DIR}/src/components -)# component.h +project(devices) +cmake_minimum_required(VERSION 3.16) -set(DEVICES_SRC - bjt.cpp - device.cpp - diac.cpp - diode.cpp - eqndefined.cpp - jfet.cpp - mosfet.cpp - thyristor.cpp - triac.cpp - tunneldiode.cpp) +include(${PROJECT_SOURCE_DIR}/../../../../cmake/readMakeList.txt) -add_library(coreDevices OBJECT ${DEVICES_SRC}) +#qucsator_SOURCE_DIR is defined as soon as a project named qucsator is created +if ((NOT qucsator_BINARY_DIR) OR (NOT qucsator_app_SOURCE_DIR) ) + message(FATAL_ERROR "This project cannot be used as standalone, because qucs_typedef is missing. Everything around the command + configure_file(\"${qucsator_SOURCE_DIR}/qucs_typedefs.h.cmake\" + \"${qucsator_BINARY_DIR}/qucs_typedefs.h\")\ + is needed to get it work. But this must be done in all subfiles and this makes no sense.") +endif() + +readVariable(MakeList SRCS DEVICES_SRC) +readVariable(MakeList HDRS DEVICES_HEADERS) -set(HEADERS device.h) +add_library(coreDevices OBJECT ${DEVICES_SRC}) +target_include_directories(coreDevices + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} # This folder + PRIVATE + ${qucsator_BINARY_DIR} + ${qucsator_app_SOURCE_DIR} + ${qucsator_app_SOURCE_DIR}/components + ${qucsator_app_SOURCE_DIR}/math) -install(FILES ${HEADERS} DESTINATION include/qucs-core) +install(FILES ${DEVICES_HEADERS} DESTINATION include/qucsator) diff --git a/src/components/devices/MakeList b/src/components/devices/MakeList new file mode 100644 index 00000000..cf0a3d03 --- /dev/null +++ b/src/components/devices/MakeList @@ -0,0 +1,23 @@ +SRCS = \ + bjt.cpp \ + device.cpp \ + diac.cpp \ + diode.cpp \ + eqndefined.cpp \ + jfet.cpp \ + mosfet.cpp \ + thyristor.cpp \ + triac.cpp \ + tunneldiode.cpp + +HDRS = \ + bjt.h \ + device.h \ + diac.h \ + diode.h \ + eqndefined.h \ + jfet.h \ + mosfet.h \ + thyristor.h \ + triac.h \ + tunneldiode.h diff --git a/src/components/devices/diode.cpp b/src/components/devices/diode.cpp index 30eac7ef..e41f4737 100644 --- a/src/components/devices/diode.cpp +++ b/src/components/devices/diode.cpp @@ -30,6 +30,7 @@ #include "device.h" #include "devstates.h" #include "diode.h" +#include "logging.h" #define NODE_C 0 /* cathode node */ #define NODE_A 1 /* anode node */ diff --git a/src/components/digital/CMakeLists.txt b/src/components/digital/CMakeLists.txt index 69f545ca..c9c2d9fd 100644 --- a/src/components/digital/CMakeLists.txt +++ b/src/components/digital/CMakeLists.txt @@ -1,18 +1,28 @@ -include_directories( - ${qucs-core_SOURCE_DIR} ${qucs-core_CURRENT_SOURCE_DIR} - ${qucs-core_SOURCE_DIR}/src/math ${qucs-core_SOURCE_DIR}/src/components -)# component.h +project(digital) +cmake_minimum_required(VERSION 3.16) -set(DIGITAL_SRC - and.cpp - buffer.cpp - digisource.cpp - digital.cpp - inverter.cpp - nand.cpp - nor.cpp - or.cpp - xnor.cpp - xor.cpp) +include(${PROJECT_SOURCE_DIR}/../../../../cmake/readMakeList.txt) +#qucsator_SOURCE_DIR is defined as soon as a project named qucsator is created +if ((NOT qucsator_BINARY_DIR) OR (NOT qucsator_app_SOURCE_DIR) ) + message(FATAL_ERROR "This project cannot be used as standalone, because qucs_typedef is missing. Everything around the command + configure_file(\"${qucsator_SOURCE_DIR}/qucs_typedefs.h.cmake\" + \"${qucsator_BINARY_DIR}/qucs_typedefs.h\")\ + is needed to get it work. But this must be done in all subfiles and this makes no sense.") +endif() + +readVariable(MakeList SRCS DIGITAL_SRC) +readVariable(MakeList HDRS DIGITAL_HEADERS) + +# TODO: why the current folder is not needed? add_library(coreDigital OBJECT ${DIGITAL_SRC}) +target_include_directories(coreDigital + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} # This folder + PRIVATE + ${qucsator_BINARY_DIR} + ${qucsator_app_SOURCE_DIR} + ${qucsator_app_SOURCE_DIR}/components + ${qucsator_app_SOURCE_DIR}/math + ) + +install(FILES ${DIGITAL_HEADERS} DESTINATION include/qucsator) diff --git a/src/components/digital/MakeList b/src/components/digital/MakeList new file mode 100644 index 00000000..c25def7d --- /dev/null +++ b/src/components/digital/MakeList @@ -0,0 +1,23 @@ +SRCS = \ + and.cpp \ + buffer.cpp \ + digisource.cpp \ + digital.cpp \ + inverter.cpp \ + nand.cpp \ + nor.cpp \ + or.cpp \ + xnor.cpp \ + xor.cpp + +HDRS = \ + and.h \ + buffer.h \ + digisource.h \ + digital.h \ + inverter.h \ + nand.h \ + nor.h \ + or.h \ + xnor.h \ + xor.h diff --git a/src/components/microstrip/CMakeLists.txt b/src/components/microstrip/CMakeLists.txt index dc4b0dfd..e662d0a0 100644 --- a/src/components/microstrip/CMakeLists.txt +++ b/src/components/microstrip/CMakeLists.txt @@ -1,31 +1,28 @@ -include_directories( - ${qucs-core_SOURCE_DIR} - ${qucs-core_CURRENT_SOURCE_DIR} - ${qucs-core_SOURCE_DIR}/src/math - ${qucs-core_SOURCE_DIR}/src/components # component.h - ${qucs-core_SOURCE_DIR}/src/components/devices) # devices.h +project(microstrip) +cmake_minimum_required(VERSION 3.16) -set(MICROSTRIP_SRC - bondwire.cpp - circularloop.cpp - cpwgap.cpp - cpwline.cpp - cpwopen.cpp - cpwshort.cpp - cpwstep.cpp - mscorner.cpp - mscoupled.cpp - mscross.cpp - msgap.cpp - mslange.cpp - msline.cpp - msmbend.cpp - msopen.cpp - msrstub.cpp - msstep.cpp - mstee.cpp - msvia.cpp - spiralinductor.cpp - substrate.cpp) +include(${PROJECT_SOURCE_DIR}/../../../../cmake/readMakeList.txt) + +#qucsator_SOURCE_DIR is defined as soon as a project named qucsator is created +if ((NOT qucsator_BINARY_DIR) OR (NOT qucsator_app_SOURCE_DIR) ) + message(FATAL_ERROR "This project cannot be used as standalone, because qucs_typedef is missing. Everything around the command + configure_file(\"${qucsator_SOURCE_DIR}/qucs_typedefs.h.cmake\" + \"${qucsator_BINARY_DIR}/qucs_typedefs.h\")\ + is needed to get it work. But this must be done in all subfiles and this makes no sense.") +endif() + +readVariable(MakeList SRCS MICROSTRIP_SRC) +readVariable(MakeList HDRS MICROSTRIP_HDRS) add_library(coreMicrostrip OBJECT ${MICROSTRIP_SRC}) +target_include_directories(coreMicrostrip + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} # This folder + PRIVATE + ${qucsator_BINARY_DIR} # qucs_typedefs.h and config.h + ${qucsator_app_SOURCE_DIR} + ${qucsator_app_SOURCE_DIR}/components + ${qucsator_app_SOURCE_DIR}/components/devices + ${qucsator_app_SOURCE_DIR}/math) + +install(FILES ${MICROSTRIP_HDRS} DESTINATION include/qucsator) + diff --git a/src/components/microstrip/MakeList b/src/components/microstrip/MakeList new file mode 100644 index 00000000..e9133317 --- /dev/null +++ b/src/components/microstrip/MakeList @@ -0,0 +1,45 @@ +SRCS = \ + bondwire.cpp \ + circularloop.cpp \ + cpwgap.cpp \ + cpwline.cpp \ + cpwopen.cpp \ + cpwshort.cpp \ + cpwstep.cpp \ + mscorner.cpp \ + mscoupled.cpp \ + mscross.cpp \ + msgap.cpp \ + mslange.cpp \ + msline.cpp \ + msmbend.cpp \ + msopen.cpp \ + msrstub.cpp \ + msstep.cpp \ + mstee.cpp \ + msvia.cpp \ + spiralinductor.cpp \ + substrate.cpp + +HDRS = \ + bondwire.h \ + circularloop.h \ + cpwgap.h \ + cpwline.h \ + cpwopen.h \ + cpwshort.h \ + cpwstep.h \ + mscorner.h \ + mscoupled.h \ + mscross.h \ + msgap.h \ + mslange.h \ + msline.h \ + msmbend.h \ + msopen.h \ + msrstub.h \ + msstep.h \ + mstee.h \ + msvia.h \ + spiralinductor.h \ + substrate.h diff --git a/src/components/spfile.cpp b/src/components/spfile.cpp index 6b79abbf..b267fb6f 100644 --- a/src/components/spfile.cpp +++ b/src/components/spfile.cpp @@ -36,6 +36,7 @@ #include "spline.h" #include "interpolator.h" #include "spfile.h" +#include using namespace qucs; diff --git a/src/components/verilog/CMakeLists.txt b/src/components/verilog/CMakeLists.txt index 0bff2aa5..eff68d7c 100644 --- a/src/components/verilog/CMakeLists.txt +++ b/src/components/verilog/CMakeLists.txt @@ -1,89 +1,57 @@ -include_directories( - ${qucs-core_SOURCE_DIR} - ${qucs-core_CURRENT_SOURCE_DIR} - ${qucs-core_SOURCE_DIR}/src/math - ${qucs-core_SOURCE_DIR}/src/components # component.h - ${qucs-core_SOURCE_DIR}/src/components/devices) # devices.h +project(verilog) +cmake_minimum_required(VERSION 3.16) -set(VA_FILES - andor4x2.va - andor4x3.va - andor4x4.va - binarytogrey4bit.va - comp_1bit.va - comp_2bit.va - comp_4bit.va - dff_SR.va - DLS_1ton.va - DLS_nto1.va - dmux2to4.va - dmux3to8.va - dmux4to16.va - EKV26MOS.va - fa1b.va - fa2b.va - gatedDlatch.va - greytobinary4bit.va - ha1b.va - hpribin4bit.va - jkff_SR.va - log_amp.va - logic_0.va - logic_1.va - MESFET.va - mod_amp.va - mux2to1.va - mux4to1.va - mux8to1.va - nigbt.va - pad2bit.va - pad3bit.va - pad4bit.va - photodiode.va - phototransistor.va - potentiometer.va - tff_SR.va - vcresistor.va) +include(${PROJECT_SOURCE_DIR}/../../../../cmake/readMakeList.txt) -# XML sripts need to build, the order matters -set(XML_BUILD - analogfunction.xml - qucsVersion.xml - qucsMODULEcore.xml - qucsMODULEdefs.xml) +readVariable(MakeList VERILOG_FILES VA_FILES) +readVariable(MakeList VERILOG_XML XML_BUILD) + +## +# Create list of XML Build files # Concatenate scripts into command: -e script1 [-e script2] set(XML_CMD) foreach(script ${XML_BUILD}) set(XML_CMD ${XML_CMD} -e ${CMAKE_CURRENT_SOURCE_DIR}/${script}) endforeach() -# Process each Verilog-A file. +## Process each Verilog-A file. +message("ADMSXML: ${ADMSXML}") set(gen_SRC) foreach(file ${VA_FILES}) get_filename_component(_name ${file} NAME_WE) set(output - ${_name}.${_name}.analogfunction.h - ${_name}.${_name}.analogfunction.cpp - ${_name}.${_name}.core.cpp - ${_name}.core.h - ${_name}.cpp - ${_name}.defs.h) + ${_name}.${_name}.analogfunction.h + ${_name}.${_name}.analogfunction.cpp + ${_name}.${_name}.core.cpp + ${_name}.core.h + ${_name}.cpp + ${_name}.defs.h) # custom command/rule to generate outputs with admsXml add_custom_command( - OUTPUT ${output} - COMMAND ${ADMSXML} ${CMAKE_CURRENT_SOURCE_DIR}/${file} ${XML_CMD} -o - ${_name} - DEPENDS ${file} ${XML_BUILD}) - list(APPEND gen_SRC ${_name}.cpp) + OUTPUT ${output} + COMMAND ${ADMSXML} ${CMAKE_CURRENT_SOURCE_DIR}/${file} ${XML_CMD} -o + ${_name} + DEPENDS ${file} ${XML_BUILD}) +list(APPEND gen_SRC ${_name}.cpp) endforeach() add_library(coreVerilog OBJECT ${gen_SRC}) - -# Distribute XML scripts +target_include_directories(coreVerilog + PUBLIC + ${CMAKE_CURRENT_BINARY_DIR} + PRIVATE + ${qucsator_BINARY_DIR} # config.h + ${qucsator_app_SOURCE_DIR} # compat.h + ${qucsator_app_SOURCE_DIR}/components # component.h + ${qucsator_app_SOURCE_DIR}/math # matrix.h + ${qucsator_app_SOURCE_DIR}/components/devices # device.h + ) + +## Distribute XML scripts set(XML_DIST ${XML_BUILD} qucsMODULEgui.xml qucsMODULEguiJSONsymbol.xml) set(MAKE_FILES cpp2lib.makefile va2cpp.makefile) -install(FILES ${XML_DIST} DESTINATION include/qucs-core) -install(FILES ${MAKE_FILES} DESTINATION include/qucs-core) +install(FILES ${XML_DIST} DESTINATION include/qucsator) +install(FILES ${MAKE_FILES} DESTINATION include/qucsator) diff --git a/src/components/verilog/MakeList b/src/components/verilog/MakeList new file mode 100644 index 00000000..6a07f728 --- /dev/null +++ b/src/components/verilog/MakeList @@ -0,0 +1,48 @@ +VERILOG_FILES = \ + DLS_1ton.va \ + DLS_nto1.va \ + EKV26MOS.va \ + MESFET.va \ + andor4x2.va \ + andor4x3.va \ + andor4x4.va \ + binarytogrey4bit.va \ + comp_1bit.va \ + comp_2bit.va \ + comp_4bit.va \ + dff_SR.va \ + dmux2to4.va \ + dmux3to8.va \ + dmux4to16.va \ + fa1b.va \ + fa2b.va \ + gatedDlatch.va \ + greytobinary4bit.va \ + ha1b.va \ + hpribin4bit.va \ + jkff_SR.va \ + log_amp.va \ + logic_0.va \ + logic_1.va \ + mod_amp.va \ + mux2to1.va \ + mux4to1.va \ + mux8to1.va \ + nigbt.va \ + pad2bit.va \ + pad3bit.va \ + pad4bit.va \ + photodiode.va \ + phototransistor.va \ + potentiometer.va \ + tff_SR.va \ + vcresistor.va + +# order is important, because vtype needed by qucsMODULEcore.xml is defined in qucsVersion.xml +VERILOG_XML = \ + analogfunction.xml \ + qucsVersion.xml \ + qucsMODULEcore.xml \ + qucsMODULEdefs.xml + #qucsMODULEgui.xml \ + #qucsMODULEguiJSONsymbol.xml \ diff --git a/src/constants.h b/src/constants.h index 5b9935a1..514dbb78 100644 --- a/src/constants.h +++ b/src/constants.h @@ -34,7 +34,7 @@ #define __CONSTANTS_H__ #include "consts.h" -#include "precision.h" +#include "math/precision.h" namespace qucs { diff --git a/src/converter/CMakeLists.txt b/src/converter/CMakeLists.txt index c2e65868..3eff3660 100644 --- a/src/converter/CMakeLists.txt +++ b/src/converter/CMakeLists.txt @@ -1,16 +1,16 @@ -include_directories( - ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src/math - ${CMAKE_CURRENT_BINARY_DIR}) # qucdefs.h +project(converter) +cmake_minimum_required(VERSION 3.16) -set(QUCSCONV_SRC - check_spice.cpp - check_vcd.cpp - matlab_producer.cpp - csv_producer.cpp - qucs_producer.cpp - qucsconv.cpp - touchstone_producer.cpp) +include(${PROJECT_SOURCE_DIR}/../../../cmake/readMakeList.txt) +find_package(BISON REQUIRED) +find_package(FLEX REQUIRED) + +#include_directories( +# ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src/math +# ${CMAKE_CURRENT_BINARY_DIR}) # qucdefs.h + +readVariable(MakeList SRCS QUCSCONV_SRC) set(ParserTypes spice vcd) @@ -47,15 +47,21 @@ add_custom_command( OUTPUT qucsdefs.h COMMAND ${CMAKE_CURRENT_BINARY_DIR}/../qucsator -l > ${CMAKE_CURRENT_BINARY_DIR}/qucsdefs.h - DEPENDS qucsator) + DEPENDS qucsator) # TODO: here is a build problem -add_custom_target(defs DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/qucsdefs.h) +add_custom_target(defs_converter DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/qucsdefs.h) +# TODO: check that the number of files in conv_generated is same as for ParserTypes add_executable(qucsconv ${QUCSCONV_SRC} ${conv_generated}) -add_dependencies(qucsconv defs) +add_dependencies(qucsconv defs_converter) +# TODO: why CMAKE_DL_LIBS needed? target_link_libraries(qucsconv libqucsator ${CMAKE_DL_LIBS}) +target_include_directories(qucsconv + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + PRIVATE ${qucsator_BINARY_DIR}) # # Handle installation diff --git a/src/converter/MakeList b/src/converter/MakeList new file mode 100644 index 00000000..cfab5a95 --- /dev/null +++ b/src/converter/MakeList @@ -0,0 +1,20 @@ +SRCS = \ + check_spice.cpp \ + check_vcd.cpp \ + csv_producer.cpp \ + matlab_producer.cpp \ + qucsconv.cpp \ + qucs_producer.cpp \ + touchstone_producer.cpp + +SRCS_YPP = \ + parse_spice.ypp \ + parse_vcd.ypp + +HDRS = \ + check_spice.h \ + check_vcd.h \ + csv_producer.h \ + matlab_producer.h \ + qucs_producer.h \ + touchstone_producer.h diff --git a/src/dcsolver.cpp b/src/dcsolver.cpp index 552de396..f4f83d61 100644 --- a/src/dcsolver.cpp +++ b/src/dcsolver.cpp @@ -27,6 +27,7 @@ #endif #include +#include #include "object.h" #include "complex.h" @@ -36,6 +37,9 @@ #include "analysis.h" #include "nasolver.h" #include "dcsolver.h" +#include "exceptionstack.h" +#include "exception.h" +#include "logging.h" namespace qucs { diff --git a/src/devstates.cpp b/src/devstates.cpp index ed20f215..b2011865 100644 --- a/src/devstates.cpp +++ b/src/devstates.cpp @@ -31,6 +31,7 @@ #include #include "devstates.h" +#include "qucs_typedefs.h" namespace qucs { diff --git a/src/devstates.h b/src/devstates.h index cb2dfe4c..68396a9f 100644 --- a/src/devstates.h +++ b/src/devstates.h @@ -25,6 +25,8 @@ #ifndef __DEVSTATES_H__ #define __DEVSTATES_H__ +#include "qucs_typedefs.h" + namespace qucs { class devstates diff --git a/src/equation.cpp b/src/equation.cpp index 68d80baa..cb7a43b9 100644 --- a/src/equation.cpp +++ b/src/equation.cpp @@ -48,6 +48,7 @@ #include "range.h" #include "exception.h" #include "exceptionstack.h" +#include "gperfappgen.h" namespace qucs { diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 9b9bcc2d..b4198df0 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -4871,5 +4871,5 @@ constant * evaluate::receiver_v_v (constant * args) { } // Include the application array. -#include "applications.h" +//#include "applications.h" diff --git a/src/exceptionstack.h b/src/exceptionstack.h index 8c96463e..2aa634bc 100644 --- a/src/exceptionstack.h +++ b/src/exceptionstack.h @@ -38,7 +38,7 @@ class exceptionstack void push (exception *); exception * pop (void); exception * top (void); - void print (const char * prefix = NULL); + void print (const char * prefix = nullptr); private: exception * root; diff --git a/src/fourier.h b/src/fourier.h index 6533e1ea..dd893745 100644 --- a/src/fourier.h +++ b/src/fourier.h @@ -25,6 +25,8 @@ #ifndef __FOURIER_H__ #define __FOURIER_H__ +#include "qucs_typedefs.h" + namespace qucs { class vector; diff --git a/src/gperfappgen.cpp b/src/gperfappgen.cpp index 71d002d1..9674e259 100644 --- a/src/gperfappgen.cpp +++ b/src/gperfappgen.cpp @@ -34,14 +34,12 @@ #include "evaluate.h" #include "equation.h" -using namespace qucs::eqn; - #include "gperfappgen.h" /* The program is used to generate the input file for a gperf run. */ int main (void) { - struct application_t * app; + struct qucs::eqn::application_t * app; char * key; int len, n = 0; @@ -57,12 +55,12 @@ int main (void) { "%%%%\n"); // Print hash key list. - for (app = applications; app->application != NULL; app++, n++) { + for (app = qucs::eqn::applications; app->application != NULL; app++, n++) { key = (char *) calloc (1, strlen (app->application) + app->nargs * 3 + 5); strcat (key, app->application); for (int i = 0; i < app->nargs; i++) { strcat (key, "_"); - strcat (key, checker::tag2key (app->args[i])); + strcat (key, qucs::eqn::checker::tag2key (app->args[i])); } len = strlen (key); fprintf (stdout, "\"%s\", %s%s%s%d\n", key, diff --git a/src/hbsolver.cpp b/src/hbsolver.cpp index 43bde0fe..b5b30307 100644 --- a/src/hbsolver.cpp +++ b/src/hbsolver.cpp @@ -29,6 +29,7 @@ #include #include +#include #include "object.h" #include "logging.h" @@ -36,7 +37,7 @@ #include "vector.h" #include "node.h" #include "circuit.h" -#include "component_id.h" +#include "components/component_id.h" #include "net.h" #include "netdefs.h" #include "strlist.h" @@ -48,6 +49,8 @@ #include "dataset.h" #include "fourier.h" #include "hbsolver.h" +#include "exception.h" +#include "exceptionstack.h" #define HB_DEBUG 0 diff --git a/src/hbsolver.h b/src/hbsolver.h index 88bd5d3f..0800a7d5 100644 --- a/src/hbsolver.h +++ b/src/hbsolver.h @@ -29,6 +29,7 @@ #include "ptrlist.h" #include "tvector.h" +#include "analysis.h" namespace qucs { diff --git a/src/input.cpp b/src/input.cpp index 2eea888c..22f7e182 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -33,8 +33,8 @@ #include #include "logging.h" -#include "component.h" -#include "components.h" +#include "components/component.h" +#include "components/components.h" #include "net.h" #include "variable.h" #include "property.h" diff --git a/src/integrator.h b/src/integrator.h index 26fad66d..f72a926f 100644 --- a/src/integrator.h +++ b/src/integrator.h @@ -26,6 +26,7 @@ #define __INTEGRATOR_H__ #include "states.h" +#include "qucs_typedefs.h" #define MODE_NONE 0 #define MODE_INIT 1 diff --git a/src/interface/CMakeLists.txt b/src/interface/CMakeLists.txt index 12a71c5d..e7779dd5 100644 --- a/src/interface/CMakeLists.txt +++ b/src/interface/CMakeLists.txt @@ -1,17 +1,33 @@ -include_directories( - ${qucs-core_SOURCE_DIR} - ${qucs-core_CURRENT_SOURCE_DIR} - ${qucs-core_SOURCE_DIR}/src/math - ${qucs-core_SOURCE_DIR}/src/components # component.h - ${qucs-core_BINARY_DIR}/src/components # generated verilog/[].core.h -) +project(interface) +cmake_minimum_required(VERSION 3.16) -set(INTERFACE_SRC qucs_interface.cpp e_trsolver.cpp) +include(${PROJECT_SOURCE_DIR}/../../../cmake/readMakeList.txt) -set(HEADERS qucs_interface.h) + +#include_directories( +# ${qucs-core_SOURCE_DIR} +# ${qucs-core_CURRENT_SOURCE_DIR} +# ${qucs-core_SOURCE_DIR}/src/math +# ${qucs-core_SOURCE_DIR}/src/components # component.h +# ${qucs-core_BINARY_DIR}/src/components # generated verilog/[].core.h +#) + +readVariable(MakeList SRCS INTERFACE_SRC) +readVariable(MakeList HDRS HEADERS) add_library(coreInterface OBJECT ${INTERFACE_SRC}) +target_include_directories(coreInterface + PUBLIC + ${qucsator_app_BINARY_DIR}/components # verilog/[].core.h + ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE + ${qucsator_BINARY_DIR} # config.h + ${qucsator_app_SOURCE_DIR} # compat.h + ${qucsator_app_SOURCE_DIR}/math # precision.h + ${qucsator_app_SOURCE_DIR}/components # component.h + ) +# coreVerilog is located in components/verilog add_dependencies(coreInterface coreVerilog) -install(FILES ${HEADERS} DESTINATION include/qucs-core) +install(FILES ${HEADERS} DESTINATION include/qucsator) diff --git a/src/interface/MakeList b/src/interface/MakeList new file mode 100644 index 00000000..1c0aa490 --- /dev/null +++ b/src/interface/MakeList @@ -0,0 +1,18 @@ +SRCS = \ + e_trsolver.cpp \ + #mextrsolver.cpp \ # for these files mex.h is needed, which gets installed with octave. So make somehow a dependency to it + #m_trsolver_interface_mex.cpp \ + qucs_interface.cpp + +HDRS = \ + e_trsolver.h \ + #mextrsolver.h \ + qucs_interface.h + +OCTAVE_FILES = \ + asynctrcircuit.m \ + cppinterface.m \ + qucs.m \ + qucstrans.m \ + qucstrsolversetup.m \ + synctrcircuit.m diff --git a/src/interface/mextrsolver.cpp b/src/interface/mextrsolver.cpp index 4bfaacfc..c522c380 100644 --- a/src/interface/mextrsolver.cpp +++ b/src/interface/mextrsolver.cpp @@ -1,5 +1,5 @@ #include -#include +#include "qucs_interface.h" #include "mextrsolver.h" using namespace qucs; diff --git a/src/logging.h b/src/logging.h index a1571269..57545eff 100644 --- a/src/logging.h +++ b/src/logging.h @@ -27,6 +27,8 @@ #define LOG_ERROR 0 #define LOG_STATUS 1 +#include "qucs_typedefs.h" +#include "config.h" #include __BEGIN_DECLS diff --git a/src/math/CMakeLists.txt b/src/math/CMakeLists.txt index 0ee3824a..f6532ea3 100644 --- a/src/math/CMakeLists.txt +++ b/src/math/CMakeLists.txt @@ -1,10 +1,26 @@ -include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) +project(math) +cmake_minimum_required(VERSION 3.16) -set(MATH_SRC # cbesselj.cpp - complex.cpp fspecial.cpp matrix.cpp real.cpp) +include(${PROJECT_SOURCE_DIR}/../../../cmake/readMakeList.txt) -set(HEADERS complex.h matrix.h precision.h real.h) +#qucsator_SOURCE_DIR is defined as soon as a project named qucsator is created +if ((NOT qucsator_BINARY_DIR) OR (NOT qucsator_app_SOURCE_DIR) ) + message(FATAL_ERROR "This project cannot be used as standalone, because qucs_typedef is missing. Everything around the command + configure_file(\"${qucsator_SOURCE_DIR}/qucs_typedefs.h.cmake\" + \"${qucsator_BINARY_DIR}/qucs_typedefs.h\")\ + is needed to get it work. But this must be done in all subfiles and this makes no sense.") +endif() + +readVariable(MakeList SRCS MATH_SRC) +readVariable(MakeList HDRS HEADERS) add_library(coreMath OBJECT ${MATH_SRC}) +# ${qucsator_BINARY_DIR} must be added, because from the qucsator/qucs_typedefs.h.cmake the header is created and this one is stored inside the Binary directory +# constants.h from qucs/src is needed in the math library. So the path must also be added +target_include_directories(coreMath PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(coreMath PRIVATE + ${qucsator_app_SOURCE_DIR} + ${qucsator_BINARY_DIR} # config.h and qucs_typedefs.h +) -install(FILES ${HEADERS} DESTINATION include/qucs-core) +install(FILES ${HEADERS} DESTINATION include/qucsator) diff --git a/src/math/MakeList b/src/math/MakeList new file mode 100644 index 00000000..24e93891 --- /dev/null +++ b/src/math/MakeList @@ -0,0 +1,13 @@ +SRCS = \ +# cbesselj.cpp \ + complex.cpp \ + fspecial.cpp \ + matrix.cpp \ + real.cpp + +HDRS = \ + complex.h \ + fspecial.h \ + matrix.h \ + precision.h \ + real.h diff --git a/src/math/complex.h b/src/math/complex.h index b7d0b68d..59697a1a 100644 --- a/src/math/complex.h +++ b/src/math/complex.h @@ -27,6 +27,7 @@ #include #include "real.h" +#include "qucs_typedefs.h" typedef std::complex nr_complex_t; diff --git a/src/math/precision.h b/src/math/precision.h index f167415c..c3b4c9f6 100644 --- a/src/math/precision.h +++ b/src/math/precision.h @@ -26,6 +26,7 @@ #define __PRECISION_H__ #include +#include "qucs_typedefs.h" #if NR_DOUBLE_SIZE == 4 /* S 23bit MAN | S 7bit EXP */ diff --git a/src/math/real.h b/src/math/real.h index 159770cb..e4487315 100644 --- a/src/math/real.h +++ b/src/math/real.h @@ -28,7 +28,8 @@ #include -#include +#include "constants.h" +#include "qucs_typedefs.h" /**It is prefered to add all used funcions into the qucs namespace. * Doing so one is forced do think about compatibility instead of using std directly. diff --git a/src/module.cpp b/src/module.cpp index ac981f7e..d323eebb 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -34,10 +34,12 @@ #include #include "netdefs.h" -#include "components.h" +#include "components/components.h" #include "analyses.h" #include "netdefs.h" #include "module.h" +#include "nodeset.h" +#include "logging.h" #ifdef __MINGW32__ #include @@ -48,7 +50,7 @@ #include //for exit // Global module hash. -qucs::hash module::modules; +qucs::hash qucs::module::modules; // Our global factories for making loaded circuit objects // The factories are populated as dynamic modules are loaded @@ -66,14 +68,14 @@ std::map< std::string, defs_t *, std::less > factorydef; #endif // Constructor creates an instance of the module class. -module::module () { +qucs::module::module () { definition = NULL; circreate = NULL; anacreate = NULL; } // Destructor deletes an instance of the module class. -module::~module () { +qucs::module::~module () { } // Definitions which do not fit elsewhere. @@ -92,7 +94,7 @@ struct define_t miscdef2 = props1, props2 }; // Registers an analysis object to the list of available modules. -void module::registerModule (analysis_definer_t define, +void qucs::module::registerModule (analysis_definer_t define, analysis_creator_t create) { module * m = new module (); m->definition = define (); @@ -101,7 +103,7 @@ void module::registerModule (analysis_definer_t define, } // Registers a circuit object to the list of available modules. -void module::registerModule (circuit_definer_t define, +void qucs::module::registerModule (circuit_definer_t define, circuit_creator_t create) { module * m = new module (); m->definition = define (); @@ -110,7 +112,7 @@ void module::registerModule (circuit_definer_t define, } // Registers a miscellaneous object to the list of available modules. -void module::registerModule (misc_definer_t define) { +void qucs::module::registerModule (misc_definer_t define) { module * m = new module (); m->definition = define (); registerModule (define()->type, m); @@ -118,14 +120,14 @@ void module::registerModule (misc_definer_t define) { /* Registers a miscellaneous structure just defined by a somple define_t structure to the list of available modules. */ -void module::registerModule (struct define_t * define) { +void qucs::module::registerModule (struct define_t * define) { module * m = new module (); m->definition = define; registerModule (define->type, m); } // Puts a module into the available module hash. -void module::registerModule (const char * type, module * m) { +void qucs::module::registerModule (const char * type, module * m) { if (modules.get ((char *) type) != NULL) { logprint (LOG_ERROR, "module already registered: %s\n", type); } @@ -136,7 +138,7 @@ void module::registerModule (const char * type, module * m) { /* Returns the definition of a module specified by its type name if such is existing and otherwise NULL. */ -struct define_t * module::getModule (char * type) { +struct define_t * qucs::module::getModule (char * type) { module * m = modules.get (type); if (m != NULL) { return m->definition; @@ -153,7 +155,7 @@ struct define_t * module::getModule (char * type) { registerModule (&val::definition) // Global static module registration. -void module::registerModules (void) { +void qucs::module::registerModules (void) { // miscellaneous registerModule (&miscdef1); @@ -264,6 +266,7 @@ void module::registerModules (void) { REGISTER_CIRCUIT (digisource); REGISTER_CIRCUIT (buffer); +#ifdef USE_VERILOG REGISTER_CIRCUIT (EKV26MOS); REGISTER_CIRCUIT (log_amp); REGISTER_CIRCUIT (mod_amp); @@ -304,6 +307,7 @@ void module::registerModules (void) { REGISTER_CIRCUIT (hpribin4bit); REGISTER_CIRCUIT (vcresistor); REGISTER_CIRCUIT (ecvs); +#endif // analyses REGISTER_ANALYSIS (dcsolver); @@ -312,11 +316,13 @@ void module::registerModules (void) { REGISTER_ANALYSIS (trsolver); REGISTER_ANALYSIS (hbsolver); REGISTER_ANALYSIS (parasweep); - REGISTER_ANALYSIS (e_trsolver); + #ifdef USE_VERILOG + REGISTER_ANALYSIS (e_trsolver); + #endif } // Global module unregistration. -void module::unregisterModules (void) { +void qucs::module::unregisterModules (void) { qucs::hashiterator it; for (it = qucs::hashiterator (modules); *it; ++it) { delete it.currentVal (); @@ -402,7 +408,7 @@ static void printprop (const char * type, const char * prefix, /* The function emits a complete list of the registered component definitions as compilable C-code. */ -void module::print (void) { +void qucs::module::print (void) { fprintf (stdout, "%s", def_prefix); qucs::hashiterator it; for (it = qucs::hashiterator (modules); *it; ++it) { @@ -434,7 +440,7 @@ void module::print (void) { // look for dynamic libs, load and register them -void module::registerDynamicModules (char *proj, std::list modlist) +void qucs::module::registerDynamicModules (char *proj, std::list modlist) { /* How it is (WAS) supposed to work: * 1) It will list the working directory contents looking for libraries @@ -534,7 +540,7 @@ void module::registerDynamicModules (char *proj, std::list modlist) // print registered components /* qucs::hashiterator it; - for (it = qucs::hashiterator (module::modules); *it; ++it) { + for (it = qucs::hashiterator (qucs::module::modules); *it; ++it) { module * m = it.currentVal (); struct define_t * def = m->definition; printf("\n" ); @@ -546,7 +552,7 @@ void module::registerDynamicModules (char *proj, std::list modlist) } // Close all the dynamic libs if any opened -void module::closeDynamicLibs() +void qucs::module::closeDynamicLibs() { for(itr=dl_list.begin(); itr!=dl_list.end(); itr++){ #if __MINGW32__ diff --git a/src/module.h b/src/module.h index 3b14aa3d..9198bfcd 100644 --- a/src/module.h +++ b/src/module.h @@ -26,7 +26,7 @@ #define __MODULE_H__ #include - +#include #include "hash.h" namespace qucs { diff --git a/src/nasolver.cpp b/src/nasolver.cpp index e84c1552..d38f2693 100644 --- a/src/nasolver.cpp +++ b/src/nasolver.cpp @@ -59,6 +59,10 @@ #include "nasolver.h" #include "constants.h" +#ifndef MAX +# define MAX(x,y) (((x) > (y)) ? (x) : (y)) +#endif + namespace qucs { // Constructor creates an unnamed instance of the nasolver class. diff --git a/src/nasolver.h b/src/nasolver.h index 5d4c293e..f841be6f 100644 --- a/src/nasolver.h +++ b/src/nasolver.h @@ -36,6 +36,7 @@ #include "eqnsys.h" #include "nasolution.h" #include "analysis.h" +#include "complex.h" // Convergence helper definitions. #define CONV_None 0 diff --git a/src/net.cpp b/src/net.cpp index 68c35e56..a5035b14 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -40,16 +40,16 @@ #include "vector.h" #include "dataset.h" #include "net.h" -#include "tee.h" -#include "open.h" -#include "itrafo.h" +#include "components/tee.h" +#include "components/open.h" +#include "components/itrafo.h" #include "ptrlist.h" #include "analysis.h" #include "nodelist.h" #include "nodeset.h" #include "equation.h" #include "environment.h" -#include "component_id.h" +#include "components/component_id.h" namespace qucs { diff --git a/src/netdefs.h b/src/netdefs.h index 8a60bd86..a3f103ca 100644 --- a/src/netdefs.h +++ b/src/netdefs.h @@ -25,6 +25,8 @@ #ifndef __NETDEFS_H__ #define __NETDEFS_H__ +#include "qucs_typedefs.h" + namespace qucs { class environment; } diff --git a/src/object.h b/src/object.h index 4dde05ea..974897c5 100644 --- a/src/object.h +++ b/src/object.h @@ -33,6 +33,7 @@ #include #include "property.h" +#include "qucs_typedefs.h" #define MCREATOR(val) \ val (); \ diff --git a/src/poly.h b/src/poly.h index 95d601d2..dcabc874 100644 --- a/src/poly.h +++ b/src/poly.h @@ -25,6 +25,8 @@ #ifndef __POLY_H__ #define __POLY_H__ +#include "qucs_typedefs.h" + namespace qucs { class poly diff --git a/src/property.h b/src/property.h index 925d9e71..4e0051dd 100644 --- a/src/property.h +++ b/src/property.h @@ -29,6 +29,8 @@ #include #include +#include "qucs_typedefs.h" + namespace qucs { class variable; diff --git a/src/range.h b/src/range.h index 9db177f5..4183ce6c 100644 --- a/src/range.h +++ b/src/range.h @@ -25,6 +25,8 @@ #ifndef __RANGE_H__ #define __RANGE_H__ +#include "qucs_typedefs.h" + namespace qucs { class range diff --git a/src/states.h b/src/states.h index 56abc501..41634962 100644 --- a/src/states.h +++ b/src/states.h @@ -27,12 +27,12 @@ namespace qucs { -/*! \class states - * \brief template class for storing state variables. - * - * This class is used for storing sets of states for use +/*! \class states + * \brief template class for storing state variables. + * + * This class is used for storing sets of states for use * by the transient integrators. - * + * */ template class states diff --git a/src/tmatrix.h b/src/tmatrix.h index 8a6e41f4..ac0675bb 100644 --- a/src/tmatrix.h +++ b/src/tmatrix.h @@ -27,6 +27,9 @@ #include +#include "tvector.h" +#include "qucs_typedefs.h" + namespace qucs { template diff --git a/src/tridiag.cpp b/src/tridiag.cpp index 94492001..5127f38a 100644 --- a/src/tridiag.cpp +++ b/src/tridiag.cpp @@ -36,6 +36,7 @@ #include "compat.h" #include "complex.h" //#include "tvector.h" +#include "tridiag.h" namespace qucs { diff --git a/src/trsolver.cpp b/src/trsolver.cpp index 9ebea14f..a2c365f7 100644 --- a/src/trsolver.cpp +++ b/src/trsolver.cpp @@ -46,6 +46,8 @@ #include "transient.h" #include "exception.h" #include "exceptionstack.h" +#include "dataset.h" +#include "vector.h" #define STEPDEBUG 0 // set to zero for release #define BREAKPOINTS 0 // exact breakpoint calculation @@ -56,6 +58,10 @@ // Macro for the n-th state of the solution vector history. #define SOL(state) (solution[(int) getState (sState, (state))]) +#ifndef MAX +# define MAX(x,y) (((x) > (y)) ? (x) : (y)) +#endif + namespace qucs { using namespace transient; diff --git a/src/ucs.cpp b/src/ucs.cpp index e1943b1a..a4c5710f 100644 --- a/src/ucs.cpp +++ b/src/ucs.cpp @@ -35,18 +35,18 @@ #include #include -#include "logging.h" -#include "precision.h" +#include "check_netlist.h" #include "component.h" #include "components.h" -#include "net.h" -#include "input.h" #include "dataset.h" -#include "equation.h" #include "environment.h" +#include "equation.h" #include "exceptionstack.h" -#include "check_netlist.h" +#include "input.h" +#include "logging.h" +#include "math/precision.h" #include "module.h" +#include "net.h" #if HAVE_UNISTD_H #include diff --git a/src/vector.h b/src/vector.h index 4a06fc7c..8581cd02 100644 --- a/src/vector.h +++ b/src/vector.h @@ -29,8 +29,9 @@ #include #include "consts.h" -#include "precision.h" -#include "complex.h" +#include "math/precision.h" +#include "math/complex.h" +#include "object.h" #ifdef log2 #undef log2 @@ -46,7 +47,7 @@ qucs::vector logspace (nr_double_t, nr_double_t, int); qucs::vector runavg (qucs::vector, const int); qucs::vector runavg (const nr_complex_t, const int); -class vector : public object +class vector : public qucs::object { public: vector * getNext (void) const { return this->next; }