OpenCores
URL https://opencores.org/ocsvn/am9080_cpu_based_on_microcoded_am29xx_bit-slices/am9080_cpu_based_on_microcoded_am29xx_bit-slices/trunk

Subversion Repositories am9080_cpu_based_on_microcoded_am29xx_bit-slices

[/] [am9080_cpu_based_on_microcoded_am29xx_bit-slices/] [trunk/] [Am9080/] [Am29XX/] [Am2901c.vhd] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 zpekic
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    00:52:57 01/01/2018 
6
-- Design Name: 
7
-- Module Name:    Am2901c - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
 
23
-- Uncomment the following library declaration if using
24
-- arithmetic functions with Signed or Unsigned values
25
use IEEE.NUMERIC_STD.ALL;
26
 
27
-- Uncomment the following library declaration if instantiating
28
-- any Xilinx primitives in this code.
29
--library UNISIM;
30
--use UNISIM.VComponents.all;
31
 
32
entity Am2901c is
33
    Port ( clk : in  STD_LOGIC;
34
           --rst : in  STD_LOGIC;
35
           a : in  STD_LOGIC_VECTOR (3 downto 0);
36
           b : in  STD_LOGIC_VECTOR (3 downto 0);
37
           d : in  STD_LOGIC_vector (3 downto 0);
38
           i : in  STD_LOGIC_VECTOR (8 downto 0);
39
           c_n : in  STD_LOGIC;
40
           oe : in  STD_LOGIC;
41
           ram0 : inout  STD_LOGIC;
42
           ram3 : inout  STD_LOGIC;
43
           qs0 : inout  STD_LOGIC;
44
           qs3 : inout  STD_LOGIC;
45
           y : out  STD_LOGIC_VECTOR (3 downto 0);
46
           g_bar : out  STD_LOGIC;
47
           p_bar : out  STD_LOGIC;
48
           ovr : out  STD_LOGIC;
49
           c_n4 : out  STD_LOGIC;
50
           f_0 : out  STD_LOGIC;
51
           f3 : out  STD_LOGIC);
52
end Am2901c;
53
 
54
architecture Behavioral of Am2901c is
55
 
56
---             I210    I543            I876
57
---             SRC     FCT             DST ---
58
constant aq,    add,            qreg: std_logic_vector(2 downto 0) :="000";
59
constant ab,    subr,           nop: std_logic_vector(2 downto 0) :="001";
60
constant zq,    subs,           rama: std_logic_vector(2 downto 0) :="010";
61
constant zb,    orrs,           ramf: std_logic_vector(2 downto 0) :="011";
62
constant za,    andrs,  ramqd: std_logic_vector(2 downto 0) :="100";
63
constant da,    notrs,  ramd: std_logic_vector(2 downto 0) :="101";
64
constant dq,    exor,           ramqu : std_logic_vector(2 downto 0) :="110";
65
constant dz,    exnor,  ramu: std_logic_vector(2 downto 0) :="111";
66
 
67
alias src: std_logic_vector(2 downto 0) is i(2 downto 0);
68
alias fct: std_logic_vector(2 downto 0) is i(5 downto 3);
69
alias dst: std_logic_vector(2 downto 0) is i(8 downto 6);
70
signal r1, r1c, s1, nr1c, ns1c, f1: STD_LOGIC_VECTOR (5 downto 0);
71
signal f, a_latch, b_latch, r, s, y_int: std_logic_vector(3 downto 0);
72
 
73
signal q: std_logic_vector(3 downto 0);
74
type ram_array is array(0 to 15) of std_logic_vector (3 downto 0);
75
signal ram: ram_array;
76
 
77
begin
78
-- REGISTERS ---
79
update_ram: process(clk, dst, ram3, ram0)
80
begin
81
        if (rising_edge(clk)) then
82
                case dst is
83
                        when rama | ramf =>
84
                                ram(to_integer(unsigned(b))) <= f;
85
                        when ramqd | ramd =>
86
                                ram(to_integer(unsigned(b))) <= ram3 & f(3) & f(2) & f(1);
87
                        when ramqu | ramu =>
88
                                ram(to_integer(unsigned(b))) <= f(2) & f(1) & f(0) & ram0;
89
                        when others =>
90
                                null;
91
                end case;
92
        end if;
93
end process;
94
 
95
update_q: process(clk, dst, qs3, qs0)
96
begin
97
        if (rising_edge(clk)) then
98
                case dst is
99
                        when qreg =>
100
                                q <= f;
101
                        when ramqd =>
102
                                q <= qs3 & q(3) & q(2) & q(1);
103
                        when ramqu =>
104
                                q <= q(2) & q(1) & q(0) & qs0;
105
                        when others =>
106
                                null;
107
                end case;
108
        end if;
109
end process;
110
 
111
a_latch <= ram(to_integer(unsigned(a))) when (clk = '1') else a_latch;
112
b_latch <= ram(to_integer(unsigned(b))) when (clk = '1') else b_latch;
113
 
114
--- ALU SOURCES ---
115
 with src select
116
    r <= a_latch when aq | ab,
117
              "0000" when zq | zb | za,
118
                   d when others;
119
 
120
 with src select
121
    s <= q when aq | zq | dq,
122
         b_latch when  ab | zb,
123
         a_latch when za | da,
124
         "0000" when others;
125
 
126
-- ALU FUNCTIONS ---             
127
r1 <=   ('0', r(3),              r(2),            r(1),    r(0),     c_n);
128
r1c <=  ('0', r(3),              r(2),            r(1),    r(0),     c_n);
129
nr1c <= ('0', not r(3), not r(2), not r(1), not r(0), c_n);
130
 
131
s1 <=   ('0', s(3),              s(2),            s(1),          s(0),     c_n);
132
ns1c <= ('0', not s(3), not s(2), not s(1),      not s(0), c_n);
133
 
134
alu: process (r1, r1c, s1, nr1c, ns1c, fct)
135
begin
136
   case fct is
137
      when add =>
138
                        f1 <= std_logic_vector(unsigned(r1c) + unsigned(s1));
139
      when subr => ---subtraction same as 2's comp addn
140
                   f1 <= std_logic_vector(unsigned(s1) + unsigned(nr1c));
141
      when subs =>
142
                        f1 <= std_logic_vector(unsigned(r1) + unsigned(ns1c));
143
      when orrs =>
144
                        f1 <= r1 or s1;
145
      when andrs =>
146
                        f1 <= r1 and s1;
147
      when notrs =>
148
                        f1 <= (not r1) and s1;
149
      when exor =>
150
                        f1 <= r1 xor s1;
151
      when exnor =>
152
                        f1 <= not(r1 xor s1);
153
      when others =>
154
                        null;
155
 end case;
156
end process;
157
 
158
--- INTERNAL OUTPUTS --
159
f <= f1(4 downto 1);
160
y_int <= a_latch when (dst = rama) else f;
161
 
162
--- INPUTS & OUTPUTS ---
163
with dst select
164
        ram0 <= f(0) when ramqd | ramd, 'Z' when others;
165
 
166
with dst select
167
        ram3 <= f(3) when ramqu | ramu, 'Z' when others;
168
 
169
with dst select
170
        qs0 <= q(0) when ramqd, 'Z' when others;
171
 
172
with dst select
173
        qs3 <= q(3) when ramqu, 'Z' when others;
174
 
175
--- OUTPUTS ---
176
c_n4 <= f1(5);
177
 
178
f_0 <= '1' when f = "0000" else '0'; -- not that these are "strong" signals, not open collector
179
 
180
f3  <= f(3);
181
 
182
g_bar <= not(
183
   (r(3) and s(3)) or
184
    ((r(3) or s(3)) and (r(2) and s(2))) or
185
         ((r(3) or s(3)) and (r(2) or s(2)) and (r(1) and s(1))) or
186
    ((r(3) or s(3)) and (r(2) or s(2)) and (r(1) or s(1)) and
187
    (r(0) and s(0))));
188
p_bar <= not(
189
    (r(3) or s(3)) and (r(2) or s(2)) and (r(1) and s(1)) and
190
    (r(0) and s(0)));
191
 
192
ovr <= f1(5) xor f1(4); --'1' when (f1(5) /= f1(4)) else '0';
193
 
194
y <= y_int when (oe = '0') else "ZZZZ";
195
 
196
end Behavioral;
197
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.