Implements various priority encoder components with combinatorial logic for encoding input vectors to output codes of varying widths. Introduces pipeline-based modules for handling calculation, ROM data fetching, and scheduling operations with AXI-like handshaking interfaces. Facilitates modular and reusable design for priority encoding and data processing tasks.
346 lines
14 KiB
VHDL
346 lines
14 KiB
VHDL
library ieee;
|
|
use ieee.std_logic_1164.all;
|
|
|
|
--@ Priority Encoder (2 to 1 bits)
|
|
--@ This is a combinatorial priority encoder that encodes the highest priority
|
|
--@ bit in the input vector to a 1-bit output code.
|
|
entity PriorityEncoder_2 is
|
|
port (
|
|
--@ Input vector to be encoded.
|
|
--@ The least significant bit has the highest priority.
|
|
I_Select : in std_logic_vector(1 downto 0) := (others => '0');
|
|
--@ Output code.
|
|
--@ The output code is the index of the highest priority bit in the input vector.
|
|
O_Code : out std_logic_vector(0 downto 0) := (others => '0')
|
|
);
|
|
end entity PriorityEncoder_2;
|
|
|
|
architecture Combinatoric of PriorityEncoder_2 is
|
|
--@ Internal signal to hold the encoded output.
|
|
signal C_Code : std_logic_vector(0 downto 0);
|
|
|
|
--@ Attribute to force the synthesis tool (XST, old Parser) to treat this as a combinatorial signal.
|
|
attribute PRIORITY_EXTRACT : string;
|
|
attribute PRIORITY_EXTRACT of C_Code : signal is "force";
|
|
begin
|
|
C_Code <= "0" when I_Select(1) = '1' else
|
|
"1" when I_Select(0) = '1' else
|
|
"-";
|
|
|
|
O_Code <= C_Code;
|
|
end architecture;
|
|
|
|
library ieee;
|
|
use ieee.std_logic_1164.all;
|
|
|
|
--@ Priority Encoder (4 to 2 bits)
|
|
--@ This is a combinatorial priority encoder that encodes the highest priority
|
|
--@ bit in the input vector to a 2-bit output code.
|
|
entity PriorityEncoder_4 is
|
|
port (
|
|
--@ Input vector to be encoded.
|
|
--@ The least significant bit has the highest priority.
|
|
I_Select : in std_logic_vector(3 downto 0) := (others => '0');
|
|
--@ Output code.
|
|
--@ The output code is the index of the highest priority bit in the input vector.
|
|
O_Code : out std_logic_vector(1 downto 0) := (others => '0')
|
|
);
|
|
end entity PriorityEncoder_4;
|
|
|
|
architecture Combinatoric of PriorityEncoder_4 is
|
|
--@ Internal signal to hold the encoded output.
|
|
signal C_Code : std_logic_vector(1 downto 0);
|
|
|
|
--@ Attribute to force the synthesis tool (XST, old Parser) to treat this as a combinatorial signal.
|
|
attribute PRIORITY_EXTRACT : string;
|
|
attribute PRIORITY_EXTRACT of C_Code : signal is "force";
|
|
begin
|
|
C_Code <= "00" when I_Select(3) = '1' else
|
|
"01" when I_Select(2) = '1' else
|
|
"10" when I_Select(1) = '1' else
|
|
"11" when I_Select(0) = '1' else
|
|
"--";
|
|
|
|
O_Code <= C_Code;
|
|
end architecture;
|
|
|
|
library ieee;
|
|
use ieee.std_logic_1164.all;
|
|
|
|
--@ Priority Encoder (8 to 3 bits)
|
|
--@ This is a combinatorial priority encoder that encodes the highest priority
|
|
--@ bit in the input vector to a 3-bit output code.
|
|
entity PriorityEncoder_8 is
|
|
port (
|
|
--@ Input vector to be encoded.
|
|
--@ The least significant bit has the highest priority.
|
|
I_Select : in std_logic_vector(7 downto 0) := (others => '0');
|
|
--@ Output code.
|
|
--@ The output code is the index of the highest priority bit in the input vector.
|
|
O_Code : out std_logic_vector(2 downto 0) := (others => '0')
|
|
);
|
|
end entity PriorityEncoder_8;
|
|
|
|
architecture Combinatoric of PriorityEncoder_8 is
|
|
--@ Internal signal to hold the encoded output.
|
|
signal C_Code : std_logic_vector(2 downto 0);
|
|
|
|
--@ Attribute to force the synthesis tool (XST, old Parser) to treat this as a combinatorial signal.
|
|
attribute PRIORITY_EXTRACT : string;
|
|
attribute PRIORITY_EXTRACT of C_Code : signal is "force";
|
|
begin
|
|
C_Code <= "000" when I_Select(7) = '1' else
|
|
"001" when I_Select(6) = '1' else
|
|
"010" when I_Select(5) = '1' else
|
|
"011" when I_Select(4) = '1' else
|
|
"100" when I_Select(3) = '1' else
|
|
"101" when I_Select(2) = '1' else
|
|
"110" when I_Select(1) = '1' else
|
|
"111" when I_Select(0) = '1' else
|
|
"---";
|
|
|
|
O_Code <= C_Code;
|
|
end architecture;
|
|
|
|
library ieee;
|
|
use ieee.std_logic_1164.all;
|
|
|
|
--@ Priority Encoder (16 to 4 bits)
|
|
--@ This is a combinatorial priority encoder that encodes the highest priority
|
|
--@ bit in the input vector to a 4-bit output code.
|
|
entity PriorityEncoder_16 is
|
|
port (
|
|
--@ Input vector to be encoded.
|
|
--@ The least significant bit has the highest priority.
|
|
I_Select : in std_logic_vector(15 downto 0) := (others => '0');
|
|
--@ Output code.
|
|
--@ The output code is the index of the highest priority bit in the input vector.
|
|
O_Code : out std_logic_vector(3 downto 0) := (others => '0')
|
|
);
|
|
end entity PriorityEncoder_16;
|
|
|
|
architecture Combinatoric of PriorityEncoder_16 is
|
|
--@ Internal signal to hold the encoded output.
|
|
signal C_Code : std_logic_vector(3 downto 0);
|
|
|
|
--@ Attribute to force the synthesis tool (XST, old Parser) to treat this as a combinatorial signal.
|
|
attribute PRIORITY_EXTRACT : string;
|
|
attribute PRIORITY_EXTRACT of C_Code : signal is "force";
|
|
begin
|
|
C_Code <= "0000" when I_Select(15) = '1' else
|
|
"0001" when I_Select(14) = '1' else
|
|
"0010" when I_Select(13) = '1' else
|
|
"0011" when I_Select(12) = '1' else
|
|
"0100" when I_Select(11) = '1' else
|
|
"0101" when I_Select(10) = '1' else
|
|
"0110" when I_Select(9) = '1' else
|
|
"0111" when I_Select(8) = '1' else
|
|
"1000" when I_Select(7) = '1' else
|
|
"1001" when I_Select(6) = '1' else
|
|
"1010" when I_Select(5) = '1' else
|
|
"1011" when I_Select(4) = '1' else
|
|
"1100" when I_Select(3) = '1' else
|
|
"1101" when I_Select(2) = '1' else
|
|
"1110" when I_Select(1) = '1' else
|
|
"1111" when I_Select(0) = '1' else
|
|
"----";
|
|
|
|
O_Code <= C_Code;
|
|
end architecture;
|
|
|
|
library ieee;
|
|
use ieee.std_logic_1164.all;
|
|
|
|
--@ Priority Encoder (32 to 5 bits)
|
|
--@ This is a combinatorial priority encoder that encodes the highest priority
|
|
--@ bit in the input vector to a 5-bit output code.
|
|
entity PriorityEncoder_32 is
|
|
port (
|
|
--@ Input vector to be encoded.
|
|
--@ The least significant bit has the highest priority.
|
|
I_Select : in std_logic_vector(31 downto 0) := (others => '0');
|
|
--@ Output code.
|
|
--@ The output code is the index of the highest priority bit in the input vector.
|
|
O_Code : out std_logic_vector(4 downto 0) := (others => '0')
|
|
);
|
|
end entity PriorityEncoder_32;
|
|
|
|
architecture Combinatoric of PriorityEncoder_32 is
|
|
--@ Internal signal to hold the encoded output.
|
|
signal C_Code : std_logic_vector(4 downto 0);
|
|
|
|
--@ Attribute to force the synthesis tool (XST, old Parser) to treat this as a combinatorial signal.
|
|
attribute PRIORITY_EXTRACT : string;
|
|
attribute PRIORITY_EXTRACT of C_Code : signal is "force";
|
|
|
|
begin
|
|
C_Code <= "00000" when I_Select(31) = '1' else
|
|
"00001" when I_Select(30) = '1' else
|
|
"00010" when I_Select(29) = '1' else
|
|
"00011" when I_Select(28) = '1' else
|
|
"00100" when I_Select(27) = '1' else
|
|
"00101" when I_Select(26) = '1' else
|
|
"00110" when I_Select(25) = '1' else
|
|
"00111" when I_Select(24) = '1' else
|
|
"01000" when I_Select(23) = '1' else
|
|
"01001" when I_Select(22) = '1' else
|
|
"01010" when I_Select(21) = '1' else
|
|
"01011" when I_Select(20) = '1' else
|
|
"01100" when I_Select(19) = '1' else
|
|
"01101" when I_Select(18) = '1' else
|
|
"01110" when I_Select(17) = '1' else
|
|
"01111" when I_Select(16) = '1' else
|
|
"10000" when I_Select(15) = '1' else
|
|
"10001" when I_Select(14) = '1' else
|
|
"10010" when I_Select(13) = '1' else
|
|
"10011" when I_Select(12) = '1' else
|
|
"10100" when I_Select(11) = '1' else
|
|
"10101" when I_Select(10) = '1' else
|
|
"10110" when I_Select(9) = '1' else
|
|
"10111" when I_Select(8) = '1' else
|
|
"11000" when I_Select(7) = '1' else
|
|
"11001" when I_Select(6) = '1' else
|
|
"11010" when I_Select(5) = '1' else
|
|
"11011" when I_Select(4) = '1' else
|
|
"11100" when I_Select(3) = '1' else
|
|
"11101" when I_Select(2) = '1' else
|
|
"11110" when I_Select(1) = '1' else
|
|
"11111" when I_Select(0) = '1' else
|
|
"-----";
|
|
|
|
O_Code <= C_Code;
|
|
end architecture;
|
|
|
|
library ieee;
|
|
use ieee.std_logic_1164.all;
|
|
|
|
--@ Priority Encoder (64 to 6 bits)
|
|
--@ This is a combinatorial priority encoder that encodes the highest priority
|
|
--@ bit in the input vector to a 6-bit output code.
|
|
entity PriorityEncoder_64 is
|
|
port (
|
|
--@ Input vector to be encoded.
|
|
--@ The least significant bit has the highest priority.
|
|
I_Select : in std_logic_vector(63 downto 0) := (others => '0');
|
|
--@ Output code.
|
|
--@ The output code is the index of the highest priority bit in the input vector.
|
|
O_Code : out std_logic_vector(5 downto 0) := (others => '0')
|
|
);
|
|
end entity PriorityEncoder_64;
|
|
|
|
architecture Combinatoric of PriorityEncoder_64 is
|
|
--@ Internal signal to hold the encoded output.
|
|
signal C_Code : std_logic_vector(5 downto 0);
|
|
|
|
--@ Attribute to force the synthesis tool (XST, old Parser) to treat this as a combinatorial signal.
|
|
attribute PRIORITY_EXTRACT : string;
|
|
attribute PRIORITY_EXTRACT of C_Code : signal is "force";
|
|
|
|
begin
|
|
C_Code <= "000000" when I_Select(63) = '1' else
|
|
"000001" when I_Select(62) = '1' else
|
|
"000010" when I_Select(61) = '1' else
|
|
"000011" when I_Select(60) = '1' else
|
|
"000100" when I_Select(59) = '1' else
|
|
"000101" when I_Select(58) = '1' else
|
|
"000110" when I_Select(57) = '1' else
|
|
"000111" when I_Select(56) = '1' else
|
|
"001000" when I_Select(55) = '1' else
|
|
"001001" when I_Select(54) = '1' else
|
|
"001010" when I_Select(53) = '1' else
|
|
"001011" when I_Select(52) = '1' else
|
|
"001100" when I_Select(51) = '1' else
|
|
"001101" when I_Select(50) = '1' else
|
|
"001110" when I_Select(49) = '1' else
|
|
"001111" when I_Select(48) = '1' else
|
|
"010000" when I_Select(47) = '1' else
|
|
"010001" when I_Select(46) = '1' else
|
|
"010010" when I_Select(45) = '1' else
|
|
"010011" when I_Select(44) = '1' else
|
|
"010100" when I_Select(43) = '1' else
|
|
"010101" when I_Select(42) = '1' else
|
|
"010110" when I_Select(41) = '1' else
|
|
"010111" when I_Select(40) = '1' else
|
|
"011000" when I_Select(39) = '1' else
|
|
"011001" when I_Select(38) = '1' else
|
|
"011010" when I_Select(37) = '1' else
|
|
"011011" when I_Select(36) = '1' else
|
|
"011100" when I_Select(35) = '1' else
|
|
"011101" when I_Select(34) = '1' else
|
|
"011110" when I_Select(33) = '1' else
|
|
"011111" when I_Select(32) = '1' else
|
|
"100000" when I_Select(31) = '1' else
|
|
"100001" when I_Select(30) = '1' else
|
|
"100010" when I_Select(29) = '1' else
|
|
"100011" when I_Select(28) = '1' else
|
|
"100100" when I_Select(27) = '1' else
|
|
"100101" when I_Select(26) = '1' else
|
|
"100110" when I_Select(25) = '1' else
|
|
"100111" when I_Select(24) = '1' else
|
|
"101000" when I_Select(23) = '1' else
|
|
"101001" when I_Select(22) = '1' else
|
|
"101010" when I_Select(21) = '1' else
|
|
"101011" when I_Select(20) = '1' else
|
|
"101100" when I_Select(19) = '1' else
|
|
"101101" when I_Select(18) = '1' else
|
|
"101110" when I_Select(17) = '1' else
|
|
"101111" when I_Select(16) = '1' else
|
|
"110000" when I_Select(15) = '1' else
|
|
"110001" when I_Select(14) = '1' else
|
|
"110010" when I_Select(13) = '1' else
|
|
"110011" when I_Select(12) = '1' else
|
|
"110100" when I_Select(11) = '1' else
|
|
"110101" when I_Select(10) = '1' else
|
|
"110110" when I_Select(9) = '1' else
|
|
"110111" when I_Select(8) = '1' else
|
|
"111000" when I_Select(7) = '1' else
|
|
"111001" when I_Select(6) = '1' else
|
|
"111010" when I_Select(5) = '1' else
|
|
"111011" when I_Select(4) = '1' else
|
|
"111100" when I_Select(3) = '1' else
|
|
"111101" when I_Select(2) = '1' else
|
|
"111110" when I_Select(1) = '1' else
|
|
"111111" when I_Select(0) = '1' else
|
|
"------";
|
|
|
|
O_Code <= C_Code;
|
|
end architecture;
|
|
|
|
library ieee;
|
|
use ieee.std_logic_1164.all;
|
|
use ieee.numeric_std.all;
|
|
use ieee.math_real.all;
|
|
|
|
--@ Priority Encoder (Generic)
|
|
--@ This is a combinatorial priority encoder that encodes the highest priority
|
|
--@ bit in the input vector to a 6-bit output code.
|
|
entity PriorityEncoder_G is
|
|
generic (
|
|
--@ Code width with minimum 2 bits and maximum 6 bits.
|
|
G_CodeWidth : integer := 6
|
|
);
|
|
port (
|
|
--@ Input vector to be encoded.
|
|
--@ The least significant bit has the highest priority.
|
|
I_Select : in std_logic_vector(2 ** G_CodeWidth - 1 downto 0);
|
|
--@ Output code.
|
|
--@ The output code is the index of the highest priority bit in the input vector.
|
|
O_Code : out std_logic_vector(G_CodeWidth - 1 downto 0)
|
|
);
|
|
end entity PriorityEncoder_G;
|
|
|
|
architecture Combinatoric of PriorityEncoder_G is
|
|
signal C_Select : std_logic_vector(63 downto 0) := (others => '-');
|
|
signal C_Code : std_logic_vector(5 downto 0) := (others => '-');
|
|
begin
|
|
|
|
entity_inst : entity work.PriorityEncoder_64
|
|
port map(
|
|
I_Select => C_Select,
|
|
O_Code => C_Code
|
|
);
|
|
|
|
C_Select(G_CodeWidth * 2 - 1 downto 0) <= I_Select;
|
|
O_Code <= C_Code(G_CodeWidth - 1 downto 0);
|
|
end architecture;
|