Of course your's code is better
Now we have :
diff -Naur old/charge_pump.comp new/charge_pump.comp
--- old/charge_pump.comp 2013-10-27 02:28:28.000000000 +0100
+++ new/charge_pump.comp 2013-11-11 13:50:38.162863405 +0100
@@ -18,6 +18,8 @@
component charge_pump "Create a square-wave for the 'charge pump'
input of some controller boards";
option singleton yes;
pin out bit out "Square wave if 'enable' is TRUE or unconnected, low
if 'enable' is FALSE";
+pin out bit out2 "Square wave, frequency divided by two";
+pin out bit out4 "Square wave, frequency divided by four";
pin in bit enable = TRUE "If FALSE, forces 'out' to be low";
function _ nofp "Toggle the output bit (if enabled)";
description """
@@ -25,13 +27,19 @@
When enabled the output is on for one period and off for one period.
To calculate the
frequency of the output 1/(period time in seconds x 2) = hz. For
example if you
have a base period of 100,000ns that is 0.0001 seconds and the formula
would be
-1/(0.0001 x 2) = 5,000 hz or 5 Khz """;
+1/(0.0001 x 2) = 5,000 hz or 5 Khz. Pins out2 and out4 gives frequency
divided by two and four.""";
license "GPL";
;;
FUNCTION(_) {
- if ( enable ) {
- out = !out;
- } else {
- out = 0;
- }
+ static int acc ;
+ if (enable){
+ acc ++ ;
+ out = (acc & 0x1);
+ out2 = (acc & 0x2);
+ out4 = (acc & 0x4);
+ } else {
+ out = 0;
+ out2 = 0;
+ out4 = 0;
+ }
}
In my opinion, this code is good for make changes in repositories.
Regards.
W dniu 11.11.2013 12:15, andy pugh pisze:
> static int acc
> if (enable){
> acc ++
> out = (acc & 0x1);
> out2 = (acc & 0x2);
> out4 = (acc & 0x4);
> } else {
> out = 0;
> out2 = 0;
> out4 = 0;
> }
------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers