├── .gitignore ├── BenchMark.lpi ├── BenchMark.lpr ├── BenchMark.lps ├── DecodeStuff.lpi ├── DecodeStuff.lpr ├── DecodeStuff.lps ├── Expressor.lpi ├── Expressor.lpr ├── Expressor.lps ├── LICENSE ├── PassThrough.lpi ├── PassThrough.lpr ├── PassThrough.lps ├── README.md ├── WhyBitGrid.txt ├── bitgrid_coding_tests.lpi ├── bitgrid_coding_tests.lpr ├── bitgrid_coding_tests.lps ├── bitgrid_gui.ico ├── bitgrid_gui.lpi ├── bitgrid_gui.lpr ├── bitgrid_gui.lps ├── bitgrid_gui.res ├── bitgridengine.pas ├── bitgridutil.pas ├── ideas.txt ├── mainform.lfm ├── mainform.pas └── readme.txt /.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | *.zip 3 | *.xl* 4 | *.csv 5 | backup/* 6 | lib/* 7 | test/* 8 | */backup/* 9 | */lib/* 10 | */test/* 11 | 12 | 13 | -------------------------------------------------------------------------------- /BenchMark.lpi: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | <UseAppBundle Value="False"/> 15 | <ResourceType Value="res"/> 16 | </General> 17 | <BuildModes> 18 | <Item Name="Default" Default="True"/> 19 | <SharedMatrixOptions Count="1"> 20 | <Item1 ID="517201400998" Modes="Default" Value="-dDisableUTF8RTL"/> 21 | </SharedMatrixOptions> 22 | </BuildModes> 23 | <PublishOptions> 24 | <Version Value="2"/> 25 | <UseFileFilters Value="True"/> 26 | </PublishOptions> 27 | <RunParams> 28 | <FormatVersion Value="2"/> 29 | </RunParams> 30 | <Units> 31 | <Unit> 32 | <Filename Value="BenchMark.lpr"/> 33 | <IsPartOfProject Value="True"/> 34 | </Unit> 35 | </Units> 36 | </ProjectOptions> 37 | <CompilerOptions> 38 | <Version Value="11"/> 39 | <PathDelim Value="\"/> 40 | <Target> 41 | <Filename Value="BenchMark"/> 42 | </Target> 43 | <SearchPaths> 44 | <IncludeFiles Value="$(ProjOutDir)"/> 45 | <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 46 | </SearchPaths> 47 | <CodeGeneration> 48 | <Optimizations> 49 | <OptimizationLevel Value="3"/> 50 | </Optimizations> 51 | </CodeGeneration> 52 | <Linking> 53 | <Debugging> 54 | <GenerateDebugInfo Value="False"/> 55 | <DebugInfoType Value="dsDwarf2Set"/> 56 | <StripSymbols Value="True"/> 57 | </Debugging> 58 | </Linking> 59 | </CompilerOptions> 60 | <Debugging> 61 | <Exceptions> 62 | <Item> 63 | <Name Value="EAbort"/> 64 | </Item> 65 | <Item> 66 | <Name Value="ECodetoolError"/> 67 | </Item> 68 | <Item> 69 | <Name Value="EFOpenError"/> 70 | </Item> 71 | </Exceptions> 72 | </Debugging> 73 | </CONFIG> 74 | -------------------------------------------------------------------------------- /BenchMark.lpr: -------------------------------------------------------------------------------- 1 | program BenchMark; 2 | uses 3 | SysUtils, DateUtils, Windows, BitgridEngine; 4 | const 5 | X = 1024; // size of the bitgrid to build 6 | Y = 1024; 7 | T = 100; // how many times to run it 8 | var 9 | Grid : TBitGrid; 10 | i : integer; 11 | T1,T2 : tDateTime; 12 | TimeElapsed, TimePerCell : Double; 13 | dx,dy : integer; 14 | begin 15 | SetConsoleOutputCP(CP_UTF8); // so we can print µSec 16 | WriteLn('Creating ',x,'*',y,' bitgrid'); 17 | Grid.Init(X,Y); 18 | 19 | for dy := 0 to Grid.Height-1 do 20 | for dx := 0 to Grid.Width-1 do 21 | Grid.Cells[dx,dy].lookup := Passthrough; 22 | 23 | Grid.Cells[Grid.Width-1,0].lookup:= $0000000088888888; 24 | For dx := 0 to Grid.Width-2 do 25 | Grid.Cells[dx,0].lookup := $FF08FF0877807780; 26 | 27 | For dx := 0 to Grid.Width-1 do 28 | Grid.Cells[dx,Grid.Height-1].lookup := $4444000044440000; // reflect down, otherwise 0 29 | 30 | WriteLn('Running ',T,' full cycles'); 31 | T1 := SysUtils.Now; 32 | For i := 1 to T do 33 | Grid.DoClock; 34 | T2 := SysUtils.Now; 35 | WriteLn('Done'); 36 | TimeElapsed := MilliSecondsBetween(T2,T1)/1000.0; 37 | WriteLn('Time Elapsed : ',TimeElapsed:8:3,' Seconds'); 38 | WriteLn('Time/Layer : ',(TimeElapsed/T):8:3,' Seconds, or ',(T/TimeElapsed):4:3,' Hz effective clock rate'); 39 | WriteLn('Time/Cell : ',(TimeElapsed*1000000.0/(X*Y*T)):8:3,' µSec'); 40 | end. 41 | 42 | -------------------------------------------------------------------------------- /BenchMark.lps: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectSession> 4 | <PathDelim Value="\"/> 5 | <Version Value="12"/> 6 | <BuildModes Active="Default"/> 7 | <Units> 8 | <Unit> 9 | <Filename Value="BenchMark.lpr"/> 10 | <IsPartOfProject Value="True"/> 11 | <IsVisibleTab Value="True"/> 12 | <CursorPos Y="29"/> 13 | <UsageCount Value="21"/> 14 | <Loaded Value="True"/> 15 | </Unit> 16 | <Unit> 17 | <Filename Value="bitgridengine2.pas"/> 18 | <EditorIndex Value="-1"/> 19 | <WindowIndex Value="1"/> 20 | <TopLine Value="-1"/> 21 | <CursorPos X="-1" Y="-1"/> 22 | <ExtraEditorCount Value="1"/> 23 | <ExtraEditor1> 24 | <EditorIndex Value="-1"/> 25 | <TopLine Value="31"/> 26 | <CursorPos X="7" Y="46"/> 27 | </ExtraEditor1> 28 | <UsageCount Value="10"/> 29 | </Unit> 30 | </Units> 31 | <JumpHistory HistoryIndex="6"> 32 | <Position> 33 | <Filename Value="BenchMark.lpr"/> 34 | <Caret Line="6" Column="28"/> 35 | </Position> 36 | <Position> 37 | <Filename Value="BenchMark.lpr"/> 38 | <Caret Line="3" Column="30"/> 39 | </Position> 40 | <Position> 41 | <Filename Value="BenchMark.lpr"/> 42 | <Caret Line="25" Column="76"/> 43 | </Position> 44 | <Position> 45 | <Filename Value="BenchMark.lpr"/> 46 | <Caret Line="14" Column="31"/> 47 | </Position> 48 | <Position> 49 | <Filename Value="BenchMark.lpr"/> 50 | <Caret Line="25" Column="65" TopLine="11"/> 51 | </Position> 52 | <Position> 53 | <Filename Value="BenchMark.lpr"/> 54 | <Caret Line="29"/> 55 | </Position> 56 | <Position> 57 | <Filename Value="BenchMark.lpr"/> 58 | <Caret Line="13" Column="19"/> 59 | </Position> 60 | </JumpHistory> 61 | <RunParams> 62 | <FormatVersion Value="2"/> 63 | <Modes ActiveMode=""/> 64 | </RunParams> 65 | </ProjectSession> 66 | </CONFIG> 67 | -------------------------------------------------------------------------------- /DecodeStuff.lpi: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectOptions> 4 | <Version Value="12"/> 5 | <PathDelim Value="\"/> 6 | <General> 7 | <Flags> 8 | <MainUnitHasCreateFormStatements Value="False"/> 9 | <MainUnitHasTitleStatement Value="False"/> 10 | <MainUnitHasScaledStatement Value="False"/> 11 | </Flags> 12 | <SessionStorage Value="InProjectDir"/> 13 | <Title Value="DecodeStuff"/> 14 | <UseAppBundle Value="False"/> 15 | <ResourceType Value="res"/> 16 | </General> 17 | <BuildModes> 18 | <Item Name="Default" Default="True"/> 19 | </BuildModes> 20 | <PublishOptions> 21 | <Version Value="2"/> 22 | <UseFileFilters Value="True"/> 23 | </PublishOptions> 24 | <RunParams> 25 | <FormatVersion Value="2"/> 26 | </RunParams> 27 | <Units> 28 | <Unit> 29 | <Filename Value="DecodeStuff.lpr"/> 30 | <IsPartOfProject Value="True"/> 31 | </Unit> 32 | </Units> 33 | </ProjectOptions> 34 | <CompilerOptions> 35 | <Version Value="11"/> 36 | <PathDelim Value="\"/> 37 | <Target> 38 | <Filename Value="DecodeStuff"/> 39 | </Target> 40 | <SearchPaths> 41 | <IncludeFiles Value="$(ProjOutDir)"/> 42 | <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 43 | </SearchPaths> 44 | </CompilerOptions> 45 | <Debugging> 46 | <Exceptions> 47 | <Item> 48 | <Name Value="EAbort"/> 49 | </Item> 50 | <Item> 51 | <Name Value="ECodetoolError"/> 52 | </Item> 53 | <Item> 54 | <Name Value="EFOpenError"/> 55 | </Item> 56 | </Exceptions> 57 | </Debugging> 58 | </CONFIG> 59 | -------------------------------------------------------------------------------- /DecodeStuff.lpr: -------------------------------------------------------------------------------- 1 | program DecodeStuff; 2 | 3 | begin 4 | end. 5 | 6 | -------------------------------------------------------------------------------- /DecodeStuff.lps: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectSession> 4 | <PathDelim Value="\"/> 5 | <Version Value="12"/> 6 | <BuildModes Active="Default"/> 7 | <Units> 8 | <Unit> 9 | <Filename Value="DecodeStuff.lpr"/> 10 | <IsPartOfProject Value="True"/> 11 | <IsVisibleTab Value="True"/> 12 | <UsageCount Value="20"/> 13 | <Loaded Value="True"/> 14 | </Unit> 15 | </Units> 16 | <JumpHistory HistoryIndex="-1"/> 17 | <RunParams> 18 | <FormatVersion Value="2"/> 19 | <Modes ActiveMode=""/> 20 | </RunParams> 21 | </ProjectSession> 22 | </CONFIG> 23 | -------------------------------------------------------------------------------- /Expressor.lpi: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectOptions> 4 | <Version Value="12"/> 5 | <PathDelim Value="\"/> 6 | <General> 7 | <Flags> 8 | <MainUnitHasCreateFormStatements Value="False"/> 9 | <MainUnitHasTitleStatement Value="False"/> 10 | <MainUnitHasScaledStatement Value="False"/> 11 | </Flags> 12 | <SessionStorage Value="InProjectDir"/> 13 | <Title Value="Expressor"/> 14 | <UseAppBundle Value="False"/> 15 | <ResourceType Value="res"/> 16 | </General> 17 | <BuildModes> 18 | <Item Name="Default" Default="True"/> 19 | </BuildModes> 20 | <PublishOptions> 21 | <Version Value="2"/> 22 | <UseFileFilters Value="True"/> 23 | </PublishOptions> 24 | <RunParams> 25 | <FormatVersion Value="2"/> 26 | </RunParams> 27 | <Units> 28 | <Unit> 29 | <Filename Value="Expressor.lpr"/> 30 | <IsPartOfProject Value="True"/> 31 | </Unit> 32 | </Units> 33 | </ProjectOptions> 34 | <CompilerOptions> 35 | <Version Value="11"/> 36 | <PathDelim Value="\"/> 37 | <Target> 38 | <Filename Value="Expressor"/> 39 | </Target> 40 | <SearchPaths> 41 | <IncludeFiles Value="$(ProjOutDir)"/> 42 | <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 43 | </SearchPaths> 44 | <Linking> 45 | <Debugging> 46 | <DebugInfoType Value="dsDwarf2Set"/> 47 | </Debugging> 48 | </Linking> 49 | </CompilerOptions> 50 | <Debugging> 51 | <Exceptions> 52 | <Item> 53 | <Name Value="EAbort"/> 54 | </Item> 55 | <Item> 56 | <Name Value="ECodetoolError"/> 57 | </Item> 58 | <Item> 59 | <Name Value="EFOpenError"/> 60 | </Item> 61 | </Exceptions> 62 | </Debugging> 63 | </CONFIG> 64 | -------------------------------------------------------------------------------- /Expressor.lpr: -------------------------------------------------------------------------------- 1 | program Expressor; 2 | uses 3 | sysutils; 4 | const 5 | _Up = 1; // (bit 0) 6 | _Right = 2; // (bit 1) 7 | _Down = 4; // (bit 2) 8 | _Left = 8; // (bit 3) 9 | var 10 | up, down, left, right : Boolean; 11 | out_up,out_down,out_left,out_right : Boolean; 12 | i,X : integer; 13 | ZZ : Int64; 14 | 15 | begin 16 | ZZ := 00; 17 | for i := 15 downto 0 do 18 | begin 19 | up := (i AND _Up) <> 0; 20 | right := (i AND _right) <> 0; 21 | down := (i AND _down) <> 0; 22 | left := (i AND _left) <> 0; 23 | 24 | // User stuff goes here 25 | (* 26 | out_up := right; 27 | out_down := right; 28 | if Up AND (Not Right) then 29 | out_left := NOT Left 30 | else 31 | out_left := left; 32 | out_right := right; 33 | *) 34 | (* 35 | out_up := false; 36 | out_down := false; 37 | out_left := not left; 38 | out_right := false; 39 | *) 40 | out_up := false; 41 | out_down := left; 42 | out_left := up; 43 | out_right := right; 44 | // back to normal stuff here 45 | 46 | x := 0; 47 | if out_up then inc(x,_up); 48 | if out_down then inc(x,_down); 49 | if out_left then inc(x,_left); 50 | if out_right then inc(x,_right); 51 | 52 | ZZ := (ZZ SHL 4) OR X; 53 | 54 | end; 55 | WriteLn('Result = ',IntToHex(ZZ,16)); 56 | ReadLn; 57 | end. 58 | 59 | -------------------------------------------------------------------------------- /Expressor.lps: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectSession> 4 | <PathDelim Value="\"/> 5 | <Version Value="12"/> 6 | <BuildModes Active="Default"/> 7 | <Units> 8 | <Unit> 9 | <Filename Value="Expressor.lpr"/> 10 | <IsPartOfProject Value="True"/> 11 | <IsVisibleTab Value="True"/> 12 | <TopLine Value="11"/> 13 | <CursorPos X="20" Y="43"/> 14 | <UsageCount Value="20"/> 15 | <Loaded Value="True"/> 16 | </Unit> 17 | </Units> 18 | <JumpHistory HistoryIndex="2"> 19 | <Position> 20 | <Filename Value="Expressor.lpr"/> 21 | <Caret Line="9" Column="6"/> 22 | </Position> 23 | <Position> 24 | <Filename Value="Expressor.lpr"/> 25 | <Caret Line="40" Column="40" TopLine="5"/> 26 | </Position> 27 | <Position> 28 | <Filename Value="Expressor.lpr"/> 29 | <Caret Line="29" Column="23" TopLine="8"/> 30 | </Position> 31 | </JumpHistory> 32 | <RunParams> 33 | <FormatVersion Value="2"/> 34 | <Modes ActiveMode=""/> 35 | </RunParams> 36 | </ProjectSession> 37 | </CONFIG> 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | <one line to give the program's name and a brief idea of what it does.> 635 | Copyright (C) <year> <name of author> 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see <https://www.gnu.org/licenses/>. 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | <program> Copyright (C) <year> <name of author> 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | <https://www.gnu.org/licenses/>. 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | <https://www.gnu.org/licenses/why-not-lgpl.html>. 675 | -------------------------------------------------------------------------------- /PassThrough.lpi: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectOptions> 4 | <Version Value="12"/> 5 | <PathDelim Value="\"/> 6 | <General> 7 | <Flags> 8 | <MainUnitHasCreateFormStatements Value="False"/> 9 | <MainUnitHasTitleStatement Value="False"/> 10 | <MainUnitHasScaledStatement Value="False"/> 11 | </Flags> 12 | <SessionStorage Value="InProjectDir"/> 13 | <Title Value="PassThrough"/> 14 | <UseAppBundle Value="False"/> 15 | <ResourceType Value="res"/> 16 | </General> 17 | <BuildModes> 18 | <Item Name="Default" Default="True"/> 19 | <SharedMatrixOptions Count="1"> 20 | <Item1 ID="517201400998" Modes="Default" Value="-dDisableUTF8RTL"/> 21 | </SharedMatrixOptions> 22 | </BuildModes> 23 | <PublishOptions> 24 | <Version Value="2"/> 25 | <UseFileFilters Value="True"/> 26 | </PublishOptions> 27 | <RunParams> 28 | <FormatVersion Value="2"/> 29 | </RunParams> 30 | <Units> 31 | <Unit> 32 | <Filename Value="PassThrough.lpr"/> 33 | <IsPartOfProject Value="True"/> 34 | </Unit> 35 | </Units> 36 | </ProjectOptions> 37 | <CompilerOptions> 38 | <Version Value="11"/> 39 | <PathDelim Value="\"/> 40 | <Target> 41 | <Filename Value="PassThrough"/> 42 | </Target> 43 | <SearchPaths> 44 | <IncludeFiles Value="$(ProjOutDir)"/> 45 | <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 46 | </SearchPaths> 47 | <CodeGeneration> 48 | <Optimizations> 49 | <OptimizationLevel Value="3"/> 50 | </Optimizations> 51 | </CodeGeneration> 52 | <Linking> 53 | <Debugging> 54 | <GenerateDebugInfo Value="False"/> 55 | <DebugInfoType Value="dsDwarf2Set"/> 56 | <StripSymbols Value="True"/> 57 | </Debugging> 58 | </Linking> 59 | </CompilerOptions> 60 | <Debugging> 61 | <Exceptions> 62 | <Item> 63 | <Name Value="EAbort"/> 64 | </Item> 65 | <Item> 66 | <Name Value="ECodetoolError"/> 67 | </Item> 68 | <Item> 69 | <Name Value="EFOpenError"/> 70 | </Item> 71 | </Exceptions> 72 | </Debugging> 73 | </CONFIG> 74 | -------------------------------------------------------------------------------- /PassThrough.lpr: -------------------------------------------------------------------------------- 1 | program PassThrough; 2 | uses 3 | SysUtils, DateUtils, Windows, BitgridEngine; 4 | const 5 | X = 32; // size of the bitgrid to build 6 | Y = 32; 7 | var 8 | Grid : TBitGrid; 9 | i,t : integer; 10 | T1,T2 : tDateTime; 11 | TimeElapsed, TimePerCell : Double; 12 | dx,dy : integer; 13 | src,dst : TextFile; 14 | c : char; 15 | begin 16 | SetConsoleOutputCP(CP_UTF8); // so we can print µSec 17 | WriteLn('Creating ',x,'*',y,' bitgrid'); 18 | Grid.Init(X,Y); 19 | 20 | for dy := 0 to Grid.Height-1 do 21 | for dx := 0 to Grid.Width-1 do 22 | Grid.Cells[dx,dy].lookup := BitGridEngine.PassThrough; 23 | 24 | T1 := SysUtils.Now; 25 | 26 | Assign(Src,'WhyBitGrid.txt'); 27 | Reset(Src); 28 | While Not Eof(Src) do 29 | begin 30 | read(src,c); 31 | Grid.PutBit(0,0,(((Byte(C) SHR 7) AND 1) <> 0)); 32 | Grid.PutBit(0,1,(((Byte(C) SHR 6) AND 1) <> 0)); 33 | Grid.PutBit(0,2,(((Byte(C) SHR 5) AND 1) <> 0)); 34 | Grid.PutBit(0,3,(((Byte(C) SHR 4) AND 1) <> 0)); 35 | Grid.PutBit(0,4,(((Byte(C) SHR 3) AND 1) <> 0)); 36 | Grid.PutBit(0,5,(((Byte(C) SHR 2) AND 1) <> 0)); 37 | Grid.PutBit(0,6,(((Byte(C) SHR 1) AND 1) <> 0)); 38 | Grid.PutBit(0,7,(((Byte(C) SHR 0) AND 1) <> 0)); 39 | Grid.DoClock; 40 | end; 41 | Close(Src); 42 | 43 | T2 := SysUtils.Now; 44 | T := Grid.CycleCount; 45 | WriteLn('Done, ',t,' cycles executed'); 46 | TimeElapsed := MilliSecondsBetween(T2,T1)/1000.0; 47 | WriteLn('Time Elapsed : ',TimeElapsed:8:3,' Seconds'); 48 | WriteLn('Time/Layer : ',(TimeElapsed/T):8:3,' Seconds, or ',(T*1.0/TimeElapsed):4:3,' Hz effective clock rate'); 49 | WriteLn('Time/Cell : ',(TimeElapsed*1000000.0/(X*Y*T)):8:3,' µSec'); 50 | end. 51 | 52 | -------------------------------------------------------------------------------- /PassThrough.lps: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectSession> 4 | <PathDelim Value="\"/> 5 | <Version Value="12"/> 6 | <BuildModes Active="Default"/> 7 | <Units> 8 | <Unit> 9 | <Filename Value="PassThrough.lpr"/> 10 | <IsPartOfProject Value="True"/> 11 | <IsVisibleTab Value="True"/> 12 | <TopLine Value="12"/> 13 | <CursorPos X="37" Y="38"/> 14 | <ExtraEditorCount Value="1"/> 15 | <ExtraEditor1> 16 | <EditorIndex Value="-1"/> 17 | <WindowIndex Value="1"/> 18 | <TopLine Value="-1"/> 19 | <CursorPos X="-1" Y="-1"/> 20 | </ExtraEditor1> 21 | <UsageCount Value="21"/> 22 | <Loaded Value="True"/> 23 | </Unit> 24 | <Unit> 25 | <Filename Value="bitgridengine2.pas"/> 26 | <EditorIndex Value="-1"/> 27 | <WindowIndex Value="1"/> 28 | <TopLine Value="-1"/> 29 | <CursorPos X="-1" Y="-1"/> 30 | <ExtraEditorCount Value="1"/> 31 | <ExtraEditor1> 32 | <EditorIndex Value="-1"/> 33 | <TopLine Value="31"/> 34 | <CursorPos X="7" Y="46"/> 35 | </ExtraEditor1> 36 | <UsageCount Value="10"/> 37 | </Unit> 38 | <Unit> 39 | <Filename Value="bitgridengine.pas"/> 40 | <UnitName Value="BitGridEngine"/> 41 | <EditorIndex Value="1"/> 42 | <TopLine Value="167"/> 43 | <CursorPos X="42" Y="194"/> 44 | <UsageCount Value="10"/> 45 | <Loaded Value="True"/> 46 | </Unit> 47 | </Units> 48 | <JumpHistory HistoryIndex="12"> 49 | <Position> 50 | <Filename Value="PassThrough.lpr"/> 51 | <Caret Line="7" TopLine="17"/> 52 | </Position> 53 | <Position> 54 | <Filename Value="PassThrough.lpr"/> 55 | <Caret Line="3" Column="46"/> 56 | </Position> 57 | <Position> 58 | <Filename Value="PassThrough.lpr"/> 59 | <Caret Line="22" Column="46"/> 60 | </Position> 61 | <Position> 62 | <Filename Value="PassThrough.lpr"/> 63 | <Caret Line="24" Column="33" TopLine="6"/> 64 | </Position> 65 | <Position> 66 | <Filename Value="PassThrough.lpr"/> 67 | <Caret Line="22" Column="46" TopLine="6"/> 68 | </Position> 69 | <Position> 70 | <Filename Value="PassThrough.lpr"/> 71 | <Caret Line="24" TopLine="13"/> 72 | </Position> 73 | <Position> 74 | <Filename Value="PassThrough.lpr"/> 75 | <Caret Line="23" TopLine="6"/> 76 | </Position> 77 | <Position> 78 | <Filename Value="PassThrough.lpr"/> 79 | <Caret Line="31" Column="5" TopLine="15"/> 80 | </Position> 81 | <Position> 82 | <Filename Value="PassThrough.lpr"/> 83 | <Caret Line="32" TopLine="10"/> 84 | </Position> 85 | <Position> 86 | <Filename Value="bitgridengine.pas"/> 87 | <Caret Line="194" Column="42" TopLine="167"/> 88 | </Position> 89 | <Position> 90 | <Filename Value="PassThrough.lpr"/> 91 | <Caret Line="31" Column="51" TopLine="10"/> 92 | </Position> 93 | <Position> 94 | <Filename Value="PassThrough.lpr"/> 95 | <Caret Line="36" Column="27" TopLine="10"/> 96 | </Position> 97 | <Position> 98 | <Filename Value="PassThrough.lpr"/> 99 | <Caret Line="9" Column="6"/> 100 | </Position> 101 | </JumpHistory> 102 | <RunParams> 103 | <FormatVersion Value="2"/> 104 | <Modes ActiveMode=""/> 105 | </RunParams> 106 | </ProjectSession> 107 | <Debugging> 108 | <BreakPoints> 109 | <Item> 110 | <Kind Value="bpkSource"/> 111 | <WatchScope Value="wpsLocal"/> 112 | <WatchKind Value="wpkWrite"/> 113 | <Source Value="PassThrough.lpr"/> 114 | <Line Value="24"/> 115 | </Item> 116 | </BreakPoints> 117 | </Debugging> 118 | </CONFIG> 119 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Mike Warot's Bitgrid Engine in Pascal, with GUI 2 | 3 | ## What's a BitGrid? 4 | 5 | A Bitgrid is a Cartesian Array of cells, each having 4 bits of input from neighboring cells, and 4 outputs to them. To make this universal, each cell requires 4 look up tables, each with 16 entries to match all possible input states. The easiest way to represent this is a 16 character long hex number, one digit per possibilitity. 6 | 7 | Thus, a compact display of the program contents of a bitgrid might be a table of such entries 8 | 9 | the choice of bit order from neighbors is arbitrary, so we pick one here 10 | 11 | Up - 1 (bit 0) 12 | Right - 2 (bit 1) 13 | Below - 4 (bit 2) 14 | Left - 8 (bit 3) 15 | 16 | So, a cell programmed to repeat its inputs back to its neighbors would be FEDCBA9876543210 17 | a cell programmed to pass through all inputs to the next cell would be FB73EA62D951C840 18 | 19 | this should be the default for all cells, or all zeros, I'm not sure yet 20 | 21 | Evaluation: 22 | Cells will be evaluated in two phases, to avoid race conditions, and make it easier to understand, in the manner of coloring a chessboard, starting with 0,0 23 | 24 | As of 6/16/2023 - benchmarks show about 60 nanoseconds/cell on a fast processor 25 | 26 | Probes: 27 | It should be possible to force a stream of bits to a given cell input, again this is arbitrary 28 | 29 | It could be done between evaluation phases 30 | 31 | The same could be done with sensing outputs, either serial bits, or parallel across a given set of locations 32 | 33 | Data Structure: 34 | Each cell will have 4 bits (a nibble) of input, 4 bits of output, and 16 nibbles of program 35 | It turns out, it's easier to just use a uint64 for the implementation, for now 36 | 37 | ## How to program a BitGrid - an ongoing adventure in Computer Science 38 | 39 | * Start from the desired output, as an pascal expression (to start) 40 | * Break that down into an acyclic directed graph that points towards the output, using the standard ops 41 | * Break each op down into logic that works on bits, making a new, finer grained graph 42 | * Break each of those down until it has 4 or fewer bit inputs (ideally 3 or less, for routing) 43 | * Now it should be possible (if it fits) to route it into the bitgrid, using a table, for each output of a cell (4 outputs/cell in the canonical cell) a pointer to where in the graph that cell is, **How many clock cycles back from the output it is**, and then satisfy each of its inputs. (Place the output cells first, then work down the tree) 44 | 45 | * Helpful other steps 46 | * Anywhere you can't fit all the inputs, add routing spacers 47 | * Anywhere there are equivalent expressions, even if the clocking is different, they can be merged, with a suitable number of spacers 48 | 49 | Then work backwards towards the input 50 | 51 | ## Status 52 | 53 | As of 6/15/2023 - Code looks awful, but I can ripple bits accross a bitgrid, and it's uploaded to github 54 | 55 | As of 8/8/2023 - I've built a crude benchmark, and can get a 1024 x 1024 grid simulated at 36 Hz on my desktop machine. And **I've figured out how I'm going to program it** 56 | 57 | As of 12/3/2023 - I'm starting to plan the Programming, Debug, I/O subsystems, so I can use the BitGridEngine to in AdventOfCode, which should be quite interesting. 58 | -------------------------------------------------------------------------------- /WhyBitGrid.txt: -------------------------------------------------------------------------------- 1 | Why are you pursuing this idea? 2 | 3 | It's been nagging at me since the 1980s, and in 1993 when I read George Guilder's call to waste transistors [1], I suspected I was on the right path. As time has gone on, I see the opprotunities I've missed in the intervening decades, and I want to get this idea out into the world before I'm gone. It's a bucket list item for me. 4 | 5 | Why should I care about this? 6 | 7 | The potential for vastly faster compute without the massive complexity of modern CPU design could open up a huge range of possible applications. It's just possible that this could make Exaflop performace far more affordable, with power, and greater efficiency. 8 | 9 | Ok... talk me through it: 10 | 11 | When you run a program in a PC, most of the transistors in that computer are idle, because most of them are in memory, waiting for that one in a billion (or more) chance to be read or written.... once that happens, it's a mad rush to get the data into (or from) the CPU, then back to waiting. Almost all of the transistors in a computer are waiting at any given instant. This is highly inefficient, from a compute standpoint. 12 | 13 | When a program needs to be faster, specialize hardware is called into play, like GPUs in graphics cards, DSPs for signal processing, or special TPU and other chips to process neural networks. If an application demands the ultimate in speed, a custom chip is made, an ASIC (Application Specific Integrated Circuit). 14 | 15 | Usually the prototype for this ASIC is implemented in a special chip called an FPGA (Field Programmable Gate Array). These chips are fairly expensive, and optimzed to act like (emulate) the ASIC, to see if it will work properly in the desired use. 16 | 17 | FPGAs are highly optimized for their task, they have special "routing" hardware to get data across the chip faster once the logic is done with it. 18 | 19 | The programs for an FPGA are written in a language such as VHDL,Verilog, RTL or other proprietary systems. These systems often take hours or days to compile a particularly large program, as it is necessary to fit all the logic within the chip most efficiently, and this is like a jigsaw puzzle. 20 | 21 | *The routing hardware makes the chip more efficient, but makes programming harder* - this is a tradeoff widely accepted in industry. 22 | 23 | This brings you up to speed on how things work at present in most systems. 24 | 25 | The BitGrid is different. It is a radical departure from the way FPGAs work. 26 | 27 | There is NO routing hardware, which means logic has to fill in for it in all cases 28 | This means that much of the logic could be wasted, if not adequately utilized. 29 | The chip is deliberately slowed down, so that every step between cells has a delay. 30 | This means that the BitGrid would be a horrible FPGA, hundreds or thousands of times slower. 31 | 32 | However... these changes offer some new possibilities 33 | 34 | Because there is no fixed routing hardware 35 | Compilers are free to send data to any cell, and nudge things around freely. 36 | A "program" can be rotated or flipped or moved around on the chip at will 37 | It's possible to route around damaged cells 38 | It is possible to completely secure a section of code by literally walling it off 39 | 40 | Because of the 2 phase clocking 41 | Each cell is deterministic, there is alwas a known output given all the inputs 42 | Race conditions and timing skew, which plague FPGAs, are eliminated. 43 | Each cell can compute its work at the exact same time all of the others are, without conflict 44 | Applications in which data flows through the chip could produce a new output on each cycle. 45 | 46 | 47 | Because of the very simple, regular structure of the BitGrid 48 | Chip design is greatly simplified, and much easier to build, test, etc. 49 | Testing and programming can be open source, verified, and trusted much easier 50 | Utilization is easy to measure, and can be planned appropriately 51 | 52 | It is my OPINION that the BitGrid offers a novel model of computation, in much the same manner as the Turing Machine, but one optimized for actual use. 53 | 54 | The downside is obvious, everything happens in parallel on this chip, it's uniquely UNsuitable for running "soft core" CPUs, etc. It requires some form of host system to set it up, and get it running. There are no tools for programming, debugging, or even proper terminology for tracking data as it flows through the system. ALL of these need to be developed. 55 | 56 | I think they are all tractible, but it's beyond what I can manage alone. I'm hoping that the open source software and hardware communities can help out with this. 57 | 58 | Thanks for your time and attention. 59 | --Mike-- 60 | 61 | Mike Warot 62 | 63 | 64 | 65 | 66 | --- Footnotes, in the HN style --- 67 | 68 | [1] https://www.wired.com/1993/04/gilder-4/ -------------------------------------------------------------------------------- /bitgrid_coding_tests.lpi: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectOptions> 4 | <Version Value="12"/> 5 | <PathDelim Value="\"/> 6 | <General> 7 | <Flags> 8 | <MainUnitHasCreateFormStatements Value="False"/> 9 | <MainUnitHasTitleStatement Value="False"/> 10 | <MainUnitHasScaledStatement Value="False"/> 11 | </Flags> 12 | <SessionStorage Value="InProjectDir"/> 13 | <Title Value="bitgrid_coding_tests"/> 14 | <UseAppBundle Value="False"/> 15 | <ResourceType Value="res"/> 16 | </General> 17 | <BuildModes> 18 | <Item Name="Default" Default="True"/> 19 | </BuildModes> 20 | <PublishOptions> 21 | <Version Value="2"/> 22 | <UseFileFilters Value="True"/> 23 | </PublishOptions> 24 | <RunParams> 25 | <FormatVersion Value="2"/> 26 | </RunParams> 27 | <Units> 28 | <Unit> 29 | <Filename Value="bitgrid_coding_tests.lpr"/> 30 | <IsPartOfProject Value="True"/> 31 | </Unit> 32 | </Units> 33 | </ProjectOptions> 34 | <CompilerOptions> 35 | <Version Value="11"/> 36 | <PathDelim Value="\"/> 37 | <Target> 38 | <Filename Value="bitgrid_coding_tests"/> 39 | </Target> 40 | <SearchPaths> 41 | <IncludeFiles Value="$(ProjOutDir)"/> 42 | <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 43 | </SearchPaths> 44 | <Linking> 45 | <Debugging> 46 | <DebugInfoType Value="dsDwarf2Set"/> 47 | </Debugging> 48 | </Linking> 49 | </CompilerOptions> 50 | <Debugging> 51 | <Exceptions> 52 | <Item> 53 | <Name Value="EAbort"/> 54 | </Item> 55 | <Item> 56 | <Name Value="ECodetoolError"/> 57 | </Item> 58 | <Item> 59 | <Name Value="EFOpenError"/> 60 | </Item> 61 | </Exceptions> 62 | </Debugging> 63 | </CONFIG> 64 | -------------------------------------------------------------------------------- /bitgrid_coding_tests.lpr: -------------------------------------------------------------------------------- 1 | program bitgrid_coding_tests; 2 | uses 3 | SysUtils, BitGridEngine, BitGridUtil; 4 | 5 | const 6 | a : string = '1010101010101010'; 7 | b : string = '1100110011001100'; 8 | c : string = '1111000011110000'; 9 | d : string = '1111111100000000'; 10 | 11 | 12 | function StringNot(S : String):String; 13 | var 14 | i : integer; 15 | t : string; 16 | begin 17 | t := ''; 18 | for i := 1 to length(S) do 19 | if s[i] = '0' then t := t + '1' 20 | else t := t + '0'; 21 | StringNot := t; 22 | end; 23 | 24 | function StringEqual(A,B : String):Boolean; 25 | var 26 | i : integer; 27 | match : boolean; 28 | begin 29 | match := true; 30 | if length(A) <> length(B) then 31 | begin 32 | WriteLn('Mismatch string length in StringEqual'); 33 | Match := False; 34 | end 35 | else 36 | for i := 1 to length(A) do 37 | if A[i] <> B[i] then 38 | Match := False; 39 | StringEqual := Match; 40 | end; 41 | 42 | Procedure StringSplit(Source, Mask : string; 43 | Var A,B : string); 44 | var 45 | i : integer; 46 | begin 47 | A := ''; 48 | B := ''; 49 | if length(Source) <> length(Mask) then 50 | WriteLn('Mismatch string length in SplitString') 51 | else 52 | for i := 1 to Length(Source) do 53 | if Mask[i] = '1' then B := B + Source[i] 54 | else A := A + Source[i]; 55 | end; 56 | 57 | Function StringMerge(Source1,Source2, Mask : String):String; 58 | var 59 | i : integer; 60 | s : string; 61 | begin 62 | s := ''; 63 | for i := 1 to length(Mask) do 64 | if Mask[i] = '1' then 65 | begin 66 | s := s + Source2[1]; 67 | Delete(Source2,1,1); 68 | end 69 | else 70 | begin 71 | s := s + Source1[1]; 72 | Delete(Source1,1,1); 73 | end; 74 | StringMerge := S; 75 | end; 76 | 77 | var 78 | x,y,z : uInt64; 79 | i,j,k : integer; 80 | s,t,Q : string; 81 | mask : uInt64; 82 | begin 83 | for i := 0 to 65535 do 84 | begin 85 | Q := ''; 86 | Mask := 32768; 87 | while Mask <> 0 do 88 | begin 89 | if (i AND Mask) <> 0 then Q := Q + '1' else Q := Q + '0'; 90 | Mask := Mask shr 1; 91 | end; 92 | 93 | WriteLn('Iteration : ',Q); 94 | 95 | StringSplit(Q,A,S,T); 96 | If StringEqual(S,T) then WriteLn('A is not involved') 97 | else WriteLn('A ',A,' splits ',Q,' into ',S,' and ',T); 98 | 99 | If (S = '00000000') AND (T <> '00000000') then 100 | WriteLn('Logical Expression A AND ',T); 101 | 102 | If (T = '11111111') AND (S <> '00000000') then 103 | WriteLn('Logical Expression A OR ',S); 104 | 105 | If StringEqual(S,StringNot(T)) then 106 | WriteLn('XOR found'); 107 | 108 | StringSplit(Q,B,S,T); 109 | If StringEqual(S,T) then WriteLn('B is not involved') 110 | else WriteLn('B ',B,' splits ',Q,' into ',S,' and ',T); 111 | If StringEqual(S,StringNot(T)) then 112 | WriteLn('XOR found'); 113 | 114 | StringSplit(Q,C,S,T); 115 | If StringEqual(S,T) then WriteLn('C is not involved') 116 | else WriteLn('C ',C,' splits ',Q,' into ',S,' and ',T); 117 | If StringEqual(S,StringNot(T)) then 118 | WriteLn('XOR found'); 119 | 120 | StringSplit(Q,D,S,T); 121 | If StringEqual(S,T) then WriteLn('D is not involved') 122 | else WriteLn('D ',D,' splits ',Q,' into ',S,' and ',T); 123 | If StringEqual(S,StringNot(T)) then 124 | WriteLn('XOR found'); 125 | end; 126 | 127 | 128 | WriteLn; 129 | WriteLn(' AllPass code is ',IntToHex(PassThrough)); 130 | WriteLn; 131 | WriteLn('The left output bits are ',IntToHex((PassThrough SHR 3) AND ($1111111111111111))); 132 | 133 | X := (PassThrough SHR 0) AND ($1111111111111111); 134 | 135 | y := 0; 136 | z := 0; 137 | for i := 15 downto 0 do 138 | if ((LeftBits shr (i*4)) AND 1)=1 then 139 | y := (y SHL 4) or ((x SHR (i*4)) AND 1) 140 | else 141 | z := (z SHL 4) or ((x SHR (i*4)) AND 1); 142 | 143 | If (Y=Z) then 144 | WriteLn('LeftBits not involved') 145 | else 146 | WriteLn('LeftBits ARE Involved : ',IntToHex(Y),' ',IntToHex(Z)); 147 | 148 | y := 0; 149 | z := 0; 150 | for i := 15 downto 0 do 151 | if ((RightBits shr (i*4)) AND 1)=1 then 152 | y := (y SHL 4) or ((x SHR (i*4)) AND 1) 153 | else 154 | z := (z SHL 4) or ((x SHR (i*4)) AND 1); 155 | 156 | If (Y=Z) then 157 | WriteLn('RightBits not involved') 158 | else 159 | WriteLn('RightBits ARE Involved : ',IntToHex(Y),' ',IntToHex(Z)); 160 | 161 | 162 | y := 0; 163 | z := 0; 164 | for i := 15 downto 0 do 165 | if ((UpBits shr (i*4)) AND 1)=1 then 166 | y := (y SHL 4) or ((x SHR (i*4)) AND 1) 167 | else 168 | z := (z SHL 4) or ((x SHR (i*4)) AND 1); 169 | 170 | If (Y=Z) then 171 | WriteLn('UpBits not involved') 172 | else 173 | WriteLn('UpBits ARE Involved : ',IntToHex(Y),' ',IntToHex(Z)); 174 | 175 | 176 | y := 0; 177 | z := 0; 178 | for i := 15 downto 0 do 179 | if ((DownBits shr (i*4)) AND 1)=1 then 180 | y := (y SHL 4) or ((x SHR (i*4)) AND 1) 181 | else 182 | z := (z SHL 4) or ((x SHR (i*4)) AND 1); 183 | 184 | If (Y=Z) then 185 | WriteLn('DownBits not involved') 186 | else 187 | WriteLn('DownBits ARE Involved : ',IntToHex(Y),' ',IntToHex(Z)); 188 | 189 | 190 | 191 | readln; 192 | end. 193 | 194 | -------------------------------------------------------------------------------- /bitgrid_coding_tests.lps: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectSession> 4 | <PathDelim Value="\"/> 5 | <Version Value="12"/> 6 | <BuildModes Active="Default"/> 7 | <Units> 8 | <Unit> 9 | <Filename Value="bitgrid_coding_tests.lpr"/> 10 | <IsPartOfProject Value="True"/> 11 | <IsVisibleTab Value="True"/> 12 | <CursorPos X="45" Y="103"/> 13 | <UsageCount Value="24"/> 14 | <Loaded Value="True"/> 15 | </Unit> 16 | <Unit> 17 | <Filename Value="bitgridutil.pas"/> 18 | <UnitName Value="BitGridUtil"/> 19 | <EditorIndex Value="2"/> 20 | <TopLine Value="13"/> 21 | <UsageCount Value="11"/> 22 | <Loaded Value="True"/> 23 | </Unit> 24 | <Unit> 25 | <Filename Value="bitgridengine.pas"/> 26 | <UnitName Value="BitGridEngine"/> 27 | <EditorIndex Value="1"/> 28 | <TopLine Value="25"/> 29 | <UsageCount Value="11"/> 30 | <Loaded Value="True"/> 31 | </Unit> 32 | </Units> 33 | <JumpHistory HistoryIndex="19"> 34 | <Position> 35 | <Filename Value="bitgrid_coding_tests.lpr"/> 36 | <Caret Line="7" Column="40"/> 37 | </Position> 38 | <Position> 39 | <Filename Value="bitgrid_coding_tests.lpr"/> 40 | <Caret Line="3" Column="5"/> 41 | </Position> 42 | <Position> 43 | <Filename Value="bitgrid_coding_tests.lpr"/> 44 | <Caret Line="7" Column="52"/> 45 | </Position> 46 | <Position> 47 | <Filename Value="bitgrid_coding_tests.lpr"/> 48 | <Caret Line="9" Column="93"/> 49 | </Position> 50 | <Position> 51 | <Filename Value="bitgrid_coding_tests.lpr"/> 52 | <Caret Line="15" Column="37"/> 53 | </Position> 54 | <Position> 55 | <Filename Value="bitgrid_coding_tests.lpr"/> 56 | <Caret Line="28" Column="44"/> 57 | </Position> 58 | <Position> 59 | <Filename Value="bitgrid_coding_tests.lpr"/> 60 | <Caret Line="18" Column="9" TopLine="2"/> 61 | </Position> 62 | <Position> 63 | <Filename Value="bitgrid_coding_tests.lpr"/> 64 | <Caret Line="17" Column="20"/> 65 | </Position> 66 | <Position> 67 | <Filename Value="bitgrid_coding_tests.lpr"/> 68 | <Caret Line="35" Column="26" TopLine="12"/> 69 | </Position> 70 | <Position> 71 | <Filename Value="bitgrid_coding_tests.lpr"/> 72 | <Caret Line="63" Column="27" TopLine="35"/> 73 | </Position> 74 | <Position> 75 | <Filename Value="bitgrid_coding_tests.lpr"/> 76 | <Caret Line="59" Column="14" TopLine="40"/> 77 | </Position> 78 | <Position> 79 | <Filename Value="bitgrid_coding_tests.lpr"/> 80 | <Caret Line="53" Column="8" TopLine="37"/> 81 | </Position> 82 | <Position> 83 | <Filename Value="bitgrid_coding_tests.lpr"/> 84 | <Caret Line="76" Column="51" TopLine="47"/> 85 | </Position> 86 | <Position> 87 | <Filename Value="bitgrid_coding_tests.lpr"/> 88 | <Caret Line="51" Column="3" TopLine="31"/> 89 | </Position> 90 | <Position> 91 | <Filename Value="bitgrid_coding_tests.lpr"/> 92 | <Caret Line="76" Column="51" TopLine="48"/> 93 | </Position> 94 | <Position> 95 | <Filename Value="bitgrid_coding_tests.lpr"/> 96 | <Caret Line="71" Column="18" TopLine="55"/> 97 | </Position> 98 | <Position> 99 | <Filename Value="bitgrid_coding_tests.lpr"/> 100 | <Caret Line="84" Column="40" TopLine="58"/> 101 | </Position> 102 | <Position> 103 | <Filename Value="bitgrid_coding_tests.lpr"/> 104 | <Caret Line="67" Column="22" TopLine="44"/> 105 | </Position> 106 | <Position> 107 | <Filename Value="bitgrid_coding_tests.lpr"/> 108 | <Caret Line="50" Column="54" TopLine="31"/> 109 | </Position> 110 | <Position> 111 | <Filename Value="bitgrid_coding_tests.lpr"/> 112 | <Caret Line="9" Column="14"/> 113 | </Position> 114 | </JumpHistory> 115 | <RunParams> 116 | <FormatVersion Value="2"/> 117 | <Modes ActiveMode=""/> 118 | </RunParams> 119 | </ProjectSession> 120 | </CONFIG> 121 | -------------------------------------------------------------------------------- /bitgrid_gui.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikewarot/Bitgrid/a7072bcfd0524c0b824be9a3a45667208f77816e/bitgrid_gui.ico -------------------------------------------------------------------------------- /bitgrid_gui.lpi: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectOptions> 4 | <Version Value="12"/> 5 | <PathDelim Value="\"/> 6 | <General> 7 | <SessionStorage Value="InProjectDir"/> 8 | <Title Value="bitgrid_gui"/> 9 | <Scaled Value="True"/> 10 | <ResourceType Value="res"/> 11 | <UseXPManifest Value="True"/> 12 | <XPManifest> 13 | <DpiAware Value="True"/> 14 | </XPManifest> 15 | <Icon Value="0"/> 16 | </General> 17 | <BuildModes> 18 | <Item Name="Default" Default="True"/> 19 | </BuildModes> 20 | <PublishOptions> 21 | <Version Value="2"/> 22 | <UseFileFilters Value="True"/> 23 | </PublishOptions> 24 | <RunParams> 25 | <FormatVersion Value="2"/> 26 | </RunParams> 27 | <RequiredPackages> 28 | <Item> 29 | <PackageName Value="LCL"/> 30 | </Item> 31 | </RequiredPackages> 32 | <Units> 33 | <Unit> 34 | <Filename Value="bitgrid_gui.lpr"/> 35 | <IsPartOfProject Value="True"/> 36 | </Unit> 37 | <Unit> 38 | <Filename Value="mainform.pas"/> 39 | <IsPartOfProject Value="True"/> 40 | <ComponentName Value="Form1"/> 41 | <HasResources Value="True"/> 42 | <ResourceBaseClass Value="Form"/> 43 | <UnitName Value="MainForm"/> 44 | </Unit> 45 | <Unit> 46 | <Filename Value="bitgridengine.pas"/> 47 | <IsPartOfProject Value="True"/> 48 | <UnitName Value="BitGridEngine"/> 49 | </Unit> 50 | <Unit> 51 | <Filename Value="readme.txt"/> 52 | <IsPartOfProject Value="True"/> 53 | </Unit> 54 | <Unit> 55 | <Filename Value="bitgridutil.pas"/> 56 | <IsPartOfProject Value="True"/> 57 | <UnitName Value="BitGridUtil"/> 58 | </Unit> 59 | </Units> 60 | </ProjectOptions> 61 | <CompilerOptions> 62 | <Version Value="11"/> 63 | <PathDelim Value="\"/> 64 | <Target> 65 | <Filename Value="bitgrid_gui"/> 66 | </Target> 67 | <SearchPaths> 68 | <IncludeFiles Value="$(ProjOutDir)"/> 69 | <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 70 | </SearchPaths> 71 | <Linking> 72 | <Debugging> 73 | <DebugInfoType Value="dsDwarf2"/> 74 | </Debugging> 75 | <Options> 76 | <Win32> 77 | <GraphicApplication Value="True"/> 78 | </Win32> 79 | </Options> 80 | </Linking> 81 | </CompilerOptions> 82 | <Debugging> 83 | <Exceptions> 84 | <Item> 85 | <Name Value="EAbort"/> 86 | </Item> 87 | <Item> 88 | <Name Value="ECodetoolError"/> 89 | </Item> 90 | <Item> 91 | <Name Value="EFOpenError"/> 92 | </Item> 93 | </Exceptions> 94 | </Debugging> 95 | </CONFIG> 96 | -------------------------------------------------------------------------------- /bitgrid_gui.lpr: -------------------------------------------------------------------------------- 1 | program bitgrid_gui; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | uses 6 | {$IFDEF UNIX} 7 | cthreads, 8 | {$ENDIF} 9 | {$IFDEF HASAMIGA} 10 | athreads, 11 | {$ENDIF} 12 | Interfaces, // this includes the LCL widgetset 13 | Forms, MainForm, BitGridEngine, BitGridUtil 14 | { you can add units after this }; 15 | 16 | {$R *.res} 17 | 18 | begin 19 | RequireDerivedFormResource:=True; 20 | Application.Scaled:=True; 21 | Application.Initialize; 22 | Application.CreateForm(TForm1, Form1); 23 | Application.Run; 24 | end. 25 | 26 | -------------------------------------------------------------------------------- /bitgrid_gui.lps: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectSession> 4 | <PathDelim Value="\"/> 5 | <Version Value="12"/> 6 | <BuildModes Active="Default"/> 7 | <Units> 8 | <Unit> 9 | <Filename Value="bitgrid_gui.lpr"/> 10 | <IsPartOfProject Value="True"/> 11 | <EditorIndex Value="1"/> 12 | <CursorPos X="46" Y="13"/> 13 | <UsageCount Value="30"/> 14 | <Loaded Value="True"/> 15 | </Unit> 16 | <Unit> 17 | <Filename Value="mainform.pas"/> 18 | <IsPartOfProject Value="True"/> 19 | <ComponentName Value="Form1"/> 20 | <HasResources Value="True"/> 21 | <ResourceBaseClass Value="Form"/> 22 | <UnitName Value="MainForm"/> 23 | <CursorPos X="35" Y="109"/> 24 | <UsageCount Value="30"/> 25 | <Loaded Value="True"/> 26 | </Unit> 27 | <Unit> 28 | <Filename Value="bitgridengine.pas"/> 29 | <IsPartOfProject Value="True"/> 30 | <UnitName Value="BitGridEngine"/> 31 | <IsVisibleTab Value="True"/> 32 | <EditorIndex Value="2"/> 33 | <TopLine Value="22"/> 34 | <CursorPos Y="46"/> 35 | <UsageCount Value="30"/> 36 | <Loaded Value="True"/> 37 | </Unit> 38 | <Unit> 39 | <Filename Value="readme.txt"/> 40 | <IsPartOfProject Value="True"/> 41 | <EditorIndex Value="-1"/> 42 | <CursorPos Y="5"/> 43 | <UsageCount Value="30"/> 44 | <DefaultSyntaxHighlighter Value="None"/> 45 | </Unit> 46 | <Unit> 47 | <Filename Value="bitgridutil.pas"/> 48 | <IsPartOfProject Value="True"/> 49 | <UnitName Value="BitGridUtil"/> 50 | <EditorIndex Value="3"/> 51 | <TopLine Value="13"/> 52 | <CursorPos X="5" Y="45"/> 53 | <UsageCount Value="21"/> 54 | <Loaded Value="True"/> 55 | </Unit> 56 | <Unit> 57 | <Filename Value="C:\lazarus\lcl\stdctrls.pp"/> 58 | <UnitName Value="StdCtrls"/> 59 | <EditorIndex Value="-1"/> 60 | <TopLine Value="1324"/> 61 | <CursorPos X="14" Y="1346"/> 62 | <UsageCount Value="10"/> 63 | </Unit> 64 | </Units> 65 | <JumpHistory HistoryIndex="29"> 66 | <Position> 67 | <Filename Value="mainform.pas"/> 68 | <Caret Line="52" Column="46" TopLine="25"/> 69 | </Position> 70 | <Position> 71 | <Filename Value="mainform.pas"/> 72 | <Caret Line="141" Column="16" TopLine="114"/> 73 | </Position> 74 | <Position> 75 | <Filename Value="bitgridengine.pas"/> 76 | <Caret Line="78" Column="35"/> 77 | </Position> 78 | <Position> 79 | <Filename Value="bitgridengine.pas"/> 80 | <Caret Line="79" Column="16" TopLine="52"/> 81 | </Position> 82 | <Position> 83 | <Filename Value="bitgridengine.pas"/> 84 | <Caret Line="100" Column="19" TopLine="73"/> 85 | </Position> 86 | <Position> 87 | <Filename Value="bitgridengine.pas"/> 88 | <Caret Line="102" Column="21" TopLine="75"/> 89 | </Position> 90 | <Position> 91 | <Filename Value="bitgridengine.pas"/> 92 | <Caret Line="23" Column="22" TopLine="7"/> 93 | </Position> 94 | <Position> 95 | <Filename Value="bitgridengine.pas"/> 96 | <Caret Line="93" Column="65" TopLine="86"/> 97 | </Position> 98 | <Position> 99 | <Filename Value="bitgridengine.pas"/> 100 | </Position> 101 | <Position> 102 | <Filename Value="bitgridengine.pas"/> 103 | <Caret Line="3" Column="16"/> 104 | </Position> 105 | <Position> 106 | <Filename Value="mainform.pas"/> 107 | <Caret Line="40" Column="58" TopLine="17"/> 108 | </Position> 109 | <Position> 110 | <Filename Value="mainform.pas"/> 111 | <Caret Line="43" Column="2" TopLine="17"/> 112 | </Position> 113 | <Position> 114 | <Filename Value="mainform.pas"/> 115 | <Caret Line="45" Column="2" TopLine="18"/> 116 | </Position> 117 | <Position> 118 | <Filename Value="mainform.pas"/> 119 | <Caret Line="83" TopLine="51"/> 120 | </Position> 121 | <Position> 122 | <Filename Value="mainform.pas"/> 123 | <Caret Line="94" TopLine="68"/> 124 | </Position> 125 | <Position> 126 | <Filename Value="bitgridengine.pas"/> 127 | <Caret Line="6" Column="35"/> 128 | </Position> 129 | <Position> 130 | <Filename Value="bitgridengine.pas"/> 131 | <Caret Line="23" Column="11"/> 132 | </Position> 133 | <Position> 134 | <Filename Value="bitgridengine.pas"/> 135 | <Caret Line="79" Column="16" TopLine="52"/> 136 | </Position> 137 | <Position> 138 | <Filename Value="bitgridengine.pas"/> 139 | <Caret Line="100" Column="19" TopLine="73"/> 140 | </Position> 141 | <Position> 142 | <Filename Value="bitgridengine.pas"/> 143 | <Caret Line="102" Column="21" TopLine="75"/> 144 | </Position> 145 | <Position> 146 | <Filename Value="mainform.pas"/> 147 | <Caret Line="2" Column="33"/> 148 | </Position> 149 | <Position> 150 | <Filename Value="bitgridutil.pas"/> 151 | <Caret Line="28" Column="29"/> 152 | </Position> 153 | <Position> 154 | <Filename Value="mainform.pas"/> 155 | <Caret Line="52" Column="47" TopLine="25"/> 156 | </Position> 157 | <Position> 158 | <Filename Value="mainform.pas"/> 159 | <Caret Line="54" Column="47" TopLine="27"/> 160 | </Position> 161 | <Position> 162 | <Filename Value="mainform.pas"/> 163 | <Caret Line="95" Column="33" TopLine="93"/> 164 | </Position> 165 | <Position> 166 | <Filename Value="mainform.pas"/> 167 | <Caret Line="8" Column="82"/> 168 | </Position> 169 | <Position> 170 | <Filename Value="bitgridengine.pas"/> 171 | <Caret Line="15" Column="48" TopLine="22"/> 172 | </Position> 173 | <Position> 174 | <Filename Value="bitgridengine.pas"/> 175 | <Caret Line="46" Column="3" TopLine="22"/> 176 | </Position> 177 | <Position> 178 | <Filename Value="mainform.pas"/> 179 | <Caret Line="113" Column="32" TopLine="97"/> 180 | </Position> 181 | <Position> 182 | <Filename Value="mainform.pas"/> 183 | <Caret Line="89" Column="38" TopLine="28"/> 184 | </Position> 185 | </JumpHistory> 186 | <RunParams> 187 | <FormatVersion Value="2"/> 188 | <Modes ActiveMode=""/> 189 | </RunParams> 190 | </ProjectSession> 191 | <Debugging> 192 | <Watches> 193 | <Item> 194 | <Expression Value="allbits"/> 195 | </Item> 196 | </Watches> 197 | </Debugging> 198 | </CONFIG> 199 | -------------------------------------------------------------------------------- /bitgrid_gui.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikewarot/Bitgrid/a7072bcfd0524c0b824be9a3a45667208f77816e/bitgrid_gui.res -------------------------------------------------------------------------------- /bitgridengine.pas: -------------------------------------------------------------------------------- 1 | unit BitGridEngine; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils; 9 | 10 | Type 11 | Nibble = 0..15; 12 | 13 | TBitCell = record 14 | input, output : nibble; 15 | lookup : Uint64; // 16 nibbles 16 | end; 17 | 18 | tBoolFunction = Function : Boolean; 19 | pBoolFunction = ^tBoolFunction; 20 | 21 | tBooleanInput = record 22 | X,Y : Integer; 23 | Source : ^Boolean; 24 | end; 25 | 26 | TBitGrid = object 27 | Cells : array of array of TBitCell; 28 | Height,Width : integer; 29 | CycleCount : UInt64; 30 | IOtest : tBooleanInput; 31 | constructor Init(Xsize, YSize : integer); 32 | destructor Done; 33 | procedure DoClock; 34 | procedure DoPhaseA; 35 | procedure DoPhaseB; 36 | procedure PutBit(X,Y : Integer; Bit : Boolean); 37 | end; 38 | 39 | 40 | Const 41 | PassThrough = $FB73EA62D951C840; 42 | 43 | LeftBits = $1111111100000000; LeftBit = 8; 44 | RightBits = $1100110011001100; RightBit = 2; 45 | UpBits = $1010101010101010; UpBit = 1; 46 | DownBits = $1111000011110000; DownBit = 4; 47 | AllBits = (LeftBits * RightBit) or (RightBits * LeftBit) OR (UpBits * DownBit) or (DownBits * UpBit); 48 | 49 | Reflector = $FEDCBA9876543210; 50 | Counter = $5DA25DA25DA25DA2; 51 | 52 | implementation 53 | 54 | Function Wrap(N,Bound : Integer):Integer; 55 | begin 56 | While N >= Bound do 57 | N := N - Bound; 58 | While N < 0 do 59 | N := N + Bound; 60 | Wrap := N; 61 | end; 62 | 63 | Constructor TBitGrid.Init(Xsize, YSize : integer); 64 | var 65 | x,y : integer; 66 | begin 67 | CycleCount := 0; 68 | SetLength(Cells,Xsize,Ysize); 69 | width := Xsize; 70 | height := Ysize; 71 | for y := 0 to Height-1 do 72 | for x := 0 to Width-1 do 73 | begin 74 | cells[x,y].input:= 0; 75 | cells[x,y].output := 0; 76 | cells[x,y].lookup := PassThrough; 77 | end; 78 | IOtest.X := 3; 79 | IOtest.Y := 7; 80 | IOtest.Source := nil; 81 | end; 82 | 83 | Destructor TBitGrid.Done; 84 | begin 85 | SetLength(Cells,0,0); 86 | end; 87 | 88 | Procedure TBitGrid.DoClock; 89 | var 90 | x,y,next : integer; 91 | begin 92 | DoPhaseA; 93 | DoPhaseB; 94 | end; 95 | 96 | procedure TBitGrid.DoPhaseA; 97 | var 98 | x,y,next : integer; 99 | begin 100 | // process the override list (one item for now) 101 | If IOtest.Source <> nil then 102 | begin 103 | If IOtest.Source^ then 104 | Cells[IOtest.X, IOtest.Y].input := $0f 105 | else 106 | Cells[IOtest.X, IOtest.Y].input := 00; ; 107 | end; 108 | 109 | // do phase A, only even cells 110 | for y := 0 to Height-1 do 111 | for x := 0 to Width-1 do 112 | if NOT Odd(x+y) then 113 | with cells[x,y] do 114 | begin 115 | // compute the new output 116 | output:= lookup SHR (input*4) AND $0f; 117 | // distribute the output to the inputs of neigbors 118 | // right 119 | next := wrap((x+1),width); 120 | if (output AND 2) <> 0 then 121 | cells[next,y].input := cells[next,y].input OR $08 122 | else 123 | cells[next,y].input := cells[next,y].input AND $07; 124 | 125 | // left 126 | next := wrap(x-1,width); 127 | if (output AND 8) <> 0 then 128 | cells[next,y].input := cells[next,y].input OR $02 129 | else 130 | cells[next,y].input := cells[next,y].input AND $0d; 131 | 132 | // down 133 | next := wrap(y+1,height); 134 | if (output AND 4) <> 0 then 135 | cells[x,next].input := cells[x,next].input OR $01 136 | else 137 | cells[x,next].input := cells[x,next].input AND $0e; 138 | 139 | // up 140 | next := wrap(y-1,height); 141 | if (output AND 1) <> 0 then 142 | cells[x,next].input := cells[x,next].input OR $04 143 | else 144 | cells[x,next].input := cells[x,next].input AND $0b; 145 | end; 146 | end; // DoPhaseA 147 | 148 | procedure TBitGrid.DoPhaseB; 149 | var 150 | x,y,next : integer; 151 | begin 152 | // do phase B, only odd cells 153 | for y := 0 to Height-1 do 154 | for x := 0 to Width-1 do 155 | if Odd(x+y) then 156 | with cells[x,y] do 157 | begin 158 | // compute the new output 159 | output:= lookup SHR (input*4) AND $0f; 160 | // distribute the output to the inputs of neigbors 161 | // right 162 | next := wrap((x+1),width); 163 | if (output AND 2) <> 0 then 164 | cells[next,y].input := cells[next,y].input OR $08 165 | else 166 | cells[next,y].input := cells[next,y].input AND $07; 167 | 168 | // left 169 | next := wrap(x-1,width); 170 | if (output AND 8) <> 0 then 171 | cells[next,y].input := cells[next,y].input OR $02 172 | else 173 | cells[next,y].input := cells[next,y].input AND $0d; 174 | 175 | // down 176 | next := wrap(y+1,height); 177 | if (output AND 4) <> 0 then 178 | cells[x,next].input := cells[x,next].input OR $01 179 | else 180 | cells[x,next].input := cells[x,next].input AND $0e; 181 | 182 | // up 183 | next := wrap(y-1,height); 184 | if (output AND 1) <> 0 then 185 | cells[x,next].input := cells[x,next].input OR $04 186 | else 187 | cells[x,next].input := cells[x,next].input AND $0b; 188 | end; 189 | Inc(CycleCount); 190 | end; // DoPhgaseB 191 | 192 | procedure TBitGrid.PutBit(X,Y : Integer; Bit : Boolean); 193 | begin 194 | // put the input to all inputs, for now 195 | if Bit then 196 | cells[x,y].input:= $0f 197 | else 198 | cells[x,y].input:= $00; 199 | end; 200 | 201 | end. 202 | 203 | -------------------------------------------------------------------------------- /bitgridutil.pas: -------------------------------------------------------------------------------- 1 | unit BitGridUtil; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | { 7 | A set of tools that help the programmer deal with a bitgrid 8 | } 9 | 10 | uses 11 | Classes, SysUtils, BitGridEngine; 12 | 13 | function DumpCode(Code : Int64):String; 14 | 15 | implementation 16 | 17 | Const 18 | Hex : Array[0..15] of Char = '0123456789ABCDEF'; 19 | 20 | function DumpCode(Code : Int64):String; 21 | var 22 | i,j,k : integer; 23 | s : string; 24 | begin 25 | s := 'Up:'; 26 | for i := 15 downto 0 do 27 | s := s + Hex[(Code SHR (i*4)) AND $01]; 28 | 29 | s := s + ' Right:'; 30 | for i := 15 downto 0 do 31 | s := s + Hex[(Code SHR ((i*4)+1)) AND $01]; 32 | 33 | s := s + ' Down:'; 34 | for i := 15 downto 0 do 35 | s := s + Hex[(Code SHR ((i*4)+2)) AND $01]; 36 | 37 | s := s + ' Left:'; 38 | for i := 15 downto 0 do 39 | s := s + Hex[(Code SHR ((i*4)+3)) AND $01]; 40 | 41 | DumpCode := 'Code : '+s; 42 | end; 43 | 44 | end. 45 | 46 | -------------------------------------------------------------------------------- /ideas.txt: -------------------------------------------------------------------------------- 1 | July 21, 2024 - random ideas to un-stick things 2 | 3 | 4 | the bitgrid can evaluate any tree of binary expressions, provided they are suitably mapped to cells 5 | 6 | mapping those nodes can be done using A* search, provided each has 4 inputs or less 7 | 8 | each node increments a "generation" or "delay" counter, and you can add delays to match things up 9 | 10 | 8x8 bit integer multiplication results in 16 bits output, and thus there are 16 inter-related binary trees to resolve 11 | 12 | I'm stuck at analysis paralysis - 13 | 14 | How to express these trees in an IR language for mapping into the bitgrid ::: a linker 15 | How to generate these trees in the first place, from source code ::: a compiler 16 | 17 | Toy example: a binary counter, with reset 18 | 19 | A0' := ~RESET OR ~A0 20 | CARRY0' := ~RESET AND A0 21 | A1' := ~RESET AND ((CARRY0' AND A1) OR (~CARRY0' AND ~A1)) 22 | CARRY1' := ~RESET AND (CARRY0' AND A1) 23 | 24 | for n = 2 to width 25 | An' := ~RESET AND ((CARRYn-1' AND An) OR (~CARRYn-1' AND ~An)) 26 | CARRYn' := ~RESET AND (CARRYn-1' AND An) 27 | 28 | restating as binary (for 2 functions, give values f(0,0),f(0,1),f(1,0),f(1,1)) 29 | 30 | A0' := f(RESET,A0):[1,0,0,0] 31 | Carry0' := f(RESET,A0):[0,1,0,0] 32 | 33 | (for 3 functions, give values f(0,0,0),f(0,0,1),f(0,1,0)....f(1,1,1) - count in binary) 34 | A1' := f(RESET,CARRY0,A1):[0,1,1,0,0,0,0,0] 35 | CARRY1' := f(RESET,CARRY0,A1):[0,0,0,1,0,0,0,0] 36 | 37 | An' := f(RESET,CARRYn-1,An):[0,1,1,0,0,0,0,0] 38 | CARRYn' := f(RESET,CARRYn-1,An):[0,0,0,1,0,0,0,0] 39 | 40 | If multiple functions use the same inputs, they can be mapped into a common cell, to be space efficient 41 | 42 | restating above to make RESET pipelined with everything else 43 | 44 | A0' := f(RESET,A0):[1,0,0,0] 45 | Carry0' := f(RESET,A0):[0,1,0,0] 46 | RESET0' := RESET 47 | 48 | (for 3 functions, give values f(0,0,0),f(0,0,1),f(0,1,0)....f(1,1,1) - count in binary) 49 | A1' := f(RESET0,CARRY0,A1):[0,1,1,0,0,0,0,0] 50 | CARRY1' := f(RESET0,CARRY0,A1):[0,0,0,1,0,0,0,0] 51 | RESET1' := RESET0 52 | 53 | An' := f(RESETn-1,CARRYn-1,An):[0,1,1,0,0,0,0,0] 54 | CARRYn' := f(RESETn-1,CARRYn-1,An):[0,0,0,1,0,0,0,0] 55 | RESETn' := RESETn-1 56 | 57 | 58 | 59 | 60 | Perhaps it's best to compile all expressions to binary tables as step #1? 61 | 62 | ---- 63 | 64 | July 27, 2024 More brainstorming 65 | 66 | According to GeoHot (George Hotz), 20 Petaflops (BFLOAT 16) is a "Person" of Compute 67 | 68 | Reference - https://geohot.github.io//blog/jekyll/update/2023/04/26/a-person-of-compute.html 69 | 70 | Search for NVidia A100, the 312 TFlops of performance is for Bfloat16 operands 71 | 72 | Assume 512 cells for a BFLOAT16 multiplier (16x16x2 for inefficiency in layout) 73 | 74 | Assume 1 GHZ clock rate 75 | 76 | 20,000,000,000,000,000 / 1000,000,000 --> 20,000,000 multipliers * 512 --> 1024,000,000 cells 77 | 78 | assume 1000 transistors / cell 79 | 80 | 1,024,000,000,000 transistors would be needed to reach GeoHot's "Person" 81 | 82 | It seems reasonable to want to decrease the number of cells in a BFLOAT16 multiplier, transistors/cell, or increas the clock frequency to decrease the total transistor count requires. 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /mainform.lfm: -------------------------------------------------------------------------------- 1 | object Form1: TForm1 2 | Left = 668 3 | Height = 711 4 | Top = 125 5 | Width = 1222 6 | Caption = 'Form1' 7 | ClientHeight = 711 8 | ClientWidth = 1222 9 | OnCreate = FormCreate 10 | OnDestroy = FormDestroy 11 | LCLVersion = '2.2.6.0' 12 | object Memo1: TMemo 13 | Left = 38 14 | Height = 597 15 | Top = 35 16 | Width = 1138 17 | Lines.Strings = ( 18 | 'Memo1' 19 | ) 20 | ScrollBars = ssAutoBoth 21 | TabOrder = 0 22 | WordWrap = False 23 | end 24 | object ButtonDumpContents: TButton 25 | Left = 32 26 | Height = 25 27 | Top = 656 28 | Width = 155 29 | Caption = 'Dump Contents' 30 | OnClick = ButtonDumpContentsClick 31 | TabOrder = 1 32 | end 33 | object ButtonRunCycle: TButton 34 | Left = 230 35 | Height = 25 36 | Top = 658 37 | Width = 123 38 | Caption = 'Run 1 Cycle' 39 | OnClick = ButtonRunCycleClick 40 | TabOrder = 2 41 | end 42 | object CheckBox1: TCheckBox 43 | Left = 935 44 | Height = 25 45 | Top = 659 46 | Width = 102 47 | Caption = 'CheckBox1' 48 | OnChange = CheckBox1Change 49 | TabOrder = 3 50 | end 51 | object ButtonPassThrough: TButton 52 | Left = 413 53 | Height = 25 54 | Top = 659 55 | Width = 227 56 | Caption = 'Passthrough experiment' 57 | OnClick = ButtonPassThroughClick 58 | TabOrder = 4 59 | end 60 | object ButtonPhaseA: TButton 61 | Left = 684 62 | Height = 25 63 | Top = 659 64 | Width = 99 65 | Caption = 'Run Phase A' 66 | OnClick = ButtonPhaseAClick 67 | TabOrder = 5 68 | end 69 | object ButtonPhaseB: TButton 70 | Left = 800 71 | Height = 25 72 | Top = 659 73 | Width = 99 74 | Caption = 'Run Phase B' 75 | OnClick = ButtonPhaseBClick 76 | TabOrder = 6 77 | end 78 | object Button1: TButton 79 | Left = 1079 80 | Height = 25 81 | Top = 664 82 | Width = 75 83 | Caption = 'Button1' 84 | OnClick = Button1Click 85 | TabOrder = 7 86 | end 87 | end 88 | -------------------------------------------------------------------------------- /mainform.pas: -------------------------------------------------------------------------------- 1 | unit MainForm; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, BitGridEngine, BitGridUtil; 9 | 10 | type 11 | 12 | { TForm1 } 13 | 14 | TForm1 = class(TForm) 15 | Button1: TButton; 16 | ButtonDumpContents: TButton; 17 | ButtonRunCycle: TButton; 18 | ButtonPassThrough: TButton; 19 | ButtonPhaseA: TButton; 20 | ButtonPhaseB: TButton; 21 | CheckBox1: TCheckBox; 22 | Memo1: TMemo; 23 | procedure Button1Click(Sender: TObject); 24 | procedure ButtonDumpContentsClick(Sender: TObject); 25 | procedure ButtonRunCycleClick(Sender: TObject); 26 | procedure ButtonPassThroughClick(Sender: TObject); 27 | procedure ButtonPhaseAClick(Sender: TObject); 28 | procedure ButtonPhaseBClick(Sender: TObject); 29 | procedure CheckBox1Change(Sender: TObject); 30 | procedure FormCreate(Sender: TObject); 31 | procedure FormDestroy(Sender: TObject); 32 | private 33 | 34 | public 35 | ButtonChecked : Boolean; 36 | 37 | end; 38 | 39 | var 40 | Form1: TForm1; 41 | Grid1 : TBitGrid; 42 | 43 | implementation 44 | 45 | {$R *.lfm} 46 | 47 | { TForm1 } 48 | 49 | procedure TForm1.FormCreate(Sender: TObject); 50 | begin 51 | Grid1.Init(10,10); 52 | Form1.Memo1.Append('10x10 grid created'); 53 | ButtonChecked := Checkbox1.Checked; 54 | Grid1.IOtest.Source := @Form1.ButtonChecked; 55 | end; 56 | 57 | procedure TForm1.ButtonDumpContentsClick(Sender: TObject); 58 | var 59 | x,y : integer; 60 | s : string; 61 | begin 62 | memo1.Append('Program Dump: '); 63 | for y := 0 to Grid1.Height-1 do 64 | begin 65 | s := IntToStr(Y)+': '; 66 | for x := 0 to Grid1.Width-1 do 67 | s := s + IntToHex(Grid1.Cells[x,y].lookup,16) + ' '; 68 | memo1.Append(s); 69 | end; 70 | 71 | memo1.Append('inputs: '); 72 | for y := 0 to Grid1.Height-1 do 73 | begin 74 | s := ' ' + IntToStr(Y)+': '; 75 | for x := 0 to Grid1.Width-1 do 76 | s := s + IntToHex(Grid1.Cells[x,y].input,1) + ' '; 77 | memo1.Append(s); 78 | end; 79 | 80 | memo1.Append('outputs: '); 81 | for y := 0 to Grid1.Height-1 do 82 | begin 83 | s := ' ' + IntToStr(Y)+': '; 84 | for x := 0 to Grid1.Width-1 do 85 | s := s + IntToHex(Grid1.Cells[x,y].output,1) + ' '; 86 | memo1.Append(s); 87 | end; 88 | 89 | memo1.Append('Allbits = '+IntToHex(AllBits,16)); 90 | memo1.Append(' '+IntToStr(Grid1.CycleCount) + ' cycles executed'); 91 | end; 92 | 93 | procedure TForm1.Button1Click(Sender: TObject); 94 | begin 95 | Memo1.Append(DumpCode(PassThrough)); 96 | end; 97 | 98 | procedure TForm1.ButtonRunCycleClick(Sender: TObject); 99 | begin 100 | Grid1.DoClock; 101 | end; 102 | 103 | procedure TForm1.ButtonPassThroughClick(Sender: TObject); 104 | var 105 | x,y : integer; 106 | begin 107 | for y := 0 to Grid1.Height-1 do 108 | for x := 0 to Grid1.Width-1 do 109 | Grid1.Cells[x,y].lookup := Passthrough; 110 | 111 | Grid1.Cells[Grid1.Width-1,0].lookup:= $0000000088888888; 112 | For x := 0 to Grid1.Width-2 do 113 | Grid1.Cells[x,0].lookup := $FF08FF0877807780; 114 | 115 | For x := 0 to Grid1.Width-1 do 116 | Grid1.Cells[x,Grid1.Height-1].lookup := $4444000044440000; // reflect down, otherwise 0 117 | 118 | end; 119 | 120 | procedure TForm1.ButtonPhaseAClick(Sender: TObject); 121 | begin 122 | Grid1.DoPhaseA; 123 | Form1.Memo1.Append('phase A executed'); 124 | end; 125 | 126 | procedure TForm1.ButtonPhaseBClick(Sender: TObject); 127 | begin 128 | Grid1.DoPhaseB; 129 | Form1.Memo1.Append('phase B executed'); 130 | end; 131 | 132 | procedure TForm1.CheckBox1Change(Sender: TObject); 133 | begin 134 | ButtonChecked := Checkbox1.Checked; 135 | end; 136 | 137 | procedure TForm1.FormDestroy(Sender: TObject); 138 | begin 139 | Grid1.Done; 140 | Form1.Memo1.Append('grid done'); 141 | end; 142 | 143 | begin 144 | 145 | end. 146 | 147 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | Mike Warot's Bitgrid Engine in Pascal, with GUI 2 | 3 | Started (finally!) 6/12/2023 4 | 5 | A bitgrid is a Cartesian Array of cells, each having 4 bits of input from neighboring cells, and 4 outputs to them. To make this universal, each cell requires 4 look up tables, each with 16 entries to match all possible input states. The easiest way to represent this is a 16 character long hex number, one digit per possibilitity. 6 | 7 | Thus, a compact display of the program contents of a bitgrid might be a table of such entries 8 | 9 | the choice of bit order from neighbors is arbitrary, so we pick one here 10 | 11 | Up - 1 (bit 0) 12 | Right - 2 (bit 1) 13 | Below - 4 (bit 2) 14 | Left - 8 (bit 3) 15 | 16 | So, a cell programmed to repeat its inputs back to its neighbors would be FEDCBA9876543210 17 | a cell programmed to pass through all inputs to the next cell would be FB73EA62D951C840 18 | 19 | this should be the default for all cells, or all zeros, I'm not sure yet 20 | 21 | Evaluation: 22 | Cells will be evaluated in two phases, to avoid race conditions, and make it easier to understand, in the manner of coloring a chessboard, starting with 0,0 23 | 24 | Probes: 25 | It should be possible to force a stream of bits to a given cell input, again this is arbitrary 26 | 27 | It could be done between evaluation phases 28 | 29 | The same could be done with sensing outputs, either serial bits, or parallel across a given set of locations 30 | 31 | Data Structure: 32 | Each cell will have 4 bits (a nibble) of input, 4 bits of output, and 16 nibbles of program 33 | It turns out, it's easier to just use a uint64 for the implementation, for now 34 | 35 | 36 | 6/15/2023 - Code looks awful, but I can ripple bits accross a bitgrid 37 | 38 | 6/16/2023 - MAW - First benchmarks 39 | 40 | Creating 1024*1024 bitgrid 41 | Running 100 full cycles 42 | Done 43 | Time Elapsed : 8.682 Seconds 44 | Time/Layer : 0.087 Seconds 45 | Time/Cell : 0.083 µSec 46 | 47 | How far can I optimize this? 48 | First pass, saving the address of the next cell, and only doing an OR or an AND, instead of both 49 | Creating 1024*1024 bitgrid 50 | Running 100 full cycles 51 | Done 52 | Time Elapsed : 5.840 Seconds 53 | Time/Layer : 0.058 Seconds 54 | Time/Cell : 0.056 µSec 55 | 56 | A+B,B,A,0 57 | 58 | 3210 A=1, B=2 59 | 0000 - False 60 | 0001 - not (a or b) 61 | 0010 - a AND (not B) 62 | 0011 - NOT b 63 | 0100 - b AND (not a) 64 | 0101 - NOT a 65 | 0110 - a XOR b 66 | 0111 - NOT (a AND b) 67 | 1000 - a AND b 68 | 1001 - NOT (a XOR b) 69 | 1010 - a 70 | 1011 - a OR (NOT b) 71 | 1100 - b 72 | 1101 - b or (NOT a) 73 | 1110 - a OR b 74 | 1111 - True 75 | 76 | 8/14/2023 - More thinking about how to proceed 77 | 78 | Expression --> Abstract Syntax Tree --> Binary Expression Tree --> Binary Logical Expression Tree --> Routing/Placement 79 | 80 | Expression Examples 81 | 82 | Output = InputA + InputB 83 | 84 | AST - Abstract Syntax Tree Examples 85 | 86 | Assign(Output,Sum(InputA,InputB)) 87 | 88 | Binary Expression Tree Examples 89 | 90 | Output = Sum(A,B) 91 | 92 | Binary Logical Expression Tree 93 | 94 | Sum0 = A0 XOR B0 95 | Carry0 = A0 AND B0 96 | Sum1 = A1 XOR B1 XOR Carry0 97 | Carry1 = (Carry0 AND A1) OR (Carry0 AND B1) OR (A1 AND B1) 98 | ... 99 | Sum(N) = A(N) XOR B(N) XOR Carry(N-1) 100 | Carry(N) = (Carry(N-1) AND A(N)) OR (Carry(N-1) AND B(N)) OR (A(N) AND B(N)) 101 | 102 | Routing and Placement 103 | 104 | Use A* algorithm for actual routing 105 | 106 | ----- 107 | 108 | December 3, 2023 109 | Long dormant, time to collide bitgrid against advent of code 110 | 111 | Need an I/O subsystem, but it has to have some features 112 | everything queued, so that it can happen at each clock cycle asynchronously 113 | Input and output queues 114 | Overwrite queues 115 | 116 | StartCycle - cycle number for the start of an I/O 117 | EndCycle - if provided, the last cycle to listen to 118 | Cell, Port - which I/O channel should a bit come from? 119 | The queues should be ring buffers for performance 120 | 121 | Start thinking about BitGrid chip actual I/O signals/performance, etc. 122 | 123 | Need a programming/debug subsystem 124 | StartCycle - cycle number to write code at 125 | Cell address, LUT values 126 | Could make it async, ok... let's do that 127 | This would allow reuse on the fly of sections to handle multiple tasks 128 | Map range of I/O or cells to display for debug, monitoring, etc. 129 | 130 | Need a logging subsystem 131 | Log all programming, debug, and I/O operations 132 | 133 | 134 | December 8, 2023 135 | Short term tasks: 136 | Build an acyclic directed graph from random choices, get it out on a text file 137 | Figure out how to map those to nodes in a grid, with 0 cost spacers 138 | Figure out how to count for delays 139 | Figure out how to map into bitgrid cells 140 | Figure out logic mapping through the above 141 | Compute delays 142 | Can we do cyclic graphs? 143 | Can we take a mapped graph and work backwards 144 | Can we route around a bad cell? 145 | Fill the bitgrid with random numbers 146 | Make that into a graph 147 | Remove unlinked nodes 148 | Show updated grid without unlinked nodes 149 | --------------------------------------------------------------------------------