LucaSkywalker

DoubleDabble.vhd

Nov 15th, 2020
78
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library IEEE;
  2. use IEEE.std_logic_1164.all;
  3. use IEEE.std_logic_arith.all;
  4. use IEEE.std_logic_misc.all;
  5. use IEEE.std_logic_unsigned.all;
  6.  
  7. entity DoubleDabble is
  8.     Port (Clk_in: IN STD_LOGIC;
  9.          Data_in: IN STD_LOGIC_VECTOR(7 DOWNTO 0);
  10.             H_out: OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
  11.             T_out: OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
  12.             U_out: OUT STD_LOGIC_VECTOR(3 DOWNTO 0));
  13. end DoubleDabble;
  14.  
  15. architecture Behavioral of DoubleDabble is
  16.     begin
  17.     Main: process(Clk_in)
  18.     variable count : STD_LOGIC_VECTOR(3 DOWNTO 0) := "0000";
  19.      variable IP : STD_LOGIC_VECTOR (19 DOWNTO 0);
  20.         begin
  21.         if Rising_Edge(Clk_in) then
  22.                 if count = "0000" then
  23.                     IP(7 DOWNTO 0) := Data_in;
  24.                     IP(19 DOWNTO 8) := "000000000000";
  25.                     H_out(3 DOWNTO 0) <= "0000";
  26.                     T_out(3 DOWNTO 0) <= "0000";
  27.                     U_out(3 DOWNTO 0) <= "0000";
  28.                     count := count + '1';
  29.                 elsif count < "1000" then
  30.                     IP := IP (18 DOWNTO 0) & '0';
  31.                     count := count + '1';
  32.                         if unsigned(IP(19 DOWNTO 16)) >= 5 then
  33.                             IP(19 DOWNTO 16) := IP(19 DOWNTO 16) + "0011";
  34.                         end if;
  35.                         if unsigned(IP(15 DOWNTO 12)) >= 5 then
  36.                             IP(15 DOWNTO 12) := IP(15 DOWNTO 12) + "0011";
  37.                         end if;
  38.                         if unsigned(IP(11 DOWNTO 8)) >= 5 then
  39.                             IP(11 DOWNTO 8) := IP(11 DOWNTO 8) + "0011";
  40.                         end if;
  41.                         H_out(3 DOWNTO 0) <= IP(19 DOWNTO 16);
  42.                         T_out(3 DOWNTO 0) <= IP(15 DOWNTO 12);
  43.                         U_out(3 DOWNTO 0) <= IP(11 DOWNTO 8);
  44.                 elsif count = "1000" then
  45.                     IP := IP (18 DOWNTO 0) & '0';
  46.                     count := count + '1';
  47.                     H_out(3 DOWNTO 0) <= IP(19 DOWNTO 16);
  48.                     T_out(3 DOWNTO 0) <= IP(15 DOWNTO 12);
  49.                     U_out(3 DOWNTO 0) <= IP(11 DOWNTO 8);
  50.                 end if;
  51.         end if;
  52.     end process Main;
  53. end Behavioral;
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×