checknode_behavioral.txt

来自「LDPC码校验节点(checknode)进行奇偶校验方程时的vhdl编程」· 文本 代码 · 共 122 行

TXT
122
字号

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_SIGNED.ALL;

entity checkNode is
    Port (
		fromBit0 	: in SIGNED (7 downto 0);
		fromBit1 	: in SIGNED (7 downto 0);
        fromBit2 	: in SIGNED (7 downto 0);

		--minOUT0	 	: out SIGNED (7 downto 0);
		--minOUT1	 	: out SIGNED (7 downto 0);
		--minOUT2	 	: out SIGNED (7 downto 0);

		--fromBitout0	: out SIGNED (7 downto 0);
		--fromBitout1	: out SIGNED (7 downto 0);
		--fromBitout2	: out SIGNED (7 downto 0);

		toBit0	 	: out SIGNED (7 downto 0);
        toBit1	 	: out SIGNED (7 downto 0);
        toBit2 		: out SIGNED (7 downto 0));
end checkNode;

architecture Behavioral of checkNode is

signal sign0 		: STD_LOGIC;
signal sign1 		: STD_LOGIC;
signal sign2 		: STD_LOGIC;
signal signTEMP0 	: STD_LOGIC;
signal signTEMP1 	: STD_LOGIC;
signal signTEMP2 	: STD_LOGIC;
signal fromBit0M 	: SIGNED (7 downto 0);
signal fromBit1M 	: SIGNED (7 downto 0);
signal fromBit2M 	: SIGNED (7 downto 0);
signal min0 		: SIGNED (7 downto 0);
signal min1 		: SIGNED (7 downto 0);
signal min2 		: SIGNED (7 downto 0);

begin

	--minOUT0 <= min0;
	--minOUT1 <= min1;
	--minOUT2 <= min2;
	--fromBitout0 <= fromBit0M;
	--fromBitout1 <= fromBit1M;
	--fromBitout2 <= fromBit2M;

	process(fromBit0, fromBit1, fromBit2)
	begin

		signTEMP0 <= fromBit0(7);
		signTEMP1 <= fromBit1(7);
		signTEMP2 <= fromBit2(7);

		-- Taking the magnitude
		if(fromBit0(7) = '1') then
			fromBit0M <= -fromBit0;
		else
			fromBit0M <= fromBit0;
		end if;
		if(fromBit1(7) = '1') then
			fromBit1M <= -fromBit1;
		else
			fromBit1M <= fromBit1;
		end if;
		if(fromBit2(7) = '1') then
			fromBit2M <= -fromBit2;
		else
			fromBit2M <= fromBit2;
		end if;

		-- Calculating the Sign
		sign0 <= signTEMP1 XOR signTEMP2;
		sign1 <= signTEMP2 XOR signTEMP0;
		sign2 <= signTEMP0 XOR signTEMP1;

		-- Calculating the Min
		if(fromBit1M < fromBit2M) then
			min0 <= fromBit1M;
		else
			min0 <= fromBit2M;
		end if;
		if(fromBit0M < fromBit2M) then
			min1 <= fromBit0M;
		else
			min1 <= fromBit2M;
		end if;
		if(fromBit0M < fromBit1M) then
			min2 <= fromBit0M;
		else
			min2 <= fromBit1M;
		end if;

		--Outputting
		if(sign0 = '1') then
			toBit0 <=  - min0;
		else
			toBit0 <=  min0;
		end if;
		if(sign1 = '1') then
			toBit1 <=  - min1;
		else
			toBit1 <=  min1;
		end if;
		if(sign2 = '1') then
			toBit2 <=  - min2;
		else
			toBit2 <=  min2;
		end if;

		--toBit0 <= min0;
		--toBit1 <= min1;
		--toBit2 <= min2;
	end process;
	--toBit0 <= min0;
	--toBit1 <= min1;
	--toBit2 <= min2;
end Behavioral;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?