diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2023-04-11 14:05:41 +0300 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2023-04-11 14:05:41 +0300 |
| commit | da14e7ca7f31cb4b9a975dbe349fb4d385592b9c (patch) | |
| tree | ea60a83ccb64af33a48f13839e6145b7c97236d2 | |
| parent | 9a6001ad380e83a545188b58145387593b117b48 (diff) | |
Fix bugs
| -rw-r--r-- | digital/atk16.dig | 446 | ||||
| -rw-r--r-- | digital/atk16_decoder.dig | 44 | ||||
| -rw-r--r-- | digital/atk16_mem.dig | 8 | ||||
| -rw-r--r-- | digital/atk16_regbank.dig | 667 | ||||
| -rw-r--r-- | src/asm_pass2.py | 8 | ||||
| -rw-r--r-- | src/asm_pass3.py | 2 | ||||
| -rw-r--r-- | src/asm_pass4.py | 6 | ||||
| -rwxr-xr-x | src/assembler.py | 5 | ||||
| -rw-r--r-- | src/assembler_eval.py | 24 | ||||
| -rw-r--r-- | src/assembler_ops.py | 16 | ||||
| -rw-r--r-- | src/ext_std.py | 19 | ||||
| -rw-r--r-- | src/test.atk16 | 2 | ||||
| -rw-r--r-- | src/test_fibo.atk16 | 72 | ||||
| -rwxr-xr-x | src/ucode.py | 8 |
14 files changed, 764 insertions, 563 deletions
diff --git a/digital/atk16.dig b/digital/atk16.dig index 1345925..ca4aa6d 100644 --- a/digital/atk16.dig +++ b/digital/atk16.dig @@ -278,34 +278,6 @@ <pos x="-40" y="-280"/> </visualElement> <visualElement> - <elementName>Clock</elementName> - <elementAttributes> - <entry> - <string>small</string> - <boolean>true</boolean> - </entry> - <entry> - <string>runRealTime</string> - <boolean>true</boolean> - </entry> - <entry> - <string>Frequency</string> - <int>10</int> - </entry> - </elementAttributes> - <pos x="-320" y="-360"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>NetName</string> - <string>CLK</string> - </entry> - </elementAttributes> - <pos x="-300" y="-360"/> - </visualElement> - <visualElement> <elementName>Tunnel</elementName> <elementAttributes> <entry> @@ -391,11 +363,6 @@ <pos x="580" y="-160"/> </visualElement> <visualElement> - <elementName>Break</elementName> - <elementAttributes/> - <pos x="-300" y="-400"/> - </visualElement> - <visualElement> <elementName>atk16_decoder.dig</elementName> <elementAttributes> <entry> @@ -525,50 +492,6 @@ <pos x="100" y="-100"/> </visualElement> <visualElement> - <elementName>Out</elementName> - <elementAttributes> - <entry> - <string>Description</string> - <string>Dummy output</string> - </entry> - <entry> - <string>Label</string> - <string>OUT</string> - </entry> - </elementAttributes> - <pos x="960" y="-140"/> - </visualElement> - <visualElement> - <elementName>Ground</elementName> - <elementAttributes> - <entry> - <string>rotation</string> - <rotation rotation="1"/> - </entry> - </elementAttributes> - <pos x="940" y="-140"/> - </visualElement> - <visualElement> - <elementName>In</elementName> - <elementAttributes> - <entry> - <string>Label</string> - <string>IN</string> - </entry> - </elementAttributes> - <pos x="960" y="-200"/> - </visualElement> - <visualElement> - <elementName>Ground</elementName> - <elementAttributes> - <entry> - <string>rotation</string> - <rotation reference="../../../../visualElement[40]/elementAttributes/entry/rotation"/> - </entry> - </elementAttributes> - <pos x="980" y="-200"/> - </visualElement> - <visualElement> <elementName>Tunnel</elementName> <elementAttributes> <entry> @@ -699,16 +622,6 @@ <elementAttributes> <entry> <string>NetName</string> - <string>IM_M</string> - </entry> - </elementAttributes> - <pos x="920" y="160"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>NetName</string> <string>IR_IE</string> </entry> </elementAttributes> @@ -786,12 +699,12 @@ </entry> <entry> <string>Data</string> - <data>c,221,3040,8000,4*0,c,221,3040,8000,4*0,c,221,3140,8000,4*0,c -,221,3140,8000,4*0,c,221,88,60,8000,0,0,0,c,221,88,60,8000,0,0,0 -,c,221,88,90,8000,0,0,0,c,221,88,90,8000,0,0,0,c,221,840,8000 + <data>c,221,3040,8000,4*0,c,221,3040,8000,4*0,c,221,3440,8000,4*0,c +,221,3440,8000,4*0,c,221,88,60,8000,0,0,0,c,221,88,60,8000,0,0,0 +,c,221,88,110,8000,0,0,0,c,221,88,110,8000,0,0,0,c,221,840,8000 ,4*0,c,221,840,8000,4*0,c,221,82,8000,4*0,c,221,82,8000,4*0,c -,221,902,8000,4*0,c,221,902,8000,4*0,c,221,8000,5*0,c,221,82,8000 -,4*0,c,221,8000,5*0,c,221,902,8000,4*0,c,221,44,8000,4*0,c,221 +,221,c02,8000,4*0,c,221,c02,8000,4*0,c,221,8000,5*0,c,221,82,8000 +,4*0,c,221,8000,5*0,c,221,c02,8000,4*0,c,221,44,8000,4*0,c,221 ,44,8000,4*0,c,221,8000,5*0,c,221,8000,5*0,c,221,8000,5*0,c,221 ,8000,5*0,c,221,8000,5*0,c,221,8000,5*0,c,221,8000,5*0,c,221,8000 ,5*0,c,221,8000,5*0,c,221,8000,5*0,c,221,4000,5*0,c,221,4000</data> @@ -911,26 +824,6 @@ <pos x="540" y="60"/> </visualElement> <visualElement> - <elementName>Testcase</elementName> - <elementAttributes> - <entry> - <string>Label</string> - <string>Sum program TODO</string> - </entry> - <entry> - <string>Testdata</string> - <testData> - <dataString>IN OUT - -program(0x4051, 0x40a2, 0x029b) - -0 x</dataString> - </testData> - </entry> - </elementAttributes> - <pos x="-60" y="-460"/> - </visualElement> - <visualElement> <elementName>atk16_jump_unit.dig</elementName> <elementAttributes/> <pos x="-220" y="-240"/> @@ -997,6 +890,147 @@ program(0x4051, 0x40a2, 0x029b) </elementAttributes> <pos x="240" y="-440"/> </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>NetName</string> + <string>IM_M</string> + </entry> + </elementAttributes> + <pos x="920" y="120"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>NetName</string> + <string>R2_OE</string> + </entry> + </elementAttributes> + <pos x="920" y="160"/> + </visualElement> + <visualElement> + <elementName>Driver</elementName> + <elementAttributes> + <entry> + <string>Bits</string> + <int>16</int> + </entry> + <entry> + <string>flipSelPos</string> + <boolean>true</boolean> + </entry> + </elementAttributes> + <pos x="560" y="-100"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>NetName</string> + <string>R2_OE</string> + </entry> + </elementAttributes> + <pos x="580" y="-80"/> + </visualElement> + <visualElement> + <elementName>Testcase</elementName> + <elementAttributes> + <entry> + <string>Label</string> + <string>Sum program TODO</string> + </entry> + <entry> + <string>Testdata</string> + <testData> + <dataString>IN OUT + +program(0x4051, 0x40a2, 0x029b) + +0 x</dataString> + </testData> + </entry> + </elementAttributes> + <pos x="900" y="760"/> + </visualElement> + <visualElement> + <elementName>Out</elementName> + <elementAttributes> + <entry> + <string>Description</string> + <string>Dummy output</string> + </entry> + <entry> + <string>Label</string> + <string>OUT</string> + </entry> + </elementAttributes> + <pos x="720" y="800"/> + </visualElement> + <visualElement> + <elementName>Ground</elementName> + <elementAttributes> + <entry> + <string>rotation</string> + <rotation rotation="1"/> + </entry> + </elementAttributes> + <pos x="700" y="800"/> + </visualElement> + <visualElement> + <elementName>In</elementName> + <elementAttributes> + <entry> + <string>Label</string> + <string>IN</string> + </entry> + </elementAttributes> + <pos x="720" y="740"/> + </visualElement> + <visualElement> + <elementName>Ground</elementName> + <elementAttributes> + <entry> + <string>rotation</string> + <rotation reference="../../../../visualElement[77]/elementAttributes/entry/rotation"/> + </entry> + </elementAttributes> + <pos x="740" y="740"/> + </visualElement> + <visualElement> + <elementName>Clock</elementName> + <elementAttributes> + <entry> + <string>small</string> + <boolean>true</boolean> + </entry> + <entry> + <string>runRealTime</string> + <boolean>true</boolean> + </entry> + <entry> + <string>Frequency</string> + <int>50</int> + </entry> + </elementAttributes> + <pos x="660" y="-340"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>NetName</string> + <string>CLK</string> + </entry> + </elementAttributes> + <pos x="680" y="-340"/> + </visualElement> + <visualElement> + <elementName>Break</elementName> + <elementAttributes/> + <pos x="680" y="-380"/> + </visualElement> </visualElements> <wires> <wire> @@ -1060,10 +1094,6 @@ program(0x4051, 0x40a2, 0x029b) <p2 x="580" y="-200"/> </wire> <wire> - <p1 x="960" y="-200"/> - <p2 x="980" y="-200"/> - </wire> - <wire> <p1 x="-240" y="-200"/> <p2 x="-220" y="-200"/> </wire> @@ -1076,10 +1106,6 @@ program(0x4051, 0x40a2, 0x029b) <p2 x="860" y="200"/> </wire> <wire> - <p1 x="940" y="-140"/> - <p2 x="960" y="-140"/> - </wire> - <wire> <p1 x="-280" y="-140"/> <p2 x="-60" y="-140"/> </wire> @@ -1116,6 +1142,10 @@ program(0x4051, 0x40a2, 0x029b) <p2 x="460" y="-80"/> </wire> <wire> + <p1 x="560" y="-80"/> + <p2 x="580" y="-80"/> + </wire> + <wire> <p1 x="400" y="-80"/> <p2 x="420" y="-80"/> </wire> @@ -1149,6 +1179,10 @@ program(0x4051, 0x40a2, 0x029b) </wire> <wire> <p1 x="400" y="-20"/> + <p2 x="520" y="-20"/> + </wire> + <wire> + <p1 x="520" y="-20"/> <p2 x="580" y="-20"/> </wire> <wire> @@ -1156,6 +1190,10 @@ program(0x4051, 0x40a2, 0x029b) <p2 x="100" y="-340"/> </wire> <wire> + <p1 x="660" y="-340"/> + <p2 x="680" y="-340"/> + </wire> + <wire> <p1 x="160" y="20"/> <p2 x="220" y="20"/> </wire> @@ -1232,6 +1270,10 @@ program(0x4051, 0x40a2, 0x029b) <p2 x="920" y="160"/> </wire> <wire> + <p1 x="700" y="800"/> + <p2 x="720" y="800"/> + </wire> + <wire> <p1 x="80" y="-100"/> <p2 x="100" y="-100"/> </wire> @@ -1244,12 +1286,20 @@ program(0x4051, 0x40a2, 0x029b) <p2 x="420" y="-100"/> </wire> <wire> + <p1 x="580" y="-100"/> + <p2 x="620" y="-100"/> + </wire> + <wire> + <p1 x="520" y="-100"/> + <p2 x="540" y="-100"/> + </wire> + <wire> <p1 x="900" y="100"/> <p2 x="920" y="100"/> </wire> <wire> - <p1 x="-320" y="-360"/> - <p2 x="-300" y="-360"/> + <p1 x="720" y="740"/> + <p2 x="740" y="740"/> </wire> <wire> <p1 x="60" y="-40"/> @@ -1353,9 +1403,17 @@ program(0x4051, 0x40a2, 0x029b) </wire> <wire> <p1 x="500" y="-120"/> + <p2 x="620" y="-120"/> + </wire> + <wire> + <p1 x="620" y="-120"/> <p2 x="920" y="-120"/> </wire> <wire> + <p1 x="900" y="120"/> + <p2 x="920" y="120"/> + </wire> + <wire> <p1 x="60" y="-60"/> <p2 x="80" y="-60"/> </wire> @@ -1388,140 +1446,148 @@ program(0x4051, 0x40a2, 0x029b) <p2 x="440" y="60"/> </wire> <wire> - <p1 x="480" y="-200"/> - <p2 x="480" y="-140"/> + <p1 x="200" y="-280"/> + <p2 x="200" y="-240"/> </wire> <wire> - <p1 x="480" y="-140"/> - <p2 x="480" y="-120"/> + <p1 x="200" y="-40"/> + <p2 x="200" y="80"/> </wire> <wire> - <p1 x="160" y="0"/> - <p2 x="160" y="20"/> + <p1 x="200" y="-240"/> + <p2 x="200" y="-140"/> </wire> <wire> - <p1 x="420" y="320"/> - <p2 x="420" y="340"/> + <p1 x="200" y="-140"/> + <p2 x="200" y="-80"/> </wire> <wire> - <p1 x="420" y="-80"/> - <p2 x="420" y="-40"/> + <p1 x="520" y="-100"/> + <p2 x="520" y="-20"/> </wire> <wire> - <p1 x="100" y="-380"/> - <p2 x="100" y="-340"/> + <p1 x="80" y="-100"/> + <p2 x="80" y="-60"/> </wire> <wire> - <p1 x="100" y="-280"/> - <p2 x="100" y="-240"/> + <p1 x="720" y="0"/> + <p2 x="720" y="80"/> </wire> <wire> - <p1 x="100" y="-340"/> - <p2 x="100" y="-280"/> + <p1 x="400" y="-100"/> + <p2 x="400" y="-80"/> </wire> <wire> - <p1 x="200" y="-280"/> - <p2 x="200" y="-240"/> + <p1 x="400" y="-60"/> + <p2 x="400" y="-20"/> </wire> <wire> - <p1 x="200" y="-40"/> - <p2 x="200" y="80"/> + <p1 x="-280" y="-240"/> + <p2 x="-280" y="-140"/> </wire> <wire> - <p1 x="200" y="-240"/> - <p2 x="200" y="-140"/> + <p1 x="280" y="320"/> + <p2 x="280" y="340"/> </wire> <wire> - <p1 x="200" y="-140"/> - <p2 x="200" y="-80"/> + <p1 x="280" y="200"/> + <p2 x="280" y="280"/> </wire> <wire> - <p1 x="40" y="280"/> - <p2 x="40" y="300"/> + <p1 x="920" y="-120"/> + <p2 x="920" y="-40"/> </wire> <wire> - <p1 x="-300" y="-400"/> - <p2 x="-300" y="-360"/> + <p1 x="220" y="-60"/> + <p2 x="220" y="-40"/> </wire> <wire> - <p1 x="-240" y="-340"/> - <p2 x="-240" y="-220"/> + <p1 x="220" y="20"/> + <p2 x="220" y="60"/> </wire> <wire> - <p1 x="80" y="-100"/> - <p2 x="80" y="-60"/> + <p1 x="860" y="-20"/> + <p2 x="860" y="200"/> </wire> <wire> - <p1 x="720" y="0"/> - <p2 x="720" y="80"/> + <p1 x="540" y="0"/> + <p2 x="540" y="20"/> </wire> <wire> - <p1 x="400" y="-100"/> - <p2 x="400" y="-80"/> + <p1 x="480" y="-200"/> + <p2 x="480" y="-140"/> </wire> <wire> - <p1 x="400" y="-60"/> - <p2 x="400" y="-20"/> + <p1 x="480" y="-140"/> + <p2 x="480" y="-120"/> </wire> <wire> - <p1 x="560" y="20"/> - <p2 x="560" y="60"/> + <p1 x="160" y="0"/> + <p2 x="160" y="20"/> </wire> <wire> - <p1 x="500" y="240"/> - <p2 x="500" y="280"/> + <p1 x="420" y="320"/> + <p2 x="420" y="340"/> </wire> <wire> - <p1 x="500" y="-120"/> - <p2 x="500" y="-100"/> + <p1 x="420" y="-80"/> + <p2 x="420" y="-40"/> </wire> <wire> - <p1 x="180" y="-20"/> - <p2 x="180" y="0"/> + <p1 x="100" y="-380"/> + <p2 x="100" y="-340"/> </wire> <wire> - <p1 x="-280" y="-240"/> - <p2 x="-280" y="-140"/> + <p1 x="100" y="-340"/> + <p2 x="100" y="-280"/> </wire> <wire> - <p1 x="280" y="320"/> - <p2 x="280" y="340"/> + <p1 x="100" y="-280"/> + <p2 x="100" y="-240"/> </wire> <wire> - <p1 x="280" y="200"/> - <p2 x="280" y="280"/> + <p1 x="40" y="280"/> + <p2 x="40" y="300"/> </wire> <wire> - <p1 x="920" y="-120"/> - <p2 x="920" y="-40"/> + <p1 x="680" y="-380"/> + <p2 x="680" y="-340"/> </wire> <wire> - <p1 x="440" y="20"/> - <p2 x="440" y="60"/> + <p1 x="620" y="-120"/> + <p2 x="620" y="-100"/> </wire> <wire> - <p1 x="-60" y="-140"/> - <p2 x="-60" y="-80"/> + <p1 x="-240" y="-340"/> + <p2 x="-240" y="-220"/> </wire> <wire> - <p1 x="380" y="-200"/> - <p2 x="380" y="-180"/> + <p1 x="560" y="20"/> + <p2 x="560" y="60"/> </wire> <wire> - <p1 x="220" y="-60"/> - <p2 x="220" y="-40"/> + <p1 x="500" y="240"/> + <p2 x="500" y="280"/> </wire> <wire> - <p1 x="220" y="20"/> - <p2 x="220" y="60"/> + <p1 x="500" y="-120"/> + <p2 x="500" y="-100"/> </wire> <wire> - <p1 x="860" y="-20"/> - <p2 x="860" y="200"/> + <p1 x="180" y="-20"/> + <p2 x="180" y="0"/> </wire> <wire> - <p1 x="540" y="0"/> - <p2 x="540" y="20"/> + <p1 x="440" y="20"/> + <p2 x="440" y="60"/> + </wire> + <wire> + <p1 x="-60" y="-140"/> + <p2 x="-60" y="-80"/> + </wire> + <wire> + <p1 x="380" y="-200"/> + <p2 x="380" y="-180"/> </wire> </wires> <measurementOrdering/> diff --git a/digital/atk16_decoder.dig b/digital/atk16_decoder.dig index 0570615..b8eb088 100644 --- a/digital/atk16_decoder.dig +++ b/digital/atk16_decoder.dig @@ -259,34 +259,6 @@ <pos x="460" y="680"/> </visualElement> <visualElement> - <elementName>Splitter</elementName> - <elementAttributes> - <entry> - <string>Input Splitting</string> - <string>9,7</string> - </entry> - <entry> - <string>Output Splitting</string> - <string>16</string> - </entry> - </elementAttributes> - <pos x="400" y="600"/> - </visualElement> - <visualElement> - <elementName>Ground</elementName> - <elementAttributes> - <entry> - <string>rotation</string> - <rotation rotation="1"/> - </entry> - <entry> - <string>Bits</string> - <int>7</int> - </entry> - </elementAttributes> - <pos x="380" y="620"/> - </visualElement> - <visualElement> <elementName>Testcase</elementName> <elementAttributes> <entry> @@ -299,6 +271,16 @@ C 0b0000001010011000 1 0 0 1 2 3 0</dataString> </elementAttributes> <pos x="120" y="160"/> </visualElement> + <visualElement> + <elementName>BitExtender</elementName> + <elementAttributes> + <entry> + <string>inputBits</string> + <int>9</int> + </entry> + </elementAttributes> + <pos x="360" y="600"/> + </visualElement> </visualElements> <wires> <wire> @@ -347,7 +329,7 @@ C 0b0000001010011000 1 0 0 1 2 3 0</dataString> </wire> <wire> <p1 x="320" y="600"/> - <p2 x="400" y="600"/> + <p2 x="360" y="600"/> </wire> <wire> <p1 x="460" y="680"/> @@ -362,10 +344,6 @@ C 0b0000001010011000 1 0 0 1 2 3 0</dataString> <p2 x="160" y="380"/> </wire> <wire> - <p1 x="380" y="620"/> - <p2 x="400" y="620"/> - </wire> - <wire> <p1 x="160" y="360"/> <p2 x="160" y="380"/> </wire> diff --git a/digital/atk16_mem.dig b/digital/atk16_mem.dig index 0a1b0e8..15f080d 100644 --- a/digital/atk16_mem.dig +++ b/digital/atk16_mem.dig @@ -67,10 +67,10 @@ </entry> <entry> <string>Data</string> - <data>420a,9c00,3dc0,1fc8,6004,f000,35c0,1fc8,37c0,1fc8,4602,259,8609 -,39c0,1fc8,3bc0,1fc8,4a01,4400,4601,898,14c0,1700,269,8400,5ff6 -,1fc9,27c0,1fc9,25c0,1fc9,2dc0,5180,2840,1fc9,2bc0,1fc9,29c0,1fc9 -,27c0,1fc9,25c0,1fc9,2dc0,5180</data> + <data>6001,8000,4001,2a00,400a,9e00,1fe0,3178,1b48,6001,f000,3148,1b48 +,3150,1b48,1011,860a,3158,1b48,4200,4401,650,1280,14c0,1009,8408 +,61fa,1b49,2540,1b49,2340,1b49,2f40,51c0,10c0,1b49,2740,1b49,2540 +,1b49,2340,1b49,2f40,51c0</data> </entry> </elementAttributes> <pos x="740" y="100"/> diff --git a/digital/atk16_regbank.dig b/digital/atk16_regbank.dig index d65e6fb..5af841b 100644 --- a/digital/atk16_regbank.dig +++ b/digital/atk16_regbank.dig @@ -83,104 +83,6 @@ <pos x="940" y="320"/> </visualElement> <visualElement> - <elementName>Ground</elementName> - <elementAttributes> - <entry> - <string>rotation</string> - <rotation rotation="1"/> - </entry> - <entry> - <string>Bits</string> - <int>16</int> - </entry> - </elementAttributes> - <pos x="920" y="320"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>rotation</string> - <rotation rotation="2"/> - </entry> - <entry> - <string>NetName</string> - <string>Q1</string> - </entry> - </elementAttributes> - <pos x="920" y="340"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>rotation</string> - <rotation rotation="2"/> - </entry> - <entry> - <string>NetName</string> - <string>Q2</string> - </entry> - </elementAttributes> - <pos x="920" y="360"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>rotation</string> - <rotation reference="../../../../visualElement[7]/elementAttributes/entry/rotation"/> - </entry> - <entry> - <string>NetName</string> - <string>Q3</string> - </entry> - </elementAttributes> - <pos x="920" y="380"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>rotation</string> - <rotation reference="../../../../visualElement[7]/elementAttributes/entry/rotation"/> - </entry> - <entry> - <string>NetName</string> - <string>Q4</string> - </entry> - </elementAttributes> - <pos x="920" y="400"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>rotation</string> - <rotation reference="../../../../visualElement[7]/elementAttributes/entry/rotation"/> - </entry> - <entry> - <string>NetName</string> - <string>Q5</string> - </entry> - </elementAttributes> - <pos x="920" y="420"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>rotation</string> - <rotation reference="../../../../visualElement[7]/elementAttributes/entry/rotation"/> - </entry> - <entry> - <string>NetName</string> - <string>Q6</string> - </entry> - </elementAttributes> - <pos x="920" y="440"/> - </visualElement> - <visualElement> <elementName>In</elementName> <elementAttributes> <entry> @@ -209,104 +111,6 @@ <pos x="940" y="600"/> </visualElement> <visualElement> - <elementName>Ground</elementName> - <elementAttributes> - <entry> - <string>rotation</string> - <rotation rotation="1"/> - </entry> - <entry> - <string>Bits</string> - <int>16</int> - </entry> - </elementAttributes> - <pos x="920" y="600"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>rotation</string> - <rotation reference="../../../../visualElement[6]/elementAttributes/entry/rotation"/> - </entry> - <entry> - <string>NetName</string> - <string>Q1</string> - </entry> - </elementAttributes> - <pos x="920" y="620"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>rotation</string> - <rotation reference="../../../../visualElement[7]/elementAttributes/entry/rotation"/> - </entry> - <entry> - <string>NetName</string> - <string>Q2</string> - </entry> - </elementAttributes> - <pos x="920" y="640"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>rotation</string> - <rotation reference="../../../../visualElement[7]/elementAttributes/entry/rotation"/> - </entry> - <entry> - <string>NetName</string> - <string>Q3</string> - </entry> - </elementAttributes> - <pos x="920" y="660"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>rotation</string> - <rotation reference="../../../../visualElement[7]/elementAttributes/entry/rotation"/> - </entry> - <entry> - <string>NetName</string> - <string>Q4</string> - </entry> - </elementAttributes> - <pos x="920" y="680"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>rotation</string> - <rotation reference="../../../../visualElement[7]/elementAttributes/entry/rotation"/> - </entry> - <entry> - <string>NetName</string> - <string>Q5</string> - </entry> - </elementAttributes> - <pos x="920" y="700"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>rotation</string> - <rotation reference="../../../../visualElement[7]/elementAttributes/entry/rotation"/> - </entry> - <entry> - <string>NetName</string> - <string>Q6</string> - </entry> - </elementAttributes> - <pos x="920" y="720"/> - </visualElement> - <visualElement> <elementName>In</elementName> <elementAttributes> <entry> @@ -488,7 +292,7 @@ <elementAttributes> <entry> <string>rotation</string> - <rotation reference="../../../../visualElement[27]/elementAttributes/entry/rotation"/> + <rotation reference="../../../../visualElement[13]/elementAttributes/entry/rotation"/> </entry> <entry> <string>NetName</string> @@ -502,7 +306,7 @@ <elementAttributes> <entry> <string>rotation</string> - <rotation reference="../../../../visualElement[28]/elementAttributes/entry/rotation"/> + <rotation reference="../../../../visualElement[14]/elementAttributes/entry/rotation"/> </entry> <entry> <string>NetName</string> @@ -531,7 +335,7 @@ <elementAttributes> <entry> <string>rotation</string> - <rotation reference="../../../../visualElement[31]/elementAttributes/entry/rotation"/> + <rotation reference="../../../../visualElement[17]/elementAttributes/entry/rotation"/> </entry> <entry> <string>NetName</string> @@ -577,7 +381,7 @@ <elementAttributes> <entry> <string>rotation</string> - <rotation reference="../../../../visualElement[27]/elementAttributes/entry/rotation"/> + <rotation reference="../../../../visualElement[13]/elementAttributes/entry/rotation"/> </entry> <entry> <string>NetName</string> @@ -591,7 +395,7 @@ <elementAttributes> <entry> <string>rotation</string> - <rotation reference="../../../../visualElement[28]/elementAttributes/entry/rotation"/> + <rotation reference="../../../../visualElement[14]/elementAttributes/entry/rotation"/> </entry> <entry> <string>NetName</string> @@ -638,7 +442,7 @@ <elementAttributes> <entry> <string>rotation</string> - <rotation reference="../../../../visualElement[27]/elementAttributes/entry/rotation"/> + <rotation reference="../../../../visualElement[13]/elementAttributes/entry/rotation"/> </entry> <entry> <string>NetName</string> @@ -652,7 +456,7 @@ <elementAttributes> <entry> <string>rotation</string> - <rotation reference="../../../../visualElement[28]/elementAttributes/entry/rotation"/> + <rotation reference="../../../../visualElement[14]/elementAttributes/entry/rotation"/> </entry> <entry> <string>NetName</string> @@ -681,7 +485,7 @@ <elementAttributes> <entry> <string>rotation</string> - <rotation reference="../../../../visualElement[31]/elementAttributes/entry/rotation"/> + <rotation reference="../../../../visualElement[17]/elementAttributes/entry/rotation"/> </entry> <entry> <string>NetName</string> @@ -816,7 +620,7 @@ <elementAttributes> <entry> <string>rotation</string> - <rotation reference="../../../../visualElement[53]/elementAttributes/entry/rotation"/> + <rotation reference="../../../../visualElement[39]/elementAttributes/entry/rotation"/> </entry> <entry> <string>NetName</string> @@ -830,7 +634,7 @@ <elementAttributes> <entry> <string>rotation</string> - <rotation reference="../../../../visualElement[54]/elementAttributes/entry/rotation"/> + <rotation reference="../../../../visualElement[40]/elementAttributes/entry/rotation"/> </entry> <entry> <string>NetName</string> @@ -859,7 +663,7 @@ <elementAttributes> <entry> <string>rotation</string> - <rotation reference="../../../../visualElement[57]/elementAttributes/entry/rotation"/> + <rotation reference="../../../../visualElement[43]/elementAttributes/entry/rotation"/> </entry> <entry> <string>NetName</string> @@ -949,84 +753,111 @@ <pos x="0" y="740"/> </visualElement> <visualElement> - <elementName>Tunnel</elementName> + <elementName>Testcase</elementName> <elementAttributes> <entry> - <string>NetName</string> - <string>RW_A</string> + <string>Testdata</string> + <testData> + <dataString>CLK Din RW_IE RW_S R1_S R2_S D1 D2 +# store and read from RA works +C 0xF 1 1 0 X X X +C 0 0 0 1 X 0xF X +C 0x5 1 1 1 X 0x5 X +C 0 0 0 1 X 0x5 X +</dataString> + </testData> </entry> </elementAttributes> - <pos x="120" y="620"/> + <pos x="900" y="920"/> </visualElement> <visualElement> - <elementName>Tunnel</elementName> + <elementName>Register</elementName> <elementAttributes> <entry> - <string>NetName</string> - <string>RW_B</string> + <string>valueIsProbe</string> + <boolean>true</boolean> + </entry> + <entry> + <string>Label</string> + <string>RG</string> + </entry> + <entry> + <string>Bits</string> + <int>16</int> </entry> </elementAttributes> - <pos x="120" y="640"/> + <pos x="560" y="1080"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> <elementAttributes> <entry> + <string>rotation</string> + <rotation reference="../../../../visualElement[39]/elementAttributes/entry/rotation"/> + </entry> + <entry> <string>NetName</string> - <string>RW_C</string> + <string>Din</string> </entry> </elementAttributes> - <pos x="120" y="660"/> + <pos x="560" y="1080"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> <elementAttributes> <entry> + <string>rotation</string> + <rotation reference="../../../../visualElement[40]/elementAttributes/entry/rotation"/> + </entry> + <entry> <string>NetName</string> - <string>RW_D</string> + <string>CLK</string> </entry> </elementAttributes> - <pos x="120" y="680"/> + <pos x="560" y="1100"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> <elementAttributes> <entry> <string>NetName</string> - <string>RW_E</string> + <string>Q7</string> </entry> </elementAttributes> - <pos x="120" y="700"/> + <pos x="640" y="1100"/> + </visualElement> + <visualElement> + <elementName>And</elementName> + <elementAttributes/> + <pos x="460" y="1120"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> <elementAttributes> <entry> + <string>rotation</string> + <rotation reference="../../../../visualElement[43]/elementAttributes/entry/rotation"/> + </entry> + <entry> <string>NetName</string> - <string>RW_F</string> + <string>RW_IE</string> </entry> </elementAttributes> - <pos x="120" y="720"/> + <pos x="460" y="1120"/> </visualElement> <visualElement> - <elementName>Testcase</elementName> + <elementName>Tunnel</elementName> <elementAttributes> <entry> - <string>Testdata</string> - <testData> - <dataString>CLK Din RW_IE RW_S R1_S R2_S D1 D2 -# store and read from RA works -C 0xF 1 1 0 X X X -C 0 0 0 1 X 0xF X -C 0x5 1 1 1 X 0x5 X -C 0 0 0 1 X 0x5 X - -# zero register read and write -C 0xA 1 0 0 X 0 X</dataString> - </testData> + <string>rotation</string> + <rotation rotation="2"/> + </entry> + <entry> + <string>NetName</string> + <string>RW_G</string> </entry> </elementAttributes> - <pos x="900" y="920"/> + <pos x="460" y="1160"/> </visualElement> <visualElement> <elementName>Register</elementName> @@ -1037,71 +868,71 @@ C 0xA 1 0 0 X 0 X</dataString> </entry> <entry> <string>Label</string> - <string>RG</string> + <string>RH</string> </entry> <entry> <string>Bits</string> <int>16</int> </entry> </elementAttributes> - <pos x="560" y="1080"/> + <pos x="560" y="1260"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> <elementAttributes> <entry> <string>rotation</string> - <rotation reference="../../../../visualElement[53]/elementAttributes/entry/rotation"/> + <rotation reference="../../../../visualElement[39]/elementAttributes/entry/rotation"/> </entry> <entry> <string>NetName</string> <string>Din</string> </entry> </elementAttributes> - <pos x="560" y="1080"/> + <pos x="560" y="1260"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> <elementAttributes> <entry> <string>rotation</string> - <rotation reference="../../../../visualElement[54]/elementAttributes/entry/rotation"/> + <rotation reference="../../../../visualElement[40]/elementAttributes/entry/rotation"/> </entry> <entry> <string>NetName</string> <string>CLK</string> </entry> </elementAttributes> - <pos x="560" y="1100"/> + <pos x="560" y="1280"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> <elementAttributes> <entry> <string>NetName</string> - <string>Q7</string> + <string>Q8</string> </entry> </elementAttributes> - <pos x="640" y="1100"/> + <pos x="640" y="1280"/> </visualElement> <visualElement> <elementName>And</elementName> <elementAttributes/> - <pos x="460" y="1120"/> + <pos x="460" y="1300"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> <elementAttributes> <entry> <string>rotation</string> - <rotation reference="../../../../visualElement[57]/elementAttributes/entry/rotation"/> + <rotation reference="../../../../visualElement[43]/elementAttributes/entry/rotation"/> </entry> <entry> <string>NetName</string> <string>RW_IE</string> </entry> </elementAttributes> - <pos x="460" y="1120"/> + <pos x="460" y="1300"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> @@ -1112,10 +943,174 @@ C 0xA 1 0 0 X 0 X</dataString> </entry> <entry> <string>NetName</string> + <string>RW_H</string> + </entry> + </elementAttributes> + <pos x="460" y="1340"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>NetName</string> + <string>RW_A</string> + </entry> + </elementAttributes> + <pos x="120" y="600"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>NetName</string> + <string>RW_B</string> + </entry> + </elementAttributes> + <pos x="120" y="620"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>NetName</string> + <string>RW_C</string> + </entry> + </elementAttributes> + <pos x="120" y="640"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>NetName</string> + <string>RW_D</string> + </entry> + </elementAttributes> + <pos x="120" y="660"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>NetName</string> + <string>RW_E</string> + </entry> + </elementAttributes> + <pos x="120" y="680"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>NetName</string> + <string>RW_F</string> + </entry> + </elementAttributes> + <pos x="120" y="700"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>NetName</string> <string>RW_G</string> </entry> </elementAttributes> - <pos x="460" y="1160"/> + <pos x="120" y="720"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>NetName</string> + <string>RW_H</string> + </entry> + </elementAttributes> + <pos x="120" y="740"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>rotation</string> + <rotation rotation="2"/> + </entry> + <entry> + <string>NetName</string> + <string>Q1</string> + </entry> + </elementAttributes> + <pos x="920" y="320"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>rotation</string> + <rotation rotation="2"/> + </entry> + <entry> + <string>NetName</string> + <string>Q2</string> + </entry> + </elementAttributes> + <pos x="920" y="340"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>rotation</string> + <rotation reference="../../../../visualElement[81]/elementAttributes/entry/rotation"/> + </entry> + <entry> + <string>NetName</string> + <string>Q3</string> + </entry> + </elementAttributes> + <pos x="920" y="360"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>rotation</string> + <rotation reference="../../../../visualElement[81]/elementAttributes/entry/rotation"/> + </entry> + <entry> + <string>NetName</string> + <string>Q4</string> + </entry> + </elementAttributes> + <pos x="920" y="380"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>rotation</string> + <rotation reference="../../../../visualElement[81]/elementAttributes/entry/rotation"/> + </entry> + <entry> + <string>NetName</string> + <string>Q5</string> + </entry> + </elementAttributes> + <pos x="920" y="400"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>rotation</string> + <rotation reference="../../../../visualElement[81]/elementAttributes/entry/rotation"/> + </entry> + <entry> + <string>NetName</string> + <string>Q6</string> + </entry> + </elementAttributes> + <pos x="920" y="420"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> @@ -1129,7 +1124,7 @@ C 0xA 1 0 0 X 0 X</dataString> <string>Q7</string> </entry> </elementAttributes> - <pos x="920" y="460"/> + <pos x="920" y="440"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> @@ -1140,44 +1135,150 @@ C 0xA 1 0 0 X 0 X</dataString> </entry> <entry> <string>NetName</string> + <string>Q8</string> + </entry> + </elementAttributes> + <pos x="920" y="460"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>rotation</string> + <rotation reference="../../../../visualElement[80]/elementAttributes/entry/rotation"/> + </entry> + <entry> + <string>NetName</string> + <string>Q1</string> + </entry> + </elementAttributes> + <pos x="920" y="600"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>rotation</string> + <rotation reference="../../../../visualElement[81]/elementAttributes/entry/rotation"/> + </entry> + <entry> + <string>NetName</string> + <string>Q2</string> + </entry> + </elementAttributes> + <pos x="920" y="620"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>rotation</string> + <rotation reference="../../../../visualElement[81]/elementAttributes/entry/rotation"/> + </entry> + <entry> + <string>NetName</string> + <string>Q3</string> + </entry> + </elementAttributes> + <pos x="920" y="640"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>rotation</string> + <rotation reference="../../../../visualElement[81]/elementAttributes/entry/rotation"/> + </entry> + <entry> + <string>NetName</string> + <string>Q4</string> + </entry> + </elementAttributes> + <pos x="920" y="660"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>rotation</string> + <rotation reference="../../../../visualElement[81]/elementAttributes/entry/rotation"/> + </entry> + <entry> + <string>NetName</string> + <string>Q5</string> + </entry> + </elementAttributes> + <pos x="920" y="680"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>rotation</string> + <rotation reference="../../../../visualElement[81]/elementAttributes/entry/rotation"/> + </entry> + <entry> + <string>NetName</string> + <string>Q6</string> + </entry> + </elementAttributes> + <pos x="920" y="700"/> + </visualElement> + <visualElement> + <elementName>Tunnel</elementName> + <elementAttributes> + <entry> + <string>rotation</string> + <rotation reference="../../../../visualElement[86]/elementAttributes/entry/rotation"/> + </entry> + <entry> + <string>NetName</string> <string>Q7</string> </entry> </elementAttributes> - <pos x="920" y="740"/> + <pos x="920" y="720"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> <elementAttributes> <entry> + <string>rotation</string> + <rotation reference="../../../../visualElement[87]/elementAttributes/entry/rotation"/> + </entry> + <entry> <string>NetName</string> - <string>RW_G</string> + <string>Q8</string> </entry> </elementAttributes> - <pos x="120" y="740"/> + <pos x="920" y="740"/> </visualElement> </visualElements> <wires> <wire> - <p1 x="920" y="320"/> - <p2 x="940" y="320"/> - </wire> - <wire> <p1 x="520" y="320"/> <p2 x="540" y="320"/> </wire> <wire> - <p1 x="920" y="640"/> - <p2 x="940" y="640"/> + <p1 x="920" y="320"/> + <p2 x="940" y="320"/> </wire> <wire> <p1 x="520" y="640"/> <p2 x="540" y="640"/> </wire> <wire> + <p1 x="920" y="640"/> + <p2 x="940" y="640"/> + </wire> + <wire> <p1 x="520" y="960"/> <p2 x="540" y="960"/> </wire> <wire> + <p1 x="620" y="1280"/> + <p2 x="640" y="1280"/> + </wire> + <wire> <p1 x="940" y="520"/> <p2 x="960" y="520"/> </wire> @@ -1222,6 +1323,10 @@ C 0xA 1 0 0 X 0 X</dataString> <p2 x="940" y="720"/> </wire> <wire> + <p1 x="540" y="1300"/> + <p2 x="560" y="1300"/> + </wire> + <wire> <p1 x="920" y="340"/> <p2 x="940" y="340"/> </wire> @@ -1230,14 +1335,14 @@ C 0xA 1 0 0 X 0 X</dataString> <p2 x="940" y="660"/> </wire> <wire> - <p1 x="920" y="600"/> - <p2 x="940" y="600"/> - </wire> - <wire> <p1 x="620" y="600"/> <p2 x="640" y="600"/> </wire> <wire> + <p1 x="920" y="600"/> + <p2 x="940" y="600"/> + </wire> + <wire> <p1 x="620" y="280"/> <p2 x="640" y="280"/> </wire> @@ -1266,38 +1371,42 @@ C 0xA 1 0 0 X 0 X</dataString> <p2 x="560" y="1120"/> </wire> <wire> - <p1 x="920" y="420"/> - <p2 x="940" y="420"/> - </wire> - <wire> <p1 x="60" y="420"/> <p2 x="80" y="420"/> </wire> <wire> + <p1 x="920" y="420"/> + <p2 x="940" y="420"/> + </wire> + <wire> <p1 x="920" y="740"/> <p2 x="940" y="740"/> </wire> <wire> - <p1 x="920" y="360"/> - <p2 x="940" y="360"/> + <p1 x="980" y="680"/> + <p2 x="1080" y="680"/> </wire> <wire> <p1 x="920" y="680"/> <p2 x="940" y="680"/> </wire> <wire> - <p1 x="980" y="680"/> - <p2 x="1080" y="680"/> + <p1 x="520" y="1320"/> + <p2 x="540" y="1320"/> </wire> <wire> - <p1 x="920" y="620"/> - <p2 x="940" y="620"/> + <p1 x="920" y="360"/> + <p2 x="940" y="360"/> </wire> <wire> <p1 x="540" y="620"/> <p2 x="560" y="620"/> </wire> <wire> + <p1 x="920" y="620"/> + <p2 x="940" y="620"/> + </wire> + <wire> <p1 x="540" y="300"/> <p2 x="560" y="300"/> </wire> @@ -1318,14 +1427,14 @@ C 0xA 1 0 0 X 0 X</dataString> <p2 x="540" y="1140"/> </wire> <wire> - <p1 x="920" y="440"/> - <p2 x="940" y="440"/> - </wire> - <wire> <p1 x="620" y="440"/> <p2 x="640" y="440"/> </wire> <wire> + <p1 x="920" y="440"/> + <p2 x="940" y="440"/> + </wire> + <wire> <p1 x="620" y="760"/> <p2 x="640" y="760"/> </wire> @@ -1381,6 +1490,10 @@ C 0xA 1 0 0 X 0 X</dataString> <p1 x="540" y="1120"/> <p2 x="540" y="1140"/> </wire> + <wire> + <p1 x="540" y="1300"/> + <p2 x="540" y="1320"/> + </wire> </wires> <measurementOrdering/> </circuit>
\ No newline at end of file diff --git a/src/asm_pass2.py b/src/asm_pass2.py index 77b8fa6..261ba06 100644 --- a/src/asm_pass2.py +++ b/src/asm_pass2.py @@ -7,6 +7,7 @@ from asm_pass1 import * class Result2Line: line_num: int parts: list[str] + original_parts: list[str] @dataclass class Result2: @@ -20,16 +21,17 @@ def pass_2(result1: Result1) -> Result2: for line in result1.lines: keyword, *args = line.parts - if not keyword.startswith("@"): + if keyword in result1.operations: fn = result1.operations[keyword] output: list[list[str]] = fn(*args) else: output = [line.parts] - for parts in output: + for (idx, parts) in enumerate(output): result_lines.append(Result2Line( line_num=line.line_num, - parts=parts + parts=parts, + original_parts=line.parts if idx == 0 else ["..."] )) return Result2( diff --git a/src/asm_pass3.py b/src/asm_pass3.py index 5365e3b..e8e44d3 100644 --- a/src/asm_pass3.py +++ b/src/asm_pass3.py @@ -8,6 +8,7 @@ class Result3Line: line_num: int address: int parts: list[str] + original_parts: list[str] @dataclass class Result3: @@ -35,6 +36,7 @@ def pass_3(result2: Result2) -> Result3: line_num=line.line_num, parts=line.parts, address=address, + original_parts=line.original_parts, )) address += 1 diff --git a/src/asm_pass4.py b/src/asm_pass4.py index 96d9e65..926b354 100644 --- a/src/asm_pass4.py +++ b/src/asm_pass4.py @@ -9,6 +9,7 @@ class Result4Line: address: int word: int text: str + original_text: str @dataclass class Result4: @@ -35,6 +36,7 @@ def pass_4(result3: Result3) -> Result4: args = list(map(lambda a: translate_opt(a, result3.options), args)) text = " ".join([keyword, *args]) + original_text = " ".join(line.original_parts) if keyword in operations: fn = operations[keyword] @@ -44,6 +46,7 @@ def pass_4(result3: Result3) -> Result4: address=line.address, word=word, text=text, + original_text=original_text, )) else: try: @@ -52,10 +55,13 @@ def pass_4(result3: Result3) -> Result4: address=line.address, word=eval_expr(result3.labels, keyword), text=text, + original_text=original_text, )) except: raise Exception(f"Invalid assembly at {line.line_num + 1}\n\n{line}") + address += 1 + return Result4( operations=result3.operations, labels=result3.labels, diff --git a/src/assembler.py b/src/assembler.py index fc7bc45..4e82deb 100755 --- a/src/assembler.py +++ b/src/assembler.py @@ -67,7 +67,10 @@ for line in result4.lines: if len(result) < 2 * line.address + 1: result.extend((2 * line.address + 1 - len(result)) * nop) - print(f"{line.address:>08x} 0x{line.word:>04x} {line.text}") + out_line = f"{line.address:>08x} 0x{line.word:>04x} {line.text}" + out_spaces_n = (42 - len(out_line)) + out_spaces = out_spaces_n * " " if out_spaces_n > 0 else 4 * " " + print(f"{out_line}{out_spaces}{line.original_text}") result[2 * line.address + 0] = ((line.word >> 8) & 0xff) result[2 * line.address + 1] = ((line.word >> 0) & 0xff) diff --git a/src/assembler_eval.py b/src/assembler_eval.py index 7cfe336..691e4eb 100644 --- a/src/assembler_eval.py +++ b/src/assembler_eval.py @@ -1,13 +1,13 @@ constants: dict[str, str] = { # Registers - "rz": "0", - "ra": "1", - "rb": "2", - "rc": "3", - "rd": "4", - "re": "5", - "rf": "6", - "rg": "7", + "ra": "0", + "rb": "1", + "rc": "2", + "rd": "3", + "re": "4", + "rf": "5", + "rg": "6", + "rh": "7", # ALU instructions "al_plus": "0", "al_minus": "1", @@ -18,10 +18,10 @@ constants: dict[str, str] = { "al_sar": "6", "al_sll": "7", # ALU flags - "f_carry": "0", - "f_overflow": "1", - "f_zero": "2", - "f_sign": "3", + "carry": "0", + "overflow": "1", + "zero": "2", + "sign": "3", } Labels = dict[str, int] diff --git a/src/assembler_ops.py b/src/assembler_ops.py index e4eeac4..b55927b 100644 --- a/src/assembler_ops.py +++ b/src/assembler_ops.py @@ -4,8 +4,8 @@ from dataclasses import dataclass @dataclass class Options: - stack_pointer = "rg" - csr_scratch = "rf" + stack_pointer = "rf" + csr_scratch = "rh" @dataclass class Meta: @@ -37,7 +37,7 @@ def make_ali(meta: Meta, labels: Labels, alu_op: str, left: str, imm: str, targe alu_op_e return word -def make_ldr(meta: Meta, labels: Labels, to_reg: str, addr_reg: str) -> int: +def make_ldr(meta: Meta, labels: Labels, addr_reg: str, to_reg: str) -> int: """LDR 0010 TTTR RRXX XXXX""" to_reg_e = eval_expr(labels, to_reg, bits=3) addr_reg_e = eval_expr(labels, addr_reg, bits=3) @@ -47,15 +47,15 @@ def make_ldr(meta: Meta, labels: Labels, to_reg: str, addr_reg: str) -> int: return word def make_str(meta: Meta, labels: Labels, from_reg: str, addr_reg: str) -> int: - """STR 0011 TTTR RRXX XXXX""" + """STR 0011 XXXL LLRR RXXX""" from_reg_e = eval_expr(labels, from_reg, bits=3) addr_reg_e = eval_expr(labels, addr_reg, bits=3) word = (0b0011 << 12) + \ - (from_reg_e << 9) + \ - (addr_reg_e << 6) + (addr_reg_e << 6) + \ + (from_reg_e << 3) return word -def make_ldi(meta: Meta, labels: Labels, to_reg: str, imm: str) -> int: +def make_ldi(meta: Meta, labels: Labels, imm: str, to_reg: str) -> int: """LDI 0100 TTTI IIII IIII""" to_reg_e = eval_expr(labels, to_reg, bits=3) imm_e = eval_expr(labels, imm, bits=9) @@ -75,6 +75,7 @@ def make_jpi(meta: Meta, labels: Labels, imm: str) -> int: """JPI 0110 XXXI IIII IIII""" imm_e = eval_expr(labels, imm, bits=9) imm_e = imm_e - meta.address - 1 + imm_e = imm_e & (0b111111111) word = (0b0110 << 12) + \ imm_e return word @@ -93,6 +94,7 @@ def make_bri(meta: Meta, labels: Labels, flag_s: str, imm: str) -> int: flag_s_e = eval_expr(labels, flag_s, bits=2) imm_e = eval_expr(labels, imm, bits=9) imm_e = imm_e - meta.address - 1 + imm_e = imm_e & (0b111111111) word = (0b1000 << 12) + \ (flag_s_e << 9) + \ imm_e diff --git a/src/ext_std.py b/src/ext_std.py index a6b175a..5f41f60 100644 --- a/src/ext_std.py +++ b/src/ext_std.py @@ -52,16 +52,25 @@ def expand_spu(reg: str) -> ExpandResult: return [["str", reg, "__STACK_POINTER"]] + expand_inc("__STACK_POINTER") def expand_spo(reg: str): - return expand_dec("__STACK_POINTER") + [["ldr", reg, "__STACK_POINTER"]] + return expand_dec("__STACK_POINTER") + [["ldr", "__STACK_POINTER", reg]] def expand_csr(addr_reg: str): - return [["lpc", "__STACK_POINTER"]] + expand_spu("__STACK_POINTER") + [["jpr", addr_reg]] + return [ + ["lpc", "__CSR_SCRATCH"], + *expand_addi("__CSR_SCRATCH", "4", "__CSR_SCRATCH"), + *expand_spu("__CSR_SCRATCH"), + ["jpr", addr_reg] + ] def expand_csi(addr_imm: str): - return [["lpc", "__STACK_POINTER"]] + expand_spu("__STACK_POINTER") + [["jpr", addr_imm]] - + return [ + ["lpc", "__CSR_SCRATCH"], + *expand_addi("__CSR_SCRATCH", "4", "__CSR_SCRATCH"), + *expand_spu("__CSR_SCRATCH"), + ["jpi", addr_imm] + ] def expand_rsr(): - return expand_spo("__STACK_POINTER") + [["jpr", "__CSR_SCRATCH"]] + return expand_spo("__CSR_SCRATCH") + [["jpr", "__CSR_SCRATCH"]] expansions: OpExpansionDict = { "add": expand_add, diff --git a/src/test.atk16 b/src/test.atk16 index 8e48892..3f2d378 100644 --- a/src/test.atk16 +++ b/src/test.atk16 @@ -22,7 +22,7 @@ mov RC RA ; RA := result of sum ldi RB 30 ; RB := 30 sub RA RB RC ; RC := RA - RB - bri f_zero @success ; if result is zero, jump to success + bri zero @success ; if result is zero, jump to success ldi RA 2 ; RA := 2 to signal failure hlt diff --git a/src/test_fibo.atk16 b/src/test_fibo.atk16 index a03f14b..8bb7a6e 100644 --- a/src/test_fibo.atk16 +++ b/src/test_fibo.atk16 @@ -1,46 +1,66 @@ -@opt stack_pointer RG -@opt csr_scratch RF - +@opt stack_pointer RF +@opt csr_scratch RH @use ext_std:* +; jump over data segment + jpi program + +; data segment +@label ram_offset + 0x8000 + @label program - ; call fibo subroutine with parameter 10 - ldi RA 10 +; set up stack pointer to point to beginning of RAM + ldi ram_offset RA + ldr RA RF + +; call fibo subroutine with parameter 10 + ldi 10 RA csi fibo hlt @label fibo - ; function fibo - ; parameters: - ; RA n : u16 - ; return value: - ; RA fibo(n) : u16 +; function fibo +; parameters: +; RA n : u16 +; return value: +; RA fibo(n) : u16 - spu RB ; prelude +; store RB, RC on stack + spu RB spu RC - - subi RA 2 RA ; if n < 2, return n - bri f_sign fibo_early - - spu RD ; prelude - - ldi RB 0 ; a = 0 - ldi RC 1 ; b = 1 +; if n < 2, return n + subi RA 2 RA + bri sign fibo_early +; store also RD on stack + spu RD +; a = 0 + ldi 0 RB +; b = 1 + ldi 1 RC @label fibo_loop - add RB RC RD ; v = a + b - mov RC RB ; a = b - mov RD RC ; b = v - dec RA ; n -= 1 - bri f_zero fibo_done ; loop while n > 0 +; v = a + b + add RB RC RD +; a = b + mov RC RB +; b = v + mov RD RC +; n -= 1 + dec RA +; loop while n > 0 + bri zero fibo_done jpi fibo_loop - @label fibo_early +; restore used registers spo RC spo RB +; return from subroutine rsr @label fibo_done mov RD RA - spo RD ; restore registers +; restore used registers + spo RD spo RC spo RB +; return from subroutine rsr diff --git a/src/ucode.py b/src/ucode.py index 9745a7e..1d050c8 100755 --- a/src/ucode.py +++ b/src/ucode.py @@ -20,9 +20,9 @@ MEM_IE = 0b0000_0000_0001_0000 MEM_OE = 0b0000_0000_0010_0000 RW_IE = 0b0000_0000_0100_0000 R1_OE = 0b0000_0000_1000_0000 -IM_M = 0b0000_0001_0000_0000 +R2_OE = 0b0000_0001_0000_0000 IR_IE = 0b0000_0010_0000_0000 -unused = 0b0000_0100_0000_0000 +IM_M = 0b0000_0100_0000_0000 LI_OE = 0b0000_1000_0000_0000 ALU_OE = 0b0001_0000_0000_0000 FR_IE = 0b0010_0000_0000_0000 @@ -51,8 +51,8 @@ ucode = [ not_branch([*fetch, IM_M|ALU_OE|FR_IE|RW_IE, US_RS, 0, 0, 0, 0]), # LDR 0010 TTTR RRXX XXXX not_branch([*fetch, R1_OE|MAR_IE, MEM_OE|RW_IE, US_RS, 0, 0, 0]), - # STR 0011 TTTR RRXX XXXX - not_branch([*fetch, R1_OE|MAR_IE, R1_OE|MEM_IE, US_RS, 0, 0, 0]), + # STR 0011 XXXL LLRR RXXX + not_branch([*fetch, R1_OE|MAR_IE, R2_OE|MEM_IE, US_RS, 0, 0, 0]), # LDI 0100 TTTI IIII IIII not_branch([*fetch, LI_OE|RW_IE, US_RS, 0, 0, 0, 0]), # JPR 0101 XXXR RRXX XXXX |
