Forum: FPGA, VHDL & Co. Spartan3 intern RAM mit 4096Byte ->2^12 mit 8 Bit breite


von Dido A. (aldibs)


Lesenswert?

Hallo Leute,

ich bin neu im Bereich der FPGA Programmierung und hab ein kleines
Problem. Ich möche ein internes RAM mit 4096Byte realisieren.
Ich verwende Spartan 3 xc3s200ft256 Starter Kit & Xilinx ISE 7.1 .

Bis jetzt habe ich geschaft 256 Byte zu realisieren2^8, sobald ich
versuche   mehr zu realisieren z.B 2^9 bekomme ich einen Fehler
meldung. und sieht folgendes aus..
   Number of Slice Flip Flops:       4,088 out of   3,840  106%
(OVERMAPPED)
  Number of 4 input LUTs:           2,812 out of   3,840   73%
Logic Distribution:
  Number of occupied Slices:        3,445 out of   1,920
179%(OVERMAPPED).

wie schaffe ich es dass ich 2^12 ohne probleme intern zu realisieren.

vielen dank im Voraus

Code

entity RAM16X8S is
    Port ( WE : in std_logic;
           D : in std_logic_vector(7 downto 0);
           CLK : in std_logic;
           A : in bit_vector(3 downto 0);
           O : out std_logic_vector(7 downto 0));
end RAM16X8S;

architecture Behavioral of RAM16X8S is
type MEM_TYPE is array (15 downto 0) of std_logic_vector(7 downto 0);
begin
P1: process(CLK, WE, A)

  Variable ADR_VAR: integer range 0 to 15;
  Variable MEM: MEM_Type;

  begin

    ADR_Var := conv_integer(to_stdLogicVector(A));


      if (CLK='1' and CLK'event) then
        if WE='1' then
          MEM(ADR_VAR) :=D;
        end if;
      end if;


      O <= MEM(ADR_VAR);
   end process P1;

end Behavioral;
---------------------------------------------------------------
entity ram32 is
    Port ( WE : in std_logic;
           CLK : in std_logic;
           EN : in std_logic;
           A : in bit_vector(3 downto 0);
           DIN : in std_logic_vector(7 downto 0);
           DOUT : out std_logic_vector(7 downto 0));
end ram32;

architecture Behavioral of ram32 is
Signal Dint : std_logic_vector(7 downto 0);
signal WEINT : std_logic;


component RAM16x8s
Port ( WE : in std_logic;
           D : in std_logic_vector(7 downto 0);
           CLK : in std_logic;
           A : in bit_vector(3 downto 0);
           O : out std_logic_vector(7 downto 0));
end component;
begin

WEINT <= WE and EN;

HIGH_Byte2: RAM16X8s
  port map (WE=>WEINT, D=>Din(7 downto 0), CLK=>CLK, A=>A, O=>Dint(7
downto 0));
  Dout <=Dint when EN='1' else (others=>'Z');

end Behavioral;
------------------------------------------------------------------
entity ram is
    Port ( WE : in std_logic;
           CLK : in std_logic;
           A : in bit_vector(8 downto 0);
           Din : in std_logic_vector(7 downto 0);
           Dout : out std_logic_vector(7 downto 0));
end ram;

architecture Behavioral of ram128 is
component ram32
port ( WE : in std_logic;
           CLK : in std_logic;
           EN : in std_logic;
           A : in bit_vector(3 downto 0);
           DIN : in std_logic_vector(7 downto 0);
           DOUT : out std_logic_vector(7 downto 0));
end component;

signal enable: std_logic_vector(63 downto 0);
signal LADR: bit_vector(3 downto 0);
signal HADR: bit_vector(4 downto 0);
begin
 HADR<=A(8 downto 4);
 LADR<=A(3 downto 0);

P1:Process(HADR)
  variable enable_var: std_logic_vector(63 downto 0);
  variable int: integer range 0 to 63;

  begin
    enable_var := (others=>'0');
    INT := conv_integer(To_StdLogicVector(HADR));

    enable_var(int):='1';
    enable <=enable_var;

end process P1;

GEN: for I in 63 downto 0 generate
    RAM_BLOCK: RAM32
    port map(WE,CLK,Enable(I),LADR,Din,Dout);
    end generate;

end Behavioral;

von Sven J. (svenj)


Lesenswert?

Moin...

definier bitte man "ohne Probleme"...

Gut, jedenfalls verbrennst du ohne ohne FF zum speichern, so kann es
schlicht nicht gehen. Mach eine Instanz Block-RAM auf und nutze die,
davon sollte genügend da sein.

--
 SJ

von Matthias (Gast)


Lesenswert?

genau, man benutzt keine Logik Zellen für größere RAM-Blöcke, da man
dadurch wie du merkst sehr schnell Logikzellen los wird.

Binde Block Ram Module ein, heißen irgendwie RAMB.... , kann man in ISE
schnell hinklicken.

von Thomas B. (paraglider)


Lesenswert?

Hallo Dido,

dein Synthetisierer nutzt anstelle des Block-RAM simple Flipflops - und
davon hat der Baustein nunmal nur knapp 4000. Wie du ihm beibringst, die
BRAMs zu benutzen, kannst du dir bei meinem Digitalen Funktionsgenerator
etwa 30 Beiträge weiter unten abschauen. Da instanziiere ich einmal ein
BRAM (in sinus_generator.vhd), einmal inferiere ich es (in
user_interface.vhd). Beide Methoden sind vom Ergebnis identisch.

Du möchtest ja eher inferieren, daher hier die Templates von Xilinx, du
findest sie auch im Webpack. Wie du siehst, ist das zumindest formal
nicht das Selbe wie in deinem Code - beim Inferieren solltest du dich
immer ziemlich genau daran halten.

Write first:
process (<clock>)
begin
   if (<clock>'event and <clock> = '1') then
      if (<ram_enable> = '1') then
         if (<write_enable> = '1') then
            <ram_name>(conv_integer(<address>)) <= <input_data>;
            <ram_output> <= <input_data>;
         else
            <ram_output> <= ram_name>(conv_integer(<address>));
         end if;
      end if;
   end if;
end process;

Read first:
process (<clock>)
begin
   if (<clock>'event and <clock> = '1') then
      if (<ram_enable> = '1') then
         if (<write_enable> = '1') then
            <ram_name>(conv_integer(<address>)) <= <input_data>;
            <ram_output> <= ram_name>(conv_integer(<address>));
         end if;
      end if;
   end if;
end process;

Gruß,
Thomas

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.