Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > t flip flops

Reply
Thread Tools

t flip flops

 
 
danaitsa_thebest@hotmail.com
Guest
Posts: n/a
 
      05-17-2006
hi to everyone...well I feel that I don't know much about
flip-flops...I've got to do a vhdl programme that will describe the
behavior of a t flip-flop...but I don't know how to link the q(t+1)
input with the q(t) output...and that because it is in force the
following:

T(input) Clock Q(t+1)-->output
0 1 Q(t)
1 1 not Q(t)

how can I do that programme?

 
Reply With Quote
 
 
 
 
KJ
Guest
Posts: n/a
 
      05-17-2006
Homework is hell sometimes.

Perhaps pick up a book on VHDL and take a look at what VHDL calls a
'process'....no more hints now

 
Reply With Quote
 
 
 
 
danaitsa_thebest@hotmail.com
Guest
Posts: n/a
 
      05-18-2006
Well what I have done so far is the following:
LIBRARY ieee;
USE ieee.std_logic_1164.all;

ENTITY Dflipflop IS
PORT (Clock,Resetn,T:IN STD_LOGIC;
Q:BUFFER STD_LOGIC);
END Dflipflop;

ARCHITECTURE Behavior OF Dflipflop IS
BEGIN
PROCESS
BEGIN(Clock,Resetn)
IF Resetn='0' THEN
Q<='0';
ELSIF T='1' AND (Clock'EVENT AND Clock='1') THEN
Q<=NOT Q;
ELSE
Q<=Q;
END IF;
END PROCESS;
END Behavior;
However I feel that is not correct as doesn't link the Q(t+1) value
with Q(t) one.(t=time)
So how can I create in VHDL Q(t+1) instance?
I searched a lot but I did not find anything.

 
Reply With Quote
 
danaitsa_thebest@hotmail.com
Guest
Posts: n/a
 
      05-18-2006
Well what I have done so far is the following:
LIBRARY ieee;
USE ieee.std_logic_1164.all;

ENTITY Dflipflop IS
PORT (Clock,Resetn,T:IN STD_LOGIC;
Q:BUFFER STD_LOGIC);
END Dflipflop;

ARCHITECTURE Behavior OF Dflipflop IS
BEGIN
PROCESS
BEGIN(Clock,Resetn)
IF Resetn='0' THEN
Q<='0';
ELSIF T='1' AND (Clock'EVENT AND Clock='1') THEN
Q<=NOT Q;
ELSE
Q<=Q;
END IF;
END PROCESS;
END Behavior;
However I feel that is not correct as doesn't link the Q(t+1) value
with Q(t) one.(t=time)
So how can I create in VHDL Q(t+1) instance?
I searched a lot but I did not find anything.

 
Reply With Quote
 
danaitsa_thebest@hotmail.com
Guest
Posts: n/a
 
      05-18-2006
Because of a mistake notice that entity is not Dflipflop but Tflipflop.

 
Reply With Quote
 
Peter
Guest
Posts: n/a
 
      05-18-2006
> ENTITY Dflipflop IS
> PORT (Clock,Resetn,T:IN STD_LOGIC;
> Q:BUFFER STD_LOGIC);
> END Dflipflop;


Shall be Tflipflop, as already said.

> ELSIF T='1' AND (Clock'EVENT AND Clock='1') THEN


This statement creates a gated clock (or more likely an error message).
Modify it to:

elsif rising_edge(clk) then
if T='1' then
.....

to keep the design synchronous.

/Peter

 
Reply With Quote
 
Thomas Stanka
Guest
Posts: n/a
 
      05-18-2006
Hi,

schrieb:
[..]
> ELSIF T='1' AND (Clock'EVENT AND Clock='1') THEN
> Q<=NOT Q;
> ELSE
> Q<=Q;
> END IF;
> END PROCESS;
> END Behavior;
> However I feel that is not correct as doesn't link the Q(t+1) value
> with Q(t) one.(t=time)
> So how can I create in VHDL Q(t+1) instance?
> I searched a lot but I did not find anything.


Why do you think, Q(t+1) is not linked with Q(t)? Just accept that t
increase by one with each rising edge of Clk.

Someone called Thebest should know that vhdl didn't require Q<=Q inside
a clocked process and a sequential process should always be:

IF Resetcondition THEN -- e.g. reset='0'
....
ELSIF rising_edge(Clk) THEN -- clk'event and clk='1' is ok, but old
style
....
END IF;

 
Reply With Quote
 
kunal
Guest
Posts: n/a
 
      05-18-2006
do this way, i think its better for u
library ieee;
use ieee.std_logic_1164.all;
entity tff is
port(t,clock, reset : in std_logic;
q : inout std_logic);
end entity tff;
architecture behavioral of tff is
begin
tflip : process(clock,reset) is
begin
if (reset = '1') then
q <= '0';
elsif (clock'event and clock = '1' ) then
q <= t xor q;
end process tflip;
end architecture behavioral;

it will work properly. when u design ff then try with charactristic
equation like jk ff or t ff as above.
the above code is in vhdl-93 syntax.

 
Reply With Quote
 
danaitsa_thebest@hotmail.com
Guest
Posts: n/a
 
      05-20-2006
Iam afraid that although the T flip-flop's net works fine with the use
of an xor synthesis,something like the following is not correct:

begin
if (reset = '0') then
q <= '0';
elsif rising_edge(Clk) then
q <= t xor q;

 
Reply With Quote
 
radarman
Guest
Posts: n/a
 
      05-21-2006
I believe Kunal's code is correct - run it through a simulator.

When t is low, q will get simply get the old value on the next clock
edge. When t is high, q will get the inverse of its old value on the
next clock edge. As long as t is high, q will toggle on every clock.
Thus, t effectively becomes the clock enable.

This is another way of looking at the problem that is logically
equivalent. (and in fact closer to what the synthesis tools will reduce
it to)

tflip: process( reset, clock)
begin
if (reset = '1') then
q <= '0';
elsif (clock'event and clock = '1' ) then
if( t = '1')then -- T is now used as a classic clock enable in
this example
q <= not q;
end if;
end if;
end process tflip;

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the basis on flip-flops replaced by a latch Weng Tianxiang VHDL 13 02-15-2010 11:44 PM
clock synchronization and flip flops john VHDL 10 04-21-2009 05:01 PM
Using a global clock as an enable for flip-flops and RAMs? mav1101 VHDL 1 09-22-2006 04:49 PM
t flip flops danaitsa_thebest@hotmail.com VHDL 0 05-17-2006 03:23 PM
Latches and flip flops crazyrdx VHDL 6 04-09-2006 11:09 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57