📄 cal_s8.vhd
字号:
--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 11:20:49 04/02/08
-- Design Name:
-- Module Name: cal_s8 - Behavioral
-- Project Name:
-- Target Device:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
--------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity cal_s8 is
port(
clk:in std_logic;
rst:in std_logic;
en_all:in std_logic;
en_con:in std_logic;
en_init:in std_logic;
din:in std_logic_vector(7 downto 0);
s8:out std_logic_vector(12 downto 0)
);
end cal_s8;
architecture Behavioral of cal_s8 is
component mul64
port(
mul64_in:in std_logic_vector(12 downto 0); --msb_lsb
mul64_out:out std_logic_vector(12 downto 0)
);
end component;
component mul16
port(
mul16_in:in std_logic_vector(12 downto 0); --msb_lsb
mul16_out:out std_logic_vector(12 downto 0)
);
end component;
signal dout7:std_logic_vector(12 downto 0);
signal dout6:std_logic_vector(12 downto 0);
signal dout5:std_logic_vector(12 downto 0);
signal dout4:std_logic_vector(12 downto 0);
signal dout3:std_logic_vector(12 downto 0);
signal dout2:std_logic_vector(12 downto 0);
signal dout1:std_logic_vector(12 downto 0);
signal dout0:std_logic_vector(12 downto 0);
signal s_mul:std_logic_vector(12 downto 0);
signal s_mul_m:std_logic_vector(12 downto 0);
signal s8_tmp:std_logic_vector(12 downto 0);
signal en_con1:std_logic;
--signal en_con:std_logic;
--signal en_con_tmp:std_logic; --------
--signal cnt:integer range 1000 downto 0;
signal n1:integer range 511 downto 0;
begin
s8<=s8_tmp;
process(clk,rst)
begin
if(rst='1')then
s8_tmp<=(others=>'0');
n1<=0;
elsif(clk'event and clk='1')then
en_con1<=en_con;
if (en_all='1')then
if n1=511 then
n1<=0;
else
n1<=n1+1;
end if;
if(en_init='1')then
s8_tmp<=(others=>'0');
else
if(en_con1='1')then
for i in 12 downto 0 loop
s8_tmp(i)<=dout7(i) xor dout6(i) xor dout5(i) xor dout4(i) xor dout3(i) xor dout2(i) xor dout1(i) xor dout0(i) xor s_mul(i);
end loop;
else
for i in 12 downto 0 loop
s8_tmp(i)<=dout7(i) xor dout6(i) xor s_mul_m(i);
end loop;
end if;
end if;
end if;
end if;
end process;
mul64_pro:
mul64
port map
(
mul64_in=>s8_tmp,
mul64_out=>s_mul
);
mul16_pro:
mul16
port map
(
mul16_in=>s8_tmp,
mul16_out=>s_mul_m
);
process(clk,rst)
begin
if (rst='1')then
dout7<=(others=>'0');
dout6<=(others=>'0');
dout5<=(others=>'0');
dout4<=(others=>'0');
dout3<=(others=>'0');
dout2<=(others=>'0');
dout1<=(others=>'0');
dout0<=(others=>'0');
elsif(clk'event and clk='1')then
if(en_all='1')then
if(en_con='1')then -----
--this is the 8th selector
if din(7)='1' then
dout7<="0110001001000";
else
dout7<=(others=>'0');
end if;
if din(6)='1' then
dout6<="1111100000101";
else
dout6<=(others=>'0');
end if;
if din(5)='1' then
dout5<="1101101110101";
else
dout5<=(others=>'0');
end if;
if din(4)='1' then
dout4<="1000101110110";
else
dout4<=(others=>'0');
end if;
if din(3)='1' then
dout3<="1100001011010";
else
dout3<=(others=>'0');
end if;
if din(2)='1' then
dout2<="0000011011000";
else
dout2<=(others=>'0');
end if;
if din(1)='1' then
dout1<="0000100000000";
else
dout1<=(others=>'0');
end if;
if din(0)='1' then
dout0<="0000000000001";
else
dout0<=(others=>'0');
end if;
else
if din(7)='1' then
dout7<="0000100000000";
else
dout7<=(others=>'0');
end if;
if din(6)='1' then
dout6<="0000000000001";
else
dout6<=(others=>'0');
end if;
end if;
end if;
end if;
end process;
--cnt_pro:
-- process(clk,rst)
-- begin
-- if(rst='1')then
-- cnt<=0;
-- elsif(clk'event and clk='1')then
-- if (en_all='1')then
-- if cnt=512 then
-- cnt<=1;
-- else
-- cnt<=cnt+1;
-- end if;
-- end if;
-- end if;
-- end process;
--
--en_con_pro:
-- process(clk)
-- begin
-- if(clk'event and clk='1')then
-- if cnt=510 then
-- en_con<='0';
-- else
-- en_con<='1';
-- end if;
-- en_con_tmp<=en_con;
-- end if;
-- end process;
end Behavioral;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -