Running short of memory

koyli

Member
Hello.

Some of you may remember my earlier posts as regards a signalling interlocking project and requiring extra inputs.
You will be glad to know I have now got onto a more level part of the learning curve and have started to write the code. The problem now is I have used 3823 bytes of memory and have only done threequarters of the code.

I am enclosing the code for one signal lever to see if it can be made more efficient. As it is, the code works and does everything it should. All the inputs should really be and`ed together, but a bit/set cannot be used after an and.
Every statement must be true for the lever to be released, but any one false statement must lock the lever.

I am using a 40X2 with six 23017 expanders. All the pins on the 40X2 are in use as ouputs to the lever frame and five expanders are used as inputs and one as outputs.

If the code cannot be made much more efficient, then can I add an extra Picaxe to share the load for the final signal levers?

I have had to cut the code by several lines as it was too long to post.

Code:
[color=Green];*********************************************************************************************88*************
;                                            Signal 19 locking
;************************************************************************************************************[/color]

[color=Blue]if [/color][color=Purple]b10 [/color][color=DarkCyan]bit [/color][color=Navy]4 [/color][color=DarkCyan]clear [/color][color=Blue]then                                                             [/color][color=Green]; points 29 reversed
      [/color][color=Blue]if [/color][color=Purple]b10 [/color][color=DarkCyan]bit [/color][color=Navy]3 [/color][color=DarkCyan]clear [/color][color=Blue]then                                                       [/color][color=Green]; points 28 reversed
            [/color][color=Blue]low C.6                                                                 [/color][color=Green]; signal 19 free
            [/color][color=Blue]if [/color][color=Purple]b10 [/color][color=DarkCyan]bit [/color][color=Navy]7 [/color][color=DarkCyan]clear [/color][color=Blue]then                                                 [/color][color=Green]; points 32 reversed
                  [/color][color=Blue]low C.6
                  if [/color][color=Purple]b6 [/color][color=DarkCyan]bit [/color][color=Navy]5 [/color][color=DarkCyan]clear [/color][color=Blue]then                                            [/color][color=Green]; points 34 normal
                        [/color][color=Blue]low C.6
                        if [/color][color=Purple]b11 [/color][color=DarkCyan]bit [/color][color=Navy]4 [/color][color=DarkCyan]set [/color][color=Blue]then                                       [/color][color=Green]; TC J2 clear
                              [/color][color=Blue]low C.6
                              if [/color][color=Purple]b4 [/color][color=DarkCyan]bit [/color][color=Navy]0 [/color][color=DarkCyan]set [/color][color=Blue]then                                  [/color][color=Green]; TC C6 clear
                                    [/color][color=Blue]low C.6
                                    if [/color][color=Purple]b5 [/color][color=DarkCyan]bit [/color][color=Navy]0 [/color][color=DarkCyan]set [/color][color=Blue]then                            [/color][color=Green]; TC B4 clear
                                          [/color][color=Blue]low C.6
                                          if [/color][color=Purple]b5 [/color][color=DarkCyan]bit [/color][color=Navy]1 [/color][color=DarkCyan]set [/color][color=Blue]then                      [/color][color=Green]; TC B3 clear
                                                [/color][color=Blue]low C.6
                                                if [/color][color=Purple]b5 [/color][color=DarkCyan]bit [/color][color=Navy]2 [/color][color=DarkCyan]set [/color][color=Blue]then                [/color][color=Green]; TC B" clear
                                                      [/color][color=Blue]low C.6
                                                      if [/color][color=Purple]b3 [/color][color=DarkCyan]bit [/color][color=Navy]2 [/color][color=DarkCyan]set [/color][color=Blue]then          [/color][color=Green]; signal 38 on
                                                            [/color][color=Blue]low C.6
                                                            if [/color][color=Purple]b2 [/color][color=DarkCyan]bit [/color][color=Navy]1 [/color][color=DarkCyan]set [/color][color=Blue]then    [/color][color=Green]; signal 46 on
                                                                  [/color][color=Blue]low C.6           [/color][color=Green]; signal 19 free
                                                            [/color][color=Blue]else high C.6           [/color][color=Green]; signal 19 locked 
                                                            [/color][color=Blue]endif                                                       
                                                      else high C.6
                                                      endif                                                 
                                                else high C.6
                                                endif                                           
                                          else high C.6
                                          endif                                     
                                    else high C.6
                                    endif                               
                              else high C.6
                              endif                         
                        else high C.6
                        endif                   
                  else high C.6
                  endif             
            else high C.6
            endif       
      else high C.6                                                                 [/color][color=Green]; signal 19 locked[/color]
[color=Blue]endif
endif



HI2COUT [PLAIN][[/PLAIN]mcp23017f[PLAIN]][/PLAIN][/color][color=Black], [/color][color=Blue]OLATA[/color][color=Black], [/color][color=Blue]([/color][color=Purple]b10[/color][color=Blue])
HI2COUT [PLAIN][[/PLAIN]mcp23017e[PLAIN]][/PLAIN][/color][color=Black], [/color][color=Blue]OLATB[/color][color=Black], [/color][color=Blue]([/color][color=Purple]b9[/color][color=Blue])[/color]
 

koyli

Member
Here is the rest of the code.

Code:
[color=Blue]if [/color][color=Purple]b7 [/color][color=DarkCyan]bit [/color][color=Navy]7 [/color][color=DarkCyan]clear [/color][color=Blue]then                                                              [/color][color=Green]; points 29 normal                                                    
      [/color][color=Blue]if [/color][color=Purple]b6 [/color][color=DarkCyan]bit [/color][color=Navy]1 [/color][color=DarkCyan]clear [/color][color=Blue]then                                                        [/color][color=Green]; points 30 normal
            [/color][color=Blue]low C.6                                                                 [/color][color=Green]; sigmal 19 free
            [/color][color=Blue]if [/color][color=Purple]b6 [/color][color=DarkCyan]bit [/color][color=Navy]2 [/color][color=DarkCyan]clear [/color][color=Blue]then                                                  [/color][color=Green]; points 31 normal
                  [/color][color=Blue]low C.6
                  if [/color][color=Purple]b5 [/color][color=DarkCyan]bit [/color][color=Navy]7 [/color][color=DarkCyan]set [/color][color=Blue]then                                              [/color][color=Green]; TC C5 clear
                        [/color][color=Blue]low C.6
                        if [/color][color=Purple]b5 [/color][color=DarkCyan]bit [/color][color=Navy]6 [/color][color=DarkCyan]clear [/color][color=Blue]then                                      [/color][color=Green]; TC C4 clear
                              [/color][color=Blue]low C.6
                              if [/color][color=Purple]b5 [/color][color=DarkCyan]bit [/color][color=Navy]5 [/color][color=DarkCyan]set [/color][color=Blue]then                                  [/color][color=Green]; TC C3 clear
                                    [/color][color=Blue]low C.6
                                    if [/color][color=Purple]b3 [/color][color=DarkCyan]bit [/color][color=Navy]5 [/color][color=DarkCyan]set [/color][color=Blue]then                            [/color][color=Green]; signal 41 on
                                          [/color][color=Blue]low C.6                                   [/color][color=Green]; signal 19 free
                                    [/color][color=Blue]else high C.6                                   [/color][color=Green]; signal 19 locked
                                    [/color][color=Blue]endif                               
                              else high C.6
                              endif                         
                        else high C.6
                        endif                   
                  else high C.6
                  endif             
            else high C.6
            endif       
      else high C.6                                                                 [/color][color=Green]; signal 19 locked
      [/color][color=Blue]endif
endif

if [/color][color=Purple]b0 [/color][color=DarkCyan]bit [/color][color=Navy]7 [/color][color=DarkCyan]set [/color][color=Blue]then                                                                [/color][color=Green]; if signal 19 is off
      [/color][color=Blue]if [/color][color=Purple]b10 [/color][color=DarkCyan]bit [/color][color=Navy]4 [/color][color=DarkCyan]clear [/color][color=Blue]then                                                       [/color][color=Green]; if points 29 reversed
      [/color][color=Blue]setbit [/color][color=Purple]b9[/color][color=Black], [/color][color=Navy]4                                                                  [/color][color=Green]; points 29 locked
      [/color][color=Blue]setbit [/color][color=Purple]b9[/color][color=Black], [/color][color=Navy]3                                                                  [/color][color=Green]; points 28 locked
      [/color][color=Blue]setbit [/color][color=Purple]b9[/color][color=Black], [/color][color=Navy]7                                                                  [/color][color=Green]; points 32 locked
      [/color][color=Blue]setbit [/color][color=Purple]b6[/color][color=Black], [/color][color=Navy]7                                                                  [/color][color=Green]; points 34 locked[/color]
[color=Blue]endif
if [/color][color=Purple]b7 [/color][color=DarkCyan]bit [/color][color=Navy]7 [/color][color=DarkCyan]clear [/color][color=Blue]then                                                              [/color][color=Green]; if points 29 normal
      [/color][color=Blue]setbit [/color][color=Purple]b9[/color][color=Black], [/color][color=Navy]4                                                                  [/color][color=Green]; points 29 locked
      [/color][color=Blue]setbit [/color][color=Purple]b9[/color][color=Black], [/color][color=Navy]6                                                                  [/color][color=Green]; points 31 locked[/color]
[color=Blue]endif
endif

HI2COUT [PLAIN][[/PLAIN]mcp23017f[PLAIN]][/PLAIN][/color][color=Black], [/color][color=Blue]OLATA[/color][color=Black], [/color][color=Blue]([/color][color=Purple]b10[/color][color=Blue])
HI2COUT [PLAIN][[/PLAIN]mcp23017e[PLAIN]][/PLAIN][/color][color=Black], [/color][color=Blue]OLATB[/color][color=Black], [/color][color=Blue]([/color][color=Purple]b9[/color][color=Blue])[/color]
 

Goeytex

Senior Member
That could not possibly be the complete code. Suggest you post the actual complete code as an attachment.

As far as the memory goes, the 40X2 memory is broken into 4 "slots". You are only using one slot.

See Manual 2 Page 200 "RUN"
 
Last edited:

Circuit

Senior Member
Hello.

Some of you may remember my earlier posts as regards a signalling interlocking project and requiring extra inputs.
You will be glad to know I have now got onto a more level part of the learning curve and have started to write the code. The problem now is I have used 3823 bytes of memory and have only done threequarters of the code.

I am enclosing the code for one signal lever to see if it can be made more efficient. As it is, the code works and does everything it should. All the inputs should really be and`ed together, but a bit/set cannot be used after an and.
Every statement must be true for the lever to be released, but any one false statement must lock the lever.

I am using a 40X2 with six 23017 expanders. All the pins on the 40X2 are in use as ouputs to the lever frame and five expanders are used as inputs and one as outputs.

If the code cannot be made much more efficient, then can I add an extra Picaxe to share the load for the final signal levers?

I have had to cut the code by several lines as it was too long to post.

Code:
[color=Green];*********************************************************************************************88*************
;                                            Signal 19 locking
;************************************************************************************************************[/color]

[color=Blue]if [/color][color=Purple]b10 [/color][color=DarkCyan]bit [/color][color=Navy]4 [/color][color=DarkCyan]clear [/color][color=Blue]then                                                             [/color][color=Green]; points 29 reversed
      [/color][color=Blue]if [/color][color=Purple]b10 [/color][color=DarkCyan]bit [/color][color=Navy]3 [/color][color=DarkCyan]clear [/color][color=Blue]then                                                       [/color][color=Green]; points 28 reversed
            [/color][color=Blue]low C.6                                                                 [/color][color=Green]; signal 19 free
            [/color][color=Blue]if [/color][color=Purple]b10 [/color][color=DarkCyan]bit [/color][color=Navy]7 [/color][color=DarkCyan]clear [/color][color=Blue]then                                                 [/color][color=Green]; points 32 reversed
                  [/color][color=Blue]low C.6
                  if [/color][color=Purple]b6 [/color][color=DarkCyan]bit [/color][color=Navy]5 [/color][color=DarkCyan]clear [/color][color=Blue]then                                            [/color][color=Green]; points 34 normal
                        [/color][color=Blue]low C.6
                        if [/color][color=Purple]b11 [/color][color=DarkCyan]bit [/color][color=Navy]4 [/color][color=DarkCyan]set [/color][color=Blue]then                                       [/color][color=Green]; TC J2 clear
                              [/color][color=Blue]low C.6
                              if [/color][color=Purple]b4 [/color][color=DarkCyan]bit [/color][color=Navy]0 [/color][color=DarkCyan]set [/color][color=Blue]then                                  [/color][color=Green]; TC C6 clear
                                    [/color][color=Blue]low C.6
                                    if [/color][color=Purple]b5 [/color][color=DarkCyan]bit [/color][color=Navy]0 [/color][color=DarkCyan]set [/color][color=Blue]then                            [/color][color=Green]; TC B4 clear
                                          [/color][color=Blue]low C.6
                                          if [/color][color=Purple]b5 [/color][color=DarkCyan]bit [/color][color=Navy]1 [/color][color=DarkCyan]set [/color][color=Blue]then                      [/color][color=Green]; TC B3 clear
                                                [/color][color=Blue]low C.6
                                                if [/color][color=Purple]b5 [/color][color=DarkCyan]bit [/color][color=Navy]2 [/color][color=DarkCyan]set [/color][color=Blue]then                [/color][color=Green]; TC B" clear
                                                      [/color][color=Blue]low C.6
                                                      if [/color][color=Purple]b3 [/color][color=DarkCyan]bit [/color][color=Navy]2 [/color][color=DarkCyan]set [/color][color=Blue]then          [/color][color=Green]; signal 38 on
                                                            [/color][color=Blue]low C.6
                                                            if [/color][color=Purple]b2 [/color][color=DarkCyan]bit [/color][color=Navy]1 [/color][color=DarkCyan]set [/color][color=Blue]then    [/color][color=Green]; signal 46 on
                                                                  [/color][color=Blue]low C.6           [/color][color=Green]; signal 19 free
                                                            [/color][color=Blue]else high C.6           [/color][color=Green]; signal 19 locked 
                                                            [/color][color=Blue]endif                                                       
                                                      else high C.6
                                                      endif                                                 
                                                else high C.6
                                                endif                                           
                                          else high C.6
                                          endif                                     
                                    else high C.6
                                    endif                               
                              else high C.6
                              endif                         
                        else high C.6
                        endif                   
                  else high C.6
                  endif             
            else high C.6
            endif       
      else high C.6                                                                 [/color][color=Green]; signal 19 locked[/color]
[color=Blue]endif
endif
You could reduce your code by using Boolean logic tests on each variable; this code seems to replace the above code with a significant reduction in space - the simulator shows your code as posted to be 210 bytes; the code below does the same job and takes up 77 bytes. This may be enough space for you to keep your code in one slot. There may be more elegant solutions, but this is my first hack at it.

Code:
[color=Blue]symbol [/color][color=Black]logic_mask [/color][color=DarkCyan]= [/color][color=Purple]b55[/color]
[color=Blue]symbol [/color][color=Black]result [/color][color=DarkCyan]= [/color][color=Purple]b54[/color]
[color=Blue]symbol [/color][color=Black]all_clear [/color][color=DarkCyan]= [/color][color=Purple]b53[/color]


[color=Blue]let [/color][color=Black]logic_mask [/color][color=DarkCyan]= [/color][color=Navy]%10011000[/color]
[color=Black]result [/color][color=DarkCyan]= [/color][color=Black]logic_mask [/color][color=DarkCyan]& [/color][color=Purple]b10[/color]
[color=Black]all_clear [/color][color=DarkCyan]=[/color][color=Black]all_clear [/color][color=DarkCyan]+ [/color][color=Black]result[/color]
[color=Blue]let [/color][color=Black]logic_mask [/color][color=DarkCyan]= [/color][color=Navy]%10100000[/color]
[color=Black]result [/color][color=DarkCyan]= [/color][color=Black]logic_mask [/color][color=DarkCyan]& [/color][color=Purple]b6[/color]
[color=Black]all_clear [/color][color=DarkCyan]= [/color][color=Black]all_clear [/color][color=DarkCyan]+ [/color][color=Black]result[/color]
[color=Blue]let [/color][color=Black]logic_mask [/color][color=DarkCyan]= [/color][color=Navy]%00000111[/color]
[color=Black]result [/color][color=DarkCyan]= [/color][color=Black]logic_mask [/color][color=DarkCyan]& [/color][color=Purple]b5[/color]
[color=Black]all_clear [/color][color=DarkCyan]= [/color][color=Black]all_clear [/color][color=DarkCyan]+ [/color][color=Black]result[/color]
[color=Blue]let [/color][color=Black]logic_mask [/color][color=DarkCyan]= [/color][color=Navy]%00000100[/color]
[color=Black]result [/color][color=DarkCyan]= [/color][color=Black]logic_mask [/color][color=DarkCyan]& [/color][color=Purple]b3[/color]
[color=Black]all_clear [/color][color=DarkCyan]= [/color][color=Black]all_clear [/color][color=DarkCyan]+ [/color][color=Black]result[/color]
[color=Blue]let [/color][color=Black]logic_mask [/color][color=DarkCyan]= [/color][color=Navy]%00000010[/color]
[color=Black]result [/color][color=DarkCyan]= [/color][color=Black]logic_mask [/color][color=DarkCyan]& [/color][color=Purple]b2[/color]
[color=Black]all_clear [/color][color=DarkCyan]= [/color][color=Black]all_clear [/color][color=DarkCyan]+ [/color][color=Black]result[/color]

[color=Blue]if [/color][color=Black]all_clear [/color][color=DarkCyan]= [/color][color=Navy]0 [/color][color=Blue]then
      low C.6
else high C.6
      endif
      pause [/color][color=Navy]1000
      [/color]
 

AllyCat

Senior Member
Hi,

If I understand correctly what you are trying to do, then I belive that all the multiple LOW C.6 s and ELSE HIGH s are redundant. Basically you have only two outcomes: either c.6 is set High or Low, so that only needs to be done once. Does the following (which is at least 30% smaller) do what you want?

Code:
high C.6           ; signal 19 locked 
if b10 bit 4 clear then                                                             ; points 29 reversed
      if b10 bit 3 clear then                                                       ; points 28 reversed
            if b10 bit 7 clear then                                                 ; points 32 reversed
                  if b6 bit 5 clear then                                            ; points 34 normal
                        if b11 bit 4 set then                                       ; TC J2 clear
                              if b4 bit 0 set then                                  ; TC C6 clear
                                    if b5 bit 0 set then                            ; TC B4 clear
                                          if b5 bit 1 set then                      ; TC B3 clear
                                                if b5 bit 2 set then                ; TC B" clear
                                                      if b3 bit 2 set then          ; signal 38 on
                                                            if b2 bit 1 set then    ; signal 46 on
                                                                  low C.6           ; signal 19 free
                                                            endif                                                       
                                                      endif                                                 
                                                endif                                           
                                          endif                                     
                                    endif                               
                              endif                         
                        endif                   
                  endif             
            endif       
       endif
   endif
Or certainly working with boolean expressions at the byte (or even word) level could be much more compact, but may lose readabilty (and then be prone to errors).

Cheers, Alan.
 
Last edited:

koyli

Member
Circuit.
I like your code. It is very elegant, if I knew what was going on.

AllyCat.

I tried that method at first, but it did not seemed to work right, but I will try it tomorrow
 

Circuit

Senior Member
Circuit.
I like your code. It is very elegant, if I knew what was going on.
Copy the code into the Editor and run a simulation.
Add a couple of lines so that you can see what happens when you change a value; in fact I have added some for you in the annotated code below.
The logic mask sets a 1 at each bit that you are testing. When you Boolean AND this to your tested variable, if the bit at the same location is zero then the result is zero. If the bit is a 1 then the result is a one. That way, you are selecting out the bits that you want to test as a group rather than going through the process of selecting each bit in turn.

You can watch the C.6 pin on the image of the PICAXE in the simulator.

Code:
[color=Blue]symbol [/color][color=Purple]logic_mask [/color][color=DarkCyan]= [/color][color=Purple]b55[/color]
[color=Blue]symbol [/color][color=Purple]result [/color][color=DarkCyan]= [/color][color=Purple]b54[/color]
[color=Blue]symbol [/color][color=Purple]all_clear [/color][color=DarkCyan]= [/color][color=Purple]b53[/color]

[color=Green]'***********this part is simply for you to try out various values in the simulator 
  [/color][color=Purple]b10 [/color][color=DarkCyan]= [/color][color=Navy]%00001111             [/color][color=Green];bit 4 is set therefore points 29 reversed
' b10 = %00000001             ;comment out the above and then run the simulator again; bit 4 is clear here. 
' b6 =  %11100010             ;you can try out any of your other variables by setting them up here for the simulator.  
' b3 =  %00000100             ;Signal 38 is set high
'*********** [/color]

[color=Blue]let [/color][color=Purple]logic_mask [/color][color=DarkCyan]= [/color][color=Navy]%10011000    [/color][color=Green];this will check for a "BIT SET" in bits 7,4 and 3 [/color]
[color=Purple]result [/color][color=DarkCyan]= [/color][color=Purple]logic_mask [/color][color=DarkCyan]& [/color][color=Purple]b10     [/color][color=Green];if any of bits 7,4 or 3 are high then the result will be >0[/color]
[color=Purple]all_clear [/color][color=DarkCyan]=[/color][color=Purple]all_clear [/color][color=DarkCyan]+ [/color][color=Purple]result [/color][color=Green];all_clear accumulates all the results as we go though the tests[/color]
[color=Blue]let [/color][color=Purple]logic_mask [/color][color=DarkCyan]= [/color][color=Navy]%10100000    [/color][color=Green];now we set the logic mask to test for bits 7 and 5 ...[/color]
[color=Purple]result [/color][color=DarkCyan]= [/color][color=Purple]logic_mask [/color][color=DarkCyan]& [/color][color=Purple]b6      [/color][color=Green];...and we apply the test to variable b6.[/color]
[color=Purple]all_clear [/color][color=DarkCyan]= [/color][color=Purple]all_clear [/color][color=DarkCyan]+ [/color][color=Purple]result[/color]
[color=Blue]let [/color][color=Purple]logic_mask [/color][color=DarkCyan]= [/color][color=Navy]%00000111[/color]
[color=Purple]result [/color][color=DarkCyan]= [/color][color=Purple]logic_mask [/color][color=DarkCyan]& [/color][color=Purple]b5      [/color][color=Green];...and so forth[/color]
[color=Purple]all_clear [/color][color=DarkCyan]= [/color][color=Purple]all_clear [/color][color=DarkCyan]+ [/color][color=Purple]result[/color]
[color=Blue]let [/color][color=Purple]logic_mask [/color][color=DarkCyan]= [/color][color=Navy]%00000100    [/color][color=Green];checking signal 38, therefore we mask up bit2 for a logic check[/color]
[color=Purple]result [/color][color=DarkCyan]= [/color][color=Purple]logic_mask [/color][color=DarkCyan]& [/color][color=Purple]b3
all_clear [/color][color=DarkCyan]= [/color][color=Purple]all_clear [/color][color=DarkCyan]+ [/color][color=Purple]result[/color]
[color=Blue]let [/color][color=Purple]logic_mask [/color][color=DarkCyan]= [/color][color=Navy]%00000010[/color]
[color=Purple]result [/color][color=DarkCyan]= [/color][color=Purple]logic_mask [/color][color=DarkCyan]& [/color][color=Purple]b2
all_clear [/color][color=DarkCyan]= [/color][color=Purple]all_clear [/color][color=DarkCyan]+ [/color][color=Purple]result[/color]

[color=Blue]if [/color][color=Purple]all_clear [/color][color=DarkCyan]= [/color][color=Navy]0 [/color][color=Blue]then         [/color][color=Green];if any bits to be tested were set high then all_clear will not be zero
      [/color][color=Blue]low C.6
else high C.6
      endif
      pause [/color][color=Navy]1000              [/color][color=Green];this is just put in here so that you can look at the C.6 pin going green in the simulator window
      [/color]
Hope that helps.
Circuit.
 

koyli

Member
That`s great Circuit. I`ve just tried your code and it seems that I need to add all the bits that should be 1`s and put that in the if all_clear = test at the end. Correct?
 

westaust55

Moderator
That`s great Circuit. I`ve just tried your code and it seems that I need to add all the bits that should be 1`s and put that in the if all_clear = test at the end. Correct?
If you also need to check for some bits set, then this can be done with just a few extra steps:

1. in the logic_mask set the bit of interest whether they are required to be a 0 or a 1.
2. get the result as per circuits scheme
3. now set the logic mask with bits set only for those that must be a "1"
4. XOR (Exclusive OR ) the result with the new logic mask

By way of a worked examples,

lets say you need b5 to have %101xxxxx (where x = don't care) and b5 has the value %10101010
1. logic_mask = %11100000
2. result = logic_mask & b5 ==> %10100000
3. logic_mask = %10100000
4 result = result XOR logic mask ==> %00000000 ==> clear to set the point/signal etc


lets say you need b5 to have %101xxxxx (where x = don't care) and b5 has the value %00101010
1. logic_mask = %11100000
2. result = logic_mask & b5 ==> %00100000
3. logic_mask = %10100000
4 result = result XOR logic mask ==> %10000000 ==> not = 0 therefore block the point change or clearing signal
 

koyli

Member
Thanks for the tip. This will save me from doing binary addition to get the correct result.

I can now rewrite the code to be more compact.

This has come just at the right time because one of the signals still to code has eight possible routes from it and another has five, so this code will save lots of memory.
 
Top