1 |
24 |
fpga_is_fu |
LIBRARY ieee;
|
2 |
|
|
USE ieee.std_logic_1164.all;
|
3 |
|
|
USE ieee.std_logic_arith.all;
|
4 |
|
|
|
5 |
|
|
entity reg_pc is
|
6 |
|
|
port(
|
7 |
|
|
adr_i : in std_logic_vector (15 downto 0);
|
8 |
|
|
clk_clk_i : in std_logic;
|
9 |
|
|
ld_i : in std_logic_vector (1 downto 0);
|
10 |
|
|
ld_pc_i : in std_logic;
|
11 |
|
|
offset_i : in std_logic_vector (15 downto 0);
|
12 |
|
|
rst_rst_n_i : in std_logic;
|
13 |
|
|
sel_pc_in_i : in std_logic;
|
14 |
|
|
sel_pc_val_i : in std_logic_vector (1 downto 0);
|
15 |
|
|
adr_nxt_pc_o : out std_logic_vector (15 downto 0);
|
16 |
|
|
adr_pc_o : out std_logic_vector (15 downto 0)
|
17 |
|
|
);
|
18 |
|
|
|
19 |
|
|
-- Declarations
|
20 |
|
|
|
21 |
|
|
end reg_pc ;
|
22 |
|
|
-- (C) 2008 - 2021 Jens Gutschmidt
|
23 |
|
|
-- (email: opencores@vivare-services.com)
|
24 |
|
|
--
|
25 |
|
|
-- Versions:
|
26 |
|
|
-- Revision 1.7 2013/07/21 11:11:00 jens
|
27 |
|
|
-- - Changing the title block and internal revision history
|
28 |
|
|
--
|
29 |
|
|
-- Revision 1.6 2009/01/04 10:20:47 eda
|
30 |
|
|
-- Changes for cosmetic issues only
|
31 |
|
|
--
|
32 |
|
|
-- Revision 1.5 2009/01/04 09:23:10 eda
|
33 |
|
|
-- - Delete unused nets and blocks (same as R6502_TC)
|
34 |
|
|
-- - Rename blocks
|
35 |
|
|
--
|
36 |
|
|
-- Revision 1.4 2009/01/03 16:53:02 eda
|
37 |
|
|
-- - Unused nets and blocks deleted
|
38 |
|
|
-- - Renamed blocks
|
39 |
|
|
--
|
40 |
|
|
-- Revision 1.3 2009/01/03 16:42:02 eda
|
41 |
|
|
-- - Unused nets and blocks deleted
|
42 |
|
|
-- - Renamed blocks
|
43 |
|
|
--
|
44 |
|
|
-- Revision 1.2 2008/12/31 19:31:24 eda
|
45 |
|
|
-- Production Release
|
46 |
|
|
--
|
47 |
|
|
--
|
48 |
|
|
--
|
49 |
|
|
-- r65c02_tc.reg_pc.struct
|
50 |
|
|
--
|
51 |
|
|
-- Date: 09.01.2021
|
52 |
|
|
-- Time: 16:56:45
|
53 |
|
|
-- By: VIVARE GmbH, Switzerland
|
54 |
|
|
--
|
55 |
|
|
-- COPYRIGHT (C) 2008 - 2021 by Jens Gutschmidt
|
56 |
|
|
--
|
57 |
|
|
-- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
|
58 |
|
|
--
|
59 |
|
|
-- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
60 |
|
|
--
|
61 |
|
|
-- You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
62 |
|
|
--
|
63 |
|
|
--
|
64 |
|
|
LIBRARY ieee;
|
65 |
|
|
USE ieee.std_logic_1164.all;
|
66 |
|
|
USE ieee.std_logic_arith.all;
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
architecture struct of reg_pc is
|
70 |
|
|
|
71 |
|
|
-- Architecture declarations
|
72 |
|
|
|
73 |
|
|
-- Internal signal declarations
|
74 |
|
|
signal adr_pc_high_o_i : std_logic_vector(7 downto 0);
|
75 |
|
|
signal adr_pc_low_o_i : std_logic_vector(7 downto 0);
|
76 |
|
|
signal adr_pc_o_i : std_logic_vector(15 downto 0);
|
77 |
|
|
signal ci_o_i : std_logic;
|
78 |
|
|
signal cout_pc_o_i : std_logic;
|
79 |
|
|
signal load3_o_i : std_logic;
|
80 |
|
|
signal load_o_i : std_logic;
|
81 |
|
|
signal offset_high_o_i : std_logic_vector(7 downto 0);
|
82 |
|
|
signal offset_low_o_i : std_logic_vector(7 downto 0);
|
83 |
|
|
signal val_o_i : std_logic_vector(7 downto 0);
|
84 |
|
|
signal val_one : std_logic_vector(7 downto 0);
|
85 |
|
|
signal val_zero : std_logic_vector(7 downto 0);
|
86 |
|
|
|
87 |
|
|
-- Implicit buffer signal declarations
|
88 |
|
|
signal adr_nxt_pc_o_internal : std_logic_vector (15 downto 0);
|
89 |
|
|
signal adr_pc_o_internal : std_logic_vector (15 downto 0);
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
-- ModuleWare signal declarations(v1.12) for instance 'U_0' of 'adff'
|
93 |
|
|
signal mw_U_0reg_cval : std_logic_vector(7 downto 0);
|
94 |
|
|
|
95 |
|
|
-- ModuleWare signal declarations(v1.12) for instance 'U_4' of 'adff'
|
96 |
|
|
signal mw_U_4reg_cval : std_logic_vector(15 downto 8);
|
97 |
|
|
|
98 |
|
|
-- ModuleWare signal declarations(v1.12) for instance 'U_3' of 'split'
|
99 |
|
|
signal mw_U_3temp_din : std_logic_vector(15 downto 0);
|
100 |
|
|
|
101 |
|
|
-- ModuleWare signal declarations(v1.12) for instance 'U_5' of 'split'
|
102 |
|
|
signal mw_U_5temp_din : std_logic_vector(15 downto 0);
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
begin
|
106 |
|
|
|
107 |
|
|
-- ModuleWare code(v1.12) for instance 'U_2' of 'add'
|
108 |
|
|
u_2combo_proc: process (adr_pc_low_o_i, val_o_i)
|
109 |
|
|
variable temp_din0 : std_logic_vector(8 downto 0);
|
110 |
|
|
variable temp_din1 : std_logic_vector(8 downto 0);
|
111 |
|
|
variable temp_sum : unsigned(8 downto 0);
|
112 |
|
|
variable temp_carry : std_logic;
|
113 |
|
|
begin
|
114 |
|
|
temp_din0 := '0' & adr_pc_low_o_i;
|
115 |
|
|
temp_din1 := '0' & val_o_i;
|
116 |
|
|
temp_carry := '0';
|
117 |
|
|
temp_sum := unsigned(temp_din0) + unsigned(temp_din1) + temp_carry;
|
118 |
|
|
adr_nxt_pc_o_internal(7 DOWNTO 0) <= conv_std_logic_vector(temp_sum(7 downto 0),8);
|
119 |
|
|
cout_pc_o_i <= temp_sum(8) ;
|
120 |
|
|
end process u_2combo_proc;
|
121 |
|
|
|
122 |
|
|
-- ModuleWare code(v1.12) for instance 'U_11' of 'add'
|
123 |
|
|
u_11combo_proc: process (adr_pc_high_o_i, offset_high_o_i, ci_o_i)
|
124 |
|
|
variable temp_din0 : std_logic_vector(8 downto 0);
|
125 |
|
|
variable temp_din1 : std_logic_vector(8 downto 0);
|
126 |
|
|
variable temp_sum : unsigned(8 downto 0);
|
127 |
|
|
variable temp_carry : std_logic;
|
128 |
|
|
begin
|
129 |
|
|
temp_din0 := '0' & adr_pc_high_o_i;
|
130 |
|
|
temp_din1 := '0' & offset_high_o_i;
|
131 |
|
|
temp_carry := ci_o_i;
|
132 |
|
|
temp_sum := unsigned(temp_din0) + unsigned(temp_din1) + temp_carry;
|
133 |
|
|
adr_nxt_pc_o_internal(15 DOWNTO 8) <= conv_std_logic_vector(temp_sum(7 downto 0),8);
|
134 |
|
|
end process u_11combo_proc;
|
135 |
|
|
|
136 |
|
|
-- ModuleWare code(v1.12) for instance 'U_0' of 'adff'
|
137 |
|
|
adr_pc_o_internal(7 DOWNTO 0) <= mw_U_0reg_cval;
|
138 |
|
|
u_0seq_proc: process (clk_clk_i, rst_rst_n_i)
|
139 |
|
|
begin
|
140 |
|
|
if (rst_rst_n_i = '0') then
|
141 |
|
|
mw_U_0reg_cval <= "00000000";
|
142 |
|
|
elsif (clk_clk_i'event and clk_clk_i='1') then
|
143 |
|
|
if (load_o_i = '1') then
|
144 |
|
|
mw_U_0reg_cval <= adr_nxt_pc_o_internal(7 DOWNTO 0);
|
145 |
|
|
end if;
|
146 |
|
|
end if;
|
147 |
|
|
end process u_0seq_proc;
|
148 |
|
|
|
149 |
|
|
-- ModuleWare code(v1.12) for instance 'U_4' of 'adff'
|
150 |
|
|
adr_pc_o_internal(15 DOWNTO 8) <= mw_U_4reg_cval;
|
151 |
|
|
u_4seq_proc: process (clk_clk_i, rst_rst_n_i)
|
152 |
|
|
begin
|
153 |
|
|
if (rst_rst_n_i = '0') then
|
154 |
|
|
mw_U_4reg_cval <= "00000000";
|
155 |
|
|
elsif (clk_clk_i'event and clk_clk_i='1') then
|
156 |
|
|
if (load3_o_i = '1') then
|
157 |
|
|
mw_U_4reg_cval <= adr_nxt_pc_o_internal(15 DOWNTO 8);
|
158 |
|
|
end if;
|
159 |
|
|
end if;
|
160 |
|
|
end process u_4seq_proc;
|
161 |
|
|
|
162 |
|
|
-- ModuleWare code(v1.12) for instance 'U_6' of 'and'
|
163 |
|
|
load_o_i <= ld_pc_i and ld_i(0);
|
164 |
|
|
|
165 |
|
|
-- ModuleWare code(v1.12) for instance 'U_7' of 'and'
|
166 |
|
|
load3_o_i <= ld_pc_i and ld_i(1);
|
167 |
|
|
|
168 |
|
|
-- ModuleWare code(v1.12) for instance 'U_10' of 'and'
|
169 |
|
|
ci_o_i <= cout_pc_o_i and ld_pc_i;
|
170 |
|
|
|
171 |
|
|
-- ModuleWare code(v1.12) for instance 'U_1' of 'constval'
|
172 |
|
|
val_zero <= "00000000";
|
173 |
|
|
|
174 |
|
|
-- ModuleWare code(v1.12) for instance 'U_9' of 'constval'
|
175 |
|
|
val_one <= "00000001";
|
176 |
|
|
|
177 |
|
|
-- ModuleWare code(v1.12) for instance 'U_8' of 'mux'
|
178 |
|
|
u_8combo_proc: process(adr_pc_o_internal, adr_i, sel_pc_in_i)
|
179 |
|
|
begin
|
180 |
|
|
case sel_pc_in_i is
|
181 |
|
|
when '0' => adr_pc_o_i <= adr_pc_o_internal;
|
182 |
|
|
when '1' => adr_pc_o_i <= adr_i;
|
183 |
|
|
when others => adr_pc_o_i <= (others => 'X');
|
184 |
|
|
end case;
|
185 |
|
|
end process u_8combo_proc;
|
186 |
|
|
|
187 |
|
|
-- ModuleWare code(v1.12) for instance 'U_13' of 'mux'
|
188 |
|
|
u_13combo_proc: process(val_one, val_zero, offset_low_o_i,
|
189 |
|
|
sel_pc_val_i)
|
190 |
|
|
begin
|
191 |
|
|
case sel_pc_val_i is
|
192 |
|
|
when "00" => val_o_i <= val_one;
|
193 |
|
|
when "01" => val_o_i <= val_zero;
|
194 |
|
|
when "10" => val_o_i <= offset_low_o_i;
|
195 |
|
|
when "11" => val_o_i <= val_zero;
|
196 |
|
|
when others => val_o_i <= (others => 'X');
|
197 |
|
|
end case;
|
198 |
|
|
end process u_13combo_proc;
|
199 |
|
|
|
200 |
|
|
-- ModuleWare code(v1.12) for instance 'U_3' of 'split'
|
201 |
|
|
mw_U_3temp_din <= adr_pc_o_i;
|
202 |
|
|
u_3combo_proc: process (mw_U_3temp_din)
|
203 |
|
|
variable temp_din: std_logic_vector(15 downto 0);
|
204 |
|
|
begin
|
205 |
|
|
temp_din := mw_U_3temp_din(15 downto 0);
|
206 |
|
|
adr_pc_low_o_i <= temp_din(7 downto 0);
|
207 |
|
|
adr_pc_high_o_i <= temp_din(15 downto 8);
|
208 |
|
|
end process u_3combo_proc;
|
209 |
|
|
|
210 |
|
|
-- ModuleWare code(v1.12) for instance 'U_5' of 'split'
|
211 |
|
|
mw_U_5temp_din <= offset_i;
|
212 |
|
|
u_5combo_proc: process (mw_U_5temp_din)
|
213 |
|
|
variable temp_din: std_logic_vector(15 downto 0);
|
214 |
|
|
begin
|
215 |
|
|
temp_din := mw_U_5temp_din(15 downto 0);
|
216 |
|
|
offset_low_o_i <= temp_din(7 downto 0);
|
217 |
|
|
offset_high_o_i <= temp_din(15 downto 8);
|
218 |
|
|
end process u_5combo_proc;
|
219 |
|
|
|
220 |
|
|
-- Instance port mappings.
|
221 |
|
|
|
222 |
|
|
-- Implicit buffered output assignments
|
223 |
|
|
adr_nxt_pc_o <= adr_nxt_pc_o_internal;
|
224 |
|
|
adr_pc_o <= adr_pc_o_internal;
|
225 |
|
|
|
226 |
|
|
end struct;
|