/
am2909-12.vhd
104 lines (92 loc) · 1.92 KB
/
am2909-12.vhd
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
-- VERSION: 1.0
-- MODULE: am2909
-- 13/1/2010
-- ************************************************************
-- Copyright (C) Stanisalw Deniziak, modified by zpekic@hotmail.com
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity am2909x12 is
port
(
-- Input ports
S : in std_logic_vector(1 downto 0);
R,D : in std_logic_vector(11 downto 0);
ORi : in std_logic_vector(11 downto 0);
nFE, PUP, nRE , nZERO, nOE, CN : in std_logic;
CLK : in std_logic;
-- Output ports
Y : out std_logic_vector(11 downto 0);
C4 : out std_logic
);
end am2909x12;
architecture RTL of am2909x12 is
signal XX, AR, F, PC, YY : std_logic_vector(11 downto 0);
begin
Sel: process (S, AR, F, PC, D)
begin
case S(1 downto 0) is
when "00" =>
XX <= PC;
when "01" =>
XX <= AR;
when "10" =>
XX <= F;
when "11" =>
XX <= D;
when others =>
null;
end case;
end process;
stos: process (CLK)
variable STK0, STK1, STK2, STK3: std_logic_vector(11 downto 0);
begin
if (rising_edge(clk)) then
if (nFE = '0') then
if PUP = '0' then
STK0 := STK1;
STK1 := STK2;
STK2 := STK3;
else
STK3 := STK2;
STK2 := STK1;
STK1 := STK0;
STK0 := PC;
end if;
end if;
end if;
F <= STK0;
end process;
AReg: process (clk)
begin
if (rising_edge(clk)) then
if nRE = '0' then
AR <= R;
end if;
end if;
end process;
uPC: process (CLK, YY, CN)
variable res : std_logic_vector(13 downto 0);
variable PCint : std_logic_vector(13 downto 0);
begin
PCint := '0' & YY & CN;
res := std_logic_vector(unsigned(PCint) + 1);
C4 <= res(13);
if (rising_edge(clk)) then
PC <= res(12 downto 1);
end if;
end process;
output: process (nOE, nZERO, XX, ORi, YY)
begin
if (nZERO = '0') then
YY <= "000000000000";
else
YY <= XX or ORi;
end if;
if (nOE = '0') then
Y <= YY;
else
Y <= "ZZZZZZZZZZZZ";
end if;
end process;
end RTL;