Untitled

 avatar
unknown
plain_text
10 months ago
3.3 kB
14
Indexable
library IEEE;
use IEEE.std_logic_1164.all;



ENTITY encoder IS
   PORT (i0,i1,i2,i3 : IN std_logic;
         x0,x1,x2,x3,x4 : OUT std_logic);
END encoder;



ARCHITECTURE behavioral OF encoder IS
  
TYPE PLA_TABLE is ARRAY (0 to 19,0 to 12) OF std_logic;

CONSTANT pla_encoder: PLA_TABLE := (
--       __        __        __        __
--| i0 , i0  ,i1  ,i1  ,i2  ,i2  ,i3  ,i3 , x0  ,x1 , x2 , x3 , x4
--
  ('0' ,'0' ,'1' ,'0' ,'0' ,'1' ,'0' ,'1' ,'1' ,'0' ,'0' ,'0' ,'0'),   --0
 ( '0' ,'0' ,'0' ,'1' ,'1' ,'0' ,'0' ,'1' ,'1' ,'0' ,'0' ,'0' ,'0'),   --1
 ( '0' ,'1' ,'0' ,'1' ,'0' ,'1' ,'1' ,'0' ,'1' ,'0' ,'0' ,'0' ,'0'),   --2
 ( '0' ,'0' ,'1' ,'0' ,'1' ,'0' ,'1' ,'0' ,'1' ,'0' ,'0' ,'0' ,'0'),   --3
 ( '0' ,'0' ,'0' ,'1' ,'1' ,'0' ,'1' ,'0' ,'0' ,'1' ,'0' ,'0' ,'0'),   --4
 ( '0' ,'1' ,'0' ,'0' ,'0' ,'1' ,'1' ,'0' ,'0' ,'1' ,'0' ,'0' ,'0'),   --5
 ( '1' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'1' ,'0' ,'1' ,'0' ,'0' ,'0'),   --6
 ( '1' ,'0' ,'0' ,'0' ,'0' ,'0' ,'1' ,'0' ,'0' ,'0' ,'1' ,'0' ,'0'),   --7
 ( '0' ,'0' ,'0' ,'0' ,'1' ,'0' ,'0' ,'1' ,'0' ,'0' ,'1' ,'0' ,'0'),   --8 
 ( '0' ,'0' ,'0' ,'1' ,'1' ,'0' ,'0' ,'0' ,'0' ,'0' ,'1' ,'0' ,'0'),   --9
 ( '0' ,'1' ,'0' ,'0' ,'0' ,'1' ,'0' ,'1' ,'0' ,'0' ,'0' ,'1' ,'0'),   --10
 ( '0' ,'0' ,'1' ,'0' ,'0' ,'0' ,'0' ,'1' ,'0' ,'0' ,'0' ,'1' ,'0'),   --11
 ( '0' ,'0' ,'1' ,'0' ,'0' ,'1' ,'0' ,'0' ,'0' ,'0' ,'0' ,'1' ,'0'),   --12
 ( '0' ,'0' ,'1' ,'0' ,'1' ,'0' ,'1' ,'0' ,'0' ,'0' ,'0' ,'0' ,'1'),   --13
 ( '0' ,'0' ,'0' ,'1' ,'0' ,'1' ,'0' ,'1' ,'0' ,'0' ,'0' ,'0' ,'1'),   --14
 ( '1' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'1'),   --15
 ( '0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0'),   --16
 ( '0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0'),   --17
 ( '0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0'),   --18
 ( '0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0')    --19
  );   
  
  
TYPE ALL_GATES is ARRAY (0 to 19) of std_logic;  
TYPE ALL_INPUT is ARRAY (0 to 7) of std_logic; 
TYPE ALL_OR is ARRAY (0 to 19,0 to 4) of std_logic; 
SIGNAL INPUT_TABLE : ALL_INPUT;
SIGNAL AND_TABLE : ALL_GATES;
SIGNAL OR_TABLE: ALL_OR;

BEGIN
  
INPUT_TABLE <= (i0,not(i0),i1,not(i1),i2,not(i2),i3,not(i3));

ANDs:
FOR c1 in 0 to 19 generate 
 
  AND_TABLE(c1) <= (INPUT_TABLE(0) or not (pla_encoder (c1,0))) and
                   (INPUT_TABLE(1) or not (pla_encoder (c1,1))) and
                   (INPUT_TABLE(2) or not (pla_encoder (c1,2))) and
                   (INPUT_TABLE(3) or not (pla_encoder (c1,3))) and
                   (INPUT_TABLE(4) or not (pla_encoder (c1,4))) and
                   (INPUT_TABLE(5) or not (pla_encoder (c1,5))) and
                   (INPUT_TABLE(6) or not (pla_encoder (c1,6))) and
                   (INPUT_TABLE(7) or not (pla_encoder (c1,7))) ;
END generate ANDs;

rows:
FOR r1 in 0 to 4 generate
  OR_TABLE(0,r1)<= (AND_TABLE(0) and pla_encoder(0,r1+8));
  columns:
  FOR c1 in 1 to 19 generate
    OR_TABLE(c1,r1) <= ((AND_TABLE(c1) and pla_encoder(c1,r1+8)) or OR_TABLE(c1-1,r1));
  END generate columns;  
END generate rows;
X0 <= OR_TABLE(19,0);
X1 <= OR_TABLE(19,1);
X2 <= OR_TABLE(19,2);
X3 <= OR_TABLE(19,3);
X4 <= OR_TABLE(19,4);
END behavioral;
Editor is loading...
Leave a Comment