SHARE
TWEET

JSI Ammo Counter ABEL source code v1

a guest May 31st, 2013 13 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MODULE AMMO_COUNTER
  2.  
  3. TITLE 'LED Ammo Counter on GAL22v10'
  4.  
  5. DECLARATIONS
  6.  
  7. DIP1 pin 2;
  8. DIP2 pin 3;
  9. DIP3 pin 4;
  10. DIP4 pin 5;
  11. DIP5 pin 6;
  12.  
  13. DIP = [DIP5, DIP4, DIP3, DIP2, DIP1];
  14.  
  15. MAG pin 7;
  16.  
  17. TRIGGER pin 8;
  18.  
  19. " 7-segment common-cathode displays (active low outputs)
  20. " Right display (DIS1)
  21.  
  22. DIS1a pin 23 istype 'com';
  23. DIS1b pin 22 istype 'com';
  24. DIS1c pin 21 istype 'com';
  25. DIS1d pin 20 istype 'com';
  26. DIS1e pin 19 istype 'com';
  27. DIS1f pin 18 istype 'com';
  28. DIS1g pin 17 istype 'com';
  29.  
  30. DIS1 = [DIS1a, DIS1b, DIS1c, DIS1d, DIS1e, DIS1f, DIS1g];
  31.  
  32. " Left display (DIS2)
  33.  
  34. DIS2a pin 16 istype 'com';
  35. DIS2b pin 15 istype 'com';
  36. DIS2c pin 14 istype 'com';
  37. DIS2d pin 13 istype 'com';
  38. DIS2e pin 11 istype 'com';
  39. DIS2f pin 10 istype 'com';
  40. DIS2g pin 9  istype 'com';
  41.  
  42. DIS2 = [DIS2a, DIS2b, DIS2c, DIS2d, DIS2e, DIS2f, DIS2g];
  43.  
  44. " 7-segment alphanumeric display code declarations
  45.  
  46. blank = [0,0,0,0,0,0,0];  " blank (all off)
  47. char0 = [1,1,1,1,1,1,0];  " 0
  48. char1 = [0,1,1,0,0,0,0];  " 1
  49. char2 = [1,1,0,1,1,0,1];  " 2
  50. char3 = [1,1,1,1,0,0,1];  " 3
  51. char4 = [0,1,1,0,0,1,1];  " 4
  52. char5 = [1,0,1,1,0,1,1];  " 5
  53. char6 = [1,0,1,1,1,1,1];  " 6
  54. char7 = [1,1,1,0,0,0,0];  " 7
  55. char8 = [1,1,1,1,1,1,1];  " 8
  56. char9 = [1,1,1,1,0,1,1];  " 9
  57.  
  58. " Pin 24 to +V
  59. " Pin 12 to GND
  60.  
  61. " User-defined variables follow
  62. " Note - these should all be declared as NODES (*not* PINS)
  63.  
  64. Q0 node istype 'reg';
  65. Q1 node istype 'reg';
  66. Q2 node istype 'reg';
  67. Q3 node istype 'reg';
  68. Q4 node istype 'reg';
  69. Q5 node istype 'reg';
  70. Q = [Q5..Q0];
  71.  
  72.  
  73. " ======================= START OF EQUATIONS SECTION =================================
  74.  
  75. "DIP switches for mag capacity
  76.  
  77. TRUTH_TABLE ([DIP5,DIP4,DIP3,DIP2,DIP1]->[Q5,Q4,Q3,Q2,Q1,Q0])
  78.              [   0,   0,   0,   0,   1]->[ 1, 1, 1, 0, 1, 1]; "6
  79.              [   0,   0,   0,   1,   d]->[ 0, 1, 0, 1, 1, 1]; "12
  80.              [   0,   0,   1,   d,   d]->[ 0, 1, 0, 0, 0, 1]; "18
  81.              [   0,   1,   d,   d,   d]->[ 0, 0, 1, 0, 1, 0]; "25
  82.              [   1,   d,   d,   d,   d]->[ 0, 0, 0, 0, 0, 0]; "35
  83.  
  84. EQUATIONS
  85.  
  86. "Counter
  87.  
  88. Q0 := !Q0;
  89. Q1 := (Q1 $ Q0);
  90. Q2 := (Q2 $ (Q1&Q0));
  91. Q3 := (Q3 $ (Q2&Q1&Q0));
  92. Q4 := (Q4 $ (Q3&Q2&Q1&Q0));
  93. Q5 := (Q5 $ (Q4&Q3&Q2&Q1&Q0));
  94. Q.AR := !MAG;
  95. Q.CLK = TRIGGER;
  96.  
  97. "LED displays
  98.  
  99. DIS1 = char0 & (([Q5..Q0] == 35)#([Q5..Q0] == 25)#([Q5..Q0] == 15)#([Q5..Q0] == 5));
  100. DIS1 = char1 & (([Q5..Q0] == 34)#([Q5..Q0] == 24)#([Q5..Q0] == 14)#([Q5..Q0] == 4));
  101. DIS1 = char2 & (([Q5..Q0] == 33)#([Q5..Q0] == 23)#([Q5..Q0] == 13)#([Q5..Q0] == 3));
  102. DIS1 = char3 & (([Q5..Q0] == 32)#([Q5..Q0] == 22)#([Q5..Q0] == 12)#([Q5..Q0] == 2));
  103. DIS1 = char4 & (([Q5..Q0] == 31)#([Q5..Q0] == 21)#([Q5..Q0] == 11)#([Q5..Q0] == 1));
  104. DIS1 = char5 & (([Q5..Q0] == 30)#([Q5..Q0] == 20)#([Q5..Q0] == 10)#([Q5..Q0] == 0));
  105. DIS1 = char6 & (([Q5..Q0] == 29)#([Q5..Q0] == 19)#([Q5..Q0] ==  9));
  106. DIS1 = char7 & (([Q5..Q0] == 28)#([Q5..Q0] == 18)#([Q5..Q0] ==  8));
  107. DIS1 = char8 & (([Q5..Q0] == 27)#([Q5..Q0] == 17)#([Q5..Q0] ==  7));
  108. DIS1 = char9 & (([Q5..Q0] == 26)#([Q5..Q0] == 16)#([Q5..Q0] ==  6));
  109. DIS1 = char0 & (([Q5..Q0] == 36)#([Q5..Q0] == 37)#([Q5..Q0] == 15)#([Q5..Q0] == 38)#([Q5..Q0] == 39)#([Q5..Q0] == 40)); "5 cycle buffer for empty
  110.  
  111. DIS2 = char0 & (([Q5..Q0] == 36)#([Q5..Q0] == 37)#([Q5..Q0] == 15)#([Q5..Q0] == 38)#([Q5..Q0] == 39)#([Q5..Q0] == 40)); "5 cycle buffer for empty
  112. DIS2 = char0 & (([Q5..Q0] == 26)#([Q5..Q0] == 27)#([Q5..Q0] == 28)#([Q5..Q0] == 29)#([Q5..Q0] == 30)#([Q5..Q0] == 31)#([Q5..Q0] == 32)#([Q5..Q0] == 33)#([Q5..Q0] == 34)#([Q5..Q0] == 35));
  113. DIS2 = char0 & (([Q5..Q0] == 26)#([Q5..Q0] == 27)#([Q5..Q0] == 28)#([Q5..Q0] == 29)#([Q5..Q0] == 30)#([Q5..Q0] == 31)#([Q5..Q0] == 32)#([Q5..Q0] == 33)#([Q5..Q0] == 34)#([Q5..Q0] == 35));
  114. DIS2 = char1 & (([Q5..Q0] == 16)#([Q5..Q0] == 17)#([Q5..Q0] == 18)#([Q5..Q0] == 19)#([Q5..Q0] == 20)#([Q5..Q0] == 21)#([Q5..Q0] == 22)#([Q5..Q0] == 23)#([Q5..Q0] == 24)#([Q5..Q0] == 25));
  115. DIS2 = char2 & (([Q5..Q0] == 6)# ([Q5..Q0] ==  7)#([Q5..Q0] ==  8)#([Q5..Q0] ==  9)#([Q5..Q0] == 10)#([Q5..Q0] == 11)#([Q5..Q0] == 12)#([Q5..Q0] == 13)#([Q5..Q0] == 14)#([Q5..Q0] == 15));
  116. DIS2 = char3 & (([Q5..Q0] == 0)# ([Q5..Q0] ==  1)#([Q5..Q0] ==  2)#([Q5..Q0] ==  3)#([Q5..Q0] ==  4)#([Q5..Q0] ==  5));
  117.  
  118. END
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top