Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - control circuit for a bus

 
Thread Tools Search this Thread
Old 06-06-2006, 09:49 AM   #1
Default control circuit for a bus


Hello to everyone,
I have to implement a control circuit for a bus.The bus has a control
circuit that swaps the values of 4 registers(8-bit each one):R1,R2,R3
and R4.The architecture of that bus should use the tri-state device.The
control circuit should have 3 inputs w,I(0) and I(1) and do the
following:

1.When I(1)=0,I(0)=0,w=1 then it swaps the values of R1,R2 & R3
2.When I(1)=0,I(0)=1,w=1 then it swaps(from left to right) the values
of R1,R2 & R3 with the help of R4
3.When I(1)=1,I(0)=0,w=1 then it swaps(from right to left)the values of
R1,R2 & R3 with the help of R4
4.When I(1)=1,I(0)=1,w=0 then it should do nothing

What I have done so far is the following:

--A programme for each register:

LIBRARY ieee ;
USE ieee.std_logic_1164.all ;

ENTITY regn IS
GENERIC ( N : INTEGER := 8 ) ;
PORT ( R : IN STD_LOGIC_VECTOR(N-1 DOWNTO 0) ;
Rin, Clock : IN STD_LOGIC ;
Q : OUT STD_LOGIC_VECTOR(N-1 DOWNTO 0) ) ;
END regn ;

ARCHITECTURE Behavior OF regn IS
BEGIN
PROCESS
BEGIN
WAIT UNTIL Clock'EVENT AND Clock = '1' ;
IF Rin = '1' THEN
Q <= R ;
END IF ;
END PROCESS ;
END Behavior ;


--A programme for the tri-state device:

LIBRARY ieee ;
USE ieee.std_logic_1164.all ;

ENTITY trin IS
GENERIC ( N : INTEGER := 8 ) ;
PORT ( X : IN STD_LOGIC_VECTOR(N-1 DOWNTO 0) ;
E : IN STD_LOGIC ;
F : OUT STD_LOGIC_VECTOR(N-1 DOWNTO 0) ) ;
END trin ;

ARCHITECTURE Behavior OF trin IS
BEGIN
F <= (OTHERS => 'Z') WHEN E = '0' ELSE X ;
END Behavior ;

-- A programme for the control-circuit

LIBRARY ieee ;
USE ieee.std_logic_1164.all ;

ENTITY shiftr IS
GENERIC ( K : INTEGER := 4 ) ;
PORT ( Resetn, Clock, w : IN STD_LOGIC ;
I : IN STD_LOGIC_VECTOR(0 TO 1) ;
Q : BUFFER STD_LOGIC_VECTOR(1 TO K) ) ;
END shiftr ;

ARCHITECTURE Behavior OF shiftr IS
BEGIN
PROCESS ( Resetn, Clock , I )
BEGIN
IF Resetn = '0' THEN
Q <= (OTHERS => '0') ;
ELSIF Clock'EVENT AND Clock = '1' THEN
IF I(1)='0' AND I(0)='0' THEN
Genbits: FOR i IN K DOWNTO 2 LOOP
Q(i) <= Q(i-1) ;
END LOOP ;

ELSIF I(1)='0' AND I(0)='1' THEN
Genbits1: FOR i IN K DOWNTO 2 LOOP
Q(i) <= Q(i-1) ;
END LOOP ;

ELSIF I(1)='1' AND I(0)='0' THEN
Genbits2: FOR i IN K DOWNTO 2 LOOP
Q(i-1) <= Q(i) ;
END LOOP ;
END IF;
Q(1) <= w ;
END IF ;
END PROCESS ;
END Behavior ;

--A programme for the package:

LIBRARY ieee ;
USE ieee.std_logic_1164.all ;

PACKAGE components IS

COMPONENT regn -- register
GENERIC ( N : INTEGER := 8 ) ;
PORT ( R : IN STD_LOGIC_VECTOR(N-1 DOWNTO 0) ;
Rin, Clock : IN STD_LOGIC ;
Q : OUT STD_LOGIC_VECTOR(N-1 DOWNTO 0) ) ;
END COMPONENT ;

COMPONENT shiftr -- shift register with async reset
GENERIC ( K : INTEGER := 4 ) ;
PORT ( Resetn, Clock, w : IN STD_LOGIC ;
Q : BUFFER STD_LOGIC_VECTOR(1 TO K) ) ;
END component ;

COMPONENT trin -- tri-state buffers
GENERIC ( N : INTEGER := 8 ) ;
PORT ( X : IN STD_LOGIC_VECTOR(N-1 DOWNTO 0) ;
E : IN STD_LOGIC ;
F : OUT STD_LOGIC_VECTOR(N-1 DOWNTO 0) ) ;
END COMPONENT ;

--A programme for the bus:

LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
USE work.components.all ;

ENTITY swap IS
PORT ( Data : IN STD_LOGIC_VECTOR(7 DOWNTO 0) ;
Resetn, w : IN STD_LOGIC ;
Clock, Extern : IN STD_LOGIC ;
RinExt : IN STD_LOGIC_VECTOR(1 TO 4) ;
BusWires : INOUT STD_LOGIC_VECTOR(7 DOWNTO 0) ) ;
END swap ;

ARCHITECTURE Behavior OF swap IS
SIGNAL Rin, Rout,Q: STD_LOGIC_VECTOR(1 TO 4) ;
SIGNAL R1, R2, R3,R4 : STD_LOGIC_VECTOR(7 DOWNTO 0) ;
BEGIN
control: shiftr GENERIC MAP ( K => 4 )
PORT MAP ( Resetn, Clock, w, Q ) ;
Rin(1) <= RinExt(1) OR Q(4) ;
Rin(2) <= RinExt(2) OR Q(3) ;
Rin(3) <= RinExt(3) OR Q(2) ;
Rin(4) <= RinExt(4) OR Q(1) ;
Rout(1) <= Q(3) ; Rout(2) <= Q(2) ; Rout(3) <= Q(1) ; Rout(4)<=Q(4);

tri_ext: trin PORT MAP ( Data, Extern, BusWires ) ;
reg1: regn PORT MAP ( BusWires, Rin(1), Clock, R1 ) ;
reg2: regn PORT MAP ( BusWires, Rin(2), Clock, R2 ) ;
reg3: regn PORT MAP ( BusWires, Rin(3), Clock, R3 ) ;
reg4: regn PORT MAP ( BusWires, Rin(4), Clock, R4 ) ;
tri1: trin PORT MAP ( R1, Rout(1), BusWires ) ;
tri2: trin PORT MAP ( R2, Rout(2), BusWires ) ;
tri3: trin PORT MAP ( R3, Rout(3), BusWires ) ;
tri4: trin PORT MAP ( R4, Rout(4), BusWires ) ;
END Behavior ;

Everything works fine except for the control circuit where I need your
help as I am an amateur user of VHDL.



danaitsa_thebest@hotmail.com
  Reply With Quote
Old 06-09-2006, 07:41 AM   #2
danaitsa_thebest@hotmail.com
 
Posts: n/a
Default Re: control circuit for a bus
Where I need your help is the following programme:

> -- A programme for the control-circuit
>
> LIBRARY ieee ;
> USE ieee.std_logic_1164.all ;
>
> ENTITY shiftr IS
> GENERIC ( K : INTEGER := 4 ) ;
> PORT ( Resetn, Clock, w : IN STD_LOGIC ;
> I : IN STD_LOGIC_VECTOR(0 TO 1) ;
> Q : BUFFER STD_LOGIC_VECTOR(1 TO K) ) ;
> END shiftr ;
>
> ARCHITECTURE Behavior OF shiftr IS
> BEGIN
> PROCESS ( Resetn, Clock , I )
> BEGIN
> IF Resetn = '0' THEN
> Q <= (OTHERS => '0') ;
> ELSIF Clock'EVENT AND Clock = '1' THEN
> IF I(1)='0' AND I(0)='0' THEN
> Genbits: FOR i IN K DOWNTO 2 LOOP
> Q(i) <= Q(i-1) ;
> END LOOP ;
>
> ELSIF I(1)='0' AND I(0)='1' THEN
> Genbits1: FOR i IN K DOWNTO 2 LOOP
> Q(i) <= Q(i-1) ;
> END LOOP ;
>
> ELSIF I(1)='1' AND I(0)='0' THEN
> Genbits2: FOR i IN K DOWNTO 2 LOOP
> Q(i-1) <= Q(i) ;
> END LOOP ;
> END IF;
> Q(1) <= w ;
> END IF ;
> END PROCESS ;
> END Behavior ;




danaitsa_thebest@hotmail.com
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to control the height of a Drop down control Siri_y Software 1 05-17-2009 06:19 AM
Mind Control and CIA'S BOURNE IDENTITY PLOT soleilmavis@gmail.com DVD Video 2 08-03-2007 09:54 PM
Ajax Atlas not working in User Control faiq Software 0 09-16-2006 08:28 AM
Charter Communications -- mind control Laura DVD Video 0 01-28-2006 03:14 AM
FS: JP1 cable to program your universial remote control, now youcan control anything you want! Mike DVD Video 0 07-15-2005 02:46 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

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