Файл: Digital design with CPLD applications and VHDL (R. Dueck, 2000).pdf
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 13.06.2025
Просмотров: 8134
Скачиваний: 6
188 |
C H A P T E R 5 • Combinational Logic Functions |
||
ENTITY mux4 IS |
|||
PORT( |
|||
d0, d1, d2, d3 : IN |
BIT; |
||
s |
: IN |
BIT_VECTOR (1 downto 0); |
|
y |
: OUT |
BIT); |
|
END mux4; |
|||
ARCHITECTURE mux4to1 OF mux4 IS
BEGIN
——Concurrent Signal Assignment
y<= ((not s(1)) and (not s(0)) and d0)
or ((not |
s(1)) and ( |
s(0)) and d1) |
|
or (( |
s(1)) and (not |
s(0)) and |
d2) |
or (( |
s(1)) and ( |
s(0)) and |
d3); |
END mux4to1;
While the concurrent signal assignment is fairly easy to use, it becomes cumbersome for larger multiplexers, such as 8-to-1 or greater.
The entity declaration will be identical for the other VHDL examples. The only change we will make will be to replace the concurrent signal assignment in the architecture body with some other VHDL construct.
Selected Signal Assignment Statement
This construct has the following form (the label is optional):
__label:
WITH __expression SELECT
__signal <= |
__expression WHEN __constant_value, |
__expression WHEN __constant_value, |
|
__expression WHEN __constant_value, |
|
__expression WHEN __constant_value; |
The 4-to-1 MUX can be described in VHDL as follows, using a selected signal assignment:
mux4sel IS |
||||
mux4sel.vhd |
d0, d1, d2, d3 : IN |
BIT; |
||
s |
: IN |
BIT_VECTOR (1 downto 0); |
||
y |
: OUT |
BIT); |
||
END mux4sel; |
||||
ARCHITECTURE mux4to1 OF mux4sel IS
BEGIN
M:WITH s SELECT
y <= d0 WHEN “00”,
d1 |
WHEN “01”, |
|
d2 |
WHEN |
“10”, |
d3 |
WHEN |
“11”; |
END mux4to1;
The selected signal assignment evaluates the expression in the WITH clause (in this case, the 2-bit vector, s) and, depending on its value, selects an expression to assign to y. Thus, if s1s0 00, y d0. If s1s0 01, then y d1, and so on for the remaining values of s1s0.
5.3 • Multiplexers |
189 |
CASE Statement within a PROCESS
In our MUX example, we could use a CASE statement as follows:
mux4case.vhd
s |
: IN |
BIT_VECTOR (1 downto 0); |
y |
: OUT |
BIT); |
END mux4case; |
ARCHITECTURE mux4to1 OF mux4case IS
BEGIN
——CASE statement within a PROCESS
——Monitor select inputs and execute if they change PROCESS (s)
BEGIN
CASE s IS
WHEN “00” |
=> |
y |
<= |
d0; |
WHEN “01” |
=> |
y |
<= |
d1; |
WHEN “10” |
=> |
y |
<= |
d2; |
WHEN “11” |
=> |
y |
<= |
d3; |
WHEN others |
=> |
y |
<= |
‘0’; |
END CASE; |
||||
END PROCESS; |
||||
END mux4to1; |
If the select inputs change, the PROCESS statements are executed. The CASE statement evaluates the select input vector, s, and chooses a signal assignment based on its value. It is good design practice to include a default case (the “others” clause) even when there are no obvious other cases. A default case is essential when using STD_LOGIC types rather than BIT types, as ‘0’ and ‘1’ values do not cover all possible cases for STD LOGIC signals. (Recall from Chapter 4 that STD_LOGIC is a nine-valued logic type, incorporating such things as “Don’t Care” (‘-’), “Unknown” (‘X’), and “High Impedance” (‘Z’), as well as ‘0’ and ‘1’.)
Multiplexer Applications |
|
Multiplexers are used for a variety of applications, including selection of one data stream |
|
out of several choices, switching multiple-bit data from several channels to one multiple- |
|
bit output, sharing data on one output over time, and generating bit patterns or waveforms. |
|
Single-Channel Data Selection |
|
The simplest way to use a multiplexer is to switch the select inputs manually in order to di- |
|
rect one data source to the MUX output. Example 5.6 shows a pair of single-pole single- |
|
throw (SPST) switches supplying the select input logic for this type of application. |
|
5.6 |
Figure 5.38 shows a digital audio switching system. The system shown can select a signal |
from one of four sources (compact disc (CD) players, labelled CD0 to CD3) and direct it to |
|
a digital signal processor (DSP) at its output. We assume we have direct access to the au- |
|
dio signals in digital form. |
|
Make a table listing which digital audio source in Figure 5.38 is routed to the DSP for |
|
each combination of the multiplexer select inputs, S1 and S0. |