Eric Nelson
Lifetime Supporting Member + Moderator
Hi guys,
Sorry I haven't had much time to contribute to the forum lately. I still drop in on occasion... :site:
Let's say I have a 32-bit shift register. I want an operator to be able to enter a value from 0 to 31 to select which bit to examine. When the corresponding bit in the shift register is ON, an output will turn on.
Looks like I want to use the 'decode' instruction (DECO), which will take a value from 0-31 and turn on the corresponding bit in the result. Then, take that result and AND it with the shift register. If the matching bit in the shift register is also ON, then the result will have a '1' in that location. Otherwise, the result will contain all zeros. Therefore, if the result is 'greater than' zero, the shift register bit being examined must be ON, so I can turn on my output.
Quicky ladder...
For example:
V2000 = 19 Value entered by operator
V2001/V2002 = 0000000000001000 0000000000000000 Decoded value (19th bit is ON)
V2003/V2004 = 0000100010110100 0100010100110010 Current shift register value (19th bit is OFF)
V2005/V2006 = 0000000000000000 0000000000000000 Result of AND. Since result is NOT greater than zero, output is OFF
Shift register advances
V2001/V2002 = 0000000000001000 0000000000000000 Decoded value (19th bit is ON)
V2003/V2004 = 0001000101101000 1000101001100100 Current shift register value (19th bit is now ON)
V2005/V2006 = 0000000000001000 0000000000000000 Result of AND. Since result is greater than zero, output is ON
Am I approaching this correctly? I know that I don't have to store the intermediate results of the accumulator. I just left them in for clarity. I will have a few dozen of these, all looking at the same shift register. Just wondering if there might be a more elegant solution?
I'm using a D2-250-1 CPU
![Clinking beer mugs :beers: 🍻](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f37b.png)
-Eric
Sorry I haven't had much time to contribute to the forum lately. I still drop in on occasion... :site:
Let's say I have a 32-bit shift register. I want an operator to be able to enter a value from 0 to 31 to select which bit to examine. When the corresponding bit in the shift register is ON, an output will turn on.
Looks like I want to use the 'decode' instruction (DECO), which will take a value from 0-31 and turn on the corresponding bit in the result. Then, take that result and AND it with the shift register. If the matching bit in the shift register is also ON, then the result will have a '1' in that location. Otherwise, the result will contain all zeros. Therefore, if the result is 'greater than' zero, the shift register bit being examined must be ON, so I can turn on my output.
Quicky ladder...
| ALW_ON +------------+
|------] [------------+----| LD V2000 | V2000 Contains a value of 0-31
| | +------------+
| | +------------+
| +----| DECO | Turn on the corresponding bit
| | +------------+
| | +------------+
| +----| OUTD V2001 | V2001 and V2002 contain the decoded value
| | +------------+
| | +------------+
| +----| LDD V2001 |
| | +------------+
| | +------------+
| +----| ANDD V2003 | V2003 and V2004 contain the shift register bits
| | +------------+
| | +------------+
| +----| OUTD V2005 | V2005 and V2006 contain the result of the AND
| | +------------+
| | +------------+
| +----| LDD V2005 |
| | +------------+
| | +------------+
| +----| CMPD K0 | Compare the result to zero
| +------------+
| RESULT > 0
|------] [--------------------------(OUT) If the result of the comparison is greater than zero, turn on the output
For example:
V2000 = 19 Value entered by operator
V2001/V2002 = 0000000000001000 0000000000000000 Decoded value (19th bit is ON)
V2003/V2004 = 0000100010110100 0100010100110010 Current shift register value (19th bit is OFF)
V2005/V2006 = 0000000000000000 0000000000000000 Result of AND. Since result is NOT greater than zero, output is OFF
Shift register advances
V2001/V2002 = 0000000000001000 0000000000000000 Decoded value (19th bit is ON)
V2003/V2004 = 0001000101101000 1000101001100100 Current shift register value (19th bit is now ON)
V2005/V2006 = 0000000000001000 0000000000000000 Result of AND. Since result is greater than zero, output is ON
Am I approaching this correctly? I know that I don't have to store the intermediate results of the accumulator. I just left them in for clarity. I will have a few dozen of these, all looking at the same shift register. Just wondering if there might be a more elegant solution?
I'm using a D2-250-1 CPU
![Clinking beer mugs :beers: 🍻](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f37b.png)
-Eric