Skip to content

Compilation of Verilog behavioral models and test benches for the four types of flip-flops (SR, JK, D, and T)

Notifications You must be signed in to change notification settings

memgonzales/hdl-flip-flop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Behavioral Modeling of Flip-Flops

badge

This project is a compilation of Verilog behavioral models and test benches for the four types of flip-flops:

  • SR flip-flops
  • JK flip-flops
  • D flip-flops
  • T flip-flops

Each of these is implemented as positive edge-triggered, with inverted and non-inverted outputs, and asynchronous reset (active-high). Positive edge-triggered describes a flip-flop where changes in its state happen only at the rising edge (low-to-high transition) of the clock. Meanwhile, asynchronous reset indicates that the activation of the reset results in the state immediately changing to 0, regardless of the synchronous input/s or the clock.

Overview of Flip-Flops

Mano (1992) defines a flip-flop — the data storage element of synchronous sequential circuits — as "a binary cell capable of storing one bit of information" (p. 22).

SR Flip-Flop

Logic diagram (SR Flip-flop)

Characteristic Table

S R Q(t + 1) Remarks
0 0 Q(t) No change
0 1 0 Reset
1 0 1 Set
1 1 ? Indeterminate

Waveform

Waveform (SR Flip-flop)

JK Flip-Flop

Logic diagram (JK Flip-flop)

Characteristic Table

J K Q(t + 1) Remarks
0 0 Q(t) No change
0 1 0 Reset
1 0 1 Set
1 1 ¬Q(t) Toggle

Waveform

Waveform (JK Flip-flop)

D Flip-Flop

Logic diagram (D Flip-flop)

Characteristic Table

D Q(t + 1) Remarks
0 0 Same as D
1 1 Same as D

Waveform

Waveform (D Flip-flop)

T Flip-Flop

Logic diagram (T Flip-flop)

Characteristic Table

T Q(t + 1) Remarks
0 Q(t) No change
1 ¬Q(t) Toggle

Waveform

Waveform (T Flip-flop)

Note that the behavioral modeling of flip-flops is derived from their respective characteristic tables.

Built Using

This project consists of source codes and test benches written in the hardware description language Verilog.

If Icarus Verilog is installed, run the following command on the terminal to compile the Verilog program:

iverilog -o <name of vvp file>.vvp <name of source code>.v <name of test bench>.v

To "execute" the program and generate the value change dumpfile (.vcd), run the following command:

vvp <name of vvp file>.vvp

To generate and view the waveform using GTKWave, run the following command:

gtkwave <name of vcd file>.vcd

In this project, the filenames (with extensions) are as follows:

Flip-Flop Source Code Test Bench VCD File
SR sr.v sr_tb.v sr.vcd
JK jk.v jk_tb.v jk.vcd
D d.v d_tb.v d.vcd
T t.v t_tb.v t.vcd

Author and References

The following reference materials were consulted:

About

Compilation of Verilog behavioral models and test benches for the four types of flip-flops (SR, JK, D, and T)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published