001.
library
IEEE
;
002.
use
IEEE.STD_LOGIC_1164.
all
;
003.
004.
package
UART_Components
is
005.
006.
function
I2SLV
(
val
,
width
:
integer
)
return
std_logic_vector
;
007.
function
SLV2I
(
val
:
std_logic_vector
)
return
integer
;
008.
010.
generic
(
Width
:
integer
:
=
8
)
;
011.
port
(
012.
AClr
:
in
std_logic
;
013.
Ck
:
in
std_logic
;
014.
WEn
:
in
std_logic
;
015.
OEn
:
in
std_logic
;
016.
ShEn
:
in
std_logic
;
017.
Cnt
:
in
std_logic
;
018.
SIn
:
in
std_logic
;
019.
D
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
020.
Q
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
021.
SOut
:
out
std_logic
022.
)
;
023.
end
component
;
024.
025.
component
BitPipe
is
026.
generic
(
Length
:
integer
:
=
2
)
;
027.
port
(
028.
Pr
:
in
std_logic
;
029.
Clr
:
in
std_logic
;
030.
Ck
:
in
std_logic
;
031.
D
:
in
std_logic
;
032.
Q
:
out
std_logic
033.
)
;
034.
end
component
;
035.
037.
generic
(
Width
:
integer
:
=
8
)
;
038.
port
(
039.
En
:
in
std_logic
;
040.
Dir
:
in
std_logic
;
041.
ChanA
:
inout
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
042.
ChanB
:
inout
std_logic_vector
(
(
Width
-
1
)
downto
0
)
043.
)
;
044.
end
component
;
045.
047.
generic
(
048.
Width
:
integer
:
=
8
;
049.
Value
:
integer
:
=
0
050.
)
;
051.
port
(
052.
Result
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
053.
)
;
054.
end
component
;
055.
057.
generic
(
Width
:
integer
:
=
8
)
;
058.
port
(
059.
Operand
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
060.
Result
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
061.
)
;
062.
end
component
;
063.
065.
generic
(
Width
:
integer
:
=
8
)
;
066.
port
(
067.
ChanA
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
068.
ChanB
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
069.
Result
:
out
std_logic
070.
)
;
071.
end
component
;
072.
074.
generic
(
Width
:
integer
:
=
8
)
;
075.
port
(
076.
ChanA
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
077.
ChanB
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
078.
Result
:
out
std_logic
079.
)
;
080.
end
component
;
081.
083.
generic
(
Width
:
integer
:
=
8
)
;
084.
port
(
085.
ChanA
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
086.
ChanB
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
087.
Result
:
out
std_logic
088.
)
;
089.
end
component
;
090.
092.
port
(
093.
Sel
:
in
std_logic
;
094.
ChanA
:
in
std_logic
;
095.
ChanB
:
in
std_logic
;
096.
Result
:
out
std_logic
097.
)
;
098.
end
component
;
099.
101.
port
(
102.
Sel
:
in
std_logic_vector
(
1
downto
0
)
;
103.
ChanA
:
in
std_logic
;
104.
ChanB
:
in
std_logic
;
105.
ChanC
:
in
std_logic
;
106.
ChanD
:
in
std_logic
;
107.
Result
:
out
std_logic
108.
)
;
109.
end
component
;
110.
111.
component
BusMux2
is
112.
generic
(
Width
:
integer
:
=
8
)
;
113.
port
(
114.
Sel
:
in
std_logic
;
115.
ChanA
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
116.
ChanB
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
117.
Result
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
118.
)
;
119.
end
component
;
120.
121.
component
BusMux4
is
122.
generic
(
Width
:
integer
:
=
8
)
;
123.
port
(
124.
Sel
:
in
std_logic_vector
(
1
downto
0
)
;
125.
ChanA
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
126.
ChanB
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
127.
ChanC
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
128.
ChanD
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
129.
Result
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
130.
)
;
131.
end
component
;
132.
134.
port
(
135.
Sel
:
in
std_logic
;
136.
Source
:
in
std_logic
;
137.
ChanA
:
out
std_logic
;
138.
ChanB
:
out
std_logic
139.
)
;
140.
end
component
;
141.
143.
port
(
144.
Sel
:
in
std_logic
;
145.
Source
:
in
std_logic
;
146.
ChanA
:
out
std_logic
;
147.
ChanB
:
out
std_logic
;
148.
ChanC
:
out
std_logic
;
149.
ChanD
:
out
std_logic
150.
)
;
151.
end
component
;
152.
153.
component
BusDeMux2
is
154.
generic
(
Width
:
integer
:
=
8
)
;
155.
port
(
156.
Sel
:
in
std_logic
;
157.
Source
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
158.
ChanA
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
159.
ChanB
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
160.
)
;
161.
end
component
;
162.
163.
component
BusDeMux4
is
164.
generic
(
Width
:
integer
:
=
8
)
;
165.
port
(
166.
Sel
:
in
std_logic
;
167.
Source
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
168.
ChanA
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
169.
ChanB
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
170.
ChanC
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
171.
ChanD
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
172.
)
;
173.
end
component
;
174.
175.
end
package
;
176.
177.
package
body
UART_Components
is
178.
179.
function
I2SLV
(
Val
,
Width
:
integer
)
return
std_logic_vector
is
180.
variable
Result
:
std_logic_vector
(
(
Width
-
1
)
downto
0
)
:
=
(
others
=
>
'
0
'
)
;
181.
variable
Bits
:
integer
:
=
Width
;
182.
begin
183.
184.
if
(
Bits
>
32
)
then
185.
Bits
:
=
32
;
186.
end
if
;
187.
188.
assert
2
*
*
Bits
>
Val
report
189.
"Value too big for std_logic_vector width"
190.
severity
Warning
;
191.
192.
for
i
in
0
to
(
Bits
-
1
)
loop
193.
194.
if
(
(
Val
/
(
2
*
*
i
)
)
mod
2
=
1
)
then
195.
196.
Result
(
i
)
:
=
'
1
'
;
197.
198.
end
if
;
199.
200.
end
loop
;
201.
202.
return
Result
;
203.
204.
end
function
;
205.
206.
function
SLV2I
(
val
:
std_logic_vector
)
return
integer
is
207.
variable
result
:
integer
:
=
0
;
208.
variable
count
:
integer
:
=
0
;
209.
begin
210.
211.
bits
:
for
i
in
val
'
low
to
val
'
high
loop
212.
213.
if
(
val
(
val
'
high
-
i
)
=
'
1
'
)
then
214.
215.
result
:
=
result
+
(
2
*
*
(
i
-
val
'
low
)
)
;
216.
217.
end
if
;
218.
219.
count
:
=
count
+
1
;
220.
221.
exit
bits
when
count
=
32
;
222.
223.
end
loop
bits
;
224.
225.
return
result
;
226.
227.
end
function
;
228.
229.
end
package
body
;
230.
231.
232.
233.
234.
235.
236.
237.
library
IEEE
;
238.
use
IEEE.STD_LOGIC_1164.
all
;
239.
use
IEEE.Numeric_Std.
all
;
240.
241.
entity
GenReg
is
242.
generic
(
Width
:
integer
:
=
8
)
;
243.
port
(
244.
AClr
:
in
std_logic
;
245.
Ck
:
in
std_logic
;
246.
WEn
:
in
std_logic
;
247.
OEn
:
in
std_logic
;
248.
ShEn
:
in
std_logic
;
249.
Cnt
:
in
std_logic
;
250.
SIn
:
in
std_logic
;
251.
D
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
252.
Q
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
253.
SOut
:
out
std_logic
254.
)
;
255.
end
entity
;
256.
257.
architecture
GenReg_A1
of
GenReg
is
258.
259.
signal
Buf
:
unsigned
(
(
Width
-
1
)
downto
0
)
;
260.
261.
begin
262.
263.
process
(
AClr
,
Ck
)
264.
begin
265.
266.
if
(
AClr
=
'
0
'
)
then
267.
268.
Buf
<
=
(
others
=
>
'
0
'
)
;
269.
270.
elsif
rising_edge
(
Ck
)
then
271.
272.
if
(
WEn
=
'
1
'
)
then
273.
274.
Buf
<
=
UNSIGNED
(
D
)
;
275.
276.
elsif
(
Cnt
=
'
1
'
)
then
277.
278.
Buf
<
=
Buf
+
1
;
279.
280.
elsif
(
ShEn
=
'
1
'
)
then
281.
282.
Buf
<
=
Buf
srl
1
;
283.
Buf
(
Width
-
1
)
<
=
SIn
;
284.
285.
end
if
;
286.
287.
end
if
;
288.
289.
end
process
;
290.
291.
SOut
<
=
Buf
(
0
)
;
292.
293.
294.
process
(
OEn
,
Buf
)
295.
begin
296.
297.
if
(
OEn
=
'
1
'
)
then
298.
299.
Q
<
=
std_logic_vector
(
Buf
)
;
300.
301.
else
302.
303.
Q
<
=
(
others
=
>
'
Z
'
)
;
304.
305.
end
if
;
306.
307.
end
process
;
308.
309.
end
architecture
;
310.
311.
312.
library
IEEE
;
313.
use
IEEE.STD_LOGIC_1164.
all
;
314.
315.
entity
BitPipe
is
316.
generic
(
Length
:
integer
:
=
2
)
;
317.
port
(
318.
Pr
:
in
std_logic
;
319.
Clr
:
in
std_logic
;
320.
Ck
:
in
std_logic
;
321.
D
:
in
std_logic
;
322.
Q
:
out
std_logic
323.
)
;
324.
end
entity
;
325.
326.
architecture
BitPipe_A1
of
BitPipe
is
327.
signal
Pipe
:
std_logic_vector
(
(
Length
-
1
)
downto
0
)
;
328.
begin
329.
330.
process
(
Pr
,
Clr
,
Ck
)
331.
begin
332.
333.
if
(
Pr
=
'
0
'
)
then
334.
335.
Pipe
<
=
(
others
=
>
'
1
'
)
;
336.
337.
elsif
(
Clr
=
'
0
'
)
then
338.
339.
Pipe
<
=
(
others
=
>
'
0
'
)
;
340.
341.
elsif
(
rising_edge
(
Ck
)
)
then
342.
343.
Pipe
(
Length
-
1
)
<
=
D
;
344.
345.
for
i
in
(
Length
-
2
)
downto
0
loop
346.
347.
Pipe
(
i
)
<
=
Pipe
(
i
+
1
)
;
348.
349.
end
loop
;
350.
351.
end
if
;
352.
353.
end
process
;
354.
355.
Q
<
=
Pipe
(
0
)
;
356.
357.
end
architecture
;
358.
359.
360.
library
IEEE
;
361.
use
IEEE.STD_LOGIC_1164.
all
;
362.
363.
entity
TriSt
is
364.
generic
(
Width
:
integer
:
=
8
)
;
365.
port
(
366.
En
:
in
std_logic
;
367.
Dir
:
in
std_logic
;
368.
ChanA
:
inout
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
369.
ChanB
:
inout
std_logic_vector
(
(
Width
-
1
)
downto
0
)
370.
)
;
371.
end
entity
;
372.
373.
architecture
TriSt_A1
of
TriSt
is
374.
begin
375.
376.
process
(
En
,
Dir
,
ChanA
,
ChanB
)
377.
begin
378.
379.
if
(
En
=
'
1
'
)
then
380.
381.
if
(
Dir
=
'
0
'
)
then
382.
383.
ChanB
<
=
ChanA
;
384.
385.
else
386.
387.
ChanA
<
=
ChanB
;
388.
389.
end
if
;
390.
391.
else
392.
393.
ChanA
<
=
(
others
=
>
'
Z
'
)
;
394.
ChanB
<
=
(
others
=
>
'
Z
'
)
;
395.
396.
end
if
;
397.
398.
end
process
;
399.
400.
end
architecture
;
401.
402.
403.
library
IEEE
;
404.
use
IEEE.STD_LOGIC_1164.
all
;
405.
use
work.UART_Components.
all
;
406.
407.
entity
Const
is
408.
generic
(
409.
Width
:
integer
:
=
8
;
410.
Value
:
integer
:
=
0
411.
)
;
412.
port
(
413.
Result
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
414.
)
;
415.
end
entity
;
416.
417.
architecture
Const_A1
of
Const
is
418.
constant
Cnst
:
std_logic_vector
(
(
Width
-
1
)
downto
0
)
:
=
I2SLV
(
Value
,
Width
)
;
419.
begin
420.
421.
Result
<
=
Cnst
;
422.
423.
end
architecture
;
424.
425.
426.
427.
library
IEEE
;
428.
use
IEEE.STD_LOGIC_1164.
all
;
429.
430.
entity
Div2
is
431.
generic
(
Width
:
integer
:
=
8
)
;
432.
port
(
433.
Operand
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
434.
Result
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
435.
)
;
436.
end
entity
;
437.
438.
architecture
DIV2_A1
of
Div2
is
439.
begin
440.
441.
process
(
Operand
)
442.
begin
443.
444.
Result
(
Width
-
1
)
<
=
'
0
'
;
445.
446.
for
i
in
(
Width
-
2
)
downto
0
loop
447.
448.
Result
(
i
)
<
=
Operand
(
i
+
1
)
;
449.
450.
end
loop
;
451.
452.
end
process
;
453.
454.
end
architecture
;
455.
456.
457.
library
IEEE
;
458.
use
IEEE.STD_LOGIC_1164.
all
;
459.
460.
entity
GEQ
is
461.
generic
(
Width
:
integer
:
=
8
)
;
462.
port
(
463.
ChanA
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
464.
ChanB
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
465.
Result
:
out
std_logic
466.
)
;
467.
end
entity
;
468.
469.
architecture
GEQ_A1
of
GEQ
is
470.
begin
471.
472.
process
(
ChanA
,
ChanB
)
473.
begin
474.
475.
if
(
ChanA
>
=
ChanB
)
then
476.
477.
Result
<
=
'
1
'
;
478.
479.
else
480.
481.
Result
<
=
'
0
'
;
482.
483.
end
if
;
484.
485.
end
process
;
486.
487.
end
architecture
;
488.
489.
490.
library
IEEE
;
491.
use
IEEE.STD_LOGIC_1164.
all
;
492.
493.
entity
GT
is
494.
generic
(
Width
:
integer
:
=
8
)
;
495.
port
(
496.
ChanA
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
497.
ChanB
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
498.
Result
:
out
std_logic
499.
)
;
500.
end
entity
;
501.
502.
architecture
GT_A1
of
GT
is
503.
begin
504.
505.
process
(
ChanA
,
ChanB
)
506.
begin
507.
508.
if
(
ChanA
>
ChanB
)
then
509.
510.
Result
<
=
'
1
'
;
511.
512.
else
513.
514.
Result
<
=
'
0
'
;
515.
516.
end
if
;
517.
518.
end
process
;
519.
520.
end
architecture
;
521.
522.
523.
library
IEEE
;
524.
use
IEEE.STD_LOGIC_1164.
all
;
525.
526.
entity
EQ
is
527.
generic
(
Width
:
integer
:
=
8
)
;
528.
port
(
529.
ChanA
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
530.
ChanB
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
531.
Result
:
out
std_logic
532.
)
;
533.
end
entity
;
534.
535.
architecture
EQ_A1
of
EQ
is
536.
begin
537.
538.
process
(
ChanA
,
ChanB
)
539.
begin
540.
541.
if
(
ChanA
=
ChanB
)
then
542.
543.
Result
<
=
'
1
'
;
544.
545.
else
546.
547.
Result
<
=
'
0
'
;
548.
549.
end
if
;
550.
551.
end
process
;
552.
553.
end
architecture
;
554.
555.
556.
library
IEEE
;
557.
use
IEEE.STD_LOGIC_1164.
all
;
558.
559.
entity
Mux2
is
560.
port
(
561.
Sel
:
in
std_logic
;
562.
ChanA
:
in
std_logic
;
563.
ChanB
:
in
std_logic
;
564.
Result
:
out
std_logic
565.
)
;
566.
end
entity
;
567.
568.
architecture
Mux2_A1
of
Mux2
is
569.
begin
570.
571.
process
(
Sel
,
ChanA
,
ChanB
)
572.
begin
573.
574.
case
(
Sel
)
is
575.
576.
when
'
0
'
=
>
577.
578.
Result
<
=
ChanA
;
579.
580.
when
'
1
'
=
>
581.
582.
Result
<
=
ChanB
;
583.
584.
when
others
=
>
585.
586.
Result
<
=
'
0
'
;
587.
588.
end
case
;
589.
590.
end
process
;
591.
592.
end
architecture
;
593.
594.
595.
library
IEEE
;
596.
use
IEEE.STD_LOGIC_1164.
all
;
597.
598.
entity
Mux4
is
599.
port
(
600.
Sel
:
in
std_logic_vector
(
1
downto
0
)
;
601.
ChanA
:
in
std_logic
;
602.
ChanB
:
in
std_logic
;
603.
ChanC
:
in
std_logic
;
604.
ChanD
:
in
std_logic
;
605.
Result
:
out
std_logic
606.
)
;
607.
end
entity
;
608.
609.
architecture
Mux4_A1
of
Mux4
is
610.
begin
611.
612.
process
(
Sel
,
ChanA
,
ChanB
,
ChanC
,
ChanD
)
613.
begin
614.
615.
case
(
Sel
)
is
616.
617.
when
"00"
=
>
618.
619.
Result
<
=
ChanA
;
620.
621.
when
"01"
=
>
622.
623.
Result
<
=
ChanB
;
624.
625.
when
"10"
=
>
626.
627.
Result
<
=
ChanC
;
628.
629.
when
"11"
=
>
630.
631.
Result
<
=
ChanD
;
632.
633.
when
others
=
>
634.
635.
Result
<
=
'
0
'
;
636.
637.
end
case
;
638.
639.
end
process
;
640.
641.
end
architecture
;
642.
643.
644.
library
IEEE
;
645.
use
IEEE.STD_LOGIC_1164.
all
;
646.
647.
entity
BusMux2
is
648.
generic
(
Width
:
integer
:
=
8
)
;
649.
port
(
650.
Sel
:
in
std_logic
;
651.
ChanA
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
652.
ChanB
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
653.
Result
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
654.
)
;
655.
end
entity
;
656.
657.
architecture
BusMux2_A1
of
BusMux2
is
658.
begin
659.
660.
process
(
Sel
,
ChanA
,
ChanB
)
661.
begin
662.
663.
case
(
Sel
)
is
664.
665.
when
'
0
'
=
>
666.
667.
Result
<
=
ChanA
;
668.
669.
when
'
1
'
=
>
670.
671.
Result
<
=
ChanB
;
672.
673.
when
others
=
>
674.
675.
Result
<
=
(
others
=
>
'
0
'
)
;
676.
677.
end
case
;
678.
679.
end
process
;
680.
681.
end
architecture
;
682.
683.
684.
library
IEEE
;
685.
use
IEEE.STD_LOGIC_1164.
all
;
686.
687.
entity
BusMux4
is
688.
generic
(
Width
:
integer
:
=
8
)
;
689.
port
(
690.
Sel
:
in
std_logic_vector
(
1
downto
0
)
;
691.
ChanA
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
692.
ChanB
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
693.
ChanC
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
694.
ChanD
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
695.
Result
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
696.
)
;
697.
end
entity
;
698.
699.
architecture
BusMux4_A1
of
BusMux4
is
700.
begin
701.
702.
process
(
Sel
,
ChanA
,
ChanB
,
ChanC
,
ChanD
)
703.
begin
704.
705.
case
(
Sel
)
is
706.
707.
when
"00"
=
>
708.
709.
Result
<
=
ChanA
;
710.
711.
when
"01"
=
>
712.
713.
Result
<
=
ChanB
;
714.
715.
when
"10"
=
>
716.
717.
Result
<
=
ChanC
;
718.
719.
when
"11"
=
>
720.
721.
Result
<
=
ChanD
;
722.
723.
when
others
=
>
724.
725.
Result
<
=
(
others
=
>
'
0
'
)
;
726.
727.
end
case
;
728.
729.
end
process
;
730.
731.
end
architecture
;
732.
733.
734.
library
IEEE
;
735.
use
IEEE.STD_LOGIC_1164.
all
;
736.
737.
entity
DeMux2
is
738.
port
(
739.
Sel
:
in
std_logic
;
740.
Source
:
in
std_logic
;
741.
ChanA
:
out
std_logic
;
742.
ChanB
:
out
std_logic
743.
)
;
744.
end
entity
;
745.
746.
architecture
DeMux2_A1
of
DeMux2
is
747.
begin
748.
749.
process
(
Sel
,
Source
)
750.
begin
751.
752.
case
(
Sel
)
is
753.
754.
when
'
0
'
=
>
755.
756.
ChanA
<
=
Source
;
757.
ChanB
<
=
'
0
'
;
758.
759.
when
'
1
'
=
>
760.
761.
ChanA
<
=
'
0
'
;
762.
ChanB
<
=
Source
;
763.
764.
when
others
=
>
765.
766.
ChanA
<
=
'
0
'
;
767.
ChanB
<
=
'
0
'
;
768.
769.
end
case
;
770.
771.
end
process
;
772.
773.
end
architecture
;
774.
775.
776.
library
IEEE
;
777.
use
IEEE.STD_LOGIC_1164.
all
;
778.
779.
entity
DeMux4
is
780.
port
(
781.
Sel
:
in
std_logic_vector
(
1
downto
0
)
;
782.
Source
:
in
std_logic
;
783.
ChanA
:
out
std_logic
;
784.
ChanB
:
out
std_logic
;
785.
ChanC
:
out
std_logic
;
786.
ChanD
:
out
std_logic
787.
)
;
788.
end
entity
;
789.
790.
architecture
DeMux4_A1
of
DeMux4
is
791.
begin
792.
793.
process
(
Sel
,
Source
)
794.
begin
795.
796.
case
(
Sel
)
is
797.
798.
when
"00"
=
>
799.
800.
ChanA
<
=
Source
;
801.
ChanB
<
=
'
0
'
;
802.
ChanC
<
=
'
0
'
;
803.
ChanD
<
=
'
0
'
;
804.
805.
when
"01"
=
>
806.
807.
ChanA
<
=
'
0
'
;
808.
ChanB
<
=
Source
;
809.
ChanC
<
=
'
0
'
;
810.
ChanD
<
=
'
0
'
;
811.
812.
when
"10"
=
>
813.
814.
ChanA
<
=
'
0
'
;
815.
ChanB
<
=
'
0
'
;
816.
ChanC
<
=
Source
;
817.
ChanD
<
=
'
0
'
;
818.
819.
when
"11"
=
>
820.
821.
ChanA
<
=
'
0
'
;
822.
ChanB
<
=
'
0
'
;
823.
ChanC
<
=
'
0
'
;
824.
ChanD
<
=
Source
;
825.
826.
827.
when
others
=
>
828.
829.
ChanA
<
=
'
0
'
;
830.
ChanB
<
=
'
0
'
;
831.
ChanC
<
=
'
0
'
;
832.
ChanD
<
=
'
0
'
;
833.
834.
end
case
;
835.
836.
end
process
;
837.
838.
end
architecture
;
839.
840.
841.
library
IEEE
;
842.
use
IEEE.STD_LOGIC_1164.
all
;
843.
844.
entity
BusDeMux2
is
845.
generic
(
Width
:
integer
:
=
8
)
;
846.
port
(
847.
Sel
:
in
std_logic
;
848.
Source
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
849.
ChanA
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
850.
ChanB
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
851.
)
;
852.
end
entity
;
853.
854.
architecture
BusDeMux2_A1
of
BusDeMux2
is
855.
begin
856.
857.
process
(
Sel
,
Source
)
858.
begin
859.
860.
case
(
Sel
)
is
861.
862.
when
'
0
'
=
>
863.
864.
ChanA
<
=
Source
;
865.
ChanB
<
=
(
others
=
>
'
0
'
)
;
866.
867.
when
'
1
'
=
>
868.
869.
ChanA
<
=
(
others
=
>
'
0
'
)
;
870.
ChanB
<
=
Source
;
871.
872.
when
others
=
>
873.
874.
ChanA
<
=
(
others
=
>
'
0
'
)
;
875.
ChanB
<
=
(
others
=
>
'
0
'
)
;
876.
877.
end
case
;
878.
879.
end
process
;
880.
881.
end
architecture
;
882.
883.
884.
library
IEEE
;
885.
use
IEEE.STD_LOGIC_1164.
all
;
886.
887.
entity
BusDeMux4
is
888.
generic
(
Width
:
integer
:
=
8
)
;
889.
port
(
890.
Sel
:
in
std_logic_vector
(
1
downto
0
)
;
891.
Source
:
in
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
892.
ChanA
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
893.
ChanB
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
894.
ChanC
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
;
895.
ChanD
:
out
std_logic_vector
(
(
Width
-
1
)
downto
0
)
896.
)
;
897.
end
entity
;
898.
899.
architecture
BusDeMux4_A1
of
BusDeMux4
is
900.
begin
901.
902.
process
(
Sel
,
Source
)
903.
begin
904.
905.
case
(
Sel
)
is
906.
907.
when
"00"
=
>
908.
909.
ChanA
<
=
Source
;
910.
ChanB
<
=
(
others
=
>
'
0
'
)
;
911.
ChanC
<
=
(
others
=
>
'
0
'
)
;
912.
ChanD
<
=
(
others
=
>
'
0
'
)
;
913.
914.
when
"01"
=
>
915.
916.
ChanA
<
=
(
others
=
>
'
0
'
)
;
917.
ChanB
<
=
Source
;
918.
ChanC
<
=
(
others
=
>
'
0
'
)
;
919.
ChanD
<
=
(
others
=
>
'
0
'
)
;
920.
921.
when
"10"
=
>
922.
923.
ChanA
<
=
(
others
=
>
'
0
'
)
;
924.
ChanB
<
=
(
others
=
>
'
0
'
)
;
925.
ChanC
<
=
Source
;
926.
ChanD
<
=
(
others
=
>
'
0
'
)
;
927.
928.
when
"11"
=
>
929.
930.
ChanA
<
=
(
others
=
>
'
0
'
)
;
931.
ChanB
<
=
(
others
=
>
'
0
'
)
;
932.
ChanC
<
=
(
others
=
>
'
0
'
)
;
933.
ChanD
<
=
Source
;
934.
935.
936.
when
others
=
>
937.
938.
ChanA
<
=
(
others
=
>
'
0
'
)
;
939.
ChanB
<
=
(
others
=
>
'
0
'
)
;
940.
ChanC
<
=
(
others
=
>
'
0
'
)
;
941.
ChanD
<
=
(
others
=
>
'
0
'
)
;
942.
943.
end
case
;
944.
945.
end
process
;
946.
947.
end
architecture
;