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