OpenCores
URL https://opencores.org/ocsvn/avr_hp/avr_hp/trunk

Subversion Repositories avr_hp

[/] [avr_hp/] [trunk/] [rtl/] [rtl_v5_cm4/] [bit_processor.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tobil
--************************************************************************************************
2
-- "Bit processor" for AVR core
3
-- Version 1.3(Special version for the JTAG OCD)
4
-- Designed by Ruslan Lepetenok
5
-- Modified 29.08.2003
6
-- Unused inputs(sreg_bit_num[2..0],idc_sbi,idc_cbi,idc_bld) was removed.
7
--************************************************************************************************
8
 
9
library IEEE;
10
use IEEE.std_logic_1164.all;
11
use IEEE.std_logic_unsigned.all;
12
 
13
entity bit_processor_cm4 is port(
14
                cp2_cml_1 : in std_logic;
15
                cp2_cml_2 : in std_logic;
16
                cp2_cml_3 : in std_logic;
17
 
18
                                                          --Clock and reset
19
                              cp2             : in  std_logic;
20
                                                          cp2en           : in  std_logic;
21
                              ireset          : in  std_logic;
22
 
23
                              bit_num_r_io    : in  std_logic_vector(2 downto 0); -- BIT NUMBER FOR CBI/SBI/BLD/BST/SBRS/SBRC/SBIC/SBIS INSTRUCTIONS
24
                              dbusin          : in  std_logic_vector(7 downto 0); -- SBI/CBI/SBIS/SBIC  IN
25
                              bitpr_io_out    : out std_logic_vector(7 downto 0); -- SBI/CBI OUT        
26
                              sreg_out        : in  std_logic_vector(7 downto 0); -- BRBS/BRBC/BLD IN 
27
                              branch          : in  std_logic_vector(2 downto 0); -- NUMBER (0..7) OF BRANCH CONDITION FOR BRBS/BRBC INSTRUCTION
28
                              bit_pr_sreg_out : out std_logic_vector(7 downto 0); -- BCLR/BSET/BST(T-FLAG ONLY)             
29
                              bld_op_out      : out std_logic_vector(7 downto 0); -- BLD OUT (T FLAG)
30
                              reg_rd_out      : in  std_logic_vector(7 downto 0); -- BST/SBRS/SBRC IN    
31
                              bit_test_op_out : out std_logic;                    -- OUTPUT OF SBIC/SBIS/SBRS/SBRC/BRBC/BRBS
32
                              -- Instructions and states
33
                              sbi_st          : in  std_logic;
34
                              cbi_st          : in  std_logic;
35
                              idc_bst         : in  std_logic;
36
                              idc_bset        : in  std_logic;
37
                              idc_bclr        : in  std_logic;
38
                              idc_sbic        : in  std_logic;
39
                              idc_sbis        : in  std_logic;
40
                              idc_sbrs        : in  std_logic;
41
                              idc_sbrc        : in  std_logic;
42
                              idc_brbs        : in  std_logic;
43
                              idc_brbc        : in  std_logic;
44
                              idc_reti        : in  std_logic
45
                                                          );
46
 
47
end bit_processor_cm4;
48
 
49
architecture RTL of bit_processor_cm4 is
50
 
51
signal sreg_t_flag     : std_logic;                      --  FOR  BLD INSTRUCTION
52
 
53
signal temp_in_data    : std_logic_vector(7 downto 0);
54
signal sreg_t_temp     : std_logic_vector(7 downto 0);
55
signal bit_num_decode   : std_logic_vector(7 downto 0);
56
signal bit_pr_sreg_out_int : std_logic_vector(7 downto 0);
57
 
58
-- SBIS/SBIC/SBRS/SBRC SIGNALS
59
signal bit_test_in      : std_logic_vector(7 downto 0);
60
signal bit_test_mux_out : std_logic_vector(7 downto 0);
61
 
62
-- BRBS/BRBC SIGNALS
63
signal branch_decode    : std_logic_vector(7 downto 0);
64
signal branch_mux       : std_logic_vector(7 downto 0);
65
 
66
signal bld_op_out_cml_out :  std_logic_vector ( 7 downto 0 );
67
signal bit_num_r_io_cml_2 :  std_logic_vector ( 2 downto 0 );
68
signal bit_num_r_io_cml_1 :  std_logic_vector ( 2 downto 0 );
69
signal dbusin_cml_3 :  std_logic_vector ( 7 downto 0 );
70
signal dbusin_cml_2 :  std_logic_vector ( 7 downto 0 );
71
signal sreg_out_cml_2 :  std_logic_vector ( 7 downto 0 );
72
signal sreg_out_cml_1 :  std_logic_vector ( 7 downto 0 );
73
signal reg_rd_out_cml_3 :  std_logic_vector ( 7 downto 0 );
74
signal reg_rd_out_cml_2 :  std_logic_vector ( 7 downto 0 );
75
signal sreg_t_flag_cml_2 :  std_logic;
76
signal temp_in_data_cml_3 :  std_logic_vector ( 7 downto 0 );
77
signal temp_in_data_cml_2 :  std_logic_vector ( 7 downto 0 );
78
signal temp_in_data_cml_1 :  std_logic_vector ( 7 downto 0 );
79
signal bit_num_decode_cml_3 :  std_logic_vector ( 7 downto 0 );
80
signal bit_num_decode_cml_2 :  std_logic_vector ( 7 downto 0 );
81
signal bit_num_decode_cml_1 :  std_logic_vector ( 7 downto 0 );
82
 
83
begin
84
 
85
 
86
 
87
process(cp2_cml_1) begin
88
if (cp2_cml_1 = '1' and cp2_cml_1'event) then
89
        bit_num_r_io_cml_1 <= bit_num_r_io;
90
        sreg_out_cml_1 <= sreg_out;
91
        temp_in_data_cml_1 <= temp_in_data;
92
        bit_num_decode_cml_1 <= bit_num_decode;
93
end if;
94
end process;
95
 
96
process(cp2_cml_2) begin
97
if (cp2_cml_2 = '1' and cp2_cml_2'event) then
98
        bit_num_r_io_cml_2 <= bit_num_r_io_cml_1;
99
        dbusin_cml_2 <= dbusin;
100
        sreg_out_cml_2 <= sreg_out_cml_1;
101
        reg_rd_out_cml_2 <= reg_rd_out;
102
        sreg_t_flag_cml_2 <= sreg_t_flag;
103
        temp_in_data_cml_2 <= temp_in_data_cml_1;
104
        bit_num_decode_cml_2 <= bit_num_decode_cml_1;
105
end if;
106
end process;
107
 
108
process(cp2_cml_3) begin
109
if (cp2_cml_3 = '1' and cp2_cml_3'event) then
110
        dbusin_cml_3 <= dbusin_cml_2;
111
        reg_rd_out_cml_3 <= reg_rd_out_cml_2;
112
        temp_in_data_cml_3 <= temp_in_data_cml_2;
113
        bit_num_decode_cml_3 <= bit_num_decode_cml_2;
114
end if;
115
end process;
116
bld_op_out <= bld_op_out_cml_out;
117
 
118
 
119
-- SynEDA CoreMultiplier
120
-- assignment(s): sreg_t_flag
121
-- replace(s): sreg_out
122
 
123
sreg_t_flag <= sreg_out_cml_1(6);
124
 
125
 
126
-- SynEDA CoreMultiplier
127
-- assignment(s): temp_in_data
128
-- replace(s): dbusin, temp_in_data
129
 
130
-- SBI/CBI STORE REGISTER
131
sbi_cbi:process(cp2,ireset)
132
begin
133
if ireset='0' then
134
temp_in_data <= (others =>'0');
135
elsif (cp2='1' and cp2'event) then temp_in_data <= temp_in_data_cml_3;
136
 if (cp2en='1') then                                                      -- Clock enable
137
  temp_in_data <= dbusin_cml_3;
138
 end if;
139
end if;
140
end process;
141
 
142
sbi_cbi_logic:for i in dbusin'range generate
143
bitpr_io_out(i) <= '1' when (sbi_st='1' and bit_num_decode(i)='1') else  -- SBI
144
                                   '0' when (cbi_st='1' and bit_num_decode(i)='1') else   -- CBI
145
                                   temp_in_data(i);                                                                          -- ???
146
end generate;
147
 
148
 
149
-- ########################################################################################
150
 
151
-- BST PART (LOAD T BIT OF SREG FROM THE GENERAL PURPOSE REGISTER)
152
bit_num_decode_logic:for i in bit_num_decode'range generate
153
bit_num_decode(i) <= '1' when (i=bit_num_r_io) else '0';
154
end generate;
155
 
156
sreg_t_temp(0) <= reg_rd_out_cml_3(0) when bit_num_decode_cml_3(0)='1' else '0';
157
bld_logic:for i in 1 to 7 generate
158
-- SynEDA CoreMultiplier
159
-- assignment(s): sreg_t_temp
160
-- replace(s): reg_rd_out, bit_num_decode
161
 
162
sreg_t_temp(i)<= reg_rd_out_cml_3(i) when bit_num_decode_cml_3(i)='1' else sreg_t_temp(i-1);
163
end generate;
164
 
165
-- BLD LOGIC
166
bld_inst:for i in reg_rd_out'range generate
167
-- SynEDA CoreMultiplier
168
-- assignment(s): bld_op_out
169
-- replace(s): bit_num_r_io, reg_rd_out, sreg_t_flag
170
 
171
bld_op_out_cml_out(i) <= sreg_t_flag_cml_2 when (i=bit_num_r_io_cml_2) else reg_rd_out_cml_2(i);
172
end generate;
173
 
174
 
175
-- ########################################################################################
176
 
177
-- BCLR/BSET/BST/RETI LOGIC
178
bclr_bset_logic:for i in 0 to 6 generate
179
bit_pr_sreg_out_int(i) <= (idc_bset and not reg_rd_out_cml_3(i)) or (not idc_bclr and reg_rd_out_cml_3(i));
180
end generate;
181
-- SynEDA CoreMultiplier
182
-- assignment(s): bit_pr_sreg_out_int
183
-- replace(s): reg_rd_out
184
 
185
-- SREG REGISTER BIT 7 - INTERRUPT ENABLE FLAG
186
bit_pr_sreg_out_int(7) <= (idc_bset and not reg_rd_out_cml_3(7)) or (not idc_bclr and reg_rd_out_cml_3(7)) or idc_reti;
187
 
188
bit_pr_sreg_out <= bit_pr_sreg_out_int(7)&sreg_t_temp(7)&bit_pr_sreg_out_int(5 downto 0) when (idc_bst='1')
189
                                                                                   else bit_pr_sreg_out_int;
190
 
191
-- SynEDA CoreMultiplier
192
-- assignment(s): bit_test_in
193
-- replace(s): dbusin, reg_rd_out
194
 
195
-- SBIC/SBIS/SBRS/SBRC LOGIC
196
bit_test_in <= dbusin_cml_2 when (idc_sbis='1' or idc_sbic='1') else reg_rd_out_cml_2;
197
 
198
bit_test_mux_out(0) <= bit_test_in(0) when bit_num_decode_cml_2(0)='1' else '0';
199
it_test_mux:for i in 1 to 7 generate
200
-- SynEDA CoreMultiplier
201
-- assignment(s): bit_test_mux_out
202
-- replace(s): bit_num_decode
203
 
204
bit_test_mux_out(i)<= bit_test_in(i) when bit_num_decode_cml_2(i)='1' else bit_test_mux_out(i-1);
205
end generate;
206
 
207
bit_test_op_out <= (bit_test_mux_out(7) and (idc_sbis or idc_sbrs)) or
208
                   (not bit_test_mux_out(7) and (idc_sbic or idc_sbrc)) or
209
                   (branch_mux(7) and idc_brbs) or
210
                   (not branch_mux(7) and idc_brbc);
211
 
212
-- BRBS/BRBC LOGIC
213
 
214
branch_decode_logic:for i in branch_decode'range generate
215
branch_decode(i) <= '1' when (i=branch) else '0';
216
end generate;
217
 
218
branch_mux(0) <= sreg_out_cml_2(0) when branch_decode(0)='1' else '0';
219
branch_mux_logic:for i in 1 to 7 generate
220
-- SynEDA CoreMultiplier
221
-- assignment(s): branch_mux
222
-- replace(s): sreg_out
223
 
224
branch_mux(i)<= sreg_out_cml_2(i) when branch_decode(i)='1' else branch_mux(i-1);
225
end generate;
226
 
227
 
228
end RTL;

powered by: WebSVN 2.1.0

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