6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 7:38 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Mon Mar 30, 2015 8:25 pm 
Offline
User avatar

Joined: Sun Sep 08, 2013 10:24 am
Posts: 740
Location: A missile silo somewhere under southern England
Hi guys

I'm trying to learn how to use WinCUPL by creating a D type flip flop. For some reason it seems to be throwing a wobbly over the following:


Code:
/*
 * Inputs
 */

Pin 2 = d;
Pin 3 = ck;

/*
 * Outputs
 */

Pin 23 = q;
Pin 22 = nq;

/*
 * Main
 */

and1a = !d;
and1b = ck;

and2a = d;
and2b = ck;

qq = !0;
nqq = !0;

nor1a = and1a & and1b;
nor1b = qq;
nor2a = and2a & and2b;
nor2b = nqq;

q2 = !(nor1a # nor1b);
nq2 = !(nor2a # nor2b);

nor1a2 = and1a & and1b;
nor1b2 = q2;
nor2a2 = and2a & and2b;
nor2b2 = nq2;

q = !(nor1a2 # nor1b2);
nq = !(nor2a2 # nor2b2);


There error points to the following statements:
Code:
qq = !0;
nqq = !0;

Attachment:
wincupl_error1.png
wincupl_error1.png [ 3.39 KiB | Viewed 6797 times ]


I've tried...
Code:
qq = 0;
nqq = 0;
and...
Code:
qq = false;
nqq = false;


But it still errors out. It doesn't seem to like me assigning a value to a variable...

Any ideas?


Top
 Profile  
Reply with quote  
PostPosted: Tue Mar 31, 2015 2:35 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1748
Location: Sacramento, CA
I'm not sure what device you are using. Here's a register setup for a 22V10:

Code:
Name      Reg;
Partno    1;
Date      11/05/10;
Revision  01;
Designer  Daryl;
Company   Rictor;
Assembly  None;
Location  None;
Device    G22V10;

/**  Inputs  **/

PIN 1  = clock;                /* Register Clock       */
PIN 2  = D;                    /* Data Input           */
PIN 3  = clr;
PIN 4  = pre;
PIN 13 = !outen;               /* Output Enable        */

/**  Outputs  **/

PIN 14 = Q1;                   /* Register Output      */
PIN 15 = Q2;                   /* Combinatorial Output */

/** Logic Equations **/

Q1.d   =  D;                   /* data input           */

Q1.sp  = pre;                  /* asynchronous preset  */

Q1.oe  = outen;                /* tri-state control    */

Q1.ar  = clr;                  /* asynchronous reset   */

Q2     = !Q1;                  /* inverted output      */


For the 22V10 and 16V8's, the register clock has to be pin 1 and the output enable pin is fixed as well for the 16V8 - pin 11.

Hope this helps!

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Tue Mar 31, 2015 8:35 am 
Offline
User avatar

Joined: Sun Sep 08, 2013 10:24 am
Posts: 740
Location: A missile silo somewhere under southern England
Thanks Bitwise

The device is a 22V10B.
I did notice that that clock input wa sin pin 1, but as I wasn't planning to actually strobe it with a crystal, but simply send it high or low, I thought I could get away with using a different pin.

Here's a circuit diagram of what I was trying to construct within the GAL:
Attachment:
circuit.png
circuit.png [ 2.64 KiB | Viewed 6772 times ]


My main concern is that I cannot seem to do create a variable and set it to a value (like a = 0)


Top
 Profile  
Reply with quote  
PostPosted: Tue Mar 31, 2015 10:06 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
I don't think there can be any variables, only constants, because this programming is not procedural (whereby it is executed from top to bottom) but more declarative (whereby the whole program describes something, all at once.)

As these values you want are constants, you can I think remove them, by considering that AND with a 1 leaves the input unchanged, as does OR with a 0, whereas AND with a 0 always produces a zero. That is, you can manually propagate these constants into the expressions, and simplify everything.

Hope this helps
Ed


Top
 Profile  
Reply with quote  
PostPosted: Tue Mar 31, 2015 11:36 am 
Offline
User avatar

Joined: Sun Sep 08, 2013 10:24 am
Posts: 740
Location: A missile silo somewhere under southern England
BigEd wrote:
I don't think there can be any variables, only constants, because this programming is not procedural (whereby it is executed from top to bottom) but more declarative (whereby the whole program describes something, all at once.)

As these values you want are constants, you can I think remove them, by considering that AND with a 1 leaves the input unchanged, as does OR with a 0, whereas AND with a 0 always produces a zero. That is, you can manually propagate these constants into the expressions, and simplify everything.

Hope this helps
Ed

Thanks Ed.
I suppose this (and obviously RAM etc) is what differentiates between a microcontroller and soemthing like a GAL.
I've obviously been thinking about this in the top down programatical way which is incorrect. This revalation is good news as it actually simplies what I'm trying to do.
I'll give it another go tonight with what you've said in mind and see how it turns out.


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 01, 2015 5:05 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1748
Location: Sacramento, CA
OK - I like a challenge so I had a go at it. Your schematic is more of a latch than a D flip-flop. I put it together using straight combinatorial logic.

Code:
Name            latch demo;
Partno          latch;
Revision        01;
Date            3/31/15;
Designer        Daryl Rictor;
Company         ;
Location        USA;
Assembly        None;
Device          p22v10;

/*********************************************************************************/
/*                                                                               */
/*  This program and its associated documentation are provided for your personal */
/*  use only and appear here exclusively by permission of the copyright holder.  */
/*  Please contact the copyright holder before re-distributing, re-publishing    */
/*  or disseminating this copyrighted work. This code is not GPL or in the       */
/*  public domain. Please respect the author's copyright.                        */
/*                                                                               */
/*  No waranty, either expressed or implied, are given.  I assume no liability   */
/*  for its use in any project or device.                                        */
/*                                                                               */
/*  Your use of this program indicates your acceptance of all license terms.     */
/*  This particular version is freeware as long as the copyright messages are    */
/*  left intact.                                                                 */ 
/*                                                                               */
/*********************************************************************************/

/* Pin Map
       --------
  x   |1     24| Vcc
  D   |2     23| Q
  E   |3     22| QN
  x   |4     21| x
  x   |5     20| x
  x   |6     19| x
  x   |7     18| x
  x   |8     17| x
  x   |9     16| x
  x   |10    15| x
  x   |11    14| x
Gnd   |12    13| x
       --------
*/


/*
 * Inputs: 
 */

/* Pin 1  =  no connect - tie to gnd or Vcc or Pin 2 */
Pin 2  =  D;
Pin 3  =  E;

/* Pin 4 - 11 and 13 - no connect - tie to gnd or Vcc */


/*
 * Outputs:  - all are simple combinatorial
 */
Pin 23 = Q;     
Pin 22 = QN;

/*
 * Logic: 
 */

Q = !(QN # (!D & E));
QN = !(Q # (D & E));


Here's what the Sim output looks like: (click on the image to make it bigger)
Attachment:
latch.png
latch.png [ 48.52 KiB | Viewed 6737 times ]


The first cycle is indeterminant because a stable state was not presented first.

Is that what you were looking for?

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 01, 2015 10:05 pm 
Offline
User avatar

Joined: Sun Sep 08, 2013 10:24 am
Posts: 740
Location: A missile silo somewhere under southern England
Yes indeed. I'm really just practicing to get an idea of how it works so that I can create a decent address decoder for my next 6502 project.
I was thinking of using the TABLE command for that...

[EDIT] Oddly, I cannot get my design to simulate. It says something about the .SI file not being found.
Do I have to create that file? If so, what else do I put in the file apart from the header (which has to be the same as the one in the PLD file as I understand it)?


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 02, 2015 2:00 am 
Offline

Joined: Tue Feb 24, 2015 11:07 pm
Posts: 81
Yes, you have to create the .SI file. There is help available from within WinCUPL at Help > CUPL Programmer's Reference then "Simulator Reference" > Statements. A minimal example might be:

Code:
$ cat DEC.SI
Name      DEC;
PartNo    00;
Date      3/7/2015;
Revision  01;
Designer  Engineer;
Company   Test;
Assembly  None;
Location  None;
Device    p22v10;


ORDER: PHI2, CS0;

VECTORS:
0H
1L


There are also examples in the C:\Wincupl\Examples\Atmel folder. "GATES" is a nice simple example.

Gotchas
  • Those odd %2s in .SI files mean insert 2 spaces
  • Don't use L or H for inputs, use 0 and 1. The error message when you don't is obtuse ( expects H, got X)
  • Don't use the ORDER: "When PHI2 is ", PHI2, ", CS0 is ", CS0; format because it breaks the waveform display


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: