Logic Gates

pilko

Senior Member
I am trying to write the code for a Parallel/series/parallel circuit.or in logic terms:
(input1 or input2) and (input3 or input4) = output 1

the code I have written so far,does work,but I have not been able to simplify it so far. please help.

Code:
main:

     if pin1=1 or pin2 =1 then let b0=1 else b0=0  endif
     
     if pin3=1 or pin4 =1 then let b1=1 else b1=0 endif
     
     if b0=1 and b1=1 then high 1 else low 1 endif
     

goto main
 

hippy

Ex-Staff (retired)
In what way are you looking to "simplify" the code ?

outpin1 = pins / 2 | pins & %1010 / %1010
 

womai

Senior Member
I would say your code is pretty good as is, and it's a clean implementation. If that's the first time you do this, then - well done!

Another option, which does not use up any variables:

Code:
main:

     if pin1=1 or pin2=1 then 
          if pin3=1 or pin4=1 then 
               high 1
          else
               low 1
          endif
     else
         low 1
     endif

goto main
Wolfgang
 

pilko

Senior Member
hippy, your salution works well and is very elegant,but untill I get to a higher level of understanding,I wondered if there is a simpler IF THEN salution.
 

womai

Senior Member
If the first if clause fails, the pin shall be set low (that's the second "else low 1").

Otherwise, check the second if condition and set the pin high if it's true, low otherwise.
 
Top