Bit::FlipFlop [was Re: SPUG: flip-flops]
Colin Meyer
cmeyer at helvella.org
Tue Feb 12 18:43:33 CST 2002
On Fri, Feb 08, 2002 at 01:54:14AM -0800, Andrew Sweger wrote:
> On Thu, 7 Feb 2002, Colin Meyer wrote:
>
> > On Thu, Feb 07, 2002 at 01:45:26AM -0800, Andrew Sweger wrote:
> > > On Wed, 6 Feb 2002, Colin Meyer wrote:
> > >
> > > > You'd rather that there was a FlipFlop class object that provided an
> > > > accessor to that state?
> > >
> > > Amen. I mean, yes.
[...]
>
> I would encourage an explicit FlipFlop class in any large production.
> (Reduced to native or builtin structures in response to optimizations
> where needed, natch.)
Well, here you go:
NAME
Bit::FlipFlop - Facilitates the maintainance of one bit of
state in Perl programs.
SYNOPSIS
use Bit::FlipFlop;
my $f = Bit::FlipFlop->new(set => sub { /start/ },
reset => sub { /end/ });
for (<INPUT>) {
$f->test;
print "**leading edge**\n" if $f->lead_edge;
print "number ", $f->series, ": $_" if $f->state;
print "**trailing edge**\n" if $f->trail_edge;
}
. . .
Read the full documentation at:
http://helvella.org/Bit::FlipFlop.html
Download the module:
http://helvella.org/Bit-FlipFlop-0.01.tar.gz
I think that actually using this module is rediculous. ;-)
Why did I do it? Well, for fun. Also, I think that it will be
instructive to those who are struggling over learning the flip flop op
from the straight Perl docs.
And I really wanted to try my hand at expressing digital logic with
ascii art:
___ $a $b | $o
$a -----| \ ---------|----
| |o---- $o F F | T
$b -----|___/ T F | T
F T | T
T T | F
(This won't be pretty to those viewing with a proportional font. It might
not be pretty to those using a fixed width font either.)
;-)
>
> Give me TMTOWTDI or give me death.
Hear hear! ;-)
Have fun,
-C.
>
> --
> Andrew B. Sweger -- The great thing about multitasking is that several
> things can go wrong at once.
>
>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list