2016-02-24 95 views
-3

我在它的方面描述图像的文本文件的RGB分量我要加载的FPGA该文件产生RGB信号,因此,如果您能好心开导我,我将感谢如何在VHDL中的RAM上加载文本文件?

欧凯所以这是我想出来的,但是这个综合需要永久完成,所以你认为这里的问题是什么?

library IEEE; 
use IEEE.STD_LOGIC_1164.ALL; 
use IEEE.STD_LOGIC_UNSIGNED.ALL; 
use STD.TEXTIO.ALL; 

-- Uncomment the following library declaration if using 
-- arithmetic functions with Signed or Unsigned values 
--use IEEE.NUMERIC_STD.ALL; 

-- Uncomment the following library declaration if instantiating 
-- any Xilinx primitives in this code. 
--library UNISIM; 
--use UNISIM.VComponents.all; 

entity RGB_Gen is 

    port(CLK : in STD_LOGIC; 
     EN : in STD_LOGIC; 
     R,G,B : out STD_LOGIC); 

end RGB_Gen; 

architecture Behavioral of RGB_Gen is 

    Type ram is array (0 to 611) of BIT_VECTOR(203 downto 0); 

    impure function InitRamFromFile(Filename : in string) return ram is 

    File readFile : text is in Filename; 
    Variable lineRead : Line; 
    Variable my_ram : ram; 

    begin 

     for i in ram'range loop 
     readline(readFile, lineRead); 
     read(lineRead, my_ram(i)); 
    end loop; 

    return my_ram; 

    end function; 

    function toSTD(B : in Bit) return STD_LOGIC is 
    begin  
     if B = '1' then 
      return '1'; 
     else 
      return '0'; 
     end if; 
    end function; 

    Signal my_ram : ram := InitRamFromFile("C:\Users\Mos_X\Desktop\output.txt"); 

    begin 

    process(CLK) 

    Variable X : Integer := 0; 
    Variable Y : Integer := 0; 

    begin 

    if rising_edge(CLK) then 
     if EN = '0' then 
      R <= '0'; 
      G <= '0'; 
      B <= '0'; 
     else 
      R <= toSTD((my_ram(Y)(X))); 
      G <= toSTD((my_ram(Y + 204)(X))); 
      G <= toSTD((my_ram(Y + 408)(X)));  
     end if; 

     if X = 203 then 
      X := 0; 
     if Y = 203 then 
      Y := 0; 
     else 
      Y := Y + 1; 
      end if; 
     else 
      X := X + 1; 
     end if; 

    end if; 

end process; 

end Behavioral; 
+1

如果综合速度很慢,你会问它做了一些艰难的事情,一个三端口RAM(ROM)机智h 204位宽端口。您有一个包含三个204位到1位多路复用器的进程。考虑三个RAM(ROM)1位宽或浪费一点内存并使用4位宽的东西。 – user1155120

+0

是否有将线读取转换为STD_LOGIC_VECTOR的方法?我想我在那里使用read(lineRead,my_ram(i))是不正确的。综合性问题现在对我来说不是什么大问题,我的首要任务就是让它工作。 – Mostafa

+0

从RAM中读取时,您正在分配'G'两次。这是打算?你正在使用哪个综合工具? –

回答

-1

所以问题是,当使能信号为0,这是使静态的,所以这

if rising_edge(CLK) then 
     if EN = '0' then 
      R <= '0'; 
      G <= '0'; 
      B <= '0'; 
     else 
      R <= toSTD((my_ram(Y)(X))); 
      G <= toSTD((my_ram(Y + 204)(X))); 
      G <= toSTD((my_ram(Y + 408)(X))); 

      if X = 203 then 
       X := 0; 
      if Y = 203 then 
       Y := 0; 
      else 
      Y := Y + 1; 
       end if; 
      else 
       X := X + 1; 
      end if; 
     end if; 
    end if; 

代替此

if rising_edge(CLK) then 
     if EN = '0' then 
      R <= '0'; 
      G <= '0'; 
      B <= '0'; 
     else 
      R <= toSTD((my_ram(Y)(X))); 
      G <= toSTD((my_ram(Y + 204)(X))); 
      G <= toSTD((my_ram(Y + 408)(X)));  
     end if; 

     if X = 203 then 
      X := 0; 
     if Y = 203 then 
      Y := 0; 
     else 
      Y := Y + 1; 
      end if; 
     else 
      X := X + 1; 
     end if; 

    end if; 

在代码中的两个计数器甚至被递增将解决问题

+2

这个问题在你的问题中并不明显。 titlei **如何在VHDL中的RAM上加载文本文件?**其中您添加了自己加载RAM的方法。而*** Okey,所以这就是我想出的,但有一个问题综合是永远完成,所以你认为这里的问题是什么??!***,你甚至没有指出什么问题是。你在问如何得到这个综合?您的答案地址中哪些问题是您的答案? – user1155120

+0

我想知道在编写所有这些代码之前,将文本文件的内容加载到fpga的内存中的最有效的方式,但是因为您都认为这个问题太广泛了,而我并没有看到这种方式,所以我继续说我的想法,并试图从中得出结果,最后我得到了图像在屏幕上,但大约5-10分钟的综合 – Mostafa

相关问题