6502.org http://forum.6502.org/ |
|
D type flip flop using GAL http://forum.6502.org/viewtopic.php?f=10&t=3255 |
Page 1 of 1 |
Author: | banedon [ Mon Mar 30, 2015 8:25 pm ] |
Post subject: | D type flip flop using GAL |
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 [ 3.39 KiB | Viewed 6801 times ] I've tried... Code: qq = 0; and...nqq = 0; 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? |
Author: | 8BIT [ Tue Mar 31, 2015 2:35 am ] |
Post subject: | Re: D type flip flop using GAL |
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 |
Author: | banedon [ Tue Mar 31, 2015 8:35 am ] |
Post subject: | Re: D type flip flop using GAL |
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 [ 2.64 KiB | Viewed 6776 times ] My main concern is that I cannot seem to do create a variable and set it to a value (like a = 0) |
Author: | BigEd [ Tue Mar 31, 2015 10:06 am ] |
Post subject: | Re: D type flip flop using GAL |
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 |
Author: | banedon [ Tue Mar 31, 2015 11:36 am ] |
Post subject: | Re: D type flip flop using GAL |
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. |
Author: | 8BIT [ Wed Apr 01, 2015 5:05 am ] |
Post subject: | Re: D type flip flop using GAL |
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: The first cycle is indeterminant because a stable state was not presented first. Is that what you were looking for? Daryl |
Author: | banedon [ Wed Apr 01, 2015 10:05 pm ] |
Post subject: | Re: D type flip flop using GAL |
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)? |
Author: | unclouded [ Thu Apr 02, 2015 2:00 am ] |
Post subject: | Re: D type flip flop using GAL |
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
|
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |