Kevin M.
Kevin M.

Reputation: 1

Making a Simple 2-Bit Asynchronous counter in WinCupl

/* INPUT PINS */

PIN    1 =  clock; /* clock input*/ 

/**************** OUTPUT PINS *********************/

PIN    14 = Q1 ; /*output*/

PIN    15 = Q2 ; /*output*/

Q1.ck = clock;

Q1.d = !Q1;

Q2.d = !Q2;

This is my code and the two lines below the output pins create a 1 bit ripple counter but I'm unsure how to transfer the output of the first flip flop to be the clock input for the second flip flop. The chip I'm trying to program is an Atmel ATF750C chip.

Upvotes: 0

Views: 6240

Answers (3)

Admiral Decker
Admiral Decker

Reputation: 11

The device does not allow separate clock definitions for individual flip-flops. The clock input to pin 1 is a shared clock for all flip-flops in the device. You could try the following instead:

Device = G16V8;

/* Inputs */

Pin 1 = CLK;  /* clock source */

Pin 11 = GND; /* ground this for registered operation */

/* Outputs */

Pin 12 = Q0;

Pin 13 = Q1;

Pin 14 = Q2;

Pin 15 = Q3;

/* Equations */

!Q0.d = !Q3;

Q0.oe = 'b'1; /* output enabled - also default */

!Q1.d = Q0;

Q1.oe = 'b'1; /* output enabled - also default */

!Q2.d = Q1;

Q2.oe = 'b'1; /* output enabled - also default */

!Q3.d = Q2;

Q3.oe = 'b'1; /* output enabled - also default */

Note: The above example would provide a 4-bit ripple binary counter/divider. For instance: An 8MHz clock input would be divided by 8 resulting in 4 shifted 1MHz outputs on each Q pin.

Upvotes: 1

Kevin M.
Kevin M.

Reputation: 1

/******** OUTPUT PINS **********/

PIN 14 = Q1.d;

PIN 15 = Q2.d;

Q1.ck = clock;

!Q1.d = Q1;

Q2.ck = !Q1;

!Q2.d = Q2;

This creates an asynchronous ripple counter that counts up in binary using D flip flops.

Upvotes: 0

Jon Smith
Jon Smith

Reputation: 1

Wincupl is a sort of primitive vhdl, but I have now figured it out. I just had to append ".d" to my output variables, then attached my clock to pin #1 and ground pin #11. And yeah I did have to get intimate with the GAL16v8 and WinCUPL documentation to figure it all out.

Upvotes: 0

Related Questions