TTL74185

Aus der Mikrocontroller.net Artikelsammlung, mit Beiträgen verschiedener Autoren (siehe Versionsgeschichte)
Wechseln zu: Navigation, Suche

nachbau eines Standard TTL, des 74185 (6 bit binary zu BCD). Siehe thread: http://www.mikrocontroller.net/topic/55594 .

Code ist nicht simuliert, läuft aber einwandfrei durch Synthese.

Wandelt man Eingang zu integer wird der code besser lesbar. Um es dem Synthese Tool leichter zu machen, wird das untere Eingangsbit nicht mit ausgewertet. Durch die select anweisung beschreibt man eine Wahrheitstabelle die einfach in LUTs und Multiplexer umgewandelt wird (Xilinx). Bei Altera mit den 6 Input LUTs spart man sich die Multiplexer.

<vhdl> LIBRARY ieee; USE ieee.std_logic_1164.ALL; USE ieee.numeric_std.ALL;

--vhdl description of 74185 --6bit binary to 2 digits BCD decoder

ENTITY ttl74185 IS

 PORT (
   binary_i : IN  STD_LOGIC_VECTOR(5 DOWNTO 0);
   bcd_o    : OUT STD_LOGIC_VECTOR(7 DOWNTO 0));

END ttl74185;

ARCHITECTURE behave OF ttl74185 IS

 --integers are better readable for humans
 SIGNAL conv_input : integer RANGE 2**5-1 DOWNTO 0;
 

BEGIN -- behave

conv_input <= to_integer(unsigned(binary_i(5 DOWNTO 1)));
 
 bcd_o(0) <= binary_i(0);
 WITH conv_input SELECT
   bcd_o(1) <=
   '1' WHEN    1,'1' WHEN  3, '1' WHEN  6, '1' WHEN  8,
   '1' WHEN   11,'1' WHEN 13, '1' WHEN 16, '1' WHEN 18,
   '1' WHEN   21,'1' WHEN 23, '1' WHEN 26, '1' WHEN 28,
   '1' WHEN   31,
   '0' WHEN OTHERS;
 WITH conv_input SELECT
   bcd_o(2) <=
   '1' WHEN    2,'1' WHEN  3, '1' WHEN  7, '1' WHEN 8,  
   '1' WHEN   12,'1' WHEN 13, '1' WHEN 17, '1' WHEN 18, 
   '1' WHEN   22,'1' WHEN 23, '1' WHEN 27, '1' WHEN 28, 
   '0' WHEN OTHERS;
             
 WITH conv_input SELECT
   bcd_o(3) <=
   '1' WHEN    4,'1' WHEN  9, '1' WHEN 14, '1' WHEN 19,  
   '1' WHEN   24,'1' WHEN 29,
   '0' WHEN OTHERS;
 WITH conv_input SELECT
   bcd_o(4) <=
   '1' WHEN  5,'1' WHEN  6, '1' WHEN  7, '1' WHEN  8, '1' WHEN  9,  
   '1' WHEN 15,'1' WHEN 16, '1' WHEN 17, '1' WHEN 18, '1' WHEN 19,  
   '1' WHEN 25,'1' WHEN 26, '1' WHEN 27, '1' WHEN 28, '1' WHEN 29,  
   '0' WHEN OTHERS;
WITH conv_input SELECT
   bcd_o(5) <=
   '1' WHEN 10,'1' WHEN 11, '1' WHEN 12, '1' WHEN 13, '1' WHEN 14,  
   '1' WHEN 15,'1' WHEN 16, '1' WHEN 17, '1' WHEN 18, '1' WHEN 19,  
   '1' WHEN 30,'1' WHEN 31,
   '0' WHEN OTHERS;

 WITH conv_input SELECT
   bcd_o(6) <=
   '1' WHEN 20,'1' WHEN 21, '1' WHEN 22, '1' WHEN 23, '1' WHEN 24,  
   '1' WHEN 25,'1' WHEN 26, '1' WHEN 27, '1' WHEN 28, '1' WHEN 29,  
   '1' WHEN 30,'1' WHEN 31,
   '0' WHEN OTHERS;
  
  bcd_o(7) <= '0';
 END behave;

</vhdl>