1 |
2 |
Valerio63 |
library IEEE;
|
2 |
|
|
use IEEE.std_logic_1164.all; -- defines std_logic types
|
3 |
|
|
use IEEE.STD_LOGIC_unsigned.all;
|
4 |
|
|
use IEEE.STD_LOGIC_arith.all;
|
5 |
|
|
|
6 |
|
|
-- 8 bit seven-way multiplexer
|
7 |
|
|
entity regmux is
|
8 |
|
|
port( sel: in STD_LOGIC_VECTOR(4 downto 0);
|
9 |
|
|
a: in STD_LOGIC_VECTOR(7 downto 0);
|
10 |
|
|
b: in STD_LOGIC_VECTOR(15 downto 0);
|
11 |
|
|
c: in STD_LOGIC_VECTOR(15 downto 0);
|
12 |
|
|
d: in STD_LOGIC_VECTOR(15 downto 0);
|
13 |
|
|
e: in STD_LOGIC_VECTOR(15 downto 0);
|
14 |
|
|
g: in STD_LOGIC_VECTOR(7 downto 0);
|
15 |
|
|
h: in STD_LOGIC_VECTOR(7 downto 0);
|
16 |
|
|
i: in STD_LOGIC_VECTOR(7 downto 0);
|
17 |
|
|
j: in STD_LOGIC_VECTOR(15 downto 0);
|
18 |
|
|
k: in STD_LOGIC_VECTOR(15 downto 0);
|
19 |
|
|
l: in STD_LOGIC_VECTOR(7 downto 0);
|
20 |
|
|
m: in STD_LOGIC_VECTOR(7 downto 0);
|
21 |
|
|
y: out STD_LOGIC_VECTOR(15 downto 0)
|
22 |
|
|
);
|
23 |
|
|
end regmux;
|
24 |
|
|
|
25 |
|
|
architecture comb of regmux is
|
26 |
|
|
constant EXT_O: STD_LOGIC_VECTOR(4 downto 0) := "00000"; -- external data bus
|
27 |
|
|
constant ARD_O: STD_LOGIC_VECTOR(4 downto 0) := "00001"; -- register C msb & lsb select
|
28 |
|
|
constant ARM_O: STD_LOGIC_VECTOR(4 downto 0) := "00010"; -- register C msb select (also returns C swapped)
|
29 |
|
|
constant XRD_O: STD_LOGIC_VECTOR(4 downto 0) := "00011"; -- register X msb & lsb select
|
30 |
|
|
constant XRM_O: STD_LOGIC_VECTOR(4 downto 0) := "00100"; -- register X msb select
|
31 |
|
|
constant YRD_O: STD_LOGIC_VECTOR(4 downto 0) := "00101"; -- register Y msb & lsb select
|
32 |
|
|
constant YRM_O: STD_LOGIC_VECTOR(4 downto 0) := "00110"; -- register Y msb select
|
33 |
|
|
constant SRD_O: STD_LOGIC_VECTOR(4 downto 0) := "00111"; -- register S lsb select
|
34 |
|
|
constant PRD_O: STD_LOGIC_VECTOR(4 downto 0) := "01000"; -- register P select
|
35 |
|
|
constant PLR_O: STD_LOGIC_VECTOR(4 downto 0) := "01001"; -- register PCL select
|
36 |
|
|
constant PHR_O: STD_LOGIC_VECTOR(4 downto 0) := "01010"; -- register PCH select
|
37 |
|
|
constant ORD_O: STD_LOGIC_VECTOR(4 downto 0) := "01011"; -- register O msb & lsb select
|
38 |
|
|
constant Z00_O: STD_LOGIC_VECTOR(4 downto 0) := "01100"; -- select (all zero output)
|
39 |
|
|
constant DRD_O: STD_LOGIC_VECTOR(4 downto 0) := "01101"; -- register D msb & lsb select
|
40 |
|
|
constant DRM_O: STD_LOGIC_VECTOR(4 downto 0) := "01110"; -- register D msb select
|
41 |
|
|
constant KRD_O: STD_LOGIC_VECTOR(4 downto 0) := "01111"; -- register K PBR
|
42 |
|
|
constant BRD_O: STD_LOGIC_VECTOR(4 downto 0) := "10000"; -- register B PBR
|
43 |
|
|
constant EXM_O: STD_LOGIC_VECTOR(4 downto 0) := "10001"; -- external data bus on MSB, O on lsb
|
44 |
|
|
constant OMD_O: STD_LOGIC_VECTOR(4 downto 0) := "10010"; -- register O msb select
|
45 |
|
|
constant PCR_O: STD_LOGIC_VECTOR(4 downto 0) := "10011"; -- register PC (16 bit) select
|
46 |
|
|
|
47 |
|
|
begin
|
48 |
|
|
process(sel,a,b,c,d,e,g,h,i,j,k,l,m)
|
49 |
|
|
begin
|
50 |
|
|
case sel is
|
51 |
|
|
when EXT_O => y(7 downto 0) <= a;
|
52 |
|
|
y(15 downto 8) <= (others => '0');
|
53 |
|
|
when EXM_O => y(15 downto 8) <= a;
|
54 |
|
|
y(7 downto 0) <= j(7 downto 0);
|
55 |
|
|
when ARD_O => y <= b;
|
56 |
|
|
when ARM_O => y(7 downto 0) <= b(15 downto 8);
|
57 |
|
|
y(15 downto 8) <= b(7 downto 0);
|
58 |
|
|
when XRD_O => y <= c;
|
59 |
|
|
when XRM_O => y(7 downto 0) <= c(15 downto 8);
|
60 |
|
|
y(15 downto 8) <= (others => '0');
|
61 |
|
|
when YRD_O => y <= d;
|
62 |
|
|
when YRM_O => y(7 downto 0) <= d(15 downto 8);
|
63 |
|
|
y(15 downto 8) <= (others => '0');
|
64 |
|
|
when SRD_O => y <= e;
|
65 |
|
|
when PRD_O => y(7 downto 0) <= g;
|
66 |
|
|
y(15 downto 8) <= (others => '0');
|
67 |
|
|
when PLR_O => y(7 downto 0) <= h;
|
68 |
|
|
y(15 downto 8) <= (others => '0');
|
69 |
|
|
when PHR_O => y(7 downto 0) <= i;
|
70 |
|
|
y(15 downto 8) <= (others => '0');
|
71 |
|
|
when ORD_O => y <= j;
|
72 |
|
|
when Z00_O => y <= (others => '0');
|
73 |
|
|
when DRD_O => y <= k;
|
74 |
|
|
when DRM_O => y(7 downto 0) <= k(15 downto 8);
|
75 |
|
|
y(15 downto 8) <= (others => '0');
|
76 |
|
|
when KRD_O => y(7 downto 0) <= l;
|
77 |
|
|
y(15 downto 8) <= (others => '0');
|
78 |
|
|
when BRD_O => y(7 downto 0) <= m;
|
79 |
|
|
y(15 downto 8) <= (others => '0');
|
80 |
|
|
when OMD_O => y(7 downto 0) <= j(15 downto 8);
|
81 |
|
|
y(15 downto 8) <= (others => '0');
|
82 |
|
|
when PCR_O => y(7 downto 0) <= h;
|
83 |
|
|
y(15 downto 8) <= i;
|
84 |
|
|
when others => y(7 downto 0) <= a;
|
85 |
|
|
y(15 downto 8) <= (others => '0');
|
86 |
|
|
end case;
|
87 |
|
|
end process;
|
88 |
|
|
end comb;
|
89 |
|
|
|
90 |
|
|
|