8.0 Resolving Multi-Signal Drivers: 8.1 Buses
8.0 Resolving Multi-Signal Drivers: 8.1 Buses
ACTL
DBUS
n
BCTL
n
A
DBUS
BCTL
0
0
1
1
1
0
1
DBUS
impementation dependent ( no
input activated)
B
A
implementation dependent (both
inputs activated)
VDD
C
in
out =
out
in
ACTL
BCTL
n
A
ACTL
0
0
1
1
BCTL
0
1
0
1
n
B
DBUS
Floating
B
A
Undefined (Avoid)
DBUS
ACTL
DBUS
BCTL
n
n
B
VDD
C
in
in*C
out =
out
in*C
in
ACTL
0
0
1
1
BCTL
0
1
0
1
DBUS
Undefined (Avoid)
A
B
Floating
When
C=1 both out transistors are turned off and the output out is left floating
C=0 one of the output transtor is enabled and the other disabled, as selected by the input data in,
out <= in.
There are situations where bus control inputs are generated by devices operating independently and
asynchronously. Interrupt request (IRQ) lines are a common example. Multiple drivers can be enabled
simultaneously during normal operation, and hence tri-state bus should not be used.
out
C
in
out =
in*C
in
VDD
Rn
ACTL
DBUS
BCTL
n
n
B
The driver is a NOR gate followed by an inverter with the pull-up resistor removed. A pull-up resistor is
provided externally to hold the bus at 1 when no driver is pulling it low. When no driver is enabled, DBUS
= 1n. If multiple drivers are enabled, then the bus will be pulled low if any enabled inputs is low, hence
DBUS is the AND of the enabled inputs.
ACTL
0
0
1
1
BCTL
0
1
0
1
DBUS
A and B
A
B
1n
out
C
C
in
in*C
out =
in
VDD
Rn
ACTL
DBUS
DBUS
BCTL
n
n
B
TTL version of the open-drain OR-gate is the open-collector NAND-gate. It is formed from the basic TTL
gate by removing the pull-up from the output. The DBUS is the OR of the enabled inputs.
ACTL
0
BCTL
0
DBUS
1n
DBUS
0n
A and B
A+B
TYPE std_ulogic IS (
U,
--Uninitialized
X,
--Forcing Unknown
0,
--Forcing 0
1,
--Forcing 1
Z,
--High Impedance
W,
--Weak Unknown
L,
--Weak 0
H,
--Weak 1
-
--Dont care
);
To use this standard logic system, VHDL code must include the following lines at the beginning.
LIBRARY IEEE, ARITHMETIC;
USE IEEE.STD_LOGIC_1164.ALL;
USE ARITHMETIC.STD_LOGIC_ARITH.ALL;
model must provide a resolution function that specifies how to resolve the assignment. Each signal that
requires a resolution function makes reference to the appropriate function in the signal declaration.
Example:
ENTITY mult_driver IS
PORT(a,b,c,d:IN qsim_state;z:OUT qsim_state);
END mult_driver;
ARCHITECTURE wired_and OF mult_driver IS
FUNCTION anding(drivers:qsim_state_vector)RETURN qsim_state IS
VARIABLE temp:qsim_state:='1';
BEGIN
FOR i IN drivers'RANGE LOOP
temp:=temp AND drivers(i);
--see the AND table
END LOOP;
RETURN temp;
END anding;
SIGNAL line_and: anding qsim_state;
BEGIN
line_and <= a;
line_and <= b;
line_and <= c;
line_and <= d;
z<= line_and;
END wired_and;
Qsim AND Table
AND
0
0
0
0
1
0
X
0
Z
1
0
1
X
X
0
0
0
0
0
0
0
0
0
0
1
U
X
0
1
X
X
0
1
X
X
0
X
X
X
Z
U
X
0
X
X
X
0
X
X
W
U
X
0
X
X
X
0
X
X
Z
0
X
X
X
L
0
0
0
0
0
0
0
0
0
H
U
X
0
1
X
X
0
1
X
U
X
0
X
X
X
0
X
X
0
0
1
X
X
Std_ulogic OR Table
OR
U
X
U
U
U
U
X
X
U
X
0
1
1
1
U
X
Z
U
X
W
U
X
L
1
1
H
U
X
-
1
1
1
1
1
0
U
X
0
1
X
X
0
1
X
1
1
1
1
1
1
1
1
1
1
X
X
1
X
X
Z
U
X
X
1
X
X
X
1
X
W
U
X
X
1
X
X
X
1
X
Z
X
1
X
X
L
U
X
0
1
X
X
0
1
X
H
1
1
1
1
1
1
1
1
1
U
X
X
1
X
X
X
1
X
If the bus is neither wired_and nor wired_or, such as wiring several signals into a common node. A new
two operand function called wire is defined:
TYPE qsim_2D IS ARRAY(qsim_state,qsim_state) OF qsim_state
FUNCTION wire (a,b:qsim_state) RETURN qsim_state IS
CONSTANT wire_table:qsim_2D:=(
(`0','X','X','0'),
(`X','1','X','1'),
(`X','X','X','X'),
(`0','1','X','Z'));
BEGIN
RETURN wire_table(a,b);
END wire;
Qsim WIRE Table
WIRE
0
0
0
X
1
X
X
0
Z
1
X
1
X
1
X
X
X
X
X
Z
0
1
X
Z
L
U
X
0
1
L
W
L
W
X
H
U
X
0
1
H
W
W
H
X
U
X
X
X
X
X
X
X
X
Interpretation of wire:
1.
2.
3.
IF the two inputs are equal, the wire value will be the same as the inputs.
wire(a,'Z')=a , wire(`Z',b)=b: Value `Z' on either of the inputs is absorbed by a stronger value (`0','1',
or`X').
wire(a,b)=X ,if a<>b and a<>'Z' and b<>'Z': conflicting non `Z' values on the inputs result in `X' value.
FUNCTION wiring(drivers:qsim_state_vector) RETURN qsim_state IS
VARIABLE temp: qsim_state:='Z';
BEGIN
FOR i IN drivers'RANGE LOOP
temp:=wire(temp,drivers(i));
END LOOP;
RETURN temp;
END wiring;
SIGNAL bus_wire:wiring qsim_state;
The corresponding resolving function of wiring in the 9-state logic system is given below:
FUNCTION resolved (s ; std_ulogic_vector) RETURN std_ulogic IS
VARIABLE result : std_ulogic := Z ; --weakest state default
BEGIN
--the test for a single driver is essential otherwise the
--loop would return X for a single driver of - and that
--would conflict with the value of a single driver unresolved signal.
IF (sLENGTH = 1) THEN RETURN s(sLOW);
ELSE
FOR i IN sRANGE LOOP
result := resolution_table(result, s(i));
END LOOP;
END IF;
RETURN result;
END resolved;
The above resolution function are best put in a design package inorder that they be available to all the
design entities. In addition, subtypes and types can be declared to handle line or bus contention that will
facilitate signal declaration that requires resolution function.
PACKAGE design_package IS
FUNCTION anding(drivers:qsim_state_vector)RETURN qsim_state;
SUBTYPE anded_qsim_state IS anding qsim_state; -- for resolving line drivers
TYPE anded_qsim_state_vector IS ARRAY(NATURAL RANGE<>) OF anded_qsim_state;
-- for resolving bus drivers
FUNCTION oring(drivers:qsim_state_vector)RETURN qsim_state;
SUBTYPE ored_qsim_state IS oring qsim_state;
TYPE ored_qsim_state_vector IS ARRAY(NATURAL RANGE<>) OF ored_qsim_state;
FUNCTION wiring(drivers:qsim_state_vector)RETURN qsim_state;
SUBTYPE wired_qsim_state IS wiring qsim_state;
TYPE wired_qsim_state_vector IS ARRAY(NATURAL RANGE<>) OF
wired_qsim_state ;
END design_package;
PACKAGE BODY design_package IS
FUNCTION anding(drivers:qsim_state_vector)RETURN qsim_state IS
VARIABLE temp:qsim_state:='1';
BEGIN
FOR i IN drivers'RANGE LOOP
temp:=temp AND drivers(i);
END LOOP;
RETURN temp;
END anding;
FUNCTION oring(drivers:qsim_state_vector)RETURN qsim_state IS
VARIABLE temp:qsim_state:='0';
BEGIN
FOR i IN drivers'RANGE LOOP
temp:=temp OR drivers(i);
END LOOP
RETURN temp;
END oring;
TYPE qsim_2D IS ARRAY(qsim_state,qsim_state) OF qsim_state
FUNCTION wire (a,b:qsim_state) RETURN qsim_state IS
CONSTANT wire_table:qsim_2D:=(
(`0','X','X','0'),
(`X','1','X','1'),
(`X','X','X','X),
(`0','1','X','Z'));
BEGIN
RETURN wire_table(a,b);
END wire;
FUNCTION wiring(drivers:qsim_state_vector) RETURN qsim_state IS
VARIABLE temp: qsim_state:='Z';
BEGIN
FOR i IN drivers'RANGE LOOP
temp:=wire(temp,drivers(i));
END LOOP;
10
RETURN temp;
END wiring;
END design_package;
Depending on the type of bus, they are declared accordingly:
SIGNAL bus_and : anded_qsim_state
--for wired_and bus
SIGNAL bus_or : ored_qsim_state --for wired_or bus
SIGNAL bus_wire: wired_qsim_state
--for wired bus
11
NOTE:
r1, r2 are wired_and bus with one driver. r3 is a wired_and bus with two drivers.
12
+5V
+5V
g1
x
r1
r3
g3
a(1)
c(1)
b(1)
x
y
a(3)
c(3)
xy
z =( x y ) ( x y )
b(3)
= x y+ x y
x
a(2)
c(2)
b(2)
g2
a(4)
c(4)
xy
b(4)
g4
r2
+5V
13
9.3.4
Tri-State Buffers
14
The block statement can be used to define tri-state logic. To synthesize tri-state devices, Autologic VHDL
utilizes the notions of disconnect, guarded assignments, and resolved bus signals. When the guard
expression of a bus signal is not true, the driver is disconnected from the target signal. This means that
other signals can drive the target, which requires a resolution function to resolve the value of the target. The
driving signal must be of the STD_LOGIC type. The resolved signal must be of signal kind bus.
The following illustrates the Autologic VHDL implementation of a single tri-state buffer:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY triout IS
PORT( oe : IN BIT; i : IN STD_LOGIC;
o : OUT STD_LOGIC BUS)
END triout;
ARCHITECTURE arch_triout IS
tri_out: BLOCK (oe =1)
BEGIN
o <= GUARDED i;
END BLOCK;
END arch_triout;
The following illustrates the CADENCE VHDL implementation of a single tri-state buffer:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY triout IS
PORT( oe : IN bit; i : IN STD_LOGIC; o : OUT STD_LOGIC BUS);
END triout;
15
The following is the Autologic VHDL implementation of a bank of four tri-state bufferes:
1
LIBRARY IEEE;
2
USE IEEE.STD_LOGIC_1164.ALL;
3
4
ENTITY tri_buf4 IS
5
PORT (oe : IN STD_LOGIC;
6
i : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
7
o : OUT STD_LOGIC_VECTOR(3 DOWNTO 0) BUS);
8
END tri_buf4;
9
10
ARCHITECTURE arch_tri_buf4 OF tri_buf4 IS
11
BEGIN
12
tri_out: BLOCK (oe = 1)
13
o <= GUARDED i;
14
END BLOCK tri_out;
END arch_tri_buf4;
The following is the CADENCE VHDL implementation of a bank of four tri-state bufferes:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY tri_buf4 IS
PORT( oe : IN bit; i : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
o : OUT STD_LOGIC_VECTOR(3 DOWNTO 0) BUS);
END tri_buf4;
ARCHITECTURE arch_tri_buf4 of tri_buf4 IS
BEGIN
process(oe,i)
begin
if oe='1' then
o<= i ;
else
o<= "ZZZZ" ;
end if;
end process;
END arch_tri_buf4;
16
If the target signal o was not defined as of kind BUS, a bank of four transparent latches is implemented
rather than a bank of four tri-state buffers.
17
18
ct
reg
wr
int_bus
data
rd
me m
A disconnection specification statement can be used to specify the disconnection delay for a guarded
signal within a guarded signal assignment. Such a statement contains the name of the signal, its type, and a
time expression that specifies the disconnection delay value. To delay the disconnection of the Int_bus
drivers, the following statement should be added to the declarative part of this architecture:
DISCONNECT Int_bus: STD_LOGIC AFTER 3 ns;
With the inclusion of this statement, if a Int_bus driver is turned off because its guard expression
becomes FALSE, the effect of this driver remains on Int_bus for 3 ns after it has been turned off. The
overall effect of this is that the output changes to `Z' 3 ns after the last source has been turned off.
Format:
DISCONNECT signal_name {,signal_name}:signal_name_type AFTER time_expression;
DISCONNECT OTHERS : signal_name_type AFTER time_expression;
DISCONNECT ALL: signal_name_type AFTER time_expression;
19
The ALL keyword used for the signal list implies that the disconnection specification applies to all
signals of the type specified.
If OTHERS is used in place of the signal list, the disconnection specification applies to signals of the
specified type for which disconnection has not been specified in the statements above this statement.
Example :
SIGNAL t: STD_LOGIC BUS; -- guarded signal declaration
DISCONNECT t: STD_LOGIC AFTER 10 ns; disconnection specification
There is a disconnection specification for every guarded signal, whether you explicitly define one or you
elect to use the implicit default. The default specification is:
DISCONNECT guarded_sig_name:guarded_sig_type AFTER 0 ns;
20