Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Calling a JK flipflop through a procedure

Reply
Thread Tools

Calling a JK flipflop through a procedure

 
 
willie willie is offline
Junior Member
Join Date: Sep 2006
Posts: 3
 
      09-13-2006
I am getting an uninitialized (U) Q and Qnot when I call a procedure that describes a JK flipflop wih both inputs to be the same:

library ieee;
use ieee.std_logic_1164.all;

entity UpDownCounter is
port(CLK : std_logic;
J, K : in std_logic;
Qo, QNOTo, J1orK1, UP, DOWNin : inout std_logic;
QoUP, QNOToDOWN, DOWN : inout std_logic;
Q_1, QNOT_1 : inout std_logic);
end UpDownCounter;

architecture UpDownCounterProcedure of UpDownCounter is
--This procedure describes a two-input AND gate with zero delay
procedure and2 (Ap, Bp : in std_logic; Cp : out std_logic) is
begin
if Ap = '1' and Bp = '1'
then Cp := '1';
else Cp := '0';
end if;
end procedure and2;

--This procedure describes a two-input OR gate with zero delay
procedure or2 (Ap, Bp : in std_logic; Cp : out std_logic) is
variable Cp_temp : std_logic;
begin
if Ap = '0' and Bp = '0'
then Cp_temp := '0';
else Cp_temp := '1';
end if;
Cp := Cp_temp;
end procedure or2;

--This procedure describes a JK flipflop
procedure jkff (Jp, Kp : in std_logic; Qp, QNOTp : inout std_logic) is

variable Qp_temp, QNOTp_temp : std_logic;
begin
if Jp = '1' and Kp = '0'
then Qp_temp := '1';
elsif Jp = '0' and Kp = '1'
then Qp_temp := '0';
elsif Jp = '0' and Kp = '0'
then Qp_temp := Qp;
else Qp_temp := not Qp;
end if;

Qp := Qp_temp;
QNOTp_temp := not Qp_temp;
QNOTp := QNOTp_temp;
end procedure jkff;

--this procedure describes an inverter
procedure inv (DOWNp : in std_logic; variable DOWNp_out : inout std_logic) is
begin
if DOWNp = '0'
then DOWNp_out := '1';
else DOWNp_out := '0';
end if ;
end procedure inv;

begin

counter : process (J, K, UP, DOWNin, CLK)
variable DOWNout, QoUPout, QNOToDOWNout, Qout, QNOTout : std_logic;
variable Qout_1, QNOTout_1 : std_logic;
variable J1orK1out, K1 : std_logic;

begin
if rising_edge(CLK) then
--calling to the procedure JKflipflop for FF0
jkff (J, K, Qout, QNOTout); -- working properly
Qo <= Qout;
QNOTo <= QNOTout;

--calling inverter procedure
inv (DOWNin, DOWNout);
DOWN <= DOWNout;

-- calling two and gates through procedure and2
and2 (Qout, UP, QoUPout);
QoUP <= QoUPout;
and2 (DOWNout, QNOTout, QNOToDOWNout);
QNOToDOWN <= QNOToDOWNout;

-- calling or2 procedure
or2 (QNOToDOWNout, QoUPout, J1orK1out);
J1orK1 <= J1orK1out;

--THIS IS WHERE I GET IN TROUBLE
-- calling procedure JKfliflop for FF1
jkff(J1orK1out, J1orK1out, Qout_1, QNOTout_1); --same inputs give me problem

--Qout_1 and QNOT_1 get a value of 'U' all thru the simulation
--please tell me what I am doing wrong, and how I can fix it.
--Thanks
--Willie


end if;
end process counter;
end UpDownCounterProcedure;
 

Last edited by willie; 09-13-2006 at 09:30 PM..
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
procedure as argument in procedure AlexWare VHDL 2 10-23-2009 09:14 AM
latch and flipflop Amit VHDL 12 06-09-2007 03:14 AM
PLEASE I NEED THE VHDL CODE FOR JK FLIPFLOP hyeazu@juno.com VHDL 9 09-27-2006 07:41 AM
'Procedure or function <stored procedure name> has too many arguments specified',,,ARGH! Mike P ASP .Net 0 06-19-2006 01:19 PM
FlipFlop Voodoo Daniel Nugent Ruby 5 07-04-2005 05:44 AM



Advertisments