Questions tagged [flip-flop]

Flip-flops (FFs) are electronic devices with two stable states. They are the simplest system capable of storing one bit of information.

Anything related to flip-flops (FFs). FFs are bistable electronic devices, i.e. devices which exhibit only two stable states. As such, they can be viewed as the simplest system capable of storing one bit of information without additional circuitry.

See Wikipedia page on flip-flops.

148 questions
29
votes
6 answers

Is Perl's flip-flop operator bugged? It has global state, how can I reset it?

I'm dismayed. OK, so this was probably the most fun Perl bug I've ever found. Even today I'm learning new stuff about Perl. Essentially, the flip-flop operator .. which returns false until the left-hand-side returns true, and then true until the…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
21
votes
3 answers

When would a Ruby flip-flop be useful?

I think I understand how a flip-flop works thanks to a tutorial, but the example there is contrived just for teaching. Can anyone give an example of how you have actually used or would use a flip-flop? I'm looking for a real-world application, not…
kajaco
  • 2,547
  • 3
  • 24
  • 33
18
votes
2 answers

What is a flip-flop operator?

I have heard and read about flip-flops with regular expressions in Perl and Ruby recently, but I was unable to find how they really work and what the common use cases are. Can anyone explain this in a language-agnostic manner? Now that I understand…
samuil
  • 5,001
  • 1
  • 37
  • 44
7
votes
3 answers

Is there a functional programming concept equivalent to the flip-flop operator in Perl or Ruby?

Ruby (and Perl) has a concept of the flip flop: file = File.open("ordinal") while file.gets print if ($_ =~ /third/) .. ($_ =~ /fifth/) end which given a list of ordinals, such as first second third fourth fifth sixth would start printing when…
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
6
votes
2 answers

Difference between D Latch Schematic and D Flip Flop Schematic

I heard that the main difference between latch and flip flops is that latches are asynchronous while flip flops are edge triggered which makes sense. But when I check out their shematic they seem pretty much same. Here is the design of a dlatch from…
Crazy_Boy53
  • 241
  • 2
  • 4
  • 10
6
votes
6 answers

Why does a Flip-Flop operator include the second condition?

The following code is using a flip-flop operator. (1..10).each {|x| print "#{x}," if x==3..x==5 } Why are the results 3,4,5? I think it should be 3,4. As mentioned in a tutorial, this expression becomes true when x == 3, and continues to be true…
Huibin Zhang
  • 1,072
  • 1
  • 15
  • 30
5
votes
4 answers

Difference between 3-dot-range operator and 2-dot-range operator in flip flop ruby

Please help me to understand the difference between range operators ... and .. as "flip-flops" used in Ruby. This is an example from Pragmatic Programmers guide to Ruby: a = (11..20).collect {|i| (i%4 == 0)..(i%3 == 0) ? i : nil} which…
gmuraleekrishna
  • 3,375
  • 1
  • 27
  • 45
4
votes
1 answer

Difference between Synchronous and Asynchronous reset in Flip Flops

always @ (posedge clk or negedge reset ) begin //Asynchrous FF end always @(posedge clk) begin if (reset) // Synchronous FF end What is the difference in the following implementations ? I mean in terms of number of size of the FF . Why and How…
chitranna
  • 1,579
  • 6
  • 25
  • 42
3
votes
1 answer

D Flip Flop in VHDL

I'm trying to implement a D Flip Flop in VHDL, using a D Latch I wrote. But there seems to be an error with the clock, and I can't figure out what that is. Here is the code for my D Latch. Library ieee; Use ieee.std_logic_1164.all; entity d_latch…
ratsimihah
  • 1,010
  • 1
  • 11
  • 22
3
votes
3 answers

Can using the ruby flip-flop as a filter be made less kludgy?

In order to get part of text, I'm using a true if kludge in front of a flip-flop: desired_portion_lines = text.each_line.find_all do |line| true if line =~ /start_regex/ .. line =~ /finish_regex/ end desired_portion =…
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
3
votes
1 answer

Calling 'scalar' on the results of the range operator (..) in Perl

So, I believe this has something to do with the difference between arrays and lists, but I don't understand what's going on here. Can anyone explain how and why Perl treats an expression like (1..4) differently than (1, 2, 3, 4) and @{[1..4]}? $…
user240438
3
votes
2 answers

why is the output of JK flip flop red in simulation?

I am posting a Code for JK Flip flop in VHDL language. the code is correct according to the JK flip flop circuit. but i got output as red line. can any one tell me the what is the problem with only JK flip flop only. Programme: JK Flip Flop…
Misal313
  • 169
  • 2
  • 8
  • 23
3
votes
5 answers

Can SystemVerilog represent a flip-flop with asynchronous set and reset without adding unsynthesizable code?

I'm coming from a Verilog-95 background, and I'm trying to figure out what Verilog-95 hoops I don't have to jump through anymore. The obvious way to write a flip flop with async set and reset in Verilog-95 is: always @(posedge clk or negedge resetb…
dan
  • 4,262
  • 7
  • 25
  • 40
2
votes
1 answer

Perl Flip-flop operator - Is it possible to treat the END of first match as START of next match?

Need some more help on flip-flop operator Below is my sample data: LS SPID ASP SPID 3-59 MGW05 SLC ACL PARMG ST SDL SLI 0 A1 17 C7STH-1&&-31 …
pkr13
  • 107
  • 2
  • 10
2
votes
3 answers

Perl: Using the flip flop function and extracting data from within the block read

I have an array called @mytitles which contains a lot of titles such as, say, title1, title2 and so on. I have a file called "Superdataset" which has information pertaining to each title. However, the info related to title1 may be of 6 lines while…
1
2 3
9 10