iA3

                    To easily learn C language
                    you must start making programs in it.

                    https://www.programmingsimplified.com/c


## QUINE-MCCLUSKEY

  $ sudo apt-get install libboost-all-dev
  $ git clone https://github.com/pfpacket/Quine-McCluskey
  $ cd Quine-McCluskey
  $ make
  $ ./qm


## Java 10 on Debian {1}{2}

  $ sudo -s
  # apt-get install dirmngr --install-recommends
  # echo "deb http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic main" | tee /etc/apt/sources.list.d/linuxuprising-java.list
  # apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 73C3DB2A
  # apt-get update
  # apt-get install oracle-java10-installer
  # exit


## Logisim

Download Logisim

  https://sourceforge.net/projects/circuit/files/2.7.x/2.7.1
  /logisim-generic-2.7.1.jar/download

Move file to ~/LogiSim folder.

  $ cd ~
  $ mkdir LogiSim
  $ mv Downloads/logisim-generic-2.7.1.jar LogiSim/

Make new entry for it using alacarte (Education menu).

  $ alacarte
  Name:    LogiSim 2.7.1
  Command: java -jar /home/virtu/LogiSim/logisim-generic-2.7.1.jar

Run LogiSim

  Education -> LogiSim 2.7.1

Draw circuit of your choice, having inputs [o] and outputs (o).

Analyze Circuit with

  Project -> Analyze Circuit

Create ladder diagram using "Expression" tab

  Window -> Combinational Analysis -> Expression.

Test ladder with LDMicro. Convert to ANSI C Arduino project and run with SimulIDE.


## Problem: Build CW and CCW running lights (12 LED in circle)

                o t0
       t11 o         o t1
             Computer
    t10 o     -----     o t2
             |     |
    t9 o     |     |     o t3
             |     |   \|/
     t8 o    |     |   -o- t4
              -----    /|\
        t7 o      t5 o
             t6 o

  a) Using "Hard Logic" (LogiSim)

  b) Based on Moore Automata (SimulIDE)

  c) Based on Arduino PLC (SimulIDE)

------

## References:

{1} https://www.linuxuprising.com/2018/04/
    install-oracle-java-10-jdk-10-in-debian.html

{2} https://blog.sleeplessbeastie.eu/2017/11/02
    /how-to-fix-missing-dirmngr/


## Draft

  ./qm tests:

  F(A,B,C,D,E,F,G,H,I,J,K,L)=A~B~C~D~E~F~G~H~I~J~K~L
  F(A,B)=A~B+B~A

ex.c

  // compile: gcc ex.c -o ex

  #include <stdio.h>

  unsigned short get_num( void) {
      int  i=0;
      char s[6] = "";
      unsigned short num = 0;

      printf("Enter the number between 0 and 65535: ");
      scanf("%5s",s);

      do {
          if ('0'<=s[i] && s[i]<='9')
              num = 10*num + s[i]-'0';
          i++;
      } while(5>=i);
      printf("it was %d\n", num);
      return num;
  }

  int main() {
      int i;
      int plus=0;
      unsigned short num = get_num();

      for (i=0; i<16; i++)
          printf("%02d  %d  %d  %d  %d  %d\n",
                  i, (i>>3)&1, (i>>2)&1, (i>>1)&1, i&1, (num>>i)&1);

      printf("F(A,B,C,D)=");
      for (i=15; i>=0; i--)
          if ((num>>i)&1) {
              if (plus) printf("+");
              plus=1;
              printf("%sD%sC%sB%sA",
                     (i>>3)&1?"~":"", (i>>2)&1?"~":"",
                     (i>>1)&1?"~":"", i&1?"~":"");
           }

      printf("\n");
      return 0;
  }
