ISE versus Modelsim inconsistency and attribute definition

I have two questions regarding the code bellow.

I need a dual port buffer (4Kx32 write only, 8Kx16 r/w port). I have instanciated 8 block RAMS as the code bellow shows:

------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; library UNISIM; use UNISIM.VComponents.all;

entity acqbuf is Port ( i_Clk : in std_logic; i_AddrA : in std_logic_vector(11 downto 0); i_DataInA : in std_logic_vector(31 downto 0); i_WrEnA : in std_logic; i_EnA : in std_logic; i_WrEnB : in std_logic; i_EnB : in std_logic; i_AddrB : in std_logic_vector(12 downto 0); i_DataInB : in std_logic_vector(15 downto 0); o_DataOutB : out std_logic_vector(15 downto 0) ); end acqbuf;

architecture structural of acqbuf is component RAMB16_S2_S4 -- pragma translate_off generic ( WRITE_MODE_A : string := "WRITE_FIRST" ; WRITE_MODE_B : string := "WRITE_FIRST" ; ); -- pragma translate_on port ( DIA : in std_logic_vector (1 downto 0); ADDRA : in std_logic_vector (12 downto 0); ENA : in std_logic; WEA : in std_logic; SSRA : in std_logic; CLKA : in std_logic; DOA : out std_logic_vector (1 downto 0); -- DIB : in std_logic_vector (3 downto 0); ADDRB : in std_logic_vector (11 downto 0); ENB : in std_logic; WEB : in std_logic; SSRB : in std_logic; CLKB : in std_logic; DOB : out std_logic_vector (3 downto 0) ); end component; attribute BOX_TYPE of RAMB16_S2_S4 : COMPONENT is "BLACK_BOX";

begin

RAM : for i in 0 to 7 generate U_RAMB16_S2_S4 : RAMB16_S2_S4 port map ( DIA => i_DataInB(i*2+1 downto i*2), ADDRA => i_AddrB, ENA => i_EnB, WEA => i_WrEnB, SSRA => '0', CLKA => i_Clk, DOA => o_DataOutB(i*2+1 downto i*2), -- DIB => i_DataInA(i*4+3 downto i*4), ADDRB => i_AddrA, ENB => i_EnA, WEB => i_WrEnA, SSRB => '0', CLKB => i_Clk, DOB => open ); end generate; end structural;

-------

Whereas this code compiles with no error under ISE, under Modelsim I get the following result:

do acqbuf_tb.fdo # ** Warning: (vlib-34) Library already exists at "work". # Model Technology ModelSim XE II vcom 5.8c Compiler 2004.03 Mar 26 2004 # -- Loading package standard # -- Loading package std_logic_1164 # -- Loading package vital_timing # -- Loading package vcomponents # -- Compiling entity acqbuf # -- Compiling architecture structural of acqbuf # ** Error: acqbuf.vhd(33): near ")": expecting: IDENTIFIER # ** Error: D:/Modeltech_xe_starter/win32xoem/vcom failed. # Error in macro ./acqbuf_tb.fdo line 5 # D:/Modeltech_xe_starter/win32xoem/vcom failed. # while executing # "vcom -93 -explicit acqbuf.vhd # "

The only way to fix it I have found is commenting the generic section. Is there a decent way to do it keeping that section?

The second question is fairly (rather?) newbie: how to define the attributes for the instanciated blocks? I suppose the declarationos in the generic section aren't enough to guarantee the instanciated components behave like I mean them to.

I tried to do it as in the snippet bellow and I get compilation error:

RAM : for i in 0 to 7 generate attribute WRITE_MODE_A : string; WRITE_MODE_A of URAMB16_S2_S4 : lable is "WRITE_FIRST"; attribute WRITE_MODE_B : string; WRITE_MODE_B of URAMB16_S2_S4 : lable is "WRITE_FIRST";

U_RAMB16_S2_S4 : RAMB16_S2_S4 port map ( DIA => i_DataInB(i*2+1 downto i*2),

Thank you in advance for your help.

Elder.

Reply to
Elder Costa
Loading thread data ...

removing the semicolon after the second generic in component should work.

Reply to
Neo

It didn't.

Reply to
Elder Costa

There seem to be various typos in those code snippets you posted- did you cut and paste, or re-type them, into your post?

Also, an important BRAM safety tip:

A variable width dual port spanning multiple BRAMs needs reindexing of the wider port bits to do what you intend.

For some old posts on this subject, see:

formatting link
formatting link

Brian

Reply to
Brian Davis

Cut and pasted. The only real typo was the extra semicolon Neo pointed out (Xst just ignores it :-( ). If you mean the exchanged As and Bs, that was due me not willing to change the VHDL code in the hierarchy this module is par of.

I guess I learned that today the worst way. It took me a couple of hours looking at simulation results to figure it out.

Thanks & regards.

Elder

Reply to
Elder Costa

Your attribute example needs underscores in the label name (U_RAM...) and proper spelling of "lable".

Your first example parses & elaborates OK in VHDL-Simili if I fix the offending semicolon as follows:

generic ( WRITE_MODE_A : string := "WRITE_FIRST" ; WRITE_MODE_B : string := "WRITE_FIRST" );

Other suggestions:

- if you're using unisim.vcomponents, there's no need to redefine the RAMB16_S2_S4 component here, as it's already defined in the unisim library

- if using XST, the last few versions of XST understand generics - you can just use a generic map without the translate on/off stuff, and skip the attributes. ( See the "Virtex Primitive Support" section of the XST manual for examples of each method )

- if you still want to use attributes, make sure they match the generics, or your synth and sim results will differ

Brian

Reply to
Brian Davis

Hmm, Google-Groups-Beta seems to have mangled the four lines of code in my last post unless you use "show options" to display the original message.

Anyone out there know how to post/read from Groups-Beta without it auto-mangling code & message text?

They've added a "fixed font" selection in the upper right corner of the reader page, which helps, but it still seems to take other liberties that don't show up on the "preview message" display.

I also miss the "email me a copy" checkbox of the "old & improved" google-groups posting mechanism.

Brian

Reply to
Brian Davis

I have had similar problems and switched to this server:

formatting link

It's a real news server and works good for free.

-- Mike Treseler

Reply to
Mike Treseler

O damn!!! I thought you meant the code in the first part of the message. You're right, I typed the bottom code snippet at home but i think office's version was right (I mean no typos). Not sure though.

Yes, I have already fixed this.

Hum... I followed Xilinx app notes and some of their example code (perhaps some old ones). This kind of code (that is, code that deploys more sofisticated - from a newbie point of view - resources from VHDL such as attributes and generic mapping) is kind of black magic for me. I just tend to follow code examples and perform minor changes needed to solve my problem. In the process I might end not using the language in the best way.

Anyway I wiped out the redundant declaration as your suggested.

I had done so.

Oh my. RTFM is always wise. Still I insist in forgetting it. :-) Too much to learn and just 24h a day. :-)

It turned out using the generic map in the instantiation (after the aforementioned wipe out) worked in simulation and generated the expected result at least as shown by FPGA editor (I played with different write modes just to check it out in both simulation and FPGA editor.)

Thanks a lot for your hints. I really appreciated.

Elder

Reply to
Elder Costa

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.