Sign In

Don't have a Xilinx account yet?

  • Choose to receive important news and product information
  • Gain access to special content
  • Personalize your web experience on Xilinx.com

Create Account

Username

Password

Forgot your password?
XClose Panel
Xilinx Home
Reply
Regular Contributor
mapedd
Posts: 51
Registered: ‎12-21-2011
0

Re: Sample project using MIG

thanks mate! that's very big help for me!

Regular Contributor
mapedd
Posts: 51
Registered: ‎12-21-2011
0

Re: Sample project using MIG

After some time i was able to synthesize the project, but there was a first bump as soon as i start trying to simluate a write to ddr, after asserting reset to high and then to low, the calib_done signal never goes to high state.

 

I've simulated my design for 15us in iSim but ddr seems to be dead.

 

I've attached my design files to this post - any  help will be appreciated 

Expert Contributor
joelby
Posts: 1,055
Registered: ‎10-05-2010

Re: Sample project using MIG

I've only had a quick look at your code, but it doesn't appear that you've hooked your UUT up to the DDR3 simulation model in your test bench. If you have a look at my MIG tutorial, you'll see that I've instantiated a ddr2_model_c3 and hooked it up (I also ran into the same problem in the beginning, and noted that you can't simulate memory access without also simulating the memory chip).

 

You've used a DDR3 part, so it looks like your model is under ipcore_dir/m_mcb_ddr3/user_design/sim/ddr3_model_c3.v . You may or may not need to fiddle with the other parameters like I did if this model doesn't default to the parameters you want. The simulation parameters are specified in the file ipcore_dir/m_mcb_ddr3/user_design/sim/m_mcb_ddr3.prj on this line:

 

verilog  work  ./ddr3_model_c3.v -d x2Gb -d sg15E -d x16 -i ./

That's all well and good if you want to run the simulation from the command line, but I don't think this applies if you run ISim from within ISE (correct me if I'm wrong!). That's why I just defined those parameters in the parameters file (which will be ddr3_model_parameters_c3.vh for you) so that there would be no confusion.

 

Also, with the DDR2 part I've simulated, I noted that calibration takes about 76 µs to complete (with a calibration clock of about 75 MHz), but you'll see a bit of activity in the simulator from time to time before it finishes. I think you can fiddle with the MIG's calibration/simulation settings to reduce this time if you're a busy guy.

 

Regular Contributor
mapedd
Posts: 51
Registered: ‎12-21-2011
0

Re: Sample project using MIG

[ Edited ]

Thanks Joel!

 

I've instantiated  ddr2_model_c3  but it's a bit tedious to connect dm_tdqs, dqs, dqs_n ports to mcb. 

Those lines in module generated from MIG are std_logic but memory model need std_logic_vector(1 downto 0), and it confuses me - what i have to connect to other pins ?

 

I've studied the example project generated by mig, there is some hackery dependant on data direction, but i don't know the purpose for this:

 

-- ========================================================================== --
-- Memory model instances                                                     -- 
-- ========================================================================== --

    mcb3_command <= (mcb3_dram_ras_n & mcb3_dram_cas_n & mcb3_dram_we_n);

    process(mcb3_dram_ck)
    begin
      if (rising_edge(mcb3_dram_ck)) then
        if (c3_sys_rst = '0') then
          mcb3_enable1   <= '0';
          mcb3_enable2 <= '0';
        elsif (mcb3_command = "100") then
          mcb3_enable2 <= '0';
        elsif (mcb3_command = "101") then
          mcb3_enable2 <= '1';
        else
          mcb3_enable2 <= mcb3_enable2;
        end if;
        mcb3_enable1     <= mcb3_enable2;
      end if;
    end process;

-----------------------------------------------------------------------------
--read
-----------------------------------------------------------------------------
    mcb3_dram_dqs_vector(1 downto 0)               <= (mcb3_dram_udqs & mcb3_dram_dqs)
                                                           when (mcb3_enable2 = '0' and mcb3_enable1 = '0')
							   else "ZZ";
    mcb3_dram_dqs_n_vector(1 downto 0)             <= (mcb3_dram_udqs_n & mcb3_dram_dqs_n)
                                                           when (mcb3_enable2 = '0' and mcb3_enable1 = '0')
							   else "ZZ";
    
-----------------------------------------------------------------------------
--write
-----------------------------------------------------------------------------
    mcb3_dram_dqs          <= mcb3_dram_dqs_vector(0)
                              when ( mcb3_enable1 = '1') else 'Z';

    mcb3_dram_udqs          <= mcb3_dram_dqs_vector(1)
                              when (mcb3_enable1 = '1') else 'Z';


     mcb3_dram_dqs_n        <= mcb3_dram_dqs_n_vector(0)
                              when (mcb3_enable1 = '1') else 'Z';
    mcb3_dram_udqs_n         <= mcb3_dram_dqs_n_vector(1)
                              when (mcb3_enable1 = '1') else 'Z';

 

 Another thing is that i've tried to simulate your design, and even after > 150 us calib_done did't go to '1', i've used iSim, should i run from the console? Or maybe i've to configure ise/isim in some special way?

 

 

p.s. If you will be reading this before New Year i wish all the best and Happy New Year 2012!

 

Expert Contributor
joelby
Posts: 1,055
Registered: ‎10-05-2010

Re: Sample project using MIG


I've instantiated  ddr2_model_c3  but it's a bit tedious to connect dm_tdqs, dqs, dqs_n ports to mcb. 

Those lines in module generated from MIG are std_logic but memory model need std_logic_vector(1 downto 0), and it confuses me - what i have to connect to other pins ? 


I'm not sure why you'd have a std_logic and a std_logic_vector for the same signal - which signal is it? I have a vague recollection that the DDR2 model has two signals for some control line but only one was required in some situations (but maybe I'm thinking about the extra lines for x16 parts). 


I've studied the example project generated by mig, there is some hackery dependant on data direction, but i don't know the purpose for this:


Not sure either - I haven't looked at the MIG-generated code recently, but it was pretty complicated. You might need to look at what the two different enable registers are used for. I certainly didn't need to do anything like that in my test bench.


Another thing is that i've tried to simulate your design, and even after > 150 us calib_done did't go to '1', i've used iSim, should i run from the console? Or maybe i've to configure ise/isim in some special way?


It should work if you launch ISim from ISE. Make sure you selected the test bench before running the simulation, though. Are the clock signals toggling? Are you seeing any logging/debug messages from the DDR model on the ISim console? It's normally pretty chatty.


p.s. If you will be reading this before New Year i wish all the best and Happy New Year 2012!


Cheers, you too!

Regular Contributor
mapedd
Posts: 51
Registered: ‎12-21-2011
0

Re: Sample project using MIG

The thing is, i need to connect mcb generated by mig with memory model, but lines do not match , some signals i think i ought to connect together are even typed mismatched (std_logic vs. std_logic_vector)

 

this is how memory model ports look like from file generated by mig:

 

   component ddr3_model_c3 is
   port (
      ck        : in    std_logic;
      ck_n     : in    std_logic;
      cke      : in    std_logic;
      cs_n    : in    std_logic;
      ras_n   : in    std_logic;
      cas_n   : in    std_logic;
      we_n    : in    std_logic;
      ba      : in    std_logic_vector((C3_MEM_BANKADDR_WIDTH - 1) downto 0);
      addr    : in    std_logic_vector((C3_MEM_ADDR_WIDTH  - 1) downto 0);
      odt     : in    std_logic;
      rst_n   : in    std_logic;
      
      -- INOUTS
      dq      : inout std_logic_vector((C3_NUM_DQ_PINS - 1) downto 0);
      
      dqs     : inout std_logic_vector((C3_NUM_DQ_PINS/16) downto 0);
      dqs_n   : inout std_logic_vector((C3_NUM_DQ_PINS/16) downto 0);
      
      tdqs_n  : out   std_logic_vector((C3_NUM_DQ_PINS/16) downto 0);
      dm_tdqs : inout std_logic_vector((C3_NUM_DQ_PINS/16) downto 0)
   );

 

 

  and this is how my ports loook slike , simple taken from mcb :

 

 

    COMPONENT m_data_buffer
    PORT(
      clk_i                                   : in  std_logic;
      rst_i                                   : in  std_logic;
      instr                                   : in  std_logic_vector(C_DATA_BUFFER_INSTR-1 downto 0);
      data_i                                  : in  std_logic_vector(C_DATA_AFE_IN_WIDTH-1 downto 0);
      data_fifo_o                             : out std_logic_vector(C_DATA_FIFO_WIDTH-1 downto 0);
      
      
      mcb3_dram_a                             : out      std_logic_vector(C3_MEM_ADDR_WIDTH-1 downto 0);
      mcb3_dram_ba                            : out      std_logic_vector(C3_MEM_BANKADDR_WIDTH-1 downto 0);
      mcb3_dram_ras_n                         : out      std_logic;
      mcb3_dram_cas_n                         : out      std_logic;
      mcb3_dram_we_n                          : out      std_logic;
      mcb3_dram_odt                           : out      std_logic;
      mcb3_dram_reset_n                       : out      std_logic;
      mcb3_dram_cke                           : out      std_logic;
      mcb3_dram_dm                            : out      std_logic;
      mcb3_dram_udm                           : out      std_logic;
      mcb3_dram_ck                            : out      std_logic;
      mcb3_dram_ck_n                          : out      std_logic;
      -- INOUTS
      mcb3_dram_dq                            : inout    std_logic_vector(C3_NUM_DQ_PINS-1 downto 0);
      
      mcb3_dram_udqs                          : inout    std_logic;
      mcb3_dram_udqs_n                        : inout    std_logic;
      
      rzq3                                    : inout    std_logic;
      zio3                                    : inout    std_logic;
      
      mcb3_dram_dqs                           : inout    std_logic;
      mcb3_dram_dqs_n                         : inout    std_logic
        );
    END COMPONENT;

parameters looks like this :

 

   constant C3_P0_MASK_SIZE           : integer := 4;
   constant C3_P0_DATA_PORT_SIZE      : integer := 32;
   constant C3_P1_MASK_SIZE           : integer := 4;
   constant C3_P1_DATA_PORT_SIZE      : integer := 32;
   constant C3_MEMCLK_PERIOD          : integer := 2503;
   constant C3_RST_ACT_LOW            : integer := 0;
   constant C3_INPUT_CLK_TYPE         : string := "SINGLE_ENDED";
   constant C3_CALIB_SOFT_IP          : string := "TRUE";
   constant C3_SIMULATION             : string := "FALSE";
   constant DEBUG_EN                  : integer := 0;
   constant C3_MEM_ADDR_ORDER         : string := "BANK_ROW_COLUMN";
   constant C3_NUM_DQ_PINS            : integer := 16;
   constant C3_MEM_ADDR_WIDTH         : integer := 14;
   constant C3_MEM_BANKADDR_WIDTH     : integer := 3;

 

so i connected both modules in my test bench this way:

 

     u_mem_c3 : ddr3_model_c3 port map
	 (
      ck        => mcb3_dram_ck,
      ck_n      => mcb3_dram_ck_n,
      cke       => mcb3_dram_cke,
      cs_n      => '0',
      ras_n     => mcb3_dram_ras_n,
      cas_n     => mcb3_dram_cas_n,
      we_n      => mcb3_dram_we_n,
      dm_tdqs   => mcb3_dram_dm,
      ba        => mcb3_dram_ba,
      addr      => mcb3_dram_a,
      dq        => mcb3_dram_dq,
      dqs       => mcb3_dram_dqs,
      dqs_n     => mcb3_dram_dqs_n,
      tdqs_n    => open,
      odt       => mcb3_dram_odt,
      rst_n     => mcb3_dram_reset_n
      );

	-- Instantiate the Unit Under Test (UUT)
   uut: m_data_buffer PORT MAP (
          clk_i               => clk_i,
          rst_i               => rst_i,
          instr               => instr,
          data_i              => data_i,
          data_fifo_o         => data_fifo_o,
          mcb3_dram_dq        => mcb3_dram_dq,
          mcb3_dram_a         => mcb3_dram_a,
          mcb3_dram_ba        => mcb3_dram_ba,
          mcb3_dram_ras_n     => mcb3_dram_ras_n,
          mcb3_dram_cas_n     => mcb3_dram_cas_n,
          mcb3_dram_we_n      => mcb3_dram_we_n,
          mcb3_dram_odt       => mcb3_dram_odt,
          mcb3_dram_reset_n   => mcb3_dram_reset_n,
          mcb3_dram_cke       => mcb3_dram_cke,
          mcb3_dram_dm        => mcb3_dram_dm(0),
          mcb3_dram_udqs      => mcb3_dram_udqs,
          mcb3_dram_udqs_n    => mcb3_dram_udqs_n,
          rzq3                => rzq3,
          zio3                => zio3,
          mcb3_dram_udm       => mcb3_dram_udm,
          mcb3_dram_dqs       => mcb3_dram_dqs,
          mcb3_dram_dqs_n     => mcb3_dram_dqs_n,
          mcb3_dram_ck        => mcb3_dram_ck,
          mcb3_dram_ck_n      => mcb3_dram_ck_n
        );

 

using signal declared this way:

 

	--BiDirs
   signal mcb3_dram_dq : std_logic_vector(15 downto 0);
   signal mcb3_dram_udqs : std_logic;
   signal mcb3_dram_udqs_n : std_logic;
   signal rzq3 : std_logic;
   signal zio3 : std_logic;
   signal mcb3_dram_dqs : std_logic;
   signal mcb3_dram_dqs_n : std_logic;

 	--Outputs
   signal data_fifo_o : std_logic_vector(31 downto 0);
   signal mcb3_dram_a : std_logic_vector(13 downto 0);
   signal mcb3_dram_ba : std_logic_vector(2 downto 0);
   signal mcb3_dram_ras_n : std_logic;
   signal mcb3_dram_cas_n : std_logic;
   signal mcb3_dram_we_n : std_logic;
   signal mcb3_dram_odt : std_logic;
   signal mcb3_dram_reset_n : std_logic;
   signal mcb3_dram_cke : std_logic;
   signal mcb3_dram_dm : std_logic_vector(0 downto 0); --
   signal mcb3_dram_udm : std_logic; 
   signal mcb3_dram_ck : std_logic;
   signal mcb3_dram_ck_n : std_logic;

 

 

and here hot some problems:

 

- signals mcb3_dram_dqs , mcb3_dram_dqs_n are one bit std_logic in mcb and there are std_logic_vector (C3_NUM_DQ_PINS/16 downto 0) in memory model, so maybe there is a bug in memory model and i add " - 1 " to the vector high end?

 

 

Expert Contributor
joelby
Posts: 1,055
Registered: ‎10-05-2010

Re: Sample project using MIG

[ Edited ]

From your 14th post, it looks like the example project uses the concatenation of the udqs(_n) and dqs(_n) signals to form the two-bit vector. The model doesn't have a udqs port, so this kind of makes sense.

 

Note that the memory model is supplied by the RAM vendor, not Xilinx, so perhaps there are just some port nomenclature mis-matches that you have to work through?

 

Actually, if you look at my test bench code (for the DDR2 model), you'll see that I've concatenated these signals too:

 

	// The Micron DDR2 SDRAM simulation model
	ddr2_model_c3 u_mem_c3(
		.ck         (DDR2CLK_P),
		.ck_n       (DDR2CLK_N),
		.cke        (DDR2CKE),
		.cs_n       (1'b0),
		.ras_n      (DDR2RASN),
		.cas_n      (DDR2CASN),
		.we_n       (DDR2WEN),
		.dm_rdqs    ({DDR2UDM,DDR2LDM}),
		.ba         (DDR2BA),
		.addr       (DDR2A),
		.dq         (DDR2DQ),
		.dqs        ({DDR2UDQS_P,DDR2LDQS_P}),
		.dqs_n      ({DDR2UDQS_N,DDR2LDQS_N}),
		.rdqs_n     (),
		.odt        (DDR2ODT)
	);

 

Regular Contributor
mapedd
Posts: 51
Registered: ‎12-21-2011
0

Re: Sample project using MIG

thanks, i swear i didn't see that concatenation, it clarifies a lot in this test bench :D, back to work, maybe today i will finally simulate that **bleep**...
Regular Contributor
mapedd
Posts: 51
Registered: ‎12-21-2011
0

Re: Sample project using MIG

Hi again.

Unfortunately after i think correctly connecting and concatenating those lines DDR RAM model don't assert calib_done signal during even long simulation.

Weird thing is that lines dramm_reset_n and dram_cke are asserted around 1.7ms, much later than in your design.

 

One thing i'm not sure about is defining those parameters:

 

verilog  work  ./ddr3_model_c3.v -d x2Gb -d sg15E -d x16 -i ./

  in the file "ddr3_model_parameters_c3.vh", did you meant to copy this line there or maybe something else?

 

I've attached link to simulation waveforms and to my project files, thanks for any help, i think there is not much left to bring this controller ( or simulation ) to life....

 

joelby's design

 

my design

Expert Contributor
joelby
Posts: 1,055
Registered: ‎10-05-2010
0

Re: Sample project using MIG


One thing i'm not sure about is defining those parameters:


Have a look at my tutorial - the bit where I said "Add the following lines to the top (customised for your RAM)". Basically, just convert each -d option to a new `define line.

 

One reason why it's taking a lot longer might be that you've got C3_SIMULATION set to FALSE in m_data_buffer.vhd - it's my understanding that setting the simulation mode makes the simulation a lot quicker, or something. I don't remember if I ever tested this myself. Do you get any debug output from the DDR3 model?