├── .clang-format ├── .gitignore ├── .gitmodules ├── .pre-commit-config.yaml ├── .swift-format ├── CMakeLists.txt ├── LICENSE ├── README.md ├── Surf ├── Surf.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── swiftpm │ │ └── Package.resolved └── Surf │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json │ ├── Base.lproj │ └── Main.storyboard │ ├── Document.swift │ ├── Info.plist │ ├── Surf.entitlements │ └── ViewController.swift ├── doc ├── img │ ├── DALL·E 2023-01-05 15.04.59 - an apple-style macOS application icon displaying the wave from The Great Wave off Kanagawa. there are no rounded corners or borders. there are no edge.png │ ├── build-icon.sh │ ├── icon-1024.png │ ├── icon-1024 │ │ └── AppIcon.iconset │ │ │ ├── Contents.json │ │ │ ├── Icon │ │ │ ├── icon_128x128.png │ │ │ ├── icon_128x128@2x.png │ │ │ ├── icon_16x16.png │ │ │ ├── icon_16x16@2x.png │ │ │ ├── icon_256x256.png │ │ │ ├── icon_256x256@2x.png │ │ │ ├── icon_32x32.png │ │ │ ├── icon_32x32@2x.png │ │ │ ├── icon_512x512.png │ │ │ └── icon_512x512@2x.png │ ├── icon.afdesign │ ├── icon.svg │ ├── vectorized-icon-non-stacked.svg │ ├── vectorized-icon.svg │ ├── waveform-file-icon-1024.png │ ├── waveform-file-icon-1024 │ │ └── waveform.iconset │ │ │ ├── Contents.json │ │ │ ├── icon_128x128.png │ │ │ ├── icon_128x128@2x.png │ │ │ ├── icon_16x16.png │ │ │ ├── icon_16x16@2x.png │ │ │ ├── icon_256x256.png │ │ │ ├── icon_256x256@2x.png │ │ │ ├── icon_32x32.png │ │ │ ├── icon_32x32@2x.png │ │ │ ├── icon_512x512.png │ │ │ └── icon_512x512@2x.png │ ├── waveform-file-icon-plain-1024 │ │ └── waveform-plain.iconset │ │ │ ├── Contents.json │ │ │ ├── icon_128x128.png │ │ │ ├── icon_128x128@2x.png │ │ │ ├── icon_16x16.png │ │ │ ├── icon_16x16@2x.png │ │ │ ├── icon_256x256.png │ │ │ ├── icon_256x256@2x.png │ │ │ ├── icon_32x32.png │ │ │ ├── icon_32x32@2x.png │ │ │ ├── icon_512x512.png │ │ │ └── icon_512x512@2x.png │ ├── waveform-file-icon.afdesign │ └── waveform-file-icon.svg ├── misc-notes.txt ├── surf-trace-format.md ├── varbit-layout.numbers ├── varbit-layout.pdf ├── vcd-grammar.abnf ├── vcd-grammar.ebnf └── vcd-grammar.lbnf ├── libsurf ├── 3rdparty │ ├── CMakeLists.txt │ ├── fpng-scoped-include │ │ └── fpng.h │ └── hedley-scoped-include │ │ └── hedley.h ├── CMakeLists.txt ├── include │ └── surf │ │ ├── common.h │ │ ├── mmap.h │ │ ├── render.h │ │ ├── surf.h │ │ ├── time.h │ │ ├── trace.h │ │ ├── varbit.h │ │ └── vcd.h ├── lib │ ├── CMakeLists.txt │ ├── common-internal.h │ ├── config.cpp │ ├── dump_types.cpp │ ├── lexy_user_config.hpp │ ├── mmap.cpp │ ├── render.cpp │ ├── time.cpp │ ├── trace.cpp │ ├── utils.cpp │ ├── utils.h │ ├── varbit.cpp │ ├── vcd-parser.cpp │ ├── vcd-parser.h │ └── vcd.cpp ├── test │ ├── CMakeLists.txt │ ├── bin2str.cpp │ └── dump-struct.cpp ├── tools │ ├── CMakeLists.txt │ └── surf-tool.cpp └── unit-tests │ ├── CMakeLists.txt │ └── varbit.cpp ├── old └── surf-v1-objc │ ├── Surf.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── jevin.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist │ └── Surf │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── icon_128x128.png │ │ ├── icon_128x128@2x.png │ │ ├── icon_16x16.png │ │ ├── icon_16x16@2x.png │ │ ├── icon_256x256.png │ │ ├── icon_256x256@2x.png │ │ ├── icon_32x32.png │ │ ├── icon_32x32@2x.png │ │ ├── icon_512x512.png │ │ └── icon_512x512@2x.png │ ├── Contents.json │ ├── waveform-plain.iconset │ │ ├── icon_128x128.png │ │ ├── icon_128x128@2x.png │ │ ├── icon_16x16.png │ │ ├── icon_16x16@2x.png │ │ ├── icon_256x256.png │ │ ├── icon_256x256@2x.png │ │ ├── icon_32x32.png │ │ ├── icon_32x32@2x.png │ │ ├── icon_512x512.png │ │ └── icon_512x512@2x.png │ └── waveform.iconset │ │ ├── icon_128x128.png │ │ ├── icon_128x128@2x.png │ │ ├── icon_16x16.png │ │ ├── icon_16x16@2x.png │ │ ├── icon_256x256.png │ │ ├── icon_256x256@2x.png │ │ ├── icon_32x32.png │ │ ├── icon_32x32@2x.png │ │ ├── icon_512x512.png │ │ └── icon_512x512@2x.png │ ├── Base.lproj │ └── Main.storyboard │ ├── Info.plist │ ├── Surf.entitlements │ ├── ViewController.h │ ├── ViewController.m │ ├── WaveformDocument.h │ ├── WaveformDocument.m │ └── main.m └── test └── vcd ├── empty.vcd └── parse-test.vcd /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: LLVM 2 | IndentWidth: 4 3 | ObjCBlockIndentWidth: 4 4 | UseTab: Never 5 | ColumnLimit: 100 6 | AccessModifierOffset: -4 7 | AllowShortBlocksOnASingleLine: Empty 8 | AllowShortFunctionsOnASingleLine: Empty 9 | AllowShortCaseLabelsOnASingleLine: false 10 | AllowShortEnumsOnASingleLine: false 11 | AllowShortIfStatementsOnASingleLine: Never 12 | AllowShortLambdasOnASingleLine: Empty 13 | AllowShortLoopsOnASingleLine: false 14 | AlignConsecutiveAssignments: Consecutive 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # vscode 2 | **/.vscode/ 3 | 4 | # build folder 5 | **/build/ 6 | 7 | # clion 8 | **/cmake-build-*/ 9 | **/.idea/ 10 | 11 | # mac 12 | **/.DS_Store 13 | 14 | # xcode 15 | **/DerivedData/ 16 | **/xcuserdata/ 17 | **/*.xcuserstate 18 | 19 | # python 20 | **/__pycache__ 21 | **/*.egg-info 22 | 23 | # jupyter-notebook 24 | **/*.ipynb_checkpoints 25 | 26 | # nbdev 27 | .last_checked 28 | .irecovery 29 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "test/waveforms"] 2 | path = test/waveforms 3 | url = https://github.com/jevinskie/digital-waveform-samples 4 | [submodule "libsurf/3rdparty/fmt"] 5 | path = libsurf/3rdparty/fmt 6 | url = https://github.com/fmtlib/fmt 7 | [submodule "libsurf/3rdparty/argparse"] 8 | path = libsurf/3rdparty/argparse 9 | url = https://github.com/p-ranav/argparse 10 | [submodule "libsurf/3rdparty/thread-pool"] 11 | path = libsurf/3rdparty/thread-pool 12 | url = https://github.com/bshoshany/thread-pool 13 | [submodule "libsurf/3rdparty/fpng"] 14 | path = libsurf/3rdparty/fpng 15 | url = https://github.com/richgel999/fpng 16 | [submodule "libsurf/3rdparty/lexy"] 17 | path = libsurf/3rdparty/lexy 18 | url = https://github.com/foonathan/lexy 19 | [submodule "libsurf/3rdparty/backward-cpp"] 20 | path = libsurf/3rdparty/backward-cpp 21 | url = https://github.com/bombela/backward-cpp 22 | [submodule "libsurf/3rdparty/magic_enum"] 23 | path = libsurf/3rdparty/magic_enum 24 | url = https://github.com/Neargye/magic_enum 25 | [submodule "libsurf/3rdparty/visit"] 26 | path = libsurf/3rdparty/visit 27 | url = https://github.com/jevinskie/visit 28 | [submodule "libsurf/3rdparty/hedley"] 29 | path = libsurf/3rdparty/hedley 30 | url = https://github.com/nemequ/hedley 31 | [submodule "libsurf/3rdparty/tagged_ptr"] 32 | path = libsurf/3rdparty/tagged_ptr 33 | url = https://github.com/marzer/tagged_ptr 34 | [submodule "libsurf/3rdparty/Catch2"] 35 | path = libsurf/3rdparty/Catch2 36 | url = https://github.com/catchorg/Catch2 37 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/mirrors-clang-format 3 | rev: v15.0.7 4 | hooks: 5 | - id: clang-format 6 | types_or: [c++, c, objective-c, objective-c++] 7 | -------------------------------------------------------------------------------- /.swift-format: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "lineLength": 100, 4 | "indentation": { 5 | "spaces": 4 6 | } 7 | } -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(surf CXX) 4 | 5 | option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." ON) 6 | 7 | if (${FORCE_COLORED_OUTPUT}) 8 | if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") 9 | add_compile_options(-fdiagnostics-color=always) 10 | elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") 11 | add_compile_options(-fcolor-diagnostics) 12 | endif () 13 | endif () 14 | 15 | set(BUILD_SHARED_LIBS OFF) 16 | 17 | # set(CMAKE_OSX_ARCHITECTURES arm64 x86_64) 18 | 19 | # To enable building with upstream LLVM/Clang that doesn't support -index-store-path option 20 | # set(CMAKE_XCODE_ATTRIBUTE_COMPILER_INDEX_STORE_ENABLE NO) 21 | 22 | if (UNIX) 23 | if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") 24 | add_compile_options(-stdlib=libc++) 25 | add_link_options(-stdlib=libc++ -fuse-ld=lld) 26 | endif() 27 | endif() 28 | 29 | add_compile_options(-ggdb3) 30 | # add_compile_options(-g0) 31 | 32 | add_compile_options(-O0 -fno-omit-frame-pointer) 33 | # add_compile_options(-fno-inline) 34 | 35 | # add_compile_options(-O3 -fvisibility=hidden -fvisibility-inlines-hidden -ffunction-sections -fdata-sections) 36 | # add_link_options(-Wl,-dead_strip) 37 | 38 | add_compile_options(-O0 -ggdb3 -fsanitize=address) 39 | add_link_options(-O0 -ggdb3 -fsanitize=address) 40 | 41 | # add_compile_options(-fsanitize=memory) 42 | # add_link_options(-fsanitize=memory) 43 | 44 | set(CMAKE_CXX_STANDARD 20) 45 | set(CMAKE_CXX_EXTENSIONS NO) 46 | 47 | add_subdirectory(libsurf) 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2023, Jevin Sweval 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # surf 2 | Surf - A digital waveform viewer for macOS 3 | -------------------------------------------------------------------------------- /Surf/Surf.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 56; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 093C7EB329771FF100190187 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 093C7EB229771FF100190187 /* AppDelegate.swift */; }; 11 | 093C7EB529771FF100190187 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 093C7EB429771FF100190187 /* ViewController.swift */; }; 12 | 093C7EB729771FF100190187 /* Document.swift in Sources */ = {isa = PBXBuildFile; fileRef = 093C7EB629771FF100190187 /* Document.swift */; }; 13 | 093C7EB929771FF200190187 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 093C7EB829771FF200190187 /* Assets.xcassets */; }; 14 | 093C7EBC29771FF200190187 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 093C7EBA29771FF200190187 /* Main.storyboard */; }; 15 | 093C7ECC297724A200190187 /* ReactiveCocoa in Frameworks */ = {isa = PBXBuildFile; productRef = 093C7ECB297724A200190187 /* ReactiveCocoa */; }; 16 | 093C7ECF297724BB00190187 /* ReactiveSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 093C7ECE297724BB00190187 /* ReactiveSwift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 093C7EAF29771FF100190187 /* Surf.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Surf.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 093C7EB229771FF100190187 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 22 | 093C7EB429771FF100190187 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 23 | 093C7EB629771FF100190187 /* Document.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Document.swift; sourceTree = ""; }; 24 | 093C7EB829771FF200190187 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 25 | 093C7EBB29771FF200190187 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 26 | 093C7EBD29771FF200190187 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 27 | 093C7EBE29771FF200190187 /* Surf.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Surf.entitlements; sourceTree = ""; }; 28 | /* End PBXFileReference section */ 29 | 30 | /* Begin PBXFrameworksBuildPhase section */ 31 | 093C7EAC29771FF100190187 /* Frameworks */ = { 32 | isa = PBXFrameworksBuildPhase; 33 | buildActionMask = 2147483647; 34 | files = ( 35 | 093C7ECC297724A200190187 /* ReactiveCocoa in Frameworks */, 36 | 093C7ECF297724BB00190187 /* ReactiveSwift in Frameworks */, 37 | ); 38 | runOnlyForDeploymentPostprocessing = 0; 39 | }; 40 | /* End PBXFrameworksBuildPhase section */ 41 | 42 | /* Begin PBXGroup section */ 43 | 093C7EA629771FF100190187 = { 44 | isa = PBXGroup; 45 | children = ( 46 | 093C7EB129771FF100190187 /* Surf */, 47 | 093C7EB029771FF100190187 /* Products */, 48 | ); 49 | sourceTree = ""; 50 | }; 51 | 093C7EB029771FF100190187 /* Products */ = { 52 | isa = PBXGroup; 53 | children = ( 54 | 093C7EAF29771FF100190187 /* Surf.app */, 55 | ); 56 | name = Products; 57 | sourceTree = ""; 58 | }; 59 | 093C7EB129771FF100190187 /* Surf */ = { 60 | isa = PBXGroup; 61 | children = ( 62 | 093C7EB229771FF100190187 /* AppDelegate.swift */, 63 | 093C7EB429771FF100190187 /* ViewController.swift */, 64 | 093C7EB629771FF100190187 /* Document.swift */, 65 | 093C7EB829771FF200190187 /* Assets.xcassets */, 66 | 093C7EBA29771FF200190187 /* Main.storyboard */, 67 | 093C7EBD29771FF200190187 /* Info.plist */, 68 | 093C7EBE29771FF200190187 /* Surf.entitlements */, 69 | ); 70 | path = Surf; 71 | sourceTree = ""; 72 | }; 73 | /* End PBXGroup section */ 74 | 75 | /* Begin PBXNativeTarget section */ 76 | 093C7EAE29771FF100190187 /* Surf */ = { 77 | isa = PBXNativeTarget; 78 | buildConfigurationList = 093C7EC129771FF200190187 /* Build configuration list for PBXNativeTarget "Surf" */; 79 | buildPhases = ( 80 | 093C7EAB29771FF100190187 /* Sources */, 81 | 093C7EAC29771FF100190187 /* Frameworks */, 82 | 093C7EAD29771FF100190187 /* Resources */, 83 | ); 84 | buildRules = ( 85 | ); 86 | dependencies = ( 87 | ); 88 | name = Surf; 89 | packageProductDependencies = ( 90 | 093C7ECB297724A200190187 /* ReactiveCocoa */, 91 | 093C7ECE297724BB00190187 /* ReactiveSwift */, 92 | ); 93 | productName = Surf; 94 | productReference = 093C7EAF29771FF100190187 /* Surf.app */; 95 | productType = "com.apple.product-type.application"; 96 | }; 97 | /* End PBXNativeTarget section */ 98 | 99 | /* Begin PBXProject section */ 100 | 093C7EA729771FF100190187 /* Project object */ = { 101 | isa = PBXProject; 102 | attributes = { 103 | BuildIndependentTargetsInParallel = 1; 104 | LastSwiftUpdateCheck = 1410; 105 | LastUpgradeCheck = 1410; 106 | TargetAttributes = { 107 | 093C7EAE29771FF100190187 = { 108 | CreatedOnToolsVersion = 14.1; 109 | }; 110 | }; 111 | }; 112 | buildConfigurationList = 093C7EAA29771FF100190187 /* Build configuration list for PBXProject "Surf" */; 113 | compatibilityVersion = "Xcode 14.0"; 114 | developmentRegion = en; 115 | hasScannedForEncodings = 0; 116 | knownRegions = ( 117 | en, 118 | Base, 119 | ); 120 | mainGroup = 093C7EA629771FF100190187; 121 | packageReferences = ( 122 | 093C7ECA297724A200190187 /* XCRemoteSwiftPackageReference "ReactiveCocoa" */, 123 | 093C7ECD297724BB00190187 /* XCRemoteSwiftPackageReference "ReactiveSwift" */, 124 | ); 125 | productRefGroup = 093C7EB029771FF100190187 /* Products */; 126 | projectDirPath = ""; 127 | projectRoot = ""; 128 | targets = ( 129 | 093C7EAE29771FF100190187 /* Surf */, 130 | ); 131 | }; 132 | /* End PBXProject section */ 133 | 134 | /* Begin PBXResourcesBuildPhase section */ 135 | 093C7EAD29771FF100190187 /* Resources */ = { 136 | isa = PBXResourcesBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | 093C7EB929771FF200190187 /* Assets.xcassets in Resources */, 140 | 093C7EBC29771FF200190187 /* Main.storyboard in Resources */, 141 | ); 142 | runOnlyForDeploymentPostprocessing = 0; 143 | }; 144 | /* End PBXResourcesBuildPhase section */ 145 | 146 | /* Begin PBXSourcesBuildPhase section */ 147 | 093C7EAB29771FF100190187 /* Sources */ = { 148 | isa = PBXSourcesBuildPhase; 149 | buildActionMask = 2147483647; 150 | files = ( 151 | 093C7EB529771FF100190187 /* ViewController.swift in Sources */, 152 | 093C7EB329771FF100190187 /* AppDelegate.swift in Sources */, 153 | 093C7EB729771FF100190187 /* Document.swift in Sources */, 154 | ); 155 | runOnlyForDeploymentPostprocessing = 0; 156 | }; 157 | /* End PBXSourcesBuildPhase section */ 158 | 159 | /* Begin PBXVariantGroup section */ 160 | 093C7EBA29771FF200190187 /* Main.storyboard */ = { 161 | isa = PBXVariantGroup; 162 | children = ( 163 | 093C7EBB29771FF200190187 /* Base */, 164 | ); 165 | name = Main.storyboard; 166 | sourceTree = ""; 167 | }; 168 | /* End PBXVariantGroup section */ 169 | 170 | /* Begin XCBuildConfiguration section */ 171 | 093C7EBF29771FF200190187 /* Debug */ = { 172 | isa = XCBuildConfiguration; 173 | buildSettings = { 174 | ALWAYS_SEARCH_USER_PATHS = NO; 175 | CLANG_ANALYZER_NONNULL = YES; 176 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 177 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 178 | CLANG_ENABLE_MODULES = YES; 179 | CLANG_ENABLE_OBJC_ARC = YES; 180 | CLANG_ENABLE_OBJC_WEAK = YES; 181 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 182 | CLANG_WARN_BOOL_CONVERSION = YES; 183 | CLANG_WARN_COMMA = YES; 184 | CLANG_WARN_CONSTANT_CONVERSION = YES; 185 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 186 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 187 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 188 | CLANG_WARN_EMPTY_BODY = YES; 189 | CLANG_WARN_ENUM_CONVERSION = YES; 190 | CLANG_WARN_INFINITE_RECURSION = YES; 191 | CLANG_WARN_INT_CONVERSION = YES; 192 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 193 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 194 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 195 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 196 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 197 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 198 | CLANG_WARN_STRICT_PROTOTYPES = YES; 199 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 200 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 201 | CLANG_WARN_UNREACHABLE_CODE = YES; 202 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 203 | COPY_PHASE_STRIP = NO; 204 | DEBUG_INFORMATION_FORMAT = dwarf; 205 | ENABLE_STRICT_OBJC_MSGSEND = YES; 206 | ENABLE_TESTABILITY = YES; 207 | GCC_C_LANGUAGE_STANDARD = gnu11; 208 | GCC_DYNAMIC_NO_PIC = NO; 209 | GCC_NO_COMMON_BLOCKS = YES; 210 | GCC_OPTIMIZATION_LEVEL = 0; 211 | GCC_PREPROCESSOR_DEFINITIONS = ( 212 | "DEBUG=1", 213 | "$(inherited)", 214 | ); 215 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 216 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 217 | GCC_WARN_UNDECLARED_SELECTOR = YES; 218 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 219 | GCC_WARN_UNUSED_FUNCTION = YES; 220 | GCC_WARN_UNUSED_VARIABLE = YES; 221 | MACOSX_DEPLOYMENT_TARGET = 13.0; 222 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 223 | MTL_FAST_MATH = YES; 224 | ONLY_ACTIVE_ARCH = YES; 225 | SDKROOT = macosx; 226 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 227 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 228 | }; 229 | name = Debug; 230 | }; 231 | 093C7EC029771FF200190187 /* Release */ = { 232 | isa = XCBuildConfiguration; 233 | buildSettings = { 234 | ALWAYS_SEARCH_USER_PATHS = NO; 235 | CLANG_ANALYZER_NONNULL = YES; 236 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 237 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 238 | CLANG_ENABLE_MODULES = YES; 239 | CLANG_ENABLE_OBJC_ARC = YES; 240 | CLANG_ENABLE_OBJC_WEAK = YES; 241 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 242 | CLANG_WARN_BOOL_CONVERSION = YES; 243 | CLANG_WARN_COMMA = YES; 244 | CLANG_WARN_CONSTANT_CONVERSION = YES; 245 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 246 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 247 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 248 | CLANG_WARN_EMPTY_BODY = YES; 249 | CLANG_WARN_ENUM_CONVERSION = YES; 250 | CLANG_WARN_INFINITE_RECURSION = YES; 251 | CLANG_WARN_INT_CONVERSION = YES; 252 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 253 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 254 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 255 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 256 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 257 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 258 | CLANG_WARN_STRICT_PROTOTYPES = YES; 259 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 260 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 261 | CLANG_WARN_UNREACHABLE_CODE = YES; 262 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 263 | COPY_PHASE_STRIP = NO; 264 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 265 | ENABLE_NS_ASSERTIONS = NO; 266 | ENABLE_STRICT_OBJC_MSGSEND = YES; 267 | GCC_C_LANGUAGE_STANDARD = gnu11; 268 | GCC_NO_COMMON_BLOCKS = YES; 269 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 270 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 271 | GCC_WARN_UNDECLARED_SELECTOR = YES; 272 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 273 | GCC_WARN_UNUSED_FUNCTION = YES; 274 | GCC_WARN_UNUSED_VARIABLE = YES; 275 | MACOSX_DEPLOYMENT_TARGET = 13.0; 276 | MTL_ENABLE_DEBUG_INFO = NO; 277 | MTL_FAST_MATH = YES; 278 | SDKROOT = macosx; 279 | SWIFT_COMPILATION_MODE = wholemodule; 280 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 281 | }; 282 | name = Release; 283 | }; 284 | 093C7EC229771FF200190187 /* Debug */ = { 285 | isa = XCBuildConfiguration; 286 | buildSettings = { 287 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 288 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 289 | CODE_SIGN_ENTITLEMENTS = Surf/Surf.entitlements; 290 | CODE_SIGN_STYLE = Automatic; 291 | COMBINE_HIDPI_IMAGES = YES; 292 | CURRENT_PROJECT_VERSION = 1; 293 | DEVELOPMENT_TEAM = ZK96P738ZR; 294 | ENABLE_HARDENED_RUNTIME = YES; 295 | GENERATE_INFOPLIST_FILE = YES; 296 | INFOPLIST_FILE = Surf/Info.plist; 297 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 298 | INFOPLIST_KEY_NSMainStoryboardFile = Main; 299 | INFOPLIST_KEY_NSPrincipalClass = NSApplication; 300 | LD_RUNPATH_SEARCH_PATHS = ( 301 | "$(inherited)", 302 | "@executable_path/../Frameworks", 303 | ); 304 | MARKETING_VERSION = 1.0; 305 | PRODUCT_BUNDLE_IDENTIFIER = vin.je.Surf; 306 | PRODUCT_NAME = "$(TARGET_NAME)"; 307 | SWIFT_EMIT_LOC_STRINGS = YES; 308 | SWIFT_VERSION = 5.0; 309 | }; 310 | name = Debug; 311 | }; 312 | 093C7EC329771FF200190187 /* Release */ = { 313 | isa = XCBuildConfiguration; 314 | buildSettings = { 315 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 316 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 317 | CODE_SIGN_ENTITLEMENTS = Surf/Surf.entitlements; 318 | CODE_SIGN_STYLE = Automatic; 319 | COMBINE_HIDPI_IMAGES = YES; 320 | CURRENT_PROJECT_VERSION = 1; 321 | DEVELOPMENT_TEAM = ZK96P738ZR; 322 | ENABLE_HARDENED_RUNTIME = YES; 323 | GENERATE_INFOPLIST_FILE = YES; 324 | INFOPLIST_FILE = Surf/Info.plist; 325 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 326 | INFOPLIST_KEY_NSMainStoryboardFile = Main; 327 | INFOPLIST_KEY_NSPrincipalClass = NSApplication; 328 | LD_RUNPATH_SEARCH_PATHS = ( 329 | "$(inherited)", 330 | "@executable_path/../Frameworks", 331 | ); 332 | MARKETING_VERSION = 1.0; 333 | PRODUCT_BUNDLE_IDENTIFIER = vin.je.Surf; 334 | PRODUCT_NAME = "$(TARGET_NAME)"; 335 | SWIFT_EMIT_LOC_STRINGS = YES; 336 | SWIFT_VERSION = 5.0; 337 | }; 338 | name = Release; 339 | }; 340 | /* End XCBuildConfiguration section */ 341 | 342 | /* Begin XCConfigurationList section */ 343 | 093C7EAA29771FF100190187 /* Build configuration list for PBXProject "Surf" */ = { 344 | isa = XCConfigurationList; 345 | buildConfigurations = ( 346 | 093C7EBF29771FF200190187 /* Debug */, 347 | 093C7EC029771FF200190187 /* Release */, 348 | ); 349 | defaultConfigurationIsVisible = 0; 350 | defaultConfigurationName = Release; 351 | }; 352 | 093C7EC129771FF200190187 /* Build configuration list for PBXNativeTarget "Surf" */ = { 353 | isa = XCConfigurationList; 354 | buildConfigurations = ( 355 | 093C7EC229771FF200190187 /* Debug */, 356 | 093C7EC329771FF200190187 /* Release */, 357 | ); 358 | defaultConfigurationIsVisible = 0; 359 | defaultConfigurationName = Release; 360 | }; 361 | /* End XCConfigurationList section */ 362 | 363 | /* Begin XCRemoteSwiftPackageReference section */ 364 | 093C7ECA297724A200190187 /* XCRemoteSwiftPackageReference "ReactiveCocoa" */ = { 365 | isa = XCRemoteSwiftPackageReference; 366 | repositoryURL = "https://github.com/ReactiveCocoa/ReactiveCocoa"; 367 | requirement = { 368 | branch = master; 369 | kind = branch; 370 | }; 371 | }; 372 | 093C7ECD297724BB00190187 /* XCRemoteSwiftPackageReference "ReactiveSwift" */ = { 373 | isa = XCRemoteSwiftPackageReference; 374 | repositoryURL = "https://github.com/ReactiveCocoa/ReactiveSwift"; 375 | requirement = { 376 | branch = master; 377 | kind = branch; 378 | }; 379 | }; 380 | /* End XCRemoteSwiftPackageReference section */ 381 | 382 | /* Begin XCSwiftPackageProductDependency section */ 383 | 093C7ECB297724A200190187 /* ReactiveCocoa */ = { 384 | isa = XCSwiftPackageProductDependency; 385 | package = 093C7ECA297724A200190187 /* XCRemoteSwiftPackageReference "ReactiveCocoa" */; 386 | productName = ReactiveCocoa; 387 | }; 388 | 093C7ECE297724BB00190187 /* ReactiveSwift */ = { 389 | isa = XCSwiftPackageProductDependency; 390 | package = 093C7ECD297724BB00190187 /* XCRemoteSwiftPackageReference "ReactiveSwift" */; 391 | productName = ReactiveSwift; 392 | }; 393 | /* End XCSwiftPackageProductDependency section */ 394 | }; 395 | rootObject = 093C7EA729771FF100190187 /* Project object */; 396 | } 397 | -------------------------------------------------------------------------------- /Surf/Surf.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Surf/Surf.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Surf/Surf.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "pins" : [ 3 | { 4 | "identity" : "reactivecocoa", 5 | "kind" : "remoteSourceControl", 6 | "location" : "https://github.com/ReactiveCocoa/ReactiveCocoa", 7 | "state" : { 8 | "branch" : "master", 9 | "revision" : "1e7e5191445d65ee26aeacf583dcdb70bf49f70e" 10 | } 11 | }, 12 | { 13 | "identity" : "reactiveswift", 14 | "kind" : "remoteSourceControl", 15 | "location" : "https://github.com/ReactiveCocoa/ReactiveSwift", 16 | "state" : { 17 | "branch" : "master", 18 | "revision" : "6b38733fd59caac8b4cbe035bbcc3cdbe0fc5037" 19 | } 20 | } 21 | ], 22 | "version" : 2 23 | } 24 | -------------------------------------------------------------------------------- /Surf/Surf/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Surf 4 | // 5 | // Created by Jevin Sweval on 1/17/23. 6 | // 7 | 8 | import Cocoa 9 | 10 | @main 11 | class AppDelegate: NSObject, NSApplicationDelegate { 12 | 13 | func applicationDidFinishLaunching(_ aNotification: Notification) { 14 | // Insert code here to initialize your application 15 | } 16 | 17 | func applicationWillTerminate(_ aNotification: Notification) { 18 | // Insert code here to tear down your application 19 | } 20 | 21 | func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { 22 | return true 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Surf/Surf/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Surf/Surf/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "scale" : "1x", 6 | "size" : "16x16" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "scale" : "2x", 11 | "size" : "16x16" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "scale" : "1x", 16 | "size" : "32x32" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "scale" : "2x", 21 | "size" : "32x32" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "scale" : "1x", 26 | "size" : "128x128" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "scale" : "2x", 31 | "size" : "128x128" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "scale" : "1x", 36 | "size" : "256x256" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "scale" : "2x", 41 | "size" : "256x256" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "scale" : "1x", 46 | "size" : "512x512" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "scale" : "2x", 51 | "size" : "512x512" 52 | } 53 | ], 54 | "info" : { 55 | "author" : "xcode", 56 | "version" : 1 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Surf/Surf/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Surf/Surf/Document.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Document.swift 3 | // Surf 4 | // 5 | // Created by Jevin Sweval on 1/17/23. 6 | // 7 | 8 | import Cocoa 9 | 10 | class Document: NSDocument { 11 | 12 | override init() { 13 | super.init() 14 | // Add your subclass-specific initialization here. 15 | } 16 | 17 | override class var autosavesInPlace: Bool { 18 | return true 19 | } 20 | 21 | override func makeWindowControllers() { 22 | // Returns the Storyboard that contains your Document window. 23 | let storyboard = NSStoryboard(name: NSStoryboard.Name("Main"), bundle: nil) 24 | let windowController = 25 | storyboard.instantiateController( 26 | withIdentifier: NSStoryboard.SceneIdentifier("Document Window Controller")) 27 | as! NSWindowController 28 | self.addWindowController(windowController) 29 | } 30 | 31 | override func data(ofType typeName: String) throws -> Data { 32 | // Insert code here to write your document to data of the specified type, throwing an error in case of failure. 33 | // Alternatively, you could remove this method and override fileWrapper(ofType:), write(to:ofType:), or write(to:ofType:for:originalContentsURL:) instead. 34 | throw NSError(domain: NSOSStatusErrorDomain, code: unimpErr, userInfo: nil) 35 | } 36 | 37 | override func read(from data: Data, ofType typeName: String) throws { 38 | // Insert code here to read your document from the given data of the specified type, throwing an error in case of failure. 39 | // Alternatively, you could remove this method and override read(from:ofType:) instead. 40 | // If you do, you should also override isEntireFileLoaded to return false if the contents are lazily loaded. 41 | throw NSError(domain: NSOSStatusErrorDomain, code: unimpErr, userInfo: nil) 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Surf/Surf/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDocumentTypes 6 | 7 | 8 | CFBundleTypeRole 9 | Editor 10 | LSItemContentTypes 11 | 12 | com.example.plain-text 13 | 14 | NSDocumentClass 15 | $(PRODUCT_MODULE_NAME).Document 16 | 17 | 18 | UTImportedTypeDeclarations 19 | 20 | 21 | UTTypeConformsTo 22 | 23 | public.plain-text 24 | 25 | UTTypeDescription 26 | Example Text 27 | UTTypeIdentifier 28 | com.example.plain-text 29 | UTTypeTagSpecification 30 | 31 | public.filename-extension 32 | 33 | exampletext 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Surf/Surf/Surf.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Surf/Surf/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Surf 4 | // 5 | // Created by Jevin Sweval on 1/17/23. 6 | // 7 | 8 | import Cocoa 9 | import ReactiveCocoa 10 | import ReactiveSwift 11 | 12 | extension Reactive where Base: CALayer { 13 | 14 | // Provided for cross-platform compatibility 15 | 16 | // public var transformValue: BindingTarget { return transform } 17 | // public var transformValues: Signal { return floatValues } 18 | } 19 | 20 | class ViewController: NSViewController { 21 | @IBOutlet weak var label: NSTextField! 22 | @IBOutlet weak var slider: NSSlider! 23 | 24 | override func viewDidLoad() { 25 | super.viewDidLoad() 26 | 27 | let (signal, observer) = Signal.pipe() 28 | // signal 29 | slider.reactive.values 30 | .observeValues { value in print(value) } 31 | label.layer?.transform = CATransform3DMakeAffineTransform(CGAffineTransform(rotationAngle: 0.5 * 2 * 3.14)) 32 | // label.layer?.reactive.transform <~ slider.reactive.values.map { value in CGAffineTransform(rotationAngle: value * 2 * 3.14) } 33 | } 34 | 35 | override var representedObject: Any? { 36 | didSet { 37 | // Update the view, if already loaded. 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /doc/img/DALL·E 2023-01-05 15.04.59 - an apple-style macOS application icon displaying the wave from The Great Wave off Kanagawa. there are no rounded corners or borders. there are no edge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/DALL·E 2023-01-05 15.04.59 - an apple-style macOS application icon displaying the wave from The Great Wave off Kanagawa. there are no rounded corners or borders. there are no edge.png -------------------------------------------------------------------------------- /doc/img/build-icon.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | rm -Rf Surf.iconset 4 | mkdir Surf.iconset 5 | sips -z 16 16 icon-1024.png --out Surf.iconset/icon_16x16.png 6 | sips -z 32 32 icon-1024.png --out Surf.iconset/icon_16x16@2x.png 7 | sips -z 32 32 icon-1024.png --out Surf.iconset/icon_32x32.png 8 | sips -z 64 64 icon-1024.png --out Surf.iconset/icon_32x32@2x.png 9 | sips -z 128 128 icon-1024.png --out Surf.iconset/icon_128x128.png 10 | sips -z 256 256 icon-1024.png --out Surf.iconset/icon_128x128@2x.png 11 | sips -z 256 256 icon-1024.png --out Surf.iconset/icon_256x256.png 12 | sips -z 512 512 icon-1024.png --out Surf.iconset/icon_256x256@2x.png 13 | sips -z 512 512 icon-1024.png --out Surf.iconset/icon_512x512.png 14 | cp icon-1024.png Surf.iconset/icon_512x512@2x.png 15 | # iconutil -c iconset Surf.iconset 16 | # rm -R Surf.iconset -------------------------------------------------------------------------------- /doc/img/icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/icon-1024.png -------------------------------------------------------------------------------- /doc/img/icon-1024/AppIcon.iconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "icon_16x16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "icon_16x16@2x.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "icon_32x32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "icon_32x32@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "icon_128x128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "icon_128x128@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "icon_256x256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "icon_256x256@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "icon_512x512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "icon_512x512@2x.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /doc/img/icon-1024/AppIcon.iconset/Icon : -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/icon-1024/AppIcon.iconset/Icon -------------------------------------------------------------------------------- /doc/img/icon-1024/AppIcon.iconset/icon_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/icon-1024/AppIcon.iconset/icon_128x128.png -------------------------------------------------------------------------------- /doc/img/icon-1024/AppIcon.iconset/icon_128x128@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/icon-1024/AppIcon.iconset/icon_128x128@2x.png -------------------------------------------------------------------------------- /doc/img/icon-1024/AppIcon.iconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/icon-1024/AppIcon.iconset/icon_16x16.png -------------------------------------------------------------------------------- /doc/img/icon-1024/AppIcon.iconset/icon_16x16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/icon-1024/AppIcon.iconset/icon_16x16@2x.png -------------------------------------------------------------------------------- /doc/img/icon-1024/AppIcon.iconset/icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/icon-1024/AppIcon.iconset/icon_256x256.png -------------------------------------------------------------------------------- /doc/img/icon-1024/AppIcon.iconset/icon_256x256@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/icon-1024/AppIcon.iconset/icon_256x256@2x.png -------------------------------------------------------------------------------- /doc/img/icon-1024/AppIcon.iconset/icon_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/icon-1024/AppIcon.iconset/icon_32x32.png -------------------------------------------------------------------------------- /doc/img/icon-1024/AppIcon.iconset/icon_32x32@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/icon-1024/AppIcon.iconset/icon_32x32@2x.png -------------------------------------------------------------------------------- /doc/img/icon-1024/AppIcon.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/icon-1024/AppIcon.iconset/icon_512x512.png -------------------------------------------------------------------------------- /doc/img/icon-1024/AppIcon.iconset/icon_512x512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/icon-1024/AppIcon.iconset/icon_512x512@2x.png -------------------------------------------------------------------------------- /doc/img/icon.afdesign: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/icon.afdesign -------------------------------------------------------------------------------- /doc/img/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /doc/img/vectorized-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 12 | 13 | 35 | 36 | 228 | 229 | 441 | 442 | 688 | 689 | 949 | 950 | 951 | 952 | -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-1024.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-1024/waveform.iconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "icon_16x16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "icon_16x16@2x.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "icon_32x32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "icon_32x32@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "icon_128x128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "icon_128x128@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "icon_256x256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "icon_256x256@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "icon_512x512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "icon_512x512@2x.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-1024/waveform.iconset/icon_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-1024/waveform.iconset/icon_128x128.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-1024/waveform.iconset/icon_128x128@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-1024/waveform.iconset/icon_128x128@2x.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-1024/waveform.iconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-1024/waveform.iconset/icon_16x16.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-1024/waveform.iconset/icon_16x16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-1024/waveform.iconset/icon_16x16@2x.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-1024/waveform.iconset/icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-1024/waveform.iconset/icon_256x256.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-1024/waveform.iconset/icon_256x256@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-1024/waveform.iconset/icon_256x256@2x.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-1024/waveform.iconset/icon_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-1024/waveform.iconset/icon_32x32.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-1024/waveform.iconset/icon_32x32@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-1024/waveform.iconset/icon_32x32@2x.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-1024/waveform.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-1024/waveform.iconset/icon_512x512.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-1024/waveform.iconset/icon_512x512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-1024/waveform.iconset/icon_512x512@2x.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "icon_16x16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "icon_16x16@2x.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "icon_32x32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "icon_32x32@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "icon_128x128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "icon_128x128@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "icon_256x256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "icon_256x256@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "icon_512x512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "icon_512x512@2x.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_128x128.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_128x128@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_128x128@2x.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_16x16.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_16x16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_16x16@2x.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_256x256.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_256x256@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_256x256@2x.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_32x32.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_32x32@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_32x32@2x.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_512x512.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_512x512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon-plain-1024/waveform-plain.iconset/icon_512x512@2x.png -------------------------------------------------------------------------------- /doc/img/waveform-file-icon.afdesign: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/img/waveform-file-icon.afdesign -------------------------------------------------------------------------------- /doc/img/waveform-file-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /doc/misc-notes.txt: -------------------------------------------------------------------------------- 1 | 2 | https://en.m.wikipedia.org/wiki/Downsampling_(signal_processing) 3 | 4 | Similar to instruction trace encoding problem 5 | 6 | Objectives: 7 | Dump fast to a core doing Zstd compression to a file for minimal simulation speed 8 | Do indexing/downsamling after the fact with a library/tool. The GUI will automatically index at load if file wasn’t post processed. 9 | 10 | 11 | 12 | Ring buffer mmap? ( ͡° ͜ʖ ͡°) 13 | 14 | Search speed up 15 | Downsampling produces set of seen values up to N values with overflow tag 16 | 17 | 18 | Cool little inset of an example piece of activity for that segment of the waveform when its otherwise solid green bar 19 | 20 | 21 | Components 22 | Render accurately region R to texture size TS 23 | 24 | Render single signal from [a,b] to a color 25 | Get signal changes in [a, b] 26 | 27 | Map pixel corners to start/end time 28 | Map an time to nearest change 29 | 30 | 31 | 32 | Insight: can paint no change, rise-or-fall, toggle. 33 | Rock paper scissors until you no longer need to check that pixel 34 | 35 | # Changes in Pixel Bounds 36 | 0 37 | Changes in Pixel Bounds 38 | 39 | 40 | 41 | For each pixel: 42 | Int n = EMPTY 43 | Bool done = false 44 | 45 | For change and not done in pixel.region.changes: 46 | If n == EMPTY 47 | n = CHANGED 48 | break 49 | If n == CHANGED: 50 | n = TOGGLE 51 | done = true 52 | break 53 | 54 | Dark green indicates toggle beyond resolution 55 | 56 | If a signal blips, green should be drawn not red 57 | 58 | 59 | 60 | 61 | 62 | Compressed integer stores 63 | Running from either end gets you what? Dual indexing? 64 | 65 | 66 | Cache full-view, zoomed out version since it takes the longest to render and is the default goto 67 | 68 | 69 | .swvf bundle 70 | 71 | 72 | Dump-first approach 73 | 74 | Idea is to have low overhead trace that streams to a dump file. The dump file will be mmaped by surf and randomly accessed. 75 | 76 | Transformation of the low overhead format to another format for fast rendering should be avoided. Surf should decode the data on the fly at runtime. 77 | 78 | Bah I forgot about dump first. Ok 79 | 80 | Minimal: 81 | Time stamp 82 | [ 83 | 16 bit signal id 84 | Value (or delta) packed 85 | ] 86 | 87 | Minimal 2: 88 | Time stamp 89 | [ 90 | 16 bit signal id 91 | ] 92 | [ 93 | Values (or deltas) packed 94 | ] 95 | 96 | Indexed: 97 | Time stamp 98 | [ 99 | 16 bit signal id 100 | ] 101 | [ 102 | Value offsets 103 | ] 104 | [ 105 | Values (variable length packed) 106 | ] 107 | 108 | How to use zstd with all of this. 109 | 110 | Using zstd removes naive/stupid easy random access. 111 | 112 | Key is to be able to seek close enough to a sync block (if using deltas, it includes/followed by all values dumped), decompress and process on the fly before either discarding the data again or putting it in a LRU cache 113 | 114 | There’s only so many horizontal pixels to render after all… right? Can you seek and zstd decompress 4k pixels at a time? 115 | 116 | -------------------------------------------------------------------------------- /doc/surf-trace-format.md: -------------------------------------------------------------------------------- 1 | # surf trace format 2 | 3 | ## Objectives 4 | *insert out-of-three-pick-two joke here* 5 | 6 | Minimal: 7 | ```c 8 | struct value_change_log { 9 | uint16_t signal_id; 10 | Value signal_val; 11 | }; 12 | struct tick_log { 13 | uint64_t tick; 14 | uint16_t num_changes; 15 | value_change_log changes[num_changes]; 16 | }; 17 | ``` 18 | 19 | Minimal alternative: 20 | ```c 21 | struct tick_log { 22 | uint64_t tick; 23 | uint16_t num_changes; 24 | uint16_t signal_ids[num_changes]; 25 | Value changes[num_changes]; 26 | }; 27 | ``` 28 | 29 | Indexed: 30 | ```c 31 | struct tick_log { 32 | uint64_t tick; 33 | uint16_t num_changes; 34 | uint16_t signal_ids[num_changes]; 35 | uint32_t value_bit_offsets[num_changes]; 36 | uint8_t value_bit_buf[]; 37 | }; 38 | ``` 39 | 40 | ```c++ 41 | void dump_tick(struct tick_log *t) { 42 | auto nc = t->num_changes; 43 | for (auto i = 0; i < num_changes; ++i) { 44 | auto id = t->signal_ids[i]; 45 | auto voff = t->value_bit_offsets[i]; 46 | Value val = decode_val(t->value_bit_buf, voff); 47 | fmt::print("v: {}\n", val); 48 | } 49 | } 50 | ``` -------------------------------------------------------------------------------- /doc/varbit-layout.numbers: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/varbit-layout.numbers -------------------------------------------------------------------------------- /doc/varbit-layout.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/doc/varbit-layout.pdf -------------------------------------------------------------------------------- /doc/vcd-grammar.abnf: -------------------------------------------------------------------------------- 1 | value-change-dump = *declaration-command *(ws declaration-command) ws *simulation-command *(ws simulation-command) 2 | declaration-command = 3 | "$comment" ws comment-text ws "$end" 4 | / "$date" ws date-text ws "$end" 5 | / "$enddefinitions" ws "$end" 6 | / "$scope" ws scope-type ws scope-identifier ws "$end" 7 | / "$timescale" ws time-number ws time-unit ws "$end" 8 | / "$upscope" ws "$end" 9 | / "$var" ws var-type ws size ws identifier-code ws reference ws "$end" 10 | / "$version" ws version-text system-task ws "$end" 11 | simulation-command = 12 | "$dumpall" ws 1*value-change ws "$end" 13 | / "$dumpoff" ws 1*value-change ws "$end" 14 | / "$dumpon" ws 1*value-change ws "$end" 15 | / "$dumpvars" ws 1*value-change ws "$end" 16 | / "$comment" ws comment-text ws "$end" 17 | / simulation-time 18 | / value-change 19 | scope-type = 20 | "begin" 21 | / "fork" 22 | / "function" 23 | / "module" 24 | / "task" 25 | time-number = "1" / "10" / "100" 26 | time-unit = "s" / "ms" / "us" / "ns" / "ps" / "fs" 27 | var-type = "event" / "integer" / "parameter" / "real" / "realtime" / "reg" / "supply0" / "supply1" / "time" / "tri" / "triand" / "trior" / "trireg" / "tri0" / "tri1" / "wand" / "wire" / "wor" 28 | simulation-time = "#" decimal-number 29 | value-change = scalar-value-change / vector-value-change 30 | scalar-value-change = value identifier-code 31 | value = "0" / "1" / "x" / "X" / "z" / "Z" 32 | vector-value-change = 33 | "b" binary-number identifier-code 34 | / "B" binary-number identifier-code 35 | / "r" real-number identifier-code 36 | / "R" real-number identifier-code 37 | identifier-code = 1*ascii-char 38 | size = decimal-number 39 | reference = 40 | identifier 41 | / identifier "[" bit-select-index"]" 42 | / identifier "[" msb-index ":" lsb-index "]" 43 | index = decimal-number 44 | ascii-char = %x20-7f 45 | scope-identifier = 1*ascii-char 46 | comment-text = 1*ascii-char 47 | date-text = 1*ascii-char 48 | version-text = 1*ascii-char 49 | system-task = "$" 1*ascii-char 50 | decimal-number = [ "+" / "-" ] 1*("0" / "1" / "2" / "3" / "4" / "5"/ "6" / "7" / "8" / "9") 51 | binary-number = 1*("0" / "1") 52 | real-number = [ "+" / "-" ] 1*decimal-number [ "." 1*decimal-number ] 53 | identifier = 1*ascii-char 54 | bit-select-index = decimal-number 55 | msb-index = decimal-number 56 | lsb-index = decimal-number 57 | ws = 1*wsp 58 | -------------------------------------------------------------------------------- /doc/vcd-grammar.ebnf: -------------------------------------------------------------------------------- 1 | value_change_dump_definitions ::= declaration_command* simulation_command* 2 | declaration_command ::= 3 | "$comment" comment_text "$end" 4 | | "$date" date_text "$end" 5 | | "$enddefinitions" "$end" 6 | | "$scope" scope_type scope_identifier "$end" 7 | | "$timescale" time_number time_unit "$end" 8 | | "$upscope" "$end" 9 | | "$var" var_type size identifier_code reference "$end" 10 | | "$version" version_text system_task "$end" 11 | simulation_command ::= 12 | "$dumpall" value_change+ "$end" 13 | | "$dumpoff" value_change+ "$end" 14 | | "$dumpon" value_change+ "$end" 15 | | "$dumpvars" value_change+ "$end" 16 | | "$comment" comment_text "$end" 17 | | simulation_time 18 | | value_change 19 | scope_type ::= 20 | "begin" 21 | | "fork" 22 | | "function" 23 | | "module" 24 | | "task" 25 | time_number ::= "1" | "10" | "100" 26 | time_unit ::= "s" | "ms" | "us" | "ns" | "ps" | "fs" 27 | var_type ::= "event" | "integer" | "parameter" | "real" | "realtime" | "reg" | "supply0" | "supply1" | "time" | "tri" | "triand" | "trior" | "trireg" | "tri0" | "tri1" | "wand" | "wire" | "wor" 28 | simulation_time ::= "#" decimal_number 29 | value_change ::= scalar_value_change | vector_value_change 30 | scalar_value_change ::= value identifier_code 31 | value ::= "0" | "1" | "x" | "X" | "z" | "Z" 32 | vector_value_change ::= 33 | "b" binary_number identifier_code 34 | | "B" binary_number identifier_code 35 | | "r" real_number identifier_code 36 | | "R" real_number identifier_code 37 | identifier_code ::= .+ 38 | size ::= decimal_number 39 | reference ::= 40 | identifier 41 | | identifier "[" bit_select_index"]" 42 | | identifier "[" msb_index ":" lsb_index "]" 43 | index ::= decimal_number 44 | scope_identifier ::= .+ 45 | comment_text ::= .+ 46 | date_text ::= .+ 47 | version_text ::= .+ 48 | system_task ::= "$" .+ -------------------------------------------------------------------------------- /doc/vcd-grammar.lbnf: -------------------------------------------------------------------------------- 1 | value_change_dump_definitions ::= declaration_command* simulation_command* 2 | declaration_command ::= 3 | "$comment" comment_text "$end" 4 | | "$date" date_text "$end" 5 | | "$enddefinitions" "$end" 6 | | "$scope" scope_type scope_identifier "$end" 7 | | "$timescale" time_number time_unit "$end" 8 | | "$upscope" "$end" 9 | | "$var" var_type size identifier_code reference "$end" 10 | | "$version" version_text system_task "$end" 11 | simulation_command ::= 12 | "$dumpall" value_change+ "$end" 13 | | "$dumpoff" value_change+ "$end" 14 | | "$dumpon" value_change+ "$end" 15 | | "$dumpvars" value_change+ "$end" 16 | | "$comment" comment_text "$end" 17 | | simulation_time 18 | | value_change 19 | scope_type ::= 20 | "begin" 21 | | "fork" 22 | | "function" 23 | | "module" 24 | | "task" 25 | time_number ::= "1" | "10" | "100" 26 | time_unit ::= "s" | "ms" | "us" | "ns" | "ps" | "fs" 27 | var_type ::= "event" | "integer" | "parameter" | "real" | "realtime" | "reg" | "supply0" | "supply1" | "time" | "tri" | "triand" | "trior" | "trireg" | "tri0" | "tri1" | "wand" | "wire" | "wor" 28 | simulation_time ::= "#" decimal_number 29 | value_change ::= scalar_value_change | vector_value_change 30 | scalar_value_change ::= value identifier_code 31 | value ::= "0" | "1" | "x" | "X" | "z" | "Z" 32 | vector_value_change ::= 33 | "b" binary_number identifier_code 34 | | "B" binary_number identifier_code 35 | | "r" real_number identifier_code 36 | | "R" real_number identifier_code 37 | identifier_code ::= .+ 38 | size ::= decimal_number 39 | reference ::= 40 | identifier 41 | | identifier "[" bit_select_index"]" 42 | | identifier "[" msb_index ":" lsb_index "]" 43 | index ::= decimal_number 44 | scope_identifier ::= .+ 45 | comment_text ::= .+ 46 | date_text ::= .+ 47 | version_text ::= .+ 48 | system_task ::= "$" .+ -------------------------------------------------------------------------------- /libsurf/3rdparty/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(argparse) 2 | 3 | add_subdirectory(Catch2) 4 | 5 | option(FMT_DOC OFF) 6 | option(FMT_TEST OFF) 7 | option(FMT_INSTALL OFF) 8 | add_subdirectory(fmt) 9 | 10 | add_library(fpng fpng/src/fpng.cpp fpng/src/fpng.h) 11 | target_compile_options(fpng PRIVATE -Wno-tautological-constant-out-of-range-compare) 12 | if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") 13 | target_compile_options(fpng PRIVATE -msse4.1 -mpclmul) 14 | endif() 15 | 16 | set_target_properties(fpng PROPERTIES PUBLIC_HEADER fpng-scoped-include/fpng.h) 17 | target_include_directories(fpng PUBLIC fpng-scoped-include) 18 | 19 | 20 | add_library(hedley INTERFACE) 21 | target_include_directories(hedley INTERFACE hedley-scoped-include) 22 | 23 | add_subdirectory(lexy) 24 | add_subdirectory(magic_enum) 25 | 26 | add_library(mz_tagged_ptr INTERFACE) 27 | target_include_directories(mz_tagged_ptr INTERFACE tagged_ptr/include) 28 | add_library(mz::tagged_ptr ALIAS mz_tagged_ptr) 29 | 30 | add_library(thread-pool INTERFACE) 31 | target_include_directories(thread-pool INTERFACE thread-pool) 32 | 33 | add_subdirectory(visit) 34 | -------------------------------------------------------------------------------- /libsurf/3rdparty/fpng-scoped-include/fpng.h: -------------------------------------------------------------------------------- 1 | ../fpng/src/fpng.h -------------------------------------------------------------------------------- /libsurf/3rdparty/hedley-scoped-include/hedley.h: -------------------------------------------------------------------------------- 1 | ../hedley/hedley.h -------------------------------------------------------------------------------- /libsurf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(3rdparty) 2 | add_subdirectory(lib) 3 | add_subdirectory(test) 4 | add_subdirectory(tools) 5 | add_subdirectory(unit-tests) 6 | -------------------------------------------------------------------------------- /libsurf/include/surf/common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #ifdef __linux__ 23 | #define SURF_LINUX 24 | #endif 25 | #ifdef _WIN32 26 | #define SURF_WIN 27 | #endif 28 | #ifdef __APPLE__ 29 | #define SURF_APPLE 30 | #endif 31 | 32 | #define SURF_EXPORT __attribute__((visibility("default"))) 33 | #define SURF_INLINE __attribute__((always_inline)) 34 | // #define SURF_INLINE 35 | #define SURF_NOINLINE __attribute__((noinline)) 36 | #define SURF_LIKELY(cond) __builtin_expect(!!(cond), 1) 37 | #define SURF_UNLIKELY(cond) __builtin_expect(!!(cond), 0) 38 | #define SURF_BREAK() __builtin_debugtrap() 39 | #define SURF_ALIGNED(n) __attribute__((aligned(n))) 40 | #define SURF_ASSUME_ALIGNED(ptr, n) __builtin_assume_aligned((ptr), (n)) 41 | #define SURF_UNREACHABLE() __builtin_unreachable() 42 | 43 | #if defined(__GNUC__) || defined(__clang__) 44 | #define SURF_PACKED __attribute__((packed)) 45 | #elif defined(_MSC_VER) 46 | #define SURF_PACKED __declspec(align(1)) 47 | #else 48 | #warning "Compiler does not support packed attribute." 49 | #define SURF_PACKED 50 | #endif 51 | 52 | #define SURF_SCA static constexpr auto 53 | 54 | #define SURF_EMPTY_SYM "∅" 55 | #define SURF_TRUE_SYM "✅" 56 | #define SURF_FALSE_SYM "❌" 57 | 58 | #if defined(__aarch64__) && __has_include() 59 | #define SURF_A64_NEON 60 | #endif 61 | 62 | namespace surf { 63 | 64 | constexpr auto pow2(uint8_t n) { 65 | return 1 << n; 66 | } 67 | 68 | constexpr auto pow2_mask(uint8_t n) { 69 | return pow2(n) - 1; 70 | } 71 | 72 | template constexpr bool is_pow2(T num) { 73 | return std::popcount(num) == 1; 74 | } 75 | 76 | // behavior: 77 | // roundup_pow2_mul(16, 16) = 16 78 | // roundup_pow2_mul(17, 16) = 32 79 | template 80 | requires requires() { requires std::unsigned_integral; } 81 | constexpr U roundup_pow2_mul(U num, size_t pow2_mul) { 82 | const U mask = static_cast(pow2_mul) - 1; 83 | return (num + mask) & ~mask; 84 | } 85 | 86 | // behavior: 87 | // rounddown_pow2_mul(16, 16) = 16 88 | // rounddown_pow2_mul(17, 16) = 16 89 | template 90 | requires requires() { requires std::unsigned_integral; } 91 | constexpr U rounddown_pow2_mul(U num, size_t pow2_mul) { 92 | const U mask = static_cast(pow2_mul) - 1; 93 | return num & ~mask; 94 | } 95 | 96 | template consteval size_t sizeofbits() { 97 | return sizeof(T) * CHAR_BIT; 98 | } 99 | 100 | consteval size_t sizeofbits(const auto &o) { 101 | return sizeof(o) * CHAR_BIT; 102 | } 103 | 104 | template size_t bytesizeof(const typename std::vector &vec) { 105 | return sizeof(T) * vec.size(); 106 | } 107 | 108 | static inline std::string boolmoji(bool b) { 109 | return b ? SURF_TRUE_SYM : SURF_FALSE_SYM; 110 | } 111 | 112 | template static constexpr auto type_name() { 113 | std::string_view name, prefix, suffix; 114 | #ifdef __clang__ 115 | name = __PRETTY_FUNCTION__; 116 | prefix = "auto surf::type_name() [T = "; 117 | suffix = "]"; 118 | #elif defined(__GNUC__) 119 | name = __PRETTY_FUNCTION__; 120 | prefix = "constexpr auto surf::type_name() [with T = "; 121 | suffix = "]"; 122 | #elif defined(_MSC_VER) 123 | name = __FUNCSIG__; 124 | prefix = "auto __cdecl surf::type_name<"; 125 | suffix = ">(void)"; 126 | #endif 127 | name.remove_prefix(prefix.size()); 128 | name.remove_suffix(suffix.size()); 129 | return name; 130 | } 131 | 132 | }; // namespace surf 133 | -------------------------------------------------------------------------------- /libsurf/include/surf/mmap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | 5 | namespace surf { 6 | 7 | class SURF_EXPORT MappedReadOnlyFile { 8 | public: 9 | MappedReadOnlyFile(const std::filesystem::path &path, const void *preferred_addr = nullptr); 10 | ~MappedReadOnlyFile(); 11 | const uint8_t *data() const; 12 | size_t size() const; 13 | std::string_view string_view() const; 14 | const std::filesystem::path &path() const; 15 | 16 | private: 17 | const std::filesystem::path m_path; 18 | const uint8_t *m_mapping; 19 | size_t m_size; 20 | }; 21 | 22 | }; // namespace surf 23 | -------------------------------------------------------------------------------- /libsurf/include/surf/render.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | #include "time.h" 5 | #include "trace.h" 6 | 7 | namespace surf { 8 | 9 | class SURF_EXPORT Renderer { 10 | public: 11 | Renderer(const Trace &trace); 12 | void render(const Time &start, const Time &end, uint32_t width, uint32_t height, 13 | const std::filesystem::path &png_path); 14 | 15 | private: 16 | const Trace &m_trace; 17 | }; 18 | 19 | } // namespace surf 20 | -------------------------------------------------------------------------------- /libsurf/include/surf/surf.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "render.h" 4 | #include "trace.h" 5 | #include "varbit.h" 6 | #include "vcd.h" 7 | -------------------------------------------------------------------------------- /libsurf/include/surf/time.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | 5 | namespace surf { 6 | 7 | class SURF_EXPORT Time { 8 | public: 9 | Time(); 10 | Time(uint64_t ticks, int timebase_power); 11 | Time(double seconds, int timebase_power); 12 | uint64_t ticks() const; 13 | double seconds() const; 14 | int timebase_power() const; 15 | static uint64_t seconds_to_ticks(double seconds, int timebase_power); 16 | static double ticks_to_seconds(uint64_t seconds, int timebase_power); 17 | 18 | private: 19 | int m_timebase_power; 20 | uint64_t m_ticks; 21 | }; 22 | 23 | } // namespace surf 24 | -------------------------------------------------------------------------------- /libsurf/include/surf/trace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | #include "time.h" 5 | 6 | namespace surf { 7 | 8 | class SURF_EXPORT Trace { 9 | public: 10 | Trace(const std::filesystem::path &path); 11 | int timebase_power() const; 12 | Time start() const; 13 | Time end() const; 14 | 15 | private: 16 | const std::filesystem::path m_path; 17 | int m_fd; 18 | int m_timebase_power; 19 | Time m_start; 20 | Time m_end; 21 | }; 22 | 23 | } // namespace surf 24 | -------------------------------------------------------------------------------- /libsurf/include/surf/varbit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | 5 | #include 6 | 7 | // TODO: optimize/remove/#ifguard masking off of bits 8 | 9 | namespace surf { 10 | 11 | namespace varbit { 12 | using sz_t = uint16_t; 13 | }; // namespace varbit 14 | 15 | class SURF_PACKED bitview { 16 | public: 17 | bitview(const uint8_t *buf, varbit::sz_t bitsz) : m_buf{buf}, m_size{bitsz} { 18 | assert(bitsz > 0); 19 | } 20 | template 21 | bitview(const T &buf, varbit::sz_t bitsz) : m_buf{(const uint8_t *)&buf}, m_size{bitsz} { 22 | assert(bitsz > 0 && bitsz <= sizeof(T) * CHAR_BIT); 23 | } 24 | 25 | const uint8_t *data() const { 26 | return m_buf; 27 | } 28 | varbit::sz_t bitsize() const { 29 | return m_size; 30 | } 31 | varbit::sz_t bytesize() const { 32 | return roundup_pow2_mul(m_size, 8) / 8; 33 | } 34 | 35 | private: 36 | const uint8_t *m_buf; 37 | varbit::sz_t m_size; 38 | }; 39 | 40 | class bitarray4 { 41 | public: 42 | bitarray4(uint8_t bits, uint8_t bitsz) : m_buf{bits}, m_size{bitsz} { 43 | assert(m_size > 0 && m_size <= 4); 44 | } 45 | bitarray4(bitview bv) : m_buf{*bv.data()}, m_size{(uint8_t)bv.bitsize()} { 46 | assert(m_size > 0 && m_size <= 4); 47 | } 48 | 49 | bitview bitview() const { 50 | return surf::bitview{data(), bitsize()}; 51 | } 52 | const uint8_t *data() const { 53 | return &m_buf; 54 | } 55 | varbit::sz_t bitsize() const { 56 | return m_size; 57 | } 58 | varbit::sz_t bytesize() const { 59 | return sizeof(m_buf); 60 | } 61 | 62 | private: 63 | uint8_t m_buf; 64 | uint8_t m_size; 65 | }; 66 | 67 | class bitarray10 { 68 | public: 69 | bitarray10(uint16_t bits, uint8_t bitsz) : m_buf{bits}, m_size{bitsz} { 70 | assert(m_size > 0 && m_size <= 10); 71 | } 72 | bitarray10(bitview bv) : m_size{(uint8_t)bv.bitsize()} { 73 | assert(m_size > 0 && m_size <= 10); 74 | memcpy(&m_buf, bv.data(), bv.bytesize()); 75 | } 76 | 77 | bitview bitview() const { 78 | return surf::bitview{data(), bitsize()}; 79 | } 80 | const uint8_t *data() const { 81 | return (uint8_t *)&m_buf; 82 | } 83 | varbit::sz_t bitsize() const { 84 | return m_size; 85 | } 86 | varbit::sz_t bytesize() const { 87 | return sizeof(m_buf); 88 | } 89 | 90 | private: 91 | uint16_t m_buf; 92 | uint8_t m_size; 93 | }; 94 | 95 | std::string bitview2string(bitview bv) { 96 | std::string bitstring; 97 | const auto data = bv.data(); 98 | const auto bitsize = bv.bitsize(); 99 | const ssize_t bytesize = (ssize_t)bv.bytesize(); 100 | if (bitsize == 0) { 101 | return ""; 102 | } 103 | if (bitsize == 1) { 104 | return (*bv.data() & 1) ? "1" : "0"; 105 | } 106 | bitstring.reserve(bytesize * 8); 107 | const uint64x2_t magic = {0x8040201008040201ull, 0x8040201008040201ull}; 108 | const uint64x2_t mask = {0x8080808080808080ull, 0x8080808080808080ull}; 109 | const uint64x2_t ascii_zeros = {0x3030303030303030ull, 0x3030303030303030ull}; 110 | ssize_t i = 0; 111 | #pragma clang loop unroll_count(4) 112 | for (; i <= bytesize - (ssize_t)sizeof(uint16_t); i += sizeof(uint16_t)) { 113 | // MCA_BEGIN("bitview2string_inner_loop"); 114 | const uint64x2_t words = {*(uint8_t *)(data + i), *(uint8_t *)(data + i + 1)}; 115 | const uint64x2_t ones_or_zeros = ((magic * words) & mask) >> 7; 116 | const uint64x2_t ones_or_zeros_ascii = ones_or_zeros + ascii_zeros; 117 | const auto ts = 118 | std::string_view{(const char *)&ones_or_zeros_ascii, sizeof(ones_or_zeros_ascii)}; 119 | bitstring += ts; 120 | // MCA_END("bitview2string_inner_loop"); 121 | } 122 | for (; i < bytesize; ++i) { 123 | uint8_t byte = data[i]; 124 | for (int8_t j = 7; j >= 0; --j) { 125 | const auto bit = (byte >> j) & 1; 126 | bitstring.push_back(bit ? '1' : '0'); 127 | } 128 | } 129 | bitstring.erase(bitstring.begin(), bitstring.begin() + (bytesize * CHAR_BIT - bitsize)); 130 | return bitstring; 131 | } 132 | 133 | namespace varbit { 134 | 135 | static constexpr sz_t bytesize4bitsize(sz_t bitsz) { 136 | return roundup_pow2_mul(bitsz, 8) / 8; 137 | } 138 | 139 | // bit 0: is_not_ptr 140 | enum class tag_ty : uint8_t { 141 | ptr = 0b00, 142 | ptr_inline56 = 0b10, 143 | inline4 = 0b01, 144 | inline10 = 0b11 145 | }; 146 | 147 | // bit 0: is_not_ptr 148 | enum class raw_buf_ptr_tag_ty : uint8_t { 149 | ptr = 0b0, 150 | inlined = 0b1 151 | }; 152 | 153 | enum class ptr_ty : uint8_t { 154 | b10_inline72, 155 | b10_heap, 156 | b16_inline_120, 157 | b16_heap, 158 | }; 159 | 160 | class SURF_PACKED tag_byte_inline4 { 161 | public: 162 | SURF_SCA tag_ty_bitpos = 0; 163 | SURF_SCA tag_ty_sz = 2; 164 | SURF_SCA nbits_minus_1_bitpos = 2; 165 | SURF_SCA nbits_minus_1_sz = 2; 166 | SURF_SCA bits_bitpos = 4; 167 | SURF_SCA bits_sz = 2; 168 | static_assert(tag_ty_sz + nbits_minus_1_sz + bits_sz <= sizeof(uint8_t) * CHAR_BIT); 169 | 170 | tag_byte_inline4(bitview bv) { 171 | assert(bv.bitsize() > 0 && bv.bitsize() <= 4); 172 | m_byte = (magic_enum::enum_integer(tag_ty::inline4) & pow2_mask(tag_ty_sz)) 173 | << tag_ty_bitpos; 174 | m_byte |= ((bv.bitsize() - 1) & pow2_mask(nbits_minus_1_sz)) << nbits_minus_1_bitpos; 175 | m_byte |= (*bv.data() & pow2_mask(bits_sz)) << bits_bitpos; 176 | } 177 | 178 | uint8_t bitsize() const { 179 | return 1 + ((m_byte >> nbits_minus_1_bitpos) & pow2_mask(nbits_minus_1_sz)); 180 | } 181 | uint8_t bytesize() const { 182 | return bytesize4bitsize(bitsize()); 183 | } 184 | 185 | bitarray4 bitarray4() { 186 | uint8_t bits = (m_byte >> bits_bitpos) & pow2_mask(bits_sz); 187 | return surf::bitarray4(bits, bitsize()); 188 | } 189 | 190 | private: 191 | uint8_t m_byte; 192 | }; 193 | static_assert(sizeof(tag_byte_inline4) == sizeof(uint8_t)); 194 | 195 | class SURF_PACKED tag_word_inline10 { 196 | public: 197 | SURF_SCA tag_ty_bitpos = 0; 198 | SURF_SCA tag_ty_sz = 2; 199 | SURF_SCA nbits_bitpos = 2; 200 | SURF_SCA nbits_sz = 4; 201 | SURF_SCA bits_bitpos = 6; 202 | SURF_SCA bits_sz = 10; 203 | static_assert(tag_ty_sz + nbits_sz + bits_sz <= sizeof(uint16_t) * CHAR_BIT); 204 | 205 | tag_word_inline10(bitview bv) { 206 | assert(bv.bitsize() > 0 && bv.bitsize() <= 10); 207 | m_word = (magic_enum::enum_integer(tag_ty::inline10) & pow2_mask(tag_ty_sz)) 208 | << tag_ty_bitpos; 209 | m_word |= (bv.bitsize() & pow2_mask(nbits_sz)) << nbits_bitpos; 210 | uint16_t bits; 211 | memcpy(&bits, bv.data(), bv.bytesize()); 212 | m_word |= (bits & pow2_mask(bits_sz)) << bits_bitpos; 213 | } 214 | 215 | uint8_t bitsize() const { 216 | return ((m_word >> nbits_bitpos) & pow2_mask(nbits_sz)); 217 | } 218 | uint8_t bytesize() const { 219 | return bytesize4bitsize(bitsize()); 220 | } 221 | 222 | bitarray10 bitarray10() { 223 | uint16_t bits = (m_word >> bits_bitpos) & pow2_mask(bits_sz); 224 | return surf::bitarray10(bits, bitsize()); 225 | } 226 | 227 | private: 228 | uint16_t m_word; 229 | }; 230 | static_assert(sizeof(tag_word_inline10) == sizeof(uint16_t)); 231 | 232 | class SURF_PACKED tagged_ptr_inline56 { 233 | public: 234 | SURF_SCA tag_ty_bitpos = 0; 235 | SURF_SCA tag_ty_sz = 2; 236 | SURF_SCA nbits_bitpos = 2; 237 | SURF_SCA nbits_sz = 6; 238 | static_assert(tag_ty_sz + nbits_sz <= sizeof(uint8_t) * CHAR_BIT); 239 | 240 | tagged_ptr_inline56(bitview bv) { 241 | assert(bv.bitsize() > 0 && bv.bitsize() <= 56); 242 | m_tag_byte = (magic_enum::enum_integer(tag_ty::ptr_inline56) & pow2_mask(tag_ty_sz)) 243 | << tag_ty_bitpos; 244 | m_tag_byte |= (bv.bitsize() & pow2_mask(nbits_sz)) << nbits_bitpos; 245 | memcpy(m_buf, bv.data(), bv.bytesize()); 246 | } 247 | 248 | const uint8_t *data() const { 249 | return m_buf; 250 | } 251 | uint8_t bitsize() const { 252 | return ((m_tag_byte >> nbits_bitpos) & pow2_mask(nbits_sz)); 253 | } 254 | uint8_t bytesize() const { 255 | return bytesize4bitsize(bitsize()); 256 | } 257 | 258 | bitview bitview() const { 259 | return surf::bitview{data(), bitsize()}; 260 | } 261 | 262 | private: 263 | uint8_t m_tag_byte; 264 | uint8_t m_buf[7]; 265 | }; 266 | static_assert(sizeof(tagged_ptr_inline56) == sizeof(void *)); 267 | 268 | union tagged_ptr { 269 | const uintptr_t m_ptrint; 270 | tagged_ptr_inline56 m_inline56; 271 | }; 272 | 273 | class SURF_PACKED heap_array_b10_inline72 { 274 | public: 275 | SURF_SCA raw_buf_ptr_tag_ty_bitpos = 0; 276 | SURF_SCA raw_buf_ptr_tag_ty_sz = 1; 277 | SURF_SCA nbits_bitpos = 1; 278 | SURF_SCA nbits_sz = 7; 279 | static_assert(raw_buf_ptr_tag_ty_bitpos + nbits_sz <= sizeof(uint8_t) * CHAR_BIT); 280 | 281 | heap_array_b10_inline72(bitview bv) { 282 | assert(bv.bitsize() > 0 && bv.bitsize() <= 72); 283 | m_buf_tag = (magic_enum::enum_integer(raw_buf_ptr_tag_ty::inlined) & 284 | pow2_mask(raw_buf_ptr_tag_ty_sz)) 285 | << raw_buf_ptr_tag_ty_bitpos; 286 | m_buf_tag |= (bv.bitsize() & pow2_mask(nbits_sz)) << nbits_bitpos; 287 | memcpy(m_buf, bv.data(), bv.bytesize()); 288 | } 289 | 290 | const uint8_t *data() const { 291 | return m_buf; 292 | } 293 | uint8_t bitsize() const { 294 | return ((m_buf_tag >> nbits_bitpos) & pow2_mask(nbits_sz)); 295 | } 296 | uint8_t bytesize() const { 297 | return bytesize4bitsize(bitsize()); 298 | } 299 | 300 | bitview bitview() const { 301 | return surf::bitview{data(), bitsize()}; 302 | } 303 | 304 | private: 305 | uint8_t m_buf_tag; 306 | uint8_t m_buf[9]; 307 | }; 308 | static_assert(sizeof(heap_array_b10_inline72) == 10); 309 | 310 | struct SURF_PACKED heap_array_b10_ptr { 311 | std::unique_ptr m_buf; 312 | sz_t m_size; 313 | }; 314 | 315 | union heap_array_b10 { 316 | uint8_t m_tag_byte; 317 | heap_array_b10_inline72 m_inline72; 318 | heap_array_b10_ptr m_buf_ptr; 319 | }; 320 | 321 | class SURF_PACKED heap_array_b16_inline120 { 322 | public: 323 | SURF_SCA raw_buf_ptr_tag_ty_bitpos = 0; 324 | SURF_SCA raw_buf_ptr_tag_ty_sz = 1; 325 | SURF_SCA nbits_bitpos = 1; 326 | SURF_SCA nbits_sz = 7; 327 | static_assert(raw_buf_ptr_tag_ty_bitpos + nbits_sz <= sizeof(uint8_t) * CHAR_BIT); 328 | 329 | heap_array_b16_inline120(bitview bv) { 330 | assert(bv.bitsize() > 0 && bv.bitsize() <= 120); 331 | m_buf_tag = (magic_enum::enum_integer(raw_buf_ptr_tag_ty::inlined) & 332 | pow2_mask(raw_buf_ptr_tag_ty_sz)) 333 | << raw_buf_ptr_tag_ty_bitpos; 334 | m_buf_tag |= (bv.bitsize() & pow2_mask(nbits_sz)) << nbits_bitpos; 335 | memcpy(m_buf, bv.data(), bv.bytesize()); 336 | } 337 | 338 | const uint8_t *data() const { 339 | return m_buf; 340 | } 341 | uint8_t bitsize() const { 342 | return ((m_buf_tag >> nbits_bitpos) & pow2_mask(nbits_sz)); 343 | } 344 | uint8_t bytesize() const { 345 | return bytesize4bitsize(bitsize()); 346 | } 347 | 348 | bitview bitview() const { 349 | return surf::bitview{data(), bitsize()}; 350 | } 351 | 352 | private: 353 | uint8_t m_buf_tag; 354 | uint8_t m_buf[15]; 355 | }; 356 | static_assert(sizeof(heap_array_b16_inline120) == 16); 357 | 358 | struct SURF_PACKED heap_array_b16_ptr { 359 | std::unique_ptr m_buf; 360 | sz_t m_size; 361 | }; 362 | 363 | // bit 0: is_ptr 364 | // bit 1: is_bit 365 | // if (!is_ptr && !is_bit) 366 | // bit 2-7: size (0 - 56 bytes) 367 | // else 368 | // bit 2: bitval 369 | class tag_byte { 370 | public: 371 | SURF_SCA is_inlined_bitpos = 0; 372 | SURF_SCA is_inlined_sz = 1; 373 | SURF_SCA is_bit_bitpos = 1; 374 | SURF_SCA is_bit_sz = 1; 375 | SURF_SCA size_bitpos = 2; 376 | SURF_SCA size_sz = 6; 377 | SURF_SCA bitval_bitpos = 2; 378 | SURF_SCA bitval_sz = 1; 379 | static_assert(is_inlined_bitpos + is_bit_sz + size_sz <= sizeof(uint8_t) * CHAR_BIT); 380 | 381 | uint8_t bitsize() const { 382 | return (m_byte >> size_bitpos) & pow2_mask(size_sz); 383 | } 384 | bool is_ptr() const { 385 | return !((m_byte >> is_inlined_bitpos) & pow2_mask(is_inlined_sz)); 386 | } 387 | bool is_bit() const { 388 | return (m_byte >> is_bit_bitpos) & pow2_mask(is_bit_sz); 389 | } 390 | SURF_SCA for_inlined(sz_t bitsz) { 391 | return tag_byte{bitsz}; 392 | } 393 | SURF_SCA for_ptr() { 394 | return tag_byte{}; 395 | } 396 | SURF_SCA for_bit(bool bit) { 397 | return tag_byte{bit}; 398 | } 399 | 400 | private: 401 | constexpr tag_byte() : m_byte{} {} 402 | 403 | constexpr tag_byte(sz_t bitsz) { 404 | assert(bitsz <= 56); 405 | assert(bitsz < pow2(size_sz)); 406 | m_byte |= pow2(is_inlined_bitpos); 407 | m_byte |= bitsz << size_bitpos; 408 | } 409 | 410 | constexpr tag_byte(bool bit) { 411 | m_byte |= pow2(is_inlined_bitpos); 412 | m_byte |= pow2(is_bit_bitpos); 413 | m_byte |= ((uint8_t)bit) << bitval_bitpos; 414 | } 415 | 416 | uint8_t m_byte; 417 | }; 418 | static_assert(sizeof(tag_byte) == 1); 419 | 420 | // FIXME: little endian only right now 421 | class varbit_inline { 422 | public: 423 | constexpr static sz_t bytesize(sz_t bitsz) { 424 | return roundup_pow2_mul(bitsz, 8) / 8; 425 | } 426 | 427 | varbit_inline() : m_tag{tag_byte::for_ptr()}, m_buf{} {} 428 | varbit_inline(bitview bv) : m_tag{tag_byte::for_inlined(bv.bitsize())} { 429 | std::copy(bv.data(), bv.data() + bv.bytesize(), m_buf); 430 | } 431 | varbit_inline(bool bit) : m_tag{tag_byte::for_bit(bit)} {} 432 | 433 | const uint8_t *data() const { 434 | return m_buf; 435 | } 436 | bitview bitview() const { 437 | return surf::bitview{data(), bitsize()}; 438 | } 439 | sz_t bitsize() const { 440 | return m_tag.bitsize(); 441 | } 442 | sz_t bytesize() const { 443 | return bytesize(bitsize()); 444 | } 445 | tag_byte tag() const { 446 | return m_tag; 447 | } 448 | 449 | private: 450 | tag_byte m_tag; 451 | uint8_t m_buf[7]; 452 | }; 453 | static_assert(sizeof(varbit_inline) == sizeof(void *)); 454 | 455 | class varbit_heap { 456 | public: 457 | constexpr static sz_t bytesize(sz_t bitsz) { 458 | return roundup_pow2_mul(bitsz, 8) / 8; 459 | } 460 | 461 | varbit_heap(bitview bv) { 462 | m_buf = std::unique_ptr{new uint8_t[bv.bytesize()]}; 463 | m_size = bv.bitsize(); 464 | std::copy(bv.data(), bv.data() + bv.bytesize(), m_buf.get()); 465 | } 466 | const uint8_t *data() const { 467 | return m_buf.get(); 468 | } 469 | bitview bitview() const { 470 | return surf::bitview{data(), bitsize()}; 471 | } 472 | sz_t bitsize() const { 473 | return m_size; 474 | } 475 | sz_t bytesize() const { 476 | return bytesize(bitsize()); 477 | } 478 | 479 | private: 480 | std::unique_ptr m_buf; 481 | sz_t m_size; 482 | }; 483 | static_assert(sizeof(varbit_heap) <= 16); 484 | static_assert(alignof(varbit_heap) >= alignof(void *)); 485 | 486 | }; // namespace varbit 487 | 488 | union SURF_EXPORT VarBit { 489 | public: 490 | constexpr static varbit::sz_t bytesize(varbit::sz_t bitsz) { 491 | return roundup_pow2_mul(bitsz, 8) / 8; 492 | } 493 | 494 | VarBit(bitview bv) { 495 | if (SURF_LIKELY(bv.bitsize() <= 7 * CHAR_BIT)) { 496 | if (bv.bitsize() == 1) { 497 | m_inlined = varbit::varbit_inline{(bool)(*bv.data() & 1)}; 498 | } else { 499 | m_inlined = varbit::varbit_inline{bv}; 500 | } 501 | } else { 502 | m_heap = new varbit::varbit_heap{bv}; 503 | } 504 | } 505 | ~VarBit() { 506 | if (SURF_UNLIKELY(m_inlined.tag().is_ptr())) { 507 | delete m_heap; 508 | } 509 | } 510 | 511 | const uint8_t *data() const { 512 | if (SURF_LIKELY(!m_inlined.tag().is_ptr())) { 513 | return m_inlined.data(); 514 | } 515 | return m_heap->data(); 516 | } 517 | bitview bitview() const { 518 | return surf::bitview{data(), bitsize()}; 519 | } 520 | varbit::sz_t bitsize() const { 521 | if (SURF_LIKELY(!m_inlined.tag().is_ptr())) { 522 | return m_inlined.bitsize(); 523 | } 524 | return m_heap->bitsize(); 525 | } 526 | varbit::sz_t bytesize() const { 527 | return bytesize(bitsize()); 528 | } 529 | 530 | private: 531 | varbit::varbit_heap *m_heap; 532 | varbit::varbit_inline m_inlined; 533 | }; 534 | static_assert(sizeof(VarBit) == sizeof(void *)); 535 | 536 | }; // namespace surf 537 | 538 | template <> struct fmt::formatter { 539 | constexpr auto parse(format_parse_context &ctx) { 540 | return ctx.begin(); 541 | } 542 | template 543 | auto format(surf::bitview const &bv, FormatContext &ctx) const -> decltype(ctx.out()) { 544 | return fmt::format_to(ctx.out(), "", bv.bitsize(), 545 | surf::bitview2string(bv)); 546 | } 547 | }; 548 | 549 | template <> struct fmt::formatter { 550 | constexpr auto parse(format_parse_context &ctx) { 551 | return ctx.begin(); 552 | } 553 | template 554 | auto format(surf::VarBit const &vb, FormatContext &ctx) const -> decltype(ctx.out()) { 555 | return fmt::format_to(ctx.out(), "", vb.bitsize(), 556 | surf::bitview2string(vb.bitview())); 557 | } 558 | }; 559 | -------------------------------------------------------------------------------- /libsurf/include/surf/vcd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | #include "mmap.h" 5 | #include "time.h" 6 | #include "trace.h" 7 | 8 | namespace surf { 9 | 10 | namespace VCDTypes { 11 | 12 | struct Comment { 13 | std::string comment; 14 | }; 15 | 16 | struct Date { 17 | std::string date; 18 | }; 19 | 20 | struct Version { 21 | std::string version; 22 | }; 23 | 24 | enum class TimeNumber : uint8_t { 25 | n1 = 1, 26 | n10 = 10, 27 | n100 = 100 28 | }; 29 | 30 | enum class TimeUnit : int8_t { 31 | s = 0, 32 | ms = -3, 33 | us = -6, 34 | ns = -9, 35 | ps = -12, 36 | fs = -15 37 | }; 38 | 39 | enum class VarType : uint8_t { 40 | event, 41 | integer, 42 | parameter, 43 | real, 44 | realtime, 45 | reg, 46 | supply0, 47 | supply1, 48 | time, 49 | tri, 50 | triand, 51 | trior, 52 | trireg, 53 | tri0, 54 | tri1, 55 | wand, 56 | wire, 57 | wor 58 | }; 59 | 60 | struct Var { 61 | std::string id; 62 | std::string ref; 63 | int size; 64 | VarType type; 65 | }; 66 | 67 | enum class ScopeType : uint8_t { 68 | begin, 69 | fork, 70 | function, 71 | module, 72 | task, 73 | root 74 | }; 75 | 76 | struct ScopeDecl { 77 | std::string id; 78 | ScopeType type; 79 | }; 80 | 81 | struct Scope { 82 | std::string id; 83 | std::vector vars; 84 | std::vector subscopes; 85 | ScopeType type; 86 | }; 87 | 88 | struct UpScope {}; 89 | 90 | struct Timescale { 91 | TimeNumber time_number; 92 | TimeUnit time_unit; 93 | }; 94 | 95 | using Declaration = std::variant; 96 | 97 | struct Declarations { 98 | std::optional> comments; 99 | std::optional date; 100 | std::optional version; 101 | Scope root_scope; 102 | std::optional timescale; 103 | }; 104 | 105 | struct DeclsCommentsFmt { 106 | std::optional> const &comments; 107 | }; 108 | 109 | struct DeclsDateFmt { 110 | std::optional const &date; 111 | }; 112 | 113 | struct DeclsVersionFmt { 114 | std::optional const &version; 115 | }; 116 | 117 | struct Tick { 118 | uint64_t tick; 119 | }; 120 | 121 | enum class ScalarValueEnum : uint8_t { 122 | v0 = 0, 123 | v1 = 1, 124 | vX = 0b10, 125 | vZ = 0b100 126 | }; 127 | 128 | class ScalarValue { 129 | public: 130 | ScalarValue(char c) { 131 | if (c == '0') { 132 | m_sve = ScalarValueEnum::v0; 133 | } else if (c == '1') { 134 | m_sve = ScalarValueEnum::v1; 135 | } else if (c == 'x' || c == 'X') { 136 | m_sve = ScalarValueEnum::vX; 137 | } else if (c == 'z' || c == 'Z') { 138 | m_sve = ScalarValueEnum::vZ; 139 | } else { 140 | throw std::out_of_range( 141 | fmt::format("ScalarValue '{:c}' not recognized as 0, 1, x, X, z, or Z", c)); 142 | } 143 | } 144 | ScalarValue(bool b, bool x, bool z) { 145 | if (SURF_UNLIKELY((int)b + (int)x + (int)z > 1)) { 146 | throw std::out_of_range( 147 | fmt::format("ScalarValue: more than one bit set: B: {} X: {} Z: {}", b, x, z)); 148 | } 149 | if (SURF_LIKELY((int)x + (int)z == 0)) { 150 | m_sve = b ? ScalarValueEnum::v1 : ScalarValueEnum::v0; 151 | return; 152 | } else if (x) { 153 | m_sve = ScalarValueEnum::vX; 154 | return; 155 | } else if (z) { 156 | m_sve = ScalarValueEnum::vZ; 157 | return; 158 | } 159 | } 160 | bool b() const { 161 | return m_sve == ScalarValueEnum::v1; 162 | } 163 | bool x() const { 164 | return m_sve == ScalarValueEnum::vX; 165 | } 166 | bool z() const { 167 | return m_sve == ScalarValueEnum::vZ; 168 | } 169 | 170 | private: 171 | ScalarValueEnum m_sve; 172 | }; 173 | 174 | struct BinaryNum { 175 | uint64_t num; 176 | }; 177 | 178 | struct RealNum { 179 | double num; 180 | }; 181 | 182 | using Value = std::variant; 183 | 184 | struct Change { 185 | Value value; 186 | std::string id; 187 | }; 188 | 189 | using SimCmd = std::variant; 190 | 191 | struct DocumentRawDecls { 192 | std::vector declarations; 193 | std::vector sim_cmds; 194 | }; 195 | 196 | struct Document { 197 | Declarations declarations; 198 | std::vector sim_cmds; 199 | }; 200 | 201 | }; // namespace VCDTypes 202 | 203 | class SURF_EXPORT VCDFile { 204 | public: 205 | VCDFile(const std::filesystem::path &path); 206 | const std::filesystem::path &path() const; 207 | std::shared_ptr surf_trace() const; 208 | int timebase_power() const; 209 | Time start() const; 210 | Time end() const; 211 | const char *data() const; 212 | size_t size() const; 213 | std::string_view string_view() const; 214 | const VCDTypes::Document &document(); 215 | const VCDTypes::Declarations &declarations() const; 216 | const std::vector &sim_cmds(); 217 | void parse_test(); 218 | 219 | private: 220 | void parse_declarations(); 221 | void parse_changes(); 222 | 223 | VCDTypes::Document m_document; 224 | std::string_view m_sim_cmds_str; 225 | bool m_parsed_changes; 226 | MappedReadOnlyFile m_mapped_file; 227 | Time m_start; 228 | Time m_end; 229 | std::shared_ptr m_trace; 230 | }; 231 | 232 | }; // namespace surf 233 | 234 | template <> struct fmt::formatter { 235 | constexpr auto parse(format_parse_context &ctx) { 236 | return ctx.begin(); 237 | } 238 | template 239 | auto format(surf::VCDTypes::Comment const &comment, FormatContext &ctx) const 240 | -> decltype(ctx.out()) { 241 | return fmt::format_to(ctx.out(), "", comment.comment); 242 | } 243 | }; 244 | 245 | template <> struct fmt::formatter { 246 | constexpr auto parse(format_parse_context &ctx) { 247 | return ctx.begin(); 248 | } 249 | template 250 | auto format(surf::VCDTypes::Tick const &tick, FormatContext &ctx) const -> decltype(ctx.out()) { 251 | return fmt::format_to(ctx.out(), "", tick.tick); 252 | } 253 | }; 254 | 255 | template <> struct fmt::formatter { 256 | constexpr auto parse(format_parse_context &ctx) { 257 | return ctx.begin(); 258 | } 259 | template 260 | auto format(surf::VCDTypes::BinaryNum const &bnum, FormatContext &ctx) const 261 | -> decltype(ctx.out()) { 262 | return fmt::format_to(ctx.out(), "", bnum.num); 263 | } 264 | }; 265 | 266 | template <> struct fmt::formatter { 267 | constexpr auto parse(format_parse_context &ctx) { 268 | return ctx.begin(); 269 | } 270 | template 271 | auto format(surf::VCDTypes::RealNum const &rnum, FormatContext &ctx) const 272 | -> decltype(ctx.out()) { 273 | return fmt::format_to(ctx.out(), "", rnum.num); 274 | } 275 | }; 276 | 277 | template <> struct fmt::formatter { 278 | constexpr auto parse(format_parse_context &ctx) { 279 | return ctx.begin(); 280 | } 281 | template 282 | auto format(surf::VCDTypes::ScalarValue const &sv, FormatContext &ctx) const 283 | -> decltype(ctx.out()) { 284 | return fmt::format_to(ctx.out(), "", sv.b() ? '1' : '0', 285 | surf::boolmoji(sv.x()), surf::boolmoji(sv.z())); 286 | } 287 | }; 288 | 289 | template <> struct fmt::formatter { 290 | constexpr auto parse(format_parse_context &ctx) { 291 | return ctx.begin(); 292 | } 293 | template 294 | auto format(surf::VCDTypes::Change const &change, FormatContext &ctx) const 295 | -> decltype(ctx.out()) { 296 | return fmt::format_to(ctx.out(), "", change.id, change.value); 297 | } 298 | }; 299 | 300 | template <> struct fmt::formatter { 301 | constexpr auto parse(format_parse_context &ctx) { 302 | return ctx.begin(); 303 | } 304 | template 305 | auto format(surf::VCDTypes::Date const &date, FormatContext &ctx) const -> decltype(ctx.out()) { 306 | return fmt::format_to(ctx.out(), "", date.date); 307 | } 308 | }; 309 | 310 | template <> struct fmt::formatter { 311 | constexpr auto parse(format_parse_context &ctx) { 312 | return ctx.begin(); 313 | } 314 | template 315 | auto format(surf::VCDTypes::Version const &version, FormatContext &ctx) const 316 | -> decltype(ctx.out()) { 317 | return fmt::format_to(ctx.out(), "", version.version); 318 | } 319 | }; 320 | 321 | template <> struct fmt::formatter { 322 | constexpr auto parse(format_parse_context &ctx) { 323 | return ctx.begin(); 324 | } 325 | template 326 | auto format(surf::VCDTypes::DeclsVersionFmt const &version, FormatContext &ctx) const 327 | -> decltype(ctx.out()) { 328 | return fmt::format_to(ctx.out(), "", version.version); 329 | } 330 | }; 331 | 332 | template <> struct fmt::formatter { 333 | constexpr auto parse(format_parse_context &ctx) { 334 | return ctx.begin(); 335 | } 336 | template 337 | auto format(surf::VCDTypes::Timescale const ×cale, FormatContext &ctx) const 338 | -> decltype(ctx.out()) { 339 | return fmt::format_to(ctx.out(), "", 340 | magic_enum::enum_integer(timescale.time_number), 341 | magic_enum::enum_name(timescale.time_unit)); 342 | } 343 | }; 344 | 345 | template <> struct fmt::formatter> { 346 | constexpr auto parse(format_parse_context &ctx) { 347 | return ctx.begin(); 348 | } 349 | template 350 | auto format(std::optional const ×cale, FormatContext &ctx) const 351 | -> decltype(ctx.out()) { 352 | if (!timescale) 353 | return fmt::format_to(ctx.out(), ""); 354 | else 355 | return fmt::format_to(ctx.out(), "", 356 | magic_enum::enum_integer(timescale->time_number), 357 | magic_enum::enum_name(timescale->time_unit)); 358 | } 359 | }; 360 | 361 | template <> struct fmt::formatter { 362 | constexpr auto parse(format_parse_context &ctx) { 363 | return ctx.begin(); 364 | } 365 | template 366 | auto format(surf::VCDTypes::ScopeDecl const &scope_decl, FormatContext &ctx) const 367 | -> decltype(ctx.out()) { 368 | return fmt::format_to(ctx.out(), "", 369 | magic_enum::enum_name(scope_decl.type), scope_decl.id); 370 | } 371 | }; 372 | 373 | template <> struct fmt::formatter { 374 | constexpr auto parse(format_parse_context &ctx) { 375 | return ctx.begin(); 376 | } 377 | template 378 | auto format(surf::VCDTypes::Scope const &scope, FormatContext &ctx) const 379 | -> decltype(ctx.out()) { 380 | return fmt::format_to(ctx.out(), "", 381 | magic_enum::enum_name(scope.type), scope.id, 382 | fmt::join(scope.vars, ", "), fmt::join(scope.subscopes, ", ")); 383 | } 384 | }; 385 | 386 | template <> struct fmt::formatter { 387 | constexpr auto parse(format_parse_context &ctx) { 388 | return ctx.begin(); 389 | } 390 | template 391 | auto format(surf::VCDTypes::Var const &var, FormatContext &ctx) const -> decltype(ctx.out()) { 392 | return fmt::format_to(ctx.out(), "", 393 | magic_enum::enum_name(var.type), var.size, var.id, var.ref); 394 | } 395 | }; 396 | 397 | template <> struct fmt::formatter { 398 | constexpr auto parse(format_parse_context &ctx) { 399 | return ctx.begin(); 400 | } 401 | template 402 | auto format(surf::VCDTypes::UpScope const &, FormatContext &ctx) const -> decltype(ctx.out()) { 403 | return fmt::format_to(ctx.out(), ""); 404 | } 405 | }; 406 | 407 | template <> struct fmt::formatter { 408 | constexpr auto parse(format_parse_context &ctx) { 409 | return ctx.begin(); 410 | } 411 | template 412 | auto format(surf::VCDTypes::DeclsCommentsFmt const &comments, FormatContext &ctx) const 413 | -> decltype(ctx.out()) { 414 | if (!comments.comments) 415 | return fmt::format_to(ctx.out(), ""); 416 | else if (comments.comments->empty()) 417 | return fmt::format_to(ctx.out(), "", 420 | fmt::join(*comments.comments, "\", \"")); 421 | } 422 | }; 423 | 424 | template <> struct fmt::formatter { 425 | constexpr auto parse(format_parse_context &ctx) { 426 | return ctx.begin(); 427 | } 428 | template 429 | auto format(surf::VCDTypes::Declarations const &decls, FormatContext &ctx) const 430 | -> decltype(ctx.out()) { 431 | return fmt::format_to(ctx.out(), " {} {}>", 432 | surf::VCDTypes::DeclsCommentsFmt{decls.comments}, decls.version, 433 | decls.date, decls.timescale, decls.root_scope); 434 | } 435 | }; 436 | 437 | template <> struct fmt::formatter { 438 | constexpr auto parse(format_parse_context &ctx) { 439 | return ctx.begin(); 440 | } 441 | template 442 | auto format(surf::VCDTypes::DocumentRawDecls const &doc_raw, FormatContext &ctx) const 443 | -> decltype(ctx.out()) { 444 | return fmt::format_to(ctx.out(), " >", 445 | fmt::join(doc_raw.declarations, ", "), 446 | fmt::join(doc_raw.sim_cmds, ", ")); 447 | } 448 | }; 449 | 450 | template <> struct fmt::formatter { 451 | constexpr auto parse(format_parse_context &ctx) { 452 | return ctx.begin(); 453 | } 454 | template 455 | auto format(surf::VCDTypes::Document const &doc, FormatContext &ctx) const 456 | -> decltype(ctx.out()) { 457 | return fmt::format_to(ctx.out(), ">", doc.declarations, 458 | fmt::join(doc.sim_cmds, ", ")); 459 | } 460 | }; 461 | -------------------------------------------------------------------------------- /libsurf/lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SURF_SRC 2 | mmap.cpp 3 | render.cpp 4 | time.cpp 5 | trace.cpp 6 | varbit.cpp 7 | vcd.cpp 8 | vcd-parser.cpp 9 | utils.cpp 10 | ) 11 | 12 | set(SURF_HDR_STANDALONE 13 | surf.h 14 | ) 15 | 16 | set(SURF_HDR_PRIVATE 17 | common-internal.h 18 | ) 19 | 20 | set(SURF_HDR) 21 | foreach(HDR ${SURF_HDR_STANDALONE}) 22 | set(HDR "${CMAKE_CURRENT_SOURCE_DIR}/../include/surf/${HDR}") 23 | list(APPEND SURF_HDR ${HDR}) 24 | endforeach() 25 | 26 | foreach(SRC ${SURF_SRC}) 27 | get_filename_component(HDR_NAME ${SRC} NAME_WLE) 28 | set(HDR "${CMAKE_CURRENT_SOURCE_DIR}/../include/surf/${HDR_NAME}.h") 29 | if(EXISTS ${HDR}) 30 | list(APPEND SURF_HDR ${HDR}) 31 | endif() 32 | set(HDR "${CMAKE_CURRENT_SOURCE_DIR}/${HDR_NAME}.h") 33 | if(EXISTS ${HDR}) 34 | list(APPEND SURF_HDR_PRIVATE ${HDR}) 35 | endif() 36 | endforeach() 37 | 38 | set(SURF_PUBLIC_LIBS 39 | fmt 40 | hedley 41 | magic_enum 42 | mz::tagged_ptr 43 | ) 44 | 45 | set(SURF_PRIVATE_LIBS 46 | fmt 47 | fpng 48 | foonathan::lexy 49 | thread-pool 50 | visit 51 | ) 52 | 53 | # SURF_HDR added for Xcode project generation 54 | add_library(surf ${SURF_SRC} ${SURF_HDR} ${SURF_HDR_PRIVATE}) 55 | set_target_properties(surf PROPERTIES PUBLIC_HEADER "${SURF_HDR}") 56 | 57 | target_link_libraries(surf 58 | PUBLIC 59 | ${SURF_PUBLIC_LIBS} 60 | PRIVATE 61 | ${SURF_PRIVATE_LIBS} 62 | ) 63 | target_compile_options(surf PRIVATE -Wall -Wextra -Wpedantic) 64 | if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") 65 | target_compile_options(surf PRIVATE -Wno-missing-field-initializers) 66 | endif() 67 | 68 | if (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")) 69 | target_compile_options(surf PRIVATE 70 | # -Wno-unused-parameter 71 | ) 72 | endif() 73 | 74 | target_include_directories(surf 75 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include 76 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} 77 | ) 78 | 79 | install(TARGETS surf 80 | ARCHIVE DESTINATION lib 81 | LIBRARY DESTINATION lib 82 | PUBLIC_HEADER DESTINATION include/surf 83 | ) 84 | 85 | add_library(surf_dump_types dump_types.cpp) 86 | target_link_libraries(surf_dump_types surf) 87 | target_compile_options(surf_dump_types PRIVATE -Wall -Wextra -Wpedantic) 88 | target_include_directories(surf_dump_types 89 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include 90 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} 91 | ) 92 | -------------------------------------------------------------------------------- /libsurf/lib/common-internal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | using namespace surf; 6 | 7 | #undef NDEBUG 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | namespace fs = std::filesystem; 23 | using namespace std::string_literals; 24 | using namespace std::literals; 25 | 26 | #define SCA static constexpr auto -------------------------------------------------------------------------------- /libsurf/lib/config.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2023 Jonathan Müller and lexy contributors 2 | // SPDX-License-Identifier: BSL-1.0 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include // lexy::parse 10 | #include // value callbacks 11 | #include // lexy::dsl::* 12 | #include // lexy::read_file 13 | 14 | #include // lexy_ext::report_error 15 | 16 | namespace { 17 | struct PackageVersion { 18 | int major; 19 | int minor; 20 | int patch; 21 | }; 22 | 23 | struct PackageConfig { 24 | std::string name; 25 | PackageVersion version; 26 | std::vector authors; 27 | }; 28 | 29 | namespace grammar { 30 | namespace dsl = lexy::dsl; 31 | 32 | struct name : lexy::token_production { 33 | struct invalid_character { 34 | static constexpr auto name = "invalid name character"; 35 | }; 36 | 37 | // Match an alpha character, followed by zero or more alphanumeric characters or 38 | // underscores. Captures it all into a lexeme. 39 | static constexpr auto rule = [] { 40 | auto lead_char = dsl::ascii::alpha; 41 | auto trailing_char = dsl::ascii::word; 42 | 43 | return dsl::identifier(lead_char, trailing_char) + 44 | dsl::peek(dsl::ascii::space).error; 45 | }(); 46 | 47 | // The final value of this production is a std::string we've created from the lexeme. 48 | static constexpr auto value = lexy::as_string; 49 | }; 50 | 51 | struct version : lexy::token_production { 52 | struct forbidden_build_string { 53 | static constexpr auto name = "build string not supported"; 54 | }; 55 | 56 | // Match three integers separated by dots, or the special tag "unreleased". 57 | static constexpr auto rule = [] { 58 | auto number = dsl::try_(dsl::integer, dsl::nullopt); 59 | auto dot = dsl::try_(dsl::period); 60 | auto dot_version = dsl::times<3>(number, dsl::sep(dot)) + 61 | dsl::peek_not(dsl::lit_c<'-'> + dsl::while_(dsl::ascii::alnum)) 62 | .error; 63 | 64 | auto unreleased = LEXY_LIT("unreleased"); 65 | 66 | return unreleased | dsl::else_ >> dot_version; 67 | }(); 68 | 69 | // Construct a PackageVersion as the result of the production. 70 | static constexpr auto value = 71 | lexy::bind(lexy::construct, lexy::_1 or 0, lexy::_2 or 0, lexy::_3 or 0); 72 | }; 73 | 74 | struct author { 75 | struct invalid_character { 76 | static constexpr auto name = "invalid string character"; 77 | }; 78 | 79 | // Match zero or more non-control code points ("characters") surrounded by quotation marks. 80 | // We allow `\u` and `\U` as escape sequences. 81 | static constexpr auto rule = [] { 82 | auto cp = (-dsl::ascii::control).error; 83 | auto escape = dsl::backslash_escape // 84 | .rule(dsl::lit_c<'u'> >> dsl::code_point_id<4>) // 85 | .rule(dsl::lit_c<'U'> >> dsl::code_point_id<8>); // 86 | 87 | return dsl::quoted(cp, escape); 88 | }(); 89 | 90 | // Construct a UTF-8 string from the quoted content. 91 | static constexpr auto value = lexy::as_string; 92 | }; 93 | 94 | struct author_list { 95 | // Match a comma separated (non-empty) list of authors surrounded by square brackets. 96 | static constexpr auto rule = dsl::square_bracketed.list(dsl::p, dsl::sep(dsl::comma)); 97 | 98 | // Collect all authors into a std::vector. 99 | static constexpr auto value = lexy::as_list>; 100 | }; 101 | 102 | struct config { 103 | struct unknown_field { 104 | static constexpr auto name = "unknown config field"; 105 | }; 106 | struct duplicate_field { 107 | static constexpr auto name = "duplicate config field"; 108 | }; 109 | 110 | // Whitespace is ' ' and '\t'. 111 | static constexpr auto whitespace = dsl::ascii::blank; 112 | 113 | static constexpr auto rule = 114 | [] { 115 | auto make_field = [](auto name, auto rule) { 116 | auto end = dsl::try_(dsl::newline, dsl::until(dsl::newline)); 117 | return name >> dsl::try_(dsl::lit_c<'='>) + rule + end; 118 | }; 119 | 120 | auto name_field = make_field(LEXY_LIT("name"), LEXY_MEM(name) = dsl::p); 121 | auto version_field = 122 | make_field(LEXY_LIT("version"), LEXY_MEM(version) = dsl::p); 123 | auto authors_field = 124 | make_field(LEXY_LIT("authors"), LEXY_MEM(authors) = dsl::p); 125 | 126 | auto combination = dsl::combination(name_field, version_field, authors_field) 127 | .missing_error.duplicate_error; 128 | return combination + dsl::eof; 129 | }(); 130 | 131 | static constexpr auto value = lexy::as_aggregate; 132 | }; 133 | } // namespace grammar 134 | } // namespace 135 | 136 | int main(int argc, char **argv) { 137 | if (argc < 2) { 138 | std::fprintf(stderr, "usage: %s ", argv[0]); 139 | return 1; 140 | } 141 | 142 | // We're requiring UTF-8 input. 143 | auto file = lexy::read_file(argv[1]); 144 | if (!file) { 145 | std::fprintf(stderr, "file '%s' not found", argv[1]); 146 | return 1; 147 | } 148 | 149 | auto result = lexy::parse(file.buffer(), lexy_ext::report_error.path(argv[1])); 150 | 151 | if (result.has_value()) { 152 | auto &config = result.value(); 153 | 154 | std::printf("Package %s (%d.%d.%d)\n", config.name.c_str(), config.version.major, 155 | config.version.minor, config.version.patch); 156 | 157 | std::puts("Created by:"); 158 | for (auto &author : config.authors) 159 | std::printf("- \"%s\"", author.c_str()); 160 | } 161 | 162 | if (!result) 163 | return 2; 164 | } 165 | -------------------------------------------------------------------------------- /libsurf/lib/dump_types.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace surf; 4 | 5 | VCDTypes::SimCmd vcd_sim_cmd; 6 | -------------------------------------------------------------------------------- /libsurf/lib/lexy_user_config.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define LEXY_ENABLE_ASSERT true 4 | -------------------------------------------------------------------------------- /libsurf/lib/mmap.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "common-internal.h" 4 | #include "utils.h" 5 | 6 | #include 7 | #include 8 | 9 | MappedReadOnlyFile::MappedReadOnlyFile(const fs::path &path, const void *preferred_addr) 10 | : m_path(path) { 11 | const auto fd_res = open(path.c_str(), O_RDONLY); 12 | posix_check(fd_res, "MappedReadOnlyFile open"); 13 | 14 | struct stat st {}; 15 | const auto fstat_res = fstat(fd_res, &st); 16 | posix_check(fstat_res, "MappedReadOnlyFile fstat"); 17 | 18 | // sz + 1 to add a null terminator 19 | const auto *buf = 20 | (const uint8_t *)mmap((void *)preferred_addr, (size_t)st.st_size + 1, PROT_READ, 21 | MAP_PRIVATE | (preferred_addr ? MAP_FIXED : 0), fd_res, 0); 22 | if (buf == MAP_FAILED) { 23 | throw std::system_error( 24 | std::make_error_code((std::errc)errno), 25 | fmt::format("MappedReadOnlyFile mmap error: {:s}", strerror(errno))); 26 | } 27 | const auto close_res = close(fd_res); 28 | posix_check(close_res, "MappedReadOnlyFile close"); 29 | 30 | m_mapping = buf; 31 | m_size = (size_t)st.st_size; 32 | } 33 | 34 | MappedReadOnlyFile::~MappedReadOnlyFile() { 35 | // sz + 1 for null terminator 36 | const auto munmap_res = munmap((void *)m_mapping, m_size + 1); 37 | posix_check(munmap_res, "MappedReadOnlyFile munmap"); 38 | } 39 | 40 | const uint8_t *MappedReadOnlyFile::data() const { 41 | return m_mapping; 42 | } 43 | 44 | size_t MappedReadOnlyFile::size() const { 45 | return m_size; 46 | } 47 | 48 | const fs::path &MappedReadOnlyFile::path() const { 49 | return m_path; 50 | } 51 | 52 | std::string_view MappedReadOnlyFile::string_view() const { 53 | return {(const char *)data(), size()}; 54 | } -------------------------------------------------------------------------------- /libsurf/lib/render.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "common-internal.h" 4 | 5 | #include 6 | 7 | Renderer::Renderer(const Trace &trace) : m_trace(trace) {} 8 | 9 | void Renderer::render(const Time &start, const Time &end, uint32_t width, uint32_t height, 10 | const fs::path &png_path) { 11 | (void)m_trace; 12 | return; 13 | } 14 | -------------------------------------------------------------------------------- /libsurf/lib/time.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "common-internal.h" 4 | 5 | Time::Time() : m_timebase_power(0), m_ticks(0) {} 6 | 7 | Time::Time(uint64_t ticks, int timebase_power) : m_timebase_power(timebase_power), m_ticks(ticks) {} 8 | 9 | Time::Time(double seconds, int timebase_power) 10 | : m_timebase_power(timebase_power), m_ticks(seconds_to_ticks(seconds, m_timebase_power)) {} 11 | 12 | uint64_t Time::ticks() const { 13 | return m_ticks; 14 | } 15 | 16 | double Time::seconds() const { 17 | return ticks_to_seconds(m_ticks, m_timebase_power); 18 | } 19 | 20 | int Time::timebase_power() const { 21 | return m_timebase_power; 22 | } 23 | 24 | uint64_t Time::seconds_to_ticks(double seconds, int timebase_power) { 25 | return 1; 26 | } 27 | 28 | double Time::ticks_to_seconds(uint64_t ticks, int timebase_power) { 29 | return 1; 30 | } 31 | -------------------------------------------------------------------------------- /libsurf/lib/trace.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "common-internal.h" 4 | #include "utils.h" 5 | 6 | Trace::Trace(const fs::path &path) : m_path(path) { 7 | m_fd = open(m_path.c_str(), O_RDONLY); 8 | posix_check(m_fd, "Surf trace open"); 9 | } 10 | 11 | int Trace::timebase_power() const { 12 | return m_timebase_power; 13 | } 14 | 15 | Time Trace::start() const { 16 | return m_start; 17 | } 18 | 19 | Time Trace::end() const { 20 | return m_end; 21 | } 22 | -------------------------------------------------------------------------------- /libsurf/lib/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | 5 | #if defined(SURF_LINUX) || defined(SURF_APPLE) 6 | #include 7 | #endif 8 | #ifdef SURF_APPLE 9 | #include 10 | #endif 11 | #ifdef SURF_WIN 12 | #include 13 | #endif 14 | 15 | namespace surf { 16 | 17 | void posix_check(int retval, const std::string &msg) { 18 | if (SURF_UNLIKELY(retval < 0)) { 19 | const auto errstr = 20 | fmt::format("POSIX error: '{:s}' retval: {:d} errno: {:d} description: '{:s}'", msg, 21 | retval, errno, strerror(errno)); 22 | fmt::print(stderr, "{:s}\n", errstr); 23 | throw std::system_error(std::make_error_code((std::errc)errno), errstr); 24 | } 25 | } 26 | 27 | uint32_t get_num_cores() { 28 | #if defined(SURF_APPLE) 29 | uint32_t num; 30 | size_t sz = sizeof(num); 31 | posix_check(sysctlbyname("hw.logicalcpu", &num, &sz, nullptr, 0), "get_num_cores"); 32 | return num; 33 | #elif defined(SURF_LINUX) 34 | return (uint32_t)sysconf(_SC_NPROCESSORS_ONLN); 35 | #else 36 | #error get_num_cores unimplemented OS 37 | #endif 38 | } 39 | 40 | bool can_use_term_colors() { 41 | #if defined(SURF_LINUX) || defined(SURF_APPLE) 42 | return isatty(fileno(stdout)); 43 | #elif defined(SURF_WIN) 44 | return _isatty(fileno(stdout)); 45 | #endif 46 | } 47 | 48 | }; // namespace surf 49 | -------------------------------------------------------------------------------- /libsurf/lib/utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common-internal.h" 4 | 5 | #include 6 | 7 | #if 0 8 | #include 9 | 10 | #define DUMP_STACK(name) \ 11 | do { \ 12 | { \ 13 | std::cout << (name) << " STACK BEGIN:" << std::endl; \ 14 | backward::StackTrace st; \ 15 | st.load_here(32); \ 16 | backward::Printer pr; \ 17 | pr.snippet = true; \ 18 | pr.color_mode = backward::ColorMode::always; \ 19 | pr.address = true; \ 20 | pr.object = true; \ 21 | pr.print(st); \ 22 | std::cout << (name) << " STACK END" << std::endl; \ 23 | } \ 24 | } while (0) 25 | #define MCA_BEGIN(name) \ 26 | do { \ 27 | __asm volatile("# LLVM-MCA-BEGIN " #name ::: "memory"); \ 28 | } while (0) 29 | #define MCA_END(name) \ 30 | do { \ 31 | __asm volatile("# LLVM-MCA-END " #name ::: "memory"); \ 32 | } while (0) 33 | #endif 34 | 35 | namespace surf { 36 | 37 | void posix_check(int retval, const std::string &msg); 38 | 39 | unsigned int get_num_cores(); 40 | 41 | bool can_use_term_colors(); 42 | 43 | // for visit(overload(...case lambdas...), variant_var) 44 | template class overload : T... { 45 | public: 46 | overload(T... t) : T(t)... {} 47 | using T::operator()...; 48 | }; 49 | 50 | // https://www.modernescpp.com/index.php/c-20-pythons-map-function 51 | template auto map(Func func, Seq seq) { 52 | typedef typename Seq::value_type value_type; 53 | using return_type = decltype(func(std::declval())); 54 | 55 | std::vector result{}; 56 | for (auto &i : seq) { 57 | result.emplace_back(func(i)); 58 | } 59 | 60 | return result; 61 | } 62 | 63 | }; // namespace surf 64 | 65 | // Credit: Arthaud Awen / davawen 66 | // https://github.com/fmtlib/fmt/issues/1367#issuecomment-1229916316 67 | template struct fmt::formatter> { 68 | std::string_view underlying_fmt; 69 | std::string_view or_else; 70 | 71 | constexpr auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) { 72 | // {:} 73 | auto it = ctx.begin(), end = ctx.end(); 74 | auto get_marker = [&it, end]() constexpr { 75 | if (it == end || *it != '<') 76 | return std::string_view(nullptr, 0); // no match 77 | auto start = ++it; 78 | 79 | while (it != end && (*it++ != '>')) 80 | ; 81 | if (it == end) 82 | throw fmt::format_error("invalid format, unfinished range"); 83 | 84 | return std::string_view(start, (it - 1) - start); 85 | }; 86 | 87 | underlying_fmt = "{}"; 88 | or_else = SURF_EMPTY_SYM; 89 | 90 | auto first = get_marker(); 91 | if (first.data()) 92 | underlying_fmt = first; 93 | 94 | auto second = get_marker(); 95 | if (second.data()) 96 | or_else = second; 97 | 98 | // Check if reached the end of the range: 99 | if (it != end && *it != '}') 100 | throw fmt::format_error("invalid format, no end bracket"); 101 | return it; 102 | } 103 | 104 | template 105 | auto format(const std::optional &p, FormatContext &ctx) const -> decltype(ctx.out()) { 106 | if (p) { 107 | return vformat_to(ctx.out(), underlying_fmt, format_arg_store{*p}); 108 | } else { 109 | return format_to(ctx.out(), "{}", or_else); 110 | } 111 | } 112 | }; -------------------------------------------------------------------------------- /libsurf/lib/varbit.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "common-internal.h" 4 | #include "utils.h" 5 | 6 | #include 7 | 8 | std::string bitview2string(bitview bv) { 9 | std::string bitstring; 10 | const auto data = bv.data(); 11 | const auto bitsize = bv.bitsize(); 12 | const ssize_t bytesize = (ssize_t)bv.bytesize(); 13 | if (bitsize == 0) { 14 | return ""; 15 | } 16 | if (bitsize == 1) { 17 | return (*bv.data() & 1) ? "1" : "0"; 18 | } 19 | bitstring.reserve(bytesize * 8); 20 | const uint64x2_t magic = {0x8040201008040201ull, 0x8040201008040201ull}; 21 | const uint64x2_t mask = {0x8080808080808080ull, 0x8080808080808080ull}; 22 | const uint64x2_t ascii_zeros = {0x3030303030303030ull, 0x3030303030303030ull}; 23 | ssize_t i = 0; 24 | #pragma clang loop unroll_count(4) 25 | for (; i <= bytesize - (ssize_t)sizeof(uint16_t); i += sizeof(uint16_t)) { 26 | // MCA_BEGIN("bitview2string_inner_loop"); 27 | const uint64x2_t words = {*(uint8_t *)(data + i), *(uint8_t *)(data + i + 1)}; 28 | const uint64x2_t ones_or_zeros = ((magic * words) & mask) >> 7; 29 | const uint64x2_t ones_or_zeros_ascii = ones_or_zeros + ascii_zeros; 30 | const auto ts = 31 | std::string_view{(const char *)&ones_or_zeros_ascii, sizeof(ones_or_zeros_ascii)}; 32 | bitstring += ts; 33 | // MCA_END("bitview2string_inner_loop"); 34 | } 35 | for (; i < bytesize; ++i) { 36 | uint8_t byte = data[i]; 37 | for (int8_t j = 7; j >= 0; --j) { 38 | const auto bit = (byte >> j) & 1; 39 | bitstring.push_back(bit ? '1' : '0'); 40 | } 41 | } 42 | bitstring.erase(bitstring.begin(), bitstring.begin() + (bytesize * CHAR_BIT - bitsize)); 43 | return bitstring; 44 | } 45 | -------------------------------------------------------------------------------- /libsurf/lib/vcd-parser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common-internal.h" 4 | #include 5 | 6 | #include 7 | 8 | #include // lexy::visualization_options 9 | 10 | namespace surf { 11 | 12 | struct VCDDeclParseError : public std::invalid_argument {}; 13 | struct VCDSimCmdsParseError : public std::invalid_argument {}; 14 | 15 | struct VCDParserDeclRet { 16 | std::vector decls; 17 | std::string_view remaining; 18 | }; 19 | VCDParserDeclRet parse_vcd_declarations(std::string_view decls_str, fs::path = "unknown", 20 | std::optional opts = {}); 21 | 22 | std::vector 23 | parse_vcd_sim_cmds(std::string_view sim_cmds_str, fs::path = "unknown", 24 | std::optional opts = {}); 25 | 26 | VCDTypes::Document parse_vcd_document(std::string_view vcd_str, fs::path path = "unknown", 27 | std::optional opts = {}); 28 | 29 | void parse_vcd_document_test(std::string_view vcd_str, const std::filesystem::path &path); 30 | 31 | VCDTypes::Declarations decls_from_decl_list(std::vector &&decls); 32 | 33 | }; // namespace surf 34 | -------------------------------------------------------------------------------- /libsurf/lib/vcd.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "common-internal.h" 4 | #include "utils.h" 5 | #include "vcd-parser.h" 6 | 7 | VCDFile::VCDFile(const fs::path &path) 8 | // : m_parsed_changes(false), m_mapped_file(path, (const void *)0x80'0000'0000) { 9 | : m_parsed_changes(false), m_mapped_file(path) { 10 | fmt::print("vcd sz: {:d} data: {:p}\n", size(), fmt::ptr(data())); 11 | auto decls_ret = parse_vcd_declarations(string_view(), m_mapped_file.path()); 12 | m_document.declarations = decls_from_decl_list(std::move(decls_ret.decls)); 13 | m_sim_cmds_str = decls_ret.remaining; 14 | } 15 | 16 | const VCDTypes::Document &VCDFile::document() { 17 | if (!m_parsed_changes) { 18 | m_document.sim_cmds = parse_vcd_sim_cmds(m_sim_cmds_str, m_mapped_file.path()); 19 | m_parsed_changes = true; 20 | } 21 | return m_document; 22 | } 23 | 24 | const VCDTypes::Declarations &VCDFile::declarations() const { 25 | return m_document.declarations; 26 | } 27 | 28 | void VCDFile::parse_test() { 29 | (void)document(); 30 | // parse_vcd_document_test(string_view(), path()); 31 | } 32 | 33 | const std::vector &VCDFile::sim_cmds() { 34 | if (!m_parsed_changes) { 35 | m_document.sim_cmds = parse_vcd_sim_cmds(m_sim_cmds_str); 36 | m_parsed_changes = true; 37 | } 38 | return m_document.sim_cmds; 39 | } 40 | 41 | const fs::path &VCDFile::path() const { 42 | return m_mapped_file.path(); 43 | } 44 | 45 | const char *VCDFile::data() const { 46 | return (const char *)m_mapped_file.data(); 47 | } 48 | 49 | size_t VCDFile::size() const { 50 | return m_mapped_file.size(); 51 | } 52 | 53 | std::string_view VCDFile::string_view() const { 54 | return m_mapped_file.string_view(); 55 | } 56 | 57 | std::shared_ptr VCDFile::surf_trace() const { 58 | return m_trace; 59 | } 60 | 61 | int VCDFile::timebase_power() const { 62 | return m_trace->timebase_power(); 63 | } 64 | 65 | Time VCDFile::start() const { 66 | return m_start; 67 | } 68 | 69 | Time VCDFile::end() const { 70 | return m_end; 71 | } 72 | 73 | // TODO: huge pages on linux 74 | -------------------------------------------------------------------------------- /libsurf/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(bin2str bin2str.cpp) 2 | target_link_libraries(bin2str surf fmt) 3 | -------------------------------------------------------------------------------- /libsurf/test/bin2str.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #include 13 | 14 | #define MCA_BEGIN(name) \ 15 | do { \ 16 | __asm volatile("# LLVM-MCA-BEGIN " #name ::: "memory"); \ 17 | } while (0) 18 | #define MCA_END(name) \ 19 | do { \ 20 | __asm volatile("# LLVM-MCA-END " #name ::: "memory"); \ 21 | } while (0) 22 | 23 | template <> struct fmt::formatter { 24 | constexpr auto parse(format_parse_context &ctx) { 25 | return ctx.begin(); 26 | } 27 | template 28 | auto format(uint8x16_t const &v8_16, FormatContext &ctx) const -> decltype(ctx.out()) { 29 | return fmt::format_to( 30 | ctx.out(), 31 | "", 33 | v8_16[0], v8_16[1], v8_16[2], v8_16[3], v8_16[4], v8_16[5], v8_16[6], v8_16[7], 34 | v8_16[8], v8_16[9], v8_16[10], v8_16[11], v8_16[12], v8_16[13], v8_16[14], v8_16[15]); 35 | } 36 | }; 37 | 38 | // correct 39 | std::string ba2s(const std::span &packed_bits) { 40 | std::string result; 41 | result.reserve(packed_bits.size() * 8); 42 | for (std::size_t i = 0; i < packed_bits.size(); ++i) { 43 | uint8_t packed = packed_bits[i]; 44 | for (int j = 7; j >= 0; --j) { 45 | uint8_t bit = (packed >> j) & 0x01; 46 | result.push_back(bit ? '1' : '0'); 47 | } 48 | } 49 | return result; 50 | } 51 | 52 | std::string ba2s(const std::vector &packed_bits) { 53 | return ba2s(std::span{packed_bits.data(), packed_bits.data() + packed_bits.size()}); 54 | } 55 | 56 | template std::string ba2s(const T &packed_bits) { 57 | return ba2s(std::span{(uint8_t *)&packed_bits, (uint8_t *)(&packed_bits + 1)}); 58 | } 59 | 60 | #if 1 61 | #if 0 62 | // jev's NEON 63 | std::string ba2s_neon(const std::span &bits) { 64 | std::string result; 65 | result.reserve(bits.size() * 8); 66 | auto data = bits.data(); 67 | ssize_t size = (ssize_t)bits.size(); 68 | ssize_t i = 0; 69 | const uint8x16_t zeros_16 = vdupq_n_u8(0); 70 | const uint8x16_t ones_16 = vdupq_n_u8(1); 71 | for (; i <= size - 16; i += 16) { 72 | uint8x16_t bv = vld1q_u8(data + i); 73 | fmt::print("bv: {}\n", bv); 74 | const uint8x16_t v0 = vsriq_n_u8(bv, zeros_16, 7); 75 | fmt::print("v0: {}\n", v0); 76 | } 77 | for (; i < size; ++i) {} 78 | return result; 79 | } 80 | #else 81 | #define BA2S_NEON_UNROLL_COUNT 8 82 | std::string ba2s_neon(const std::span &bits) { 83 | const auto data = bits.data(); 84 | ssize_t size = (ssize_t)bits.size(); 85 | std::string bitstring; 86 | bitstring.reserve(size * 8); 87 | const uint64x2_t magic = {0x8040201008040201ull, 0x8040201008040201ull}; 88 | const uint64x2_t mask = {0x8080808080808080ull, 0x8080808080808080ull}; 89 | const uint64x2_t ascii_zeros = {0x3030303030303030ull, 0x3030303030303030ull}; 90 | ssize_t i = 0; 91 | // #pragma clang loop unroll_count(BA2S_NEON_UNROLL_COUNT) 92 | for (; i <= size - sizeof(uint16_t); i += sizeof(uint16_t)) { 93 | // MCA_BEGIN("ba2s_neon_inner_loop"); 94 | const uint64x2_t words = *(uint64x2_t *)(data + i); 95 | const uint64x2_t ones_or_zeros = ((magic * words) & mask) >> 7; 96 | const uint64x2_t ones_or_zeros_ascii = ones_or_zeros + ascii_zeros; 97 | const auto ts = 98 | std::string_view{(const char *)&ones_or_zeros_ascii, sizeof(ones_or_zeros_ascii)}; 99 | bitstring += ts; 100 | // MCA_END("ba2s_neon_inner_loop"); 101 | } 102 | for (; i < size; ++i) { 103 | uint8_t byte = data[i]; 104 | for (int8_t j = 7; j >= 0; --j) { 105 | const auto bit = (byte >> j) & 0x01; 106 | bitstring.push_back(bit ? '1' : '0'); 107 | } 108 | } 109 | return bitstring; 110 | } 111 | 112 | #endif 113 | 114 | std::string ba2s_neon(const std::vector &packed_bits) { 115 | return ba2s_neon(std::span{packed_bits.data(), packed_bits.data() + packed_bits.size()}); 116 | } 117 | 118 | template std::string ba2s_neon(const T &packed_bits) { 119 | fmt::print("packed_bits type: {}\n", surf::type_name()); 120 | return ba2s_neon(std::span{(uint8_t *)&packed_bits, (uint8_t *)(&packed_bits + 1)}); 121 | } 122 | 123 | #endif 124 | 125 | #if 0 126 | // correct 127 | std::string bit_array_to_string(const std::vector& packed_bits) { 128 | std::string result; 129 | result.reserve(packed_bits.size() * 8); 130 | for (std::size_t i = 0; i < packed_bits.size(); ++i) { 131 | char packed = packed_bits[i]; 132 | for (int j = 7; j >= 0; --j) { 133 | uint8_t bit = (packed >> j) & 0x01; 134 | result.push_back(bit ? '1' : '0'); 135 | } 136 | } 137 | return result; 138 | } 139 | #endif 140 | 141 | #if 0 142 | std::string bit_array_to_string(const std::vector& packed_bits) { 143 | std::string result; 144 | for (const auto& packed_bit : packed_bits) { 145 | for (int i = 7; i >= 0; --i) { 146 | result += (packed_bit & (1 << i)) ? '1' : '0'; 147 | } 148 | } 149 | return result; 150 | } 151 | #endif 152 | 153 | #if 0 154 | std::string bit_array_to_string(const std::vector& bits) { 155 | std::string result; 156 | const uint8_t* data = bits.data(); 157 | size_t size = bits.size(); 158 | size_t i = 0; 159 | for (; i <= size - 16; i += 16) { 160 | uint8x16_t bits_vector = vld1q_u8(data + i); 161 | uint8x16_t lookup_vector = vcreate_u8(0x0101010101010101ull); 162 | uint8x16_t result_vector = vtstq_u8(bits_vector, lookup_vector); 163 | uint8_t mask = 0x80; 164 | uint8x16_t mask_vector = vdupq_n_u8(mask); 165 | uint8x16_t mask_vector_2 = vorrq_u8(mask_vector, vshlq_n_u8(mask_vector, 1)); 166 | uint8x16_t mask_vector_4 = vorrq_u8(mask_vector_2, vshlq_n_u8(mask_vector_2, 2)); 167 | uint8x16_t mask_vector_8 = vorrq_u8(mask_vector_4, vshlq_n_u8(mask_vector_4, 4)); 168 | result_vector = vandq_u8(result_vector, mask_vector_8); 169 | uint8_t result_array[16]; 170 | vst1q_u8(result_array, result_vector); 171 | for (int j = 0; j < 16; ++j) { 172 | result += (result_array[j] & 0x80) ? '1' : '0'; 173 | result += (result_array[j] & 0x40) ? '1' : '0'; 174 | result += (result_array[j] & 0x20) ? '1' : '0'; 175 | result += (result_array[j] & 0x10) ? '1' : '0'; 176 | result += (result_array[j] & 0x08) ? '1' : '0'; 177 | result += (result_array[j] & 0x04) ? '1' : '0'; 178 | result += (result_array[j] & 0x02) ? '1' : '0'; 179 | result += (result_array[j] & 0x01) ? '1' : '0'; 180 | } 181 | } 182 | for (; i < size; ++i) { 183 | uint8_t byte = data[i]; 184 | result += (byte & 0x80) ? '1' : '0'; 185 | result += (byte & 0x40) ? '1' : '0'; 186 | result += (byte & 0x20) ? '1' : '0'; 187 | result += (byte & 0x10) ? '1' : '0'; 188 | result += (byte & 0x08) ? '1' : '0'; 189 | result += (byte & 0x04) ? '1' : '0'; 190 | result += (byte & 0x02) ? '1' : '0'; 191 | result += (byte & 0x01) ? '1' : '0'; 192 | } 193 | return result; 194 | } 195 | #endif 196 | 197 | int main(int argc, const char **argv) { 198 | assert(argc == 2); 199 | uint64_t n = std::stoull(argv[1], nullptr, 0); 200 | // fmt::print("ba2s: {}\n", ba2s(n)); 201 | // fmt::print("ba2s_neon: {}\n", ba2s_neon(n)); 202 | const std::vector v16 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; 203 | fmt::print("ba2s: {}\n", ba2s(v16)); 204 | fmt::print("ba2s_neon: {}\n", ba2s_neon(v16)); 205 | return 0; 206 | } 207 | -------------------------------------------------------------------------------- /libsurf/test/dump-struct.cpp: -------------------------------------------------------------------------------- 1 | // clang++ -std=c++20 -c -o /dev/null -Xclang -fdump-record-layouts libsurf/test/dump-struct.cpp 2 | 3 | #include 4 | #include 5 | 6 | struct varbit_heap { 7 | std::vector buf; 8 | bool sign; 9 | }; 10 | 11 | varbit_heap varbit_heap_dummy; 12 | -------------------------------------------------------------------------------- /libsurf/tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(surf-tool surf-tool.cpp) 2 | target_compile_options(surf-tool PRIVATE -Wall -Wextra -Wpedantic) 3 | target_link_libraries(surf-tool PRIVATE argparse fmt surf) 4 | 5 | install(TARGETS surf-tool 6 | RUNTIME DESTINATION bin 7 | ) 8 | -------------------------------------------------------------------------------- /libsurf/tools/surf-tool.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace surf; 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | int main(int argc, const char **argv) { 12 | argparse::ArgumentParser parser("surf-tool"); 13 | parser.add_argument("-v", "--vcd-trace").help("input VCD file path"); 14 | parser.add_argument("-t", "--surf-trace").help("input Surf file path"); 15 | parser.add_argument("-r", "--render") 16 | .implicit_value("surf-render.png") 17 | .help("output PNG render path"); 18 | parser.add_argument("-s", "--start").help("render start time"); 19 | parser.add_argument("-e", "--end").help("render end time"); 20 | parser.add_argument("-T", "--ticks") 21 | .default_value(false) 22 | .implicit_value(true) 23 | .help("use ticks for times"); 24 | parser.add_argument("-W", "--width") 25 | .default_value((uint32_t)4096) 26 | .scan<'i', uint32_t>() 27 | .help("render width (pixels)"); 28 | parser.add_argument("-H", "--height") 29 | .default_value((uint32_t)4096) 30 | .scan<'i', uint32_t>() 31 | .help("render height (pixels)"); 32 | parser.add_argument("-l", "--loop") 33 | .default_value(false) 34 | .implicit_value(true) 35 | .help("loop for testing"); 36 | 37 | try { 38 | parser.parse_args(argc, argv); 39 | } catch (const std::runtime_error &err) { 40 | fmt::print(stderr, "Error parsing arguments: {:s}\n", err.what()); 41 | return -2; 42 | } 43 | 44 | fmt::print("cwd is: {:s}\n", std::filesystem::current_path()); 45 | 46 | std::shared_ptr trace; 47 | 48 | if (const auto vcd_path = parser.present("--vcd-trace")) { 49 | VCDFile vcd_trace(*vcd_path); 50 | vcd_trace.parse_test(); 51 | return 0; 52 | trace = vcd_trace.surf_trace(); 53 | } else { 54 | if (const auto surf_path = parser.present("--surf-trace")) { 55 | trace = std::make_shared(*surf_path); 56 | } else { 57 | fmt::print(stderr, "Missing input trace (VCD or Surf) file.\n"); 58 | return -2; 59 | } 60 | } 61 | 62 | Time start_time; 63 | Time end_time; 64 | const auto use_ticks = parser["--ticks"] == true; 65 | const auto width = parser.get("--width"); 66 | const auto height = parser.get("--height"); 67 | 68 | fmt::print("use_ticks: {:b}\n", use_ticks); 69 | fmt::print("width: {:d} height: {:d}\n", width, height); 70 | 71 | if (parser.get("--loop")) { 72 | while (true) { 73 | usleep(1'000'000); 74 | } 75 | } 76 | 77 | assert(trace); 78 | 79 | if (parser.present("--start")) { 80 | if (use_ticks) { 81 | start_time = Time(parser.get("--start"), trace->timebase_power()); 82 | } else { 83 | start_time = Time(parser.get("--start"), trace->timebase_power()); 84 | } 85 | } else { 86 | start_time = trace->start(); 87 | } 88 | if (parser.present("--end")) { 89 | if (use_ticks) { 90 | end_time = Time(parser.get("--end"), trace->timebase_power()); 91 | } else { 92 | end_time = Time(parser.get("--end"), trace->timebase_power()); 93 | } 94 | } else { 95 | end_time = trace->end(); 96 | } 97 | 98 | if (const auto png_path = parser.present("--render")) { 99 | Renderer renderer(*trace); 100 | renderer.render(start_time, end_time, width, height, *png_path); 101 | } 102 | 103 | fmt::print("hello from surf-tool\n"); 104 | return 0; 105 | } 106 | -------------------------------------------------------------------------------- /libsurf/unit-tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SURF_UNIT_TEST_SRC 2 | varbit.cpp 3 | ) 4 | 5 | add_executable(surf-unit-tests ${SURF_UNIT_TEST_SRC}) 6 | target_link_libraries(surf-unit-tests PRIVATE surf fmt Catch2 Catch2WithMain) 7 | -------------------------------------------------------------------------------- /libsurf/unit-tests/varbit.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace surf; 3 | 4 | #include 5 | #include 6 | 7 | #define TS "[VarBit]" 8 | 9 | TEST_CASE("build", TS) { 10 | uint64_t buf = 0b1010; 11 | const auto bv = bitview{buf, 4}; 12 | VarBit vb{bv}; 13 | fmt::print("VarBit: {}\n", vb); 14 | REQUIRE(fmt::format("{}", vb) == ""); 15 | } 16 | -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 56; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 091879DA2967400F0024642A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 091879D92967400F0024642A /* AppDelegate.m */; }; 11 | 091879DD2967400F0024642A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 091879DC2967400F0024642A /* ViewController.m */; }; 12 | 091879E02967400F0024642A /* WaveformDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = 091879DF2967400F0024642A /* WaveformDocument.m */; }; 13 | 091879E5296740100024642A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 091879E3296740100024642A /* Main.storyboard */; }; 14 | 091879E8296740100024642A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 091879E7296740100024642A /* main.m */; }; 15 | 09DB114B29677E1F00407DE8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 09DB114A29677E1F00407DE8 /* Assets.xcassets */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 091879D52967400F0024642A /* Surf.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Surf.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 091879D82967400F0024642A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 21 | 091879D92967400F0024642A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 22 | 091879DB2967400F0024642A /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 23 | 091879DC2967400F0024642A /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 24 | 091879DE2967400F0024642A /* WaveformDocument.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WaveformDocument.h; sourceTree = ""; }; 25 | 091879DF2967400F0024642A /* WaveformDocument.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WaveformDocument.m; sourceTree = ""; }; 26 | 091879E4296740100024642A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 27 | 091879E6296740100024642A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 28 | 091879E7296740100024642A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 29 | 091879E9296740100024642A /* Surf.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Surf.entitlements; sourceTree = ""; }; 30 | 09DB114A29677E1F00407DE8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | 091879D22967400F0024642A /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | ); 39 | runOnlyForDeploymentPostprocessing = 0; 40 | }; 41 | /* End PBXFrameworksBuildPhase section */ 42 | 43 | /* Begin PBXGroup section */ 44 | 091879CC2967400F0024642A = { 45 | isa = PBXGroup; 46 | children = ( 47 | 091879D72967400F0024642A /* Surf */, 48 | 091879D62967400F0024642A /* Products */, 49 | ); 50 | sourceTree = ""; 51 | }; 52 | 091879D62967400F0024642A /* Products */ = { 53 | isa = PBXGroup; 54 | children = ( 55 | 091879D52967400F0024642A /* Surf.app */, 56 | ); 57 | name = Products; 58 | sourceTree = ""; 59 | }; 60 | 091879D72967400F0024642A /* Surf */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | 091879D82967400F0024642A /* AppDelegate.h */, 64 | 091879D92967400F0024642A /* AppDelegate.m */, 65 | 091879DB2967400F0024642A /* ViewController.h */, 66 | 091879DC2967400F0024642A /* ViewController.m */, 67 | 091879DE2967400F0024642A /* WaveformDocument.h */, 68 | 091879DF2967400F0024642A /* WaveformDocument.m */, 69 | 091879E3296740100024642A /* Main.storyboard */, 70 | 091879E6296740100024642A /* Info.plist */, 71 | 091879E7296740100024642A /* main.m */, 72 | 091879E9296740100024642A /* Surf.entitlements */, 73 | 09DB114A29677E1F00407DE8 /* Assets.xcassets */, 74 | ); 75 | path = Surf; 76 | sourceTree = ""; 77 | }; 78 | /* End PBXGroup section */ 79 | 80 | /* Begin PBXNativeTarget section */ 81 | 091879D42967400F0024642A /* Surf */ = { 82 | isa = PBXNativeTarget; 83 | buildConfigurationList = 091879EC296740100024642A /* Build configuration list for PBXNativeTarget "Surf" */; 84 | buildPhases = ( 85 | 091879D12967400F0024642A /* Sources */, 86 | 091879D22967400F0024642A /* Frameworks */, 87 | 091879D32967400F0024642A /* Resources */, 88 | ); 89 | buildRules = ( 90 | ); 91 | dependencies = ( 92 | ); 93 | name = Surf; 94 | productName = Surf; 95 | productReference = 091879D52967400F0024642A /* Surf.app */; 96 | productType = "com.apple.product-type.application"; 97 | }; 98 | /* End PBXNativeTarget section */ 99 | 100 | /* Begin PBXProject section */ 101 | 091879CD2967400F0024642A /* Project object */ = { 102 | isa = PBXProject; 103 | attributes = { 104 | BuildIndependentTargetsInParallel = 1; 105 | LastUpgradeCheck = 1410; 106 | TargetAttributes = { 107 | 091879D42967400F0024642A = { 108 | CreatedOnToolsVersion = 14.1; 109 | }; 110 | }; 111 | }; 112 | buildConfigurationList = 091879D02967400F0024642A /* Build configuration list for PBXProject "Surf" */; 113 | compatibilityVersion = "Xcode 14.0"; 114 | developmentRegion = en; 115 | hasScannedForEncodings = 0; 116 | knownRegions = ( 117 | en, 118 | Base, 119 | ); 120 | mainGroup = 091879CC2967400F0024642A; 121 | productRefGroup = 091879D62967400F0024642A /* Products */; 122 | projectDirPath = ""; 123 | projectRoot = ""; 124 | targets = ( 125 | 091879D42967400F0024642A /* Surf */, 126 | ); 127 | }; 128 | /* End PBXProject section */ 129 | 130 | /* Begin PBXResourcesBuildPhase section */ 131 | 091879D32967400F0024642A /* Resources */ = { 132 | isa = PBXResourcesBuildPhase; 133 | buildActionMask = 2147483647; 134 | files = ( 135 | 09DB114B29677E1F00407DE8 /* Assets.xcassets in Resources */, 136 | 091879E5296740100024642A /* Main.storyboard in Resources */, 137 | ); 138 | runOnlyForDeploymentPostprocessing = 0; 139 | }; 140 | /* End PBXResourcesBuildPhase section */ 141 | 142 | /* Begin PBXSourcesBuildPhase section */ 143 | 091879D12967400F0024642A /* Sources */ = { 144 | isa = PBXSourcesBuildPhase; 145 | buildActionMask = 2147483647; 146 | files = ( 147 | 091879E02967400F0024642A /* WaveformDocument.m in Sources */, 148 | 091879DD2967400F0024642A /* ViewController.m in Sources */, 149 | 091879E8296740100024642A /* main.m in Sources */, 150 | 091879DA2967400F0024642A /* AppDelegate.m in Sources */, 151 | ); 152 | runOnlyForDeploymentPostprocessing = 0; 153 | }; 154 | /* End PBXSourcesBuildPhase section */ 155 | 156 | /* Begin PBXVariantGroup section */ 157 | 091879E3296740100024642A /* Main.storyboard */ = { 158 | isa = PBXVariantGroup; 159 | children = ( 160 | 091879E4296740100024642A /* Base */, 161 | ); 162 | name = Main.storyboard; 163 | sourceTree = ""; 164 | }; 165 | /* End PBXVariantGroup section */ 166 | 167 | /* Begin XCBuildConfiguration section */ 168 | 091879EA296740100024642A /* Debug */ = { 169 | isa = XCBuildConfiguration; 170 | buildSettings = { 171 | ALWAYS_SEARCH_USER_PATHS = NO; 172 | CLANG_ANALYZER_NONNULL = YES; 173 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 174 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 175 | CLANG_ENABLE_MODULES = YES; 176 | CLANG_ENABLE_OBJC_ARC = YES; 177 | CLANG_ENABLE_OBJC_WEAK = YES; 178 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 179 | CLANG_WARN_BOOL_CONVERSION = YES; 180 | CLANG_WARN_COMMA = YES; 181 | CLANG_WARN_CONSTANT_CONVERSION = YES; 182 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 183 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 184 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 185 | CLANG_WARN_EMPTY_BODY = YES; 186 | CLANG_WARN_ENUM_CONVERSION = YES; 187 | CLANG_WARN_INFINITE_RECURSION = YES; 188 | CLANG_WARN_INT_CONVERSION = YES; 189 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 190 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 191 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 192 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 193 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 194 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 195 | CLANG_WARN_STRICT_PROTOTYPES = YES; 196 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 197 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 198 | CLANG_WARN_UNREACHABLE_CODE = YES; 199 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 200 | COPY_PHASE_STRIP = NO; 201 | DEBUG_INFORMATION_FORMAT = dwarf; 202 | ENABLE_STRICT_OBJC_MSGSEND = YES; 203 | ENABLE_TESTABILITY = YES; 204 | GCC_C_LANGUAGE_STANDARD = gnu11; 205 | GCC_DYNAMIC_NO_PIC = NO; 206 | GCC_NO_COMMON_BLOCKS = YES; 207 | GCC_OPTIMIZATION_LEVEL = 0; 208 | GCC_PREPROCESSOR_DEFINITIONS = ( 209 | "DEBUG=1", 210 | "$(inherited)", 211 | ); 212 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 213 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 214 | GCC_WARN_UNDECLARED_SELECTOR = YES; 215 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 216 | GCC_WARN_UNUSED_FUNCTION = YES; 217 | GCC_WARN_UNUSED_VARIABLE = YES; 218 | MACOSX_DEPLOYMENT_TARGET = 13.0; 219 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 220 | MTL_FAST_MATH = YES; 221 | ONLY_ACTIVE_ARCH = YES; 222 | SDKROOT = macosx; 223 | }; 224 | name = Debug; 225 | }; 226 | 091879EB296740100024642A /* Release */ = { 227 | isa = XCBuildConfiguration; 228 | buildSettings = { 229 | ALWAYS_SEARCH_USER_PATHS = NO; 230 | CLANG_ANALYZER_NONNULL = YES; 231 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 232 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 233 | CLANG_ENABLE_MODULES = YES; 234 | CLANG_ENABLE_OBJC_ARC = YES; 235 | CLANG_ENABLE_OBJC_WEAK = YES; 236 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 237 | CLANG_WARN_BOOL_CONVERSION = YES; 238 | CLANG_WARN_COMMA = YES; 239 | CLANG_WARN_CONSTANT_CONVERSION = YES; 240 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 241 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 242 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 243 | CLANG_WARN_EMPTY_BODY = YES; 244 | CLANG_WARN_ENUM_CONVERSION = YES; 245 | CLANG_WARN_INFINITE_RECURSION = YES; 246 | CLANG_WARN_INT_CONVERSION = YES; 247 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 248 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 249 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 250 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 251 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 252 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 253 | CLANG_WARN_STRICT_PROTOTYPES = YES; 254 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 255 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 256 | CLANG_WARN_UNREACHABLE_CODE = YES; 257 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 258 | COPY_PHASE_STRIP = NO; 259 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 260 | ENABLE_NS_ASSERTIONS = NO; 261 | ENABLE_STRICT_OBJC_MSGSEND = YES; 262 | GCC_C_LANGUAGE_STANDARD = gnu11; 263 | GCC_NO_COMMON_BLOCKS = YES; 264 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 265 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 266 | GCC_WARN_UNDECLARED_SELECTOR = YES; 267 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 268 | GCC_WARN_UNUSED_FUNCTION = YES; 269 | GCC_WARN_UNUSED_VARIABLE = YES; 270 | MACOSX_DEPLOYMENT_TARGET = 13.0; 271 | MTL_ENABLE_DEBUG_INFO = NO; 272 | MTL_FAST_MATH = YES; 273 | SDKROOT = macosx; 274 | }; 275 | name = Release; 276 | }; 277 | 091879ED296740100024642A /* Debug */ = { 278 | isa = XCBuildConfiguration; 279 | buildSettings = { 280 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 281 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 282 | ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; 283 | CODE_SIGN_ENTITLEMENTS = Surf/Surf.entitlements; 284 | CODE_SIGN_STYLE = Automatic; 285 | COMBINE_HIDPI_IMAGES = YES; 286 | CURRENT_PROJECT_VERSION = 1; 287 | DEVELOPMENT_TEAM = ZK96P738ZR; 288 | ENABLE_HARDENED_RUNTIME = YES; 289 | GENERATE_INFOPLIST_FILE = YES; 290 | INFOPLIST_FILE = Surf/Info.plist; 291 | INFOPLIST_KEY_NSMainStoryboardFile = Main; 292 | INFOPLIST_KEY_NSPrincipalClass = NSApplication; 293 | LD_RUNPATH_SEARCH_PATHS = ( 294 | "$(inherited)", 295 | "@executable_path/../Frameworks", 296 | ); 297 | MARKETING_VERSION = 1.0; 298 | PRODUCT_BUNDLE_IDENTIFIER = vin.je.Surf; 299 | PRODUCT_NAME = "$(TARGET_NAME)"; 300 | SWIFT_EMIT_LOC_STRINGS = YES; 301 | }; 302 | name = Debug; 303 | }; 304 | 091879EE296740100024642A /* Release */ = { 305 | isa = XCBuildConfiguration; 306 | buildSettings = { 307 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 308 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 309 | ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; 310 | CODE_SIGN_ENTITLEMENTS = Surf/Surf.entitlements; 311 | CODE_SIGN_STYLE = Automatic; 312 | COMBINE_HIDPI_IMAGES = YES; 313 | CURRENT_PROJECT_VERSION = 1; 314 | DEVELOPMENT_TEAM = ZK96P738ZR; 315 | ENABLE_HARDENED_RUNTIME = YES; 316 | GENERATE_INFOPLIST_FILE = YES; 317 | INFOPLIST_FILE = Surf/Info.plist; 318 | INFOPLIST_KEY_NSMainStoryboardFile = Main; 319 | INFOPLIST_KEY_NSPrincipalClass = NSApplication; 320 | LD_RUNPATH_SEARCH_PATHS = ( 321 | "$(inherited)", 322 | "@executable_path/../Frameworks", 323 | ); 324 | MARKETING_VERSION = 1.0; 325 | PRODUCT_BUNDLE_IDENTIFIER = vin.je.Surf; 326 | PRODUCT_NAME = "$(TARGET_NAME)"; 327 | SWIFT_EMIT_LOC_STRINGS = YES; 328 | }; 329 | name = Release; 330 | }; 331 | /* End XCBuildConfiguration section */ 332 | 333 | /* Begin XCConfigurationList section */ 334 | 091879D02967400F0024642A /* Build configuration list for PBXProject "Surf" */ = { 335 | isa = XCConfigurationList; 336 | buildConfigurations = ( 337 | 091879EA296740100024642A /* Debug */, 338 | 091879EB296740100024642A /* Release */, 339 | ); 340 | defaultConfigurationIsVisible = 0; 341 | defaultConfigurationName = Release; 342 | }; 343 | 091879EC296740100024642A /* Build configuration list for PBXNativeTarget "Surf" */ = { 344 | isa = XCConfigurationList; 345 | buildConfigurations = ( 346 | 091879ED296740100024642A /* Debug */, 347 | 091879EE296740100024642A /* Release */, 348 | ); 349 | defaultConfigurationIsVisible = 0; 350 | defaultConfigurationName = Release; 351 | }; 352 | /* End XCConfigurationList section */ 353 | }; 354 | rootObject = 091879CD2967400F0024642A /* Project object */; 355 | } 356 | -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf.xcodeproj/xcuserdata/jevin.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Surf.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Surf 4 | // 5 | // Created by Jevin Sweval on 1/5/23. 6 | // 7 | 8 | #import 9 | 10 | @interface AppDelegate : NSObject 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // Surf 4 | // 5 | // Created by Jevin Sweval on 1/5/23. 6 | // 7 | 8 | #import "AppDelegate.h" 9 | 10 | @interface AppDelegate () 11 | 12 | @end 13 | 14 | @implementation AppDelegate 15 | 16 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 17 | // Insert code here to initialize your application 18 | } 19 | 20 | - (void)applicationWillTerminate:(NSNotification *)aNotification { 21 | // Insert code here to tear down your application 22 | } 23 | 24 | - (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app { 25 | return YES; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "platform" : "universal", 6 | "reference" : "systemIndigoColor" 7 | }, 8 | "idiom" : "universal" 9 | }, 10 | { 11 | "appearances" : [ 12 | { 13 | "appearance" : "luminosity", 14 | "value" : "dark" 15 | } 16 | ], 17 | "color" : { 18 | "platform" : "universal", 19 | "reference" : "systemIndigoColor" 20 | }, 21 | "idiom" : "universal" 22 | } 23 | ], 24 | "info" : { 25 | "author" : "xcode", 26 | "version" : 1 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "icon_16x16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "icon_16x16@2x.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "icon_32x32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "icon_32x32@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "icon_128x128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "icon_128x128@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "icon_256x256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "icon_256x256@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "icon_512x512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "icon_512x512@2x.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_128x128.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_16x16.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_256x256.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_32x32.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_512x512.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_128x128.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_128x128@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_128x128@2x.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_16x16.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_16x16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_16x16@2x.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_256x256.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_256x256@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_256x256@2x.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_32x32.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_32x32@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_32x32@2x.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_512x512.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_512x512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform-plain.iconset/icon_512x512@2x.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_128x128.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_128x128@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_128x128@2x.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_16x16.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_16x16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_16x16@2x.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_256x256.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_256x256@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_256x256@2x.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_32x32.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_32x32@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_32x32@2x.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_512x512.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_512x512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/old/surf-v1-objc/Surf/Assets.xcassets/waveform.iconset/icon_512x512@2x.png -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDocumentTypes 6 | 7 | 8 | CFBundleTypeName 9 | Value Change Dump 10 | CFBundleTypeRole 11 | Viewer 12 | LSHandlerRank 13 | Alternate 14 | LSItemContentTypes 15 | 16 | public.value-change-dump 17 | 18 | NSDocumentClass 19 | WaveformDocument 20 | 21 | 22 | UTExportedTypeDeclarations 23 | 24 | 25 | UTTypeConformsTo 26 | 27 | public.data 28 | 29 | UTTypeDescription 30 | Value Change Dump 31 | UTTypeIconFile 32 | waveform 33 | UTTypeIcons 34 | 35 | UTTypeIconBadgeName 36 | waveform-plain 37 | UTTypeIconText 38 | VCD 39 | 40 | UTTypeIdentifier 41 | public.value-change-dump 42 | UTTypeReferenceURL 43 | https://en.wikipedia.org/wiki/Value_change_dump 44 | UTTypeTagSpecification 45 | 46 | public.filename-extension 47 | 48 | vcd 49 | VCD 50 | 51 | 52 | 53 | 54 | UTImportedTypeDeclarations 55 | 56 | 57 | UTTypeConformsTo 58 | 59 | public.data 60 | 61 | UTTypeDescription 62 | Value Change Dump 63 | UTTypeIcons 64 | 65 | UTTypeIconBadgeName 66 | waveform-plain 67 | UTTypeIconText 68 | VCD 69 | 70 | UTTypeIdentifier 71 | public.value-change-dump 72 | UTTypeReferenceURL 73 | https://en.wikipedia.org/wiki/Value_change_dump 74 | UTTypeTagSpecification 75 | 76 | public.filename-extension 77 | 78 | vcd 79 | VCD 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/Surf.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // Surf 4 | // 5 | // Created by Jevin Sweval on 1/5/23. 6 | // 7 | 8 | #import 9 | 10 | @interface ViewController : NSViewController 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // Surf 4 | // 5 | // Created by Jevin Sweval on 1/5/23. 6 | // 7 | 8 | #import "ViewController.h" 9 | 10 | @implementation ViewController 11 | 12 | - (void)viewDidLoad { 13 | [super viewDidLoad]; 14 | 15 | // Do any additional setup after loading the view. 16 | } 17 | 18 | - (void)setRepresentedObject:(id)representedObject { 19 | [super setRepresentedObject:representedObject]; 20 | 21 | // Update the view, if already loaded. 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/WaveformDocument.h: -------------------------------------------------------------------------------- 1 | // 2 | // Document.h 3 | // Surf 4 | // 5 | // Created by Jevin Sweval on 1/5/23. 6 | // 7 | 8 | #import 9 | 10 | @interface WaveformDocument : NSDocument 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/WaveformDocument.m: -------------------------------------------------------------------------------- 1 | // 2 | // WaveformDocument.m 3 | // Surf 4 | // 5 | // Created by Jevin Sweval on 1/5/23. 6 | // 7 | 8 | #import "WaveformDocument.h" 9 | 10 | @interface WaveformDocument () 11 | @property(atomic, strong) NSURL *url; 12 | @property(atomic, strong) NSData *data; 13 | @end 14 | 15 | @implementation WaveformDocument 16 | 17 | - (instancetype)init { 18 | self = [super init]; 19 | if (self) { 20 | // Add your subclass-specific initialization here. 21 | } 22 | return self; 23 | } 24 | 25 | + (BOOL)autosavesInPlace { 26 | return YES; 27 | } 28 | 29 | - (void)makeWindowControllers { 30 | // Override to return the Storyboard file name of the document. 31 | [self 32 | addWindowController:[[NSStoryboard storyboardWithName:@"Main" bundle:nil] 33 | instantiateControllerWithIdentifier:@"Document Window Controller"]]; 34 | } 35 | 36 | - (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError { 37 | // Read-only, not implemented 38 | [NSException raise:@"UnimplementedMethod" 39 | format:@"%@ is unimplemented", NSStringFromSelector(_cmd)]; 40 | return nil; 41 | } 42 | 43 | - (BOOL)isEntireFileLoaded { 44 | return NO; 45 | } 46 | 47 | - (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError { 48 | NSLog(@"data: %@ type: %@\n", data, typeName); 49 | return YES; 50 | } 51 | 52 | - (BOOL)readFromURL:(NSURL *)url error:(NSError *_Nullable *)outError { 53 | self.url = url; 54 | self.data = [NSData dataWithContentsOfURL:self.url 55 | options:NSDataReadingMappedIfSafe 56 | error:outError]; 57 | if (outError || !self.data) { 58 | return NO; 59 | } 60 | return YES; 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /old/surf-v1-objc/Surf/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Surf 4 | // 5 | // Created by Jevin Sweval on 1/5/23. 6 | // 7 | 8 | #import 9 | 10 | int main(int argc, const char *argv[]) { 11 | @autoreleasepool { 12 | // Setup code that might create autoreleased objects goes here. 13 | } 14 | return NSApplicationMain(argc, argv); 15 | } 16 | -------------------------------------------------------------------------------- /test/vcd/empty.vcd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jevinskie/surf/06a5de7acab990167a4c7f7abfd7ffa4c4a5d947/test/vcd/empty.vcd -------------------------------------------------------------------------------- /test/vcd/parse-test.vcd: -------------------------------------------------------------------------------- 1 | $comment decl comment $end 2 | $timescale 10 ns $end 3 | $version Hand Mk I $end 4 | $scope module TOP $end 5 | $var wire 1 O! sim_trace $end 6 | $comment decl comment dos $end 7 | $var wire 1 O" sim_stop $end 8 | $scope module cpu $end 9 | $var wire 32 !! pc_addr [31:0] $end 10 | $upscope $end 11 | $scope module cpu2 $end 12 | $var wire 32 !2 pc2_addr [31:0] $end 13 | $upscope $end 14 | $upscope $end 15 | $enddefinitions $end 16 | #10 17 | 0 a 18 | $comment lol hai $end 19 | #11 20 | x b 21 | z C 22 | #14 23 | b0100 F! 24 | 1 a 25 | #15 26 | r243.1337 UN 27 | r-13.37 noU 28 | --------------------------------------------------------------------------------