aeddy2008
Newbie level 2
Need help with coding to make a GAL16V8 into a counter with the an up button, a down button, and a clear button, I am also trying to turn the counter in to a 2 led display score board with a three way toggle switch that acts as an enabler to allow the counter to advance or decrease when activated. This code will be duplicated to a second GAL16V8 to make this possible. My current output on the Seven segment is nothing, and i have checked and double checked the wiring. I believe it is something with my code. Please help. Thanks aaron
Name Aaron ;
PartNo 00 ;
Date 7/24/2012 ;
Revision 01 ;
Designer Engineer ;
Company ACC ;
Assembly None ;
Location ;
Device virtual ;
/* *************** INPUT PINS ******************** */
PIN 1 = !CLK ; /* When Engaged increases count */
PIN 2 = !DIR ; /* When engaged reduces count */
PIN 3 = !CLR ; /* Clear Button to reset count to 0 */
PIN 4 = !ENABLE ; /* Enabling 3 Way Switch */
pin 11 = !oe ; /* Register output Enable */
/* *************** OUTPUT PINS *********************/
PIN [12..18] = [Q6..0]; /* Counter output */
Pin 19 = Carry; /* ripple carry out */
/* *************** Declarations and Intermediate Variable Definitions ***************/
field count = [Q6..0]; /*Declare Counter bit field*/
$define S0 'b'0000001
$define S1 'b'1001111
$define S2 'b'0010010
$define S3 'b'0000110
$define S4 'b'1001100
$define S5 'b'0100100
$define S6 'b'1100000
$define S7 'b'0001111
$define S8 'b'0000000
$define S9 'b'0001000
field mode = [!CLK,!DIR,!CLR,!ENABLE]; */ declare filed mode controle */
UP = mode : 0; */ define count up mode */
DOWN = mode : 1; */ define count down mode */
CLEAR = mode : 2; */ define count clear mode */
ENABLE = mode : 3; */ define count enable to advance, three way switch */
/* *************** Logic Equations *********************/
sequence counter { /* push button counter */
present S0 if UP & ENABLE next S1;
if DOWN & ENABLE next S9;
if CLEAR & ENABLE next S0;
default next S0;
present S1 if UP & ENABLE next S2;
if UP & DOWN & ENABLE next S0;
if CLEAR & ENABLE next S0;
default next S1;
present S2 if UP & ENABLE next S3;
if UP & DOWN & ENABLE next S1;
if CLEAR & ENABLE next S0;
default next S2;
present S3 if UP & ENABLE next S4;
if UP & DOWN & ENABLE next S2;
if CLEAR & ENABLE next S0;
default next S3;
present S4 if UP & ENABLE next S5;
if UP & DOWN & ENABLE next S3;
if CLEAR & ENABLE next S0;
default next S4;
present S5 if UP & ENABLE next S6;
if UP & DOWN & ENABLE next S4;
if CLEAR & ENABLE next S0;
default next S5;
present S6 if UP & ENABLE next S7;
if UP & DOWN & ENABLE next S5;
if CLEAR & ENABLE next S0;
default next S6;
present S7 if UP & ENABLE next S8;
if UP & DOWN & ENABLE next S6;
if CLEAR & ENABLE next S0;
default next S7;
present S8 if UP & ENABLE next S9;
if UP & DOWN & ENABLE next S7;
if CLEAR & ENABLE next S0;
default next S8;
present S9 if UP & ENABLE next S0;
if UP & DOWN & ENABLE next S8;
if CLEAR & ENABLE next S0;
default next S9;
}
- - - Updated - - -
Forgot to mention the circuit is active low. I am thinking this may affect my code.
Name Aaron ;
PartNo 00 ;
Date 7/24/2012 ;
Revision 01 ;
Designer Engineer ;
Company ACC ;
Assembly None ;
Location ;
Device virtual ;
/* *************** INPUT PINS ******************** */
PIN 1 = !CLK ; /* When Engaged increases count */
PIN 2 = !DIR ; /* When engaged reduces count */
PIN 3 = !CLR ; /* Clear Button to reset count to 0 */
PIN 4 = !ENABLE ; /* Enabling 3 Way Switch */
pin 11 = !oe ; /* Register output Enable */
/* *************** OUTPUT PINS *********************/
PIN [12..18] = [Q6..0]; /* Counter output */
Pin 19 = Carry; /* ripple carry out */
/* *************** Declarations and Intermediate Variable Definitions ***************/
field count = [Q6..0]; /*Declare Counter bit field*/
$define S0 'b'0000001
$define S1 'b'1001111
$define S2 'b'0010010
$define S3 'b'0000110
$define S4 'b'1001100
$define S5 'b'0100100
$define S6 'b'1100000
$define S7 'b'0001111
$define S8 'b'0000000
$define S9 'b'0001000
field mode = [!CLK,!DIR,!CLR,!ENABLE]; */ declare filed mode controle */
UP = mode : 0; */ define count up mode */
DOWN = mode : 1; */ define count down mode */
CLEAR = mode : 2; */ define count clear mode */
ENABLE = mode : 3; */ define count enable to advance, three way switch */
/* *************** Logic Equations *********************/
sequence counter { /* push button counter */
present S0 if UP & ENABLE next S1;
if DOWN & ENABLE next S9;
if CLEAR & ENABLE next S0;
default next S0;
present S1 if UP & ENABLE next S2;
if UP & DOWN & ENABLE next S0;
if CLEAR & ENABLE next S0;
default next S1;
present S2 if UP & ENABLE next S3;
if UP & DOWN & ENABLE next S1;
if CLEAR & ENABLE next S0;
default next S2;
present S3 if UP & ENABLE next S4;
if UP & DOWN & ENABLE next S2;
if CLEAR & ENABLE next S0;
default next S3;
present S4 if UP & ENABLE next S5;
if UP & DOWN & ENABLE next S3;
if CLEAR & ENABLE next S0;
default next S4;
present S5 if UP & ENABLE next S6;
if UP & DOWN & ENABLE next S4;
if CLEAR & ENABLE next S0;
default next S5;
present S6 if UP & ENABLE next S7;
if UP & DOWN & ENABLE next S5;
if CLEAR & ENABLE next S0;
default next S6;
present S7 if UP & ENABLE next S8;
if UP & DOWN & ENABLE next S6;
if CLEAR & ENABLE next S0;
default next S7;
present S8 if UP & ENABLE next S9;
if UP & DOWN & ENABLE next S7;
if CLEAR & ENABLE next S0;
default next S8;
present S9 if UP & ENABLE next S0;
if UP & DOWN & ENABLE next S8;
if CLEAR & ENABLE next S0;
default next S9;
}
- - - Updated - - -
Forgot to mention the circuit is active low. I am thinking this may affect my code.