coding help

Discussion in 'The Projects Forum' started by pakhi, Dec 21, 2011.

  1. pakhi

    Thread Starter New Member

    Dec 21, 2011
    1
    0
    Hi,
    this code has no connection between input and output. can anyone please help me to separate the RAM and take data from RAM to do the computation,
    The input data should fill the RAM ,
    I mean the module RLD should have an input data line which actually fill the Ram location and the circuit is taking data from RAM and do the computation. How can modify the code like that?
     
  2. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    I'm posting it enclosed in code tags so somebody can be of more assistance:
    Code ( (Unknown Language)):
    1.  
    2. library IEEE;
    3. use IEEE.STD_LOGIC_1164.ALL;
    4. use IEEE.NUMERIC_STD.ALL;
    5. entity RLD is
    6.  Port ( clk : in STD_LOGIC;
    7.  cout : out STD_LOGIC;
    8. lastut : out STD_LOGIC_VECTOR(7 downto 0));
    9.  end RLD;
    10. architecture Behavioral of RLD is type RAM_t is array (0 to 15) of std_logic_vector (7 downto 0);
    11. signal RAM : RAM_t := ( x"AA", x"00", x"FF", x"FF", x"01", x"00", x"00", x"01", x"AA", x"AA", x"00", x"FF",
    12. x"FF", x"03", others=>x"00");
    13. signal idx : integer range RAM_t'range := 0;
    14. signal rpt : integer range 0 to 255; -- repeat counter max. 255
    15. signal last : std_logic_vector(7 downto 0) := x"FF"; -- for lastuble-byte check: beware the first byte in RAM being xff!
    16. signal gl : std_logic := '0'; -- get length out of RAM
    17. signal phase : std_logic := '0';
    18. begin
    19. process begin
    20. wait until rising_edge(clk);
    21. phase <= not phase;
    22.  if (phase='0') then
    23.  if (rpt>0) then  -- something to repeat?
    24. rpt <= rpt-1;
    25. else idx <= idx+1;  -- beware of reaching the end of the RAM!
    26. if (last=RAM(idx)) then  -- next: get length
    27.  gl <= '1';
    28. else
    29.  last <= RAM(idx);
    30. end if;
    31. end if;
    32. else if (gl='1') then -- get length
    33.  rpt <= to_integer(unsigned(RAM(idx)));
    34.  idx <= idx+1; -- beware of reaching the end of the RAM!
    35.  end if;
    36. gl <= '0';
    37. end if;
    38. end process;
    39. lastut <= last;
    40. cout <= phase;
    41. end Behavioral;
    42.  
     
Loading...