snapkitty
compilers
python
SNAPKITTYWEST commited on
Commit
476d05b
Β·
verified Β·
1 Parent(s): b86c469

Sync with GitHub, license metadata from LICENSE files, commercial license notice

Browse files

metadata license: None -> other (snapkitty-tri-license)
README: License section appended
README: GitHub source link added

Files changed (1) hide show
  1. README.md +184 -162
README.md CHANGED
@@ -1,162 +1,184 @@
1
- # MACROGROK β€” AGC-Inspired Fixed-Point Macro-Model
2
-
3
- Patent Pending β€” BEL ESPRIT D ACCORD TRUST HOLDINGS INC.
4
-
5
- Extremely constrained, narrow-task models for 15-bit / Qm.n environments. Code lives in ROM, state in ~2K erasable words. Every bit is budgeted.
6
-
7
- ## 1. Model Purpose & Scope
8
-
9
- * Single, narrowly defined task: attitude correction, trajectory offset, binary/multi-class decision, low-dimensional control law.
10
- * No general-purpose LM or large feature spaces.
11
- * Input/output dimensions very small (typically ≀ 8–16).
12
-
13
- ## 2. Numeric Representation
14
-
15
- * Word: 15-bit data (modern 16-bit with 1-bit reserved).
16
- * Fixed-point Qm.n (e.g., Q1.14, Q3.12, Q7.8) chosen per variable, scale documented per quantity.
17
- * Double/triple precision only where required.
18
- * Saturation handling: clamp, wrap, or flag β€” defined per variable.
19
-
20
- ## 3. Memory Layout
21
-
22
- **Erasable (RAM) β€” ~2K words target:**
23
- State vector, input buffer, accumulators, flags/mode bits, tiny stack.
24
-
25
- **Fixed (ROM) β€” majority:**
26
- Model constants (weights/biases, lookup tables, scale factors), code/macros, pre-computed coefficients. Bank/segment switching optional.
27
-
28
- ## 4. Core Data Structures
29
-
30
- ```
31
- STATE : fixed-point vector (persistent)
32
- INPUT : fixed-point vector (current observation)
33
- OUTPUT : fixed-point vector or discrete command
34
- ACC : accumulator(s) β€” single/double precision
35
- SCALES : constant scale factors
36
- FLAGS : mode, validity, saturation bits
37
- ```
38
-
39
- ## 5. Macro Routine Categories
40
-
41
- `LOAD_INPUT` / `SCALE_INPUT` Β· `MATVEC_TINY` / `DOT_PRODUCT_FIXED` (unrolled) Β· `LOOKUP_SEGMENT` / `PIECEWISE_LINEAR` Β· `ACTIVATE` (clip/ReLU/threshold) Β· `UPDATE_STATE` Β· `NORMALIZE`/`RESCALE` Β· `SATURATE` Β· `EMIT_OUTPUT`
42
-
43
- Macros expand to shifts, adds, MUL16, and table lookups β€” no floating point.
44
-
45
- ## 6. Forward Pass
46
-
47
- ```
48
- 1. Acquire and scale input β†’ INPUT
49
- 2. Optional tiny feature transform
50
- 3. Core block(s) (mat-vec + nonlinearity, macro-expanded)
51
- 4. State update (if recurrent)
52
- 5. Output scaling + saturation
53
- 6. Write command / flags
54
- ```
55
-
56
- All steps use fixed-point ops and explicit erasable temporaries.
57
-
58
- ## 7. Initialization
59
-
60
- Weights/biases/tables in fixed storage; init routine copies needed values to erasable once. Constants never modified at runtime.
61
-
62
- ## 8. Executive Wrapper (Optional)
63
-
64
- Cyclic/priority executive, ability to skip non-critical sections under pressure, watchdog/validity flags.
65
-
66
- ## 9. Documentation Requirement
67
-
68
- For every variable and macro: Qm.n format, physical units, scale, valid range, overflow behavior, memory location (erasable bank or fixed address).
69
-
70
- ## 10. Example Skeleton
71
-
72
- ```
73
- ; FIXED (ROM)
74
- WEIGHTS_Q3_12 ...
75
- BIAS_Q3_12 ...
76
- SCALE_IN ... SCALE_OUT ...
77
-
78
- ; ERASABLE (RAM)
79
- STATE DS 4 ; Q3.12
80
- INPUT DS 4
81
- OUTPUT DS 2
82
- ACC DS 2 ; double precision
83
-
84
- ; MACROS
85
- MACRO DOT4 ; 4-element dot
86
- MACRO SAT_Q3_12
87
- MACRO UPDATE_STATE
88
-
89
- INFER
90
- LOAD_INPUT
91
- SCALE_INPUT
92
- DOT4 WEIGHTS_Q3_12, INPUT, ACC
93
- ADD BIAS
94
- SAT_Q3_12
95
- UPDATE_STATE
96
- SCALE_OUTPUT
97
- STORE OUTPUT
98
- RETURN
99
- ```
100
-
101
- ## Design Principles
102
-
103
- Every bit budgeted β€” tables + interpolation over general arithmetic β€” unrolled tiny loops β€” minimal contiguous mutable state β€” specialized routine, not general engine.
104
-
105
- ---
106
-
107
- ## Fixed-Point Contract (INFER4 Example)
108
-
109
- 4-input binary decision, Q format per quantity, saturate to 32-bit ACC.
110
-
111
- | Symbol | Format | Role | Overflow |
112
- |---|---|---|---|
113
- | `INPUT[4]` | Q1.14 | sensors [-1,1) | clamp |
114
- | `WEIGHTS[4]` | Q1.14 | ROM coefficients | const |
115
- | `BIAS` | Q3.12 | offset | const |
116
- | `ACC` | Q7.24 32-bit | dot accumulator | saturate |
117
- | `STATE` | Q3.12 | smoothed output | clamp |
118
- | `OUTPUT` | Q1.14 | command | clamp |
119
- | `FLAGS` | bits | validity/sat/decision | β€” |
120
-
121
- Q1.14 * Q1.14 β†’ Q2.28 β†’ >>4 β†’ Q3.24 (4 products in 32-bit), >>12 β†’ Q3.12 + `BIAS`.
122
-
123
- ## Memory Map
124
-
125
- ```
126
- ; FIXED / ROM
127
- WEIGHTS_Q1_14: DC 2458, -1638, 819, 3277
128
- BIAS_Q3_12: DC -256
129
- ALPHA_Q1_14: DC 12288 ; 0.75
130
- ONE_Q1_14: DC 16384
131
- OUT_MIN_Q1_14: DC -16384
132
- OUT_MAX_Q1_14: DC 16383
133
- SCORE_MIN_Q3_12: DC -8192 ; -2.0 Q3.12
134
- SCORE_MAX_Q3_12: DC 8191 ; +2.0
135
-
136
- ; ERASABLE / RAM
137
- INPUT: DS 4
138
- STATE: DS 1 ; Q3.12
139
- OUTPUT: DS 1
140
- ACC_HI: DS 1 ; 32-bit hi
141
- ACC_LO: DS 1 ; 32-bit lo
142
- TMP0: DS 1
143
- TMP1: DS 1
144
- FLAGS: DS 1
145
- FLAG_VALID=0001 FLAG_SAT=0002 FLAG_POSITIVE=0004
146
- ```
147
-
148
- ## Primitive Macros
149
-
150
- See `examples/infer4.asm` for full `CLR_ACC`, `MAC_Q1_14` (preserves `PROD_HI:PROD_LO` before `ADD32`), `ACC_TO_Q3_12`, `SAT_Q3_12`, `DOT4_Q1_14`, `THRESHOLD_Q3_12` (+1.0/-1.0), `UPDATE_STATE_3_4` (`(3*STATE+TARGET)/4`).
151
-
152
- ## INFER4 Routine
153
-
154
- `examples/infer4.asm` β€” `INFER4: CLR FLAGS β†’ DOT4 β†’ ACC_TO_Q3_12 β†’ ADD BIAS β†’ SAT β†’ THRESHOLD β†’ UPDATE_STATE_3_4 β†’ OUTPUT=STATE β†’ FLAG_VALID β†’ RET`
155
-
156
- Simulator: `python src/sim.py` (Q1.14/Q3.12 fixed-point, matches assembly semantics).
157
-
158
- ## References
159
-
160
- [1] Virtual AGC Manual β€” ibiblio.org/apollo/assembly_language_manual.html
161
- [2] AGC β€” Wikipedia
162
- [3] Block II: 2048 erasable + 36864 fixed words, 15 data bits + parity
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: snapkitty-tri-license
4
+ license_link: https://huggingface.co/Snapkitty/MACROGROK/blob/main/LICENSE.tri
5
+ tags:
6
+ - snapkitty
7
+ ---
8
+
9
+ > Source: [github.com/SNAPKITTYWEST/MACROGROK](https://github.com/SNAPKITTYWEST/MACROGROK)
10
+
11
+ # MACROGROK β€” AGC-Inspired Fixed-Point Macro-Model
12
+
13
+ Patent Pending β€” BEL ESPRIT D ACCORD TRUST HOLDINGS INC.
14
+
15
+ Extremely constrained, narrow-task models for 15-bit / Qm.n environments. Code lives in ROM, state in ~2K erasable words. Every bit is budgeted.
16
+
17
+ ## 1. Model Purpose & Scope
18
+
19
+ * Single, narrowly defined task: attitude correction, trajectory offset, binary/multi-class decision, low-dimensional control law.
20
+ * No general-purpose LM or large feature spaces.
21
+ * Input/output dimensions very small (typically ≀ 8–16).
22
+
23
+ ## 2. Numeric Representation
24
+
25
+ * Word: 15-bit data (modern 16-bit with 1-bit reserved).
26
+ * Fixed-point Qm.n (e.g., Q1.14, Q3.12, Q7.8) chosen per variable, scale documented per quantity.
27
+ * Double/triple precision only where required.
28
+ * Saturation handling: clamp, wrap, or flag β€” defined per variable.
29
+
30
+ ## 3. Memory Layout
31
+
32
+ **Erasable (RAM) β€” ~2K words target:**
33
+ State vector, input buffer, accumulators, flags/mode bits, tiny stack.
34
+
35
+ **Fixed (ROM) β€” majority:**
36
+ Model constants (weights/biases, lookup tables, scale factors), code/macros, pre-computed coefficients. Bank/segment switching optional.
37
+
38
+ ## 4. Core Data Structures
39
+
40
+ ```
41
+ STATE : fixed-point vector (persistent)
42
+ INPUT : fixed-point vector (current observation)
43
+ OUTPUT : fixed-point vector or discrete command
44
+ ACC : accumulator(s) β€” single/double precision
45
+ SCALES : constant scale factors
46
+ FLAGS : mode, validity, saturation bits
47
+ ```
48
+
49
+ ## 5. Macro Routine Categories
50
+
51
+ `LOAD_INPUT` / `SCALE_INPUT` Β· `MATVEC_TINY` / `DOT_PRODUCT_FIXED` (unrolled) Β· `LOOKUP_SEGMENT` / `PIECEWISE_LINEAR` Β· `ACTIVATE` (clip/ReLU/threshold) Β· `UPDATE_STATE` Β· `NORMALIZE`/`RESCALE` Β· `SATURATE` Β· `EMIT_OUTPUT`
52
+
53
+ Macros expand to shifts, adds, MUL16, and table lookups β€” no floating point.
54
+
55
+ ## 6. Forward Pass
56
+
57
+ ```
58
+ 1. Acquire and scale input β†’ INPUT
59
+ 2. Optional tiny feature transform
60
+ 3. Core block(s) (mat-vec + nonlinearity, macro-expanded)
61
+ 4. State update (if recurrent)
62
+ 5. Output scaling + saturation
63
+ 6. Write command / flags
64
+ ```
65
+
66
+ All steps use fixed-point ops and explicit erasable temporaries.
67
+
68
+ ## 7. Initialization
69
+
70
+ Weights/biases/tables in fixed storage; init routine copies needed values to erasable once. Constants never modified at runtime.
71
+
72
+ ## 8. Executive Wrapper (Optional)
73
+
74
+ Cyclic/priority executive, ability to skip non-critical sections under pressure, watchdog/validity flags.
75
+
76
+ ## 9. Documentation Requirement
77
+
78
+ For every variable and macro: Qm.n format, physical units, scale, valid range, overflow behavior, memory location (erasable bank or fixed address).
79
+
80
+ ## 10. Example Skeleton
81
+
82
+ ```
83
+ ; FIXED (ROM)
84
+ WEIGHTS_Q3_12 ...
85
+ BIAS_Q3_12 ...
86
+ SCALE_IN ... SCALE_OUT ...
87
+
88
+ ; ERASABLE (RAM)
89
+ STATE DS 4 ; Q3.12
90
+ INPUT DS 4
91
+ OUTPUT DS 2
92
+ ACC DS 2 ; double precision
93
+
94
+ ; MACROS
95
+ MACRO DOT4 ; 4-element dot
96
+ MACRO SAT_Q3_12
97
+ MACRO UPDATE_STATE
98
+
99
+ INFER
100
+ LOAD_INPUT
101
+ SCALE_INPUT
102
+ DOT4 WEIGHTS_Q3_12, INPUT, ACC
103
+ ADD BIAS
104
+ SAT_Q3_12
105
+ UPDATE_STATE
106
+ SCALE_OUTPUT
107
+ STORE OUTPUT
108
+ RETURN
109
+ ```
110
+
111
+ ## Design Principles
112
+
113
+ Every bit budgeted β€” tables + interpolation over general arithmetic β€” unrolled tiny loops β€” minimal contiguous mutable state β€” specialized routine, not general engine.
114
+
115
+ ---
116
+
117
+ ## Fixed-Point Contract (INFER4 Example)
118
+
119
+ 4-input binary decision, Q format per quantity, saturate to 32-bit ACC.
120
+
121
+ | Symbol | Format | Role | Overflow |
122
+ |---|---|---|---|
123
+ | `INPUT[4]` | Q1.14 | sensors [-1,1) | clamp |
124
+ | `WEIGHTS[4]` | Q1.14 | ROM coefficients | const |
125
+ | `BIAS` | Q3.12 | offset | const |
126
+ | `ACC` | Q7.24 32-bit | dot accumulator | saturate |
127
+ | `STATE` | Q3.12 | smoothed output | clamp |
128
+ | `OUTPUT` | Q1.14 | command | clamp |
129
+ | `FLAGS` | bits | validity/sat/decision | β€” |
130
+
131
+ Q1.14 * Q1.14 β†’ Q2.28 β†’ >>4 β†’ Q3.24 (4 products in 32-bit), >>12 β†’ Q3.12 + `BIAS`.
132
+
133
+ ## Memory Map
134
+
135
+ ```
136
+ ; FIXED / ROM
137
+ WEIGHTS_Q1_14: DC 2458, -1638, 819, 3277
138
+ BIAS_Q3_12: DC -256
139
+ ALPHA_Q1_14: DC 12288 ; 0.75
140
+ ONE_Q1_14: DC 16384
141
+ OUT_MIN_Q1_14: DC -16384
142
+ OUT_MAX_Q1_14: DC 16383
143
+ SCORE_MIN_Q3_12: DC -8192 ; -2.0 Q3.12
144
+ SCORE_MAX_Q3_12: DC 8191 ; +2.0
145
+
146
+ ; ERASABLE / RAM
147
+ INPUT: DS 4
148
+ STATE: DS 1 ; Q3.12
149
+ OUTPUT: DS 1
150
+ ACC_HI: DS 1 ; 32-bit hi
151
+ ACC_LO: DS 1 ; 32-bit lo
152
+ TMP0: DS 1
153
+ TMP1: DS 1
154
+ FLAGS: DS 1
155
+ FLAG_VALID=0001 FLAG_SAT=0002 FLAG_POSITIVE=0004
156
+ ```
157
+
158
+ ## Primitive Macros
159
+
160
+ See `examples/infer4.asm` for full `CLR_ACC`, `MAC_Q1_14` (preserves `PROD_HI:PROD_LO` before `ADD32`), `ACC_TO_Q3_12`, `SAT_Q3_12`, `DOT4_Q1_14`, `THRESHOLD_Q3_12` (+1.0/-1.0), `UPDATE_STATE_3_4` (`(3*STATE+TARGET)/4`).
161
+
162
+ ## INFER4 Routine
163
+
164
+ `examples/infer4.asm` β€” `INFER4: CLR FLAGS β†’ DOT4 β†’ ACC_TO_Q3_12 β†’ ADD BIAS β†’ SAT β†’ THRESHOLD β†’ UPDATE_STATE_3_4 β†’ OUTPUT=STATE β†’ FLAG_VALID β†’ RET`
165
+
166
+ Simulator: `python src/sim.py` (Q1.14/Q3.12 fixed-point, matches assembly semantics).
167
+
168
+ ## References
169
+
170
+ [1] Virtual AGC Manual β€” ibiblio.org/apollo/assembly_language_manual.html
171
+ [2] AGC β€” Wikipedia
172
+ [3] Block II: 2048 erasable + 36864 fixed words, 15 data bits + parity
173
+
174
+ ---
175
+
176
+ ## License
177
+
178
+ Licensed under **SnapKitty Tri-License**. Full text: [LICENSE.tri](LICENSE.tri).
179
+
180
+ ### πŸ’Ό Commercial License
181
+
182
+ Snapkitty code is free and open under **AGPL-3.0** for open-source use. Building a commercial product or service? A **proprietary commercial license** from Snapkitty Collective LLC lets you ship this code without the AGPL's source-sharing and network-use obligations.
183
+
184
+ **[β†’ Get a commercial license](mailto:A.parr@belespritdaccord.uk?subject=Commercial%20license:%20MACROGROK)** Β· A.parr@belespritdaccord.uk