Rising Edge D flip Flop code in c++

A

as

Hi folks,
am a newbie in C++ world. Normally I use matlab more often. But right
now I want to create a Rising Edge
D Flip-Flop model which has two Digital inputs, i.e. INPUTDATA and a
CLOCK. The functionality of Rising Edge D Flip Flop is that whenever a
rising edge of CLOCK signal will occur ( Rising Edge : 0 to 1 ) the
output will be the similar state of INPUTDATA signal, otherwise (if it
will be not a rising edge and CLOCK signal is 0 or 1) then the present
output will be the Previous state of the output.
I am facing the problem in case of accessing the previous values.
If you people have any suggestion please let me know.
Thanks in advance,
Cheers,
Joydeep.
 
A

anon

as said:
Hi folks,
am a newbie in C++ world. Normally I use matlab more often. But right
now I want to create a Rising Edge
D Flip-Flop model which has two Digital inputs, i.e. INPUTDATA and a
CLOCK. The functionality of Rising Edge D Flip Flop is that whenever a
rising edge of CLOCK signal will occur ( Rising Edge : 0 to 1 ) the
output will be the similar state of INPUTDATA signal, otherwise (if it
will be not a rising edge and CLOCK signal is 0 or 1) then the present
output will be the Previous state of the output.
I am facing the problem in case of accessing the previous values.

IMO the problem is not that hard to solve. Everything is clear how it
should work
If you people have any suggestion please let me know.

1) start coding
2) test your code
3) brush your teeth after every meal
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

Hi folks,
am a newbie in C++ world. Normally I use matlab more often. But right
now I want to create a Rising Edge
D Flip-Flop model which has two Digital inputs, i.e. INPUTDATA and a
CLOCK. The functionality of Rising Edge D Flip Flop is that whenever a
rising edge of CLOCK signal will occur ( Rising Edge : 0 to 1 ) the
output will be the similar state of INPUTDATA signal, otherwise (if it
will be not a rising edge and CLOCK signal is 0 or 1) then the present
output will be the Previous state of the output.
I am facing the problem in case of accessing the previous values.
If you people have any suggestion please let me know.


You need a class to represent the flip-flip, you need to keep track of
three things, the current state of the flip-flip, the current state of
the input data, and the current clock state. Three bool variables will do.

Then you need a method the tell the flip-flip that the input data has
changed, it should look something like this

void setInput(bool input)

and a method to signal a change in the clock

void clock(bool clock)

and lastly some way to read the state from the flip-flop

bool getState()

The magic should happen in the clock() method, in there you check if the
clock-state is changed since the last call of clock(), and if it is,
check if the state changed from 0 to 1, in which case the state of the
flip-flop should be set to the state of the input.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top