📄 cal_s0.vhd
字号:
--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 11:20:49 04/02/08
-- Design Name:
-- Module Name: cal_s0 - 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_s0 is
port(
clk:in std_logic;
rst:in std_logic;
en_all:in std_logic;
din:in std_logic_vector(7 downto 0);
s0:out std_logic_vector(12 downto 0)
);
end cal_s0;
architecture Behavioral of cal_s0 is
--component mul0
-- port(
-- mul0_in:in std_logic_vector(12 downto 0); --msb_lsb
-- mul0_out:out std_logic_vector(12 downto 0)
-- );
--end component;
component mul0
port(
mul0_in:in std_logic_vector(12 downto 0); --msb_lsb
mul0_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 s0_tmp:std_logic_vector(12 downto 0);
signal en_con1:std_logic;
signal en_con:std_logic;
signal cnt:integer range 1000 downto 0;
signal n1:integer range 511 downto 0;
begin
s0<=s0_tmp;
process(clk,rst)
begin
if(rst='1')then
s0_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_con1='1')then
for i in 12 downto 0 loop
s0_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
-- s0_tmp(i)<=dout7(i) xor dout6(i) xor s_mul_m(i);
s0_tmp(i)<=dout7(i) xor dout6(i) xor s_mul(i);
end loop;
end if;
end if;
end if;
end process;
mul0_pro:
mul0
port map
(
mul0_in=>s0_tmp,
mul0_out=>s_mul
);
--mul0_pro:
-- mul0
-- port map
-- (
-- mul0_in=>s0_tmp,
-- mul0_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 0th selector
if din(7)='1' then
dout7<="0000000000001";
else
dout7<=(others=>'0');
end if;
if din(6)='1' then
dout6<="0000000000001";
else
dout6<=(others=>'0');
end if;
if din(5)='1' then
dout5<="0000000000001";
else
dout5<=(others=>'0');
end if;
if din(4)='1' then
dout4<="0000000000001";
else
dout4<=(others=>'0');
end if;
if din(3)='1' then
dout3<="0000000000001";
else
dout3<=(others=>'0');
end if;
if din(2)='1' then
dout2<="0000000000001";
else
dout2<=(others=>'0');
end if;
if din(1)='1' then
dout1<="0000000000001";
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<="0000000000001";
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;
end if;
end process;
end Behavioral;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -