Can anyone think of a workaround - Ideally I want to pass an accesstype into an entity (not for synt

Discussion in 'VHDL' started by Tricky, Apr 8, 2011.

  1. Tricky

    Tricky Guest

    Im building a model of a memory interface. The entity mimics the
    interface of the normal memory interface with multiple request,
    address, ack and data valid lines, one set per channel. Internally I
    have a protected type that handles the memory modelling (dynamically
    creating memory locations as they are accessed so I dont have a
    monstrous 256Mbyte array declared) and another protected that handles
    the read queue.

    As this is modelling a memory in a video system, I want to be able to
    dump whole images (ie bypassing the whole interface) into memory, for
    example if Im only testing the other bits of the design on the read
    side of the interface. I have everything I need for reading/writing
    bitmaps to specific array types, but I just need to get these arrays
    into this entity.

    Heres the pinch - I really dont want to specify the size of the image,
    as this may well handle multiple video standards on hardware, so I
    need the image sizes to vary accordingly. Id love to be able to pass
    in an access type and watch the transactions on it - but of course
    access types can only be variables - therefore not suitable for ports
    on an entity. Can anyone think of any other way I could get these
    arrays into the interface without padding?

    The only thing I can think of is sticking image sizes as generics and
    declaring the "image" port to this size, but I would prefer more
    flexibility.

    So - am I just pushing too hard? How long before someone pipes up that
    I should try System Verilog?
    Tricky, Apr 8, 2011
    #1
    1. Advertising

  2. Tricky

    KJ Guest

    Re: Can anyone think of a workaround - Ideally I want to pass anaccess type into an entity (not for synthesis)

    On Apr 8, 11:12 am, Tricky <> wrote:
    > Im building a model of a memory interface. The entity mimics the
    > interface of the normal memory interface with multiple request,
    > address, ack and data valid lines, one set per channel. Internally I
    > have a protected type that handles the memory modelling (dynamically
    > creating memory locations as they are accessed so I dont have a
    > monstrous 256Mbyte array declared) and another protected that handles
    > the read queue.
    >
    > As this is modelling a memory in a video system, I want to be able to
    > dump whole images (ie bypassing the whole interface) into memory, for
    > example if Im only testing the other bits of the design on the read
    > side of the interface. I have everything I need for reading/writing
    > bitmaps to specific array types, but I just need to get these arrays
    > into this entity.
    >
    > Heres the pinch - I really dont want to specify the size of the image,
    > as this may well handle multiple video standards on hardware, so I
    > need the image sizes to vary accordingly. Id love to be able to pass
    > in an access type and watch the transactions on it - but of course
    > access types can only be variables - therefore not suitable for ports
    > on an entity. Can anyone think of any other way I could get these
    > arrays into the interface without padding?
    >


    Dump the data to a file. Use a string to pass the file name into the
    memory model. If the file name needs to be able to be changed during
    the simulation (i.e. if it must be a 'signal' rather than a 'generic')
    than the only limitation will be that the string name will need to be
    a fixed size. Even that limitation can be less onerous if you simply
    use a loooooong string size, null terminate the string and then have
    the memory model construct the file name by looking for the null
    termination.

    Even better, if you're using standard bitmap file formats like .BMP
    for the exchange than you can create read/write BMP file procedures
    which you will no doubt use somewhere down the road and not be tied to
    this particular memory model instance.

    Kevin Jennings
    KJ, Apr 8, 2011
    #2
    1. Advertising

  3. Tricky

    Andy Guest

    Re: Can anyone think of a workaround - Ideally I want to pass anaccess type into an entity (not for synthesis)

    On Apr 8, 10:12 am, Tricky <> wrote:
    > Im building a model of a memory interface. The entity mimics the
    > interface of the normal memory interface with multiple request,
    > address, ack and data valid lines, one set per channel. Internally I
    > have a protected type that handles the memory modelling (dynamically
    > creating memory locations as they are accessed so I dont have a
    > monstrous 256Mbyte array declared) and another protected that handles
    > the read queue.
    >
    > As this is modelling a memory in a video system, I want to be able to
    > dump whole images (ie bypassing the whole interface) into memory, for
    > example if Im only testing the other bits of the design on the read
    > side of the interface. I have everything I need for reading/writing
    > bitmaps to specific array types, but I just need to get these arrays
    > into this entity.
    >
    > Heres the pinch - I really dont want to specify the size of the image,
    > as this may well handle multiple video standards on hardware, so I
    > need the image sizes to vary accordingly. Id love to be able to pass
    > in an access type and watch the transactions on it - but of course
    > access types can only be variables - therefore not suitable for ports
    > on an entity. Can anyone think of any other way I could get these
    > arrays into the interface without padding?
    >
    > The only thing I can think of is sticking image sizes as generics and
    > declaring the "image" port to this size, but I would prefer more
    > flexibility.
    >
    > So - am I just pushing too hard? How long before someone pipes up that
    > I should try System Verilog?


    How about flattening your image into a single vector, and pass it in
    on an unconstrained array (e.g. SLV) port? Add generics (static) or
    other ports (dynamic) for pixel/row/column size to tell the model how
    to extract the image from the linear vector.

    Andy
    Andy, Apr 8, 2011
    #3
  4. Re: Can anyone think of a workaround - Ideally I want to pass an access type into an entity (not for synthesis)

    On Fri, 8 Apr 2011 08:12:52 -0700 (PDT), Tricky wrote:

    > Id love to be able to pass
    >in an access type and watch the transactions on it - but of course
    >access types can only be variables - therefore not suitable for ports
    >on an entity. Can anyone think of any other way I could get these
    >arrays into the interface without padding?


    In the past when I've needed to do this kind of thing,
    one approach has been to create a package with a pool
    of objects (shared variables) in it, and then have
    entity instances register themselves with the package
    by calling appropriate functions in it. An instance
    can supply its own instance name to such a call as
    a string including 'PATH_NAME, allowing the package
    to work out which instance placed the call. It's
    a bit upside-down and clumsy, but can sometimes
    provide the kind of functional communication you
    seem to be wanting. You likely need some sort of
    side-channel into the instances, in the form of
    a regular port of boolean or some enumerated
    type, to allow you to signal interesting events
    from one instance to another; the instances can
    then use the package pool as a shared communication
    medium, and the idea of each instance registering
    itself with the package by means of its string
    instance name stops things being outrageously
    global.

    It's a while since I did any of this, so the
    details are a bit sketchy in my mind. But it looks
    as though I may soon be needing to dust off these
    tricks once again...
    --
    Jonathan Bromley
    Jonathan Bromley, Apr 8, 2011
    #4
  5. Tricky

    Tricky Guest

    Re: Can anyone think of a workaround - Ideally I want to pass anaccess type into an entity (not for synthesis)

    On Apr 8, 8:31 pm, KJ <> wrote:
    > On Apr 8, 11:12 am, Tricky <> wrote:
    >
    >
    >
    > > Im building a model of a memory interface. The entity mimics the
    > > interface of the normal memory interface with multiple request,
    > > address, ack and data valid lines, one set per channel. Internally I
    > > have a protected type that handles the memory modelling (dynamically
    > > creating memory locations as they are accessed so I dont have a
    > > monstrous 256Mbyte array declared) and another protected that handles
    > > the read queue.

    >
    > > As this is modelling a memory in a video system, I want to be able to
    > > dump whole images (ie bypassing the whole interface) into memory, for
    > > example if Im only testing the other bits of the design on the read
    > > side of the interface. I have everything I need for reading/writing
    > > bitmaps to specific array types, but I just need to get these arrays
    > > into this entity.

    >
    > > Heres the pinch - I really dont want to specify the size of the image,
    > > as this may well handle multiple video standards on hardware, so I
    > > need the image sizes to vary accordingly. Id love to be able to pass
    > > in an access type and watch the transactions on it - but of course
    > > access types can only be variables - therefore not suitable for ports
    > > on an entity. Can anyone think of any other way I could get these
    > > arrays into the interface without padding?

    >
    > Dump the data to a file.  Use a string to pass the file name into the
    > memory model.  If the file name needs to be able to be changed during
    > the simulation (i.e. if it must be a 'signal' rather than a 'generic')
    > than the only limitation will be that the string name will need to be
    > a fixed size.  Even that limitation can be less onerous if you simply
    > use a loooooong string size, null terminate the string and then have
    > the memory model construct the file name by looking for the null
    > termination.
    >
    > Even better, if you're using standard bitmap file formats like .BMP
    > for the exchange than you can create read/write BMP file procedures
    > which you will no doubt use somewhere down the road and not be tied to
    > this particular memory model instance.
    >
    > Kevin Jennings


    Thanks all of you for the ideas.

    Kevins is definatly the most practical for me. Ive had a library full
    of bitmap reading, writing and colour space converting for about 3
    years, so the string thing is easiest (already have a string pad
    function and string tokenising protected type, so I can easily pass in
    multiple images in a single generic from the top level testbench) -
    normally I throw images around in their own array type once read,
    which is probably why I didnt think of it myself.

    Im going to make a record type with start address and image path, and
    sit on that port waiting for a transaction.

    Cheers guys :)
    Tricky, Apr 9, 2011
    #5
  6. Re: Can anyone think of a workaround - Ideally I want to pass an access type into an entity (not for synthesis)

    KJ <> writes:

    > Dump the data to a file. Use a string to pass the file name into the
    > memory model. If the file name needs to be able to be changed during
    > the simulation (i.e. if it must be a 'signal' rather than a 'generic')
    > than the only limitation will be that the string name will need to be
    > a fixed size. Even that limitation can be less onerous if you simply
    > use a loooooong string size, null terminate the string and then have
    > the memory model construct the file name by looking for the null
    > termination.
    >
    > Even better, if you're using standard bitmap file formats like .BMP
    > for the exchange than you can create read/write BMP file procedures
    > which you will no doubt use somewhere down the road and not be tied to
    > this particular memory model instance.


    Seconded.

    For other readers (as I know both KJ and Tricky know this) when I do this, I
    use ASCII-PGM files, as I've found accessing binary files (like BMP) to be
    non-portable across simulators. If this doesn't matter to you, by all means
    use BMP :)

    Cheers,
    Martin

    --

    TRW Conekt - Consultancy in Engineering, Knowledge and Technology
    http://www.conekt.co.uk/capabilities/39-electronic-hardware
    Martin Thompson, Apr 11, 2011
    #6
  7. Re: Can anyone think of a workaround - Ideally I want to pass anaccess type into an entity (not for synthesis)

    On Mon, 11 Apr 2011 11:14:12 +0100, Martin Thompson wrote:

    > KJ <> writes:
    >
    >> Dump the data to a file. Use a string to pass the file name into the
    >> memory model. If the file name needs to be able to be changed during
    >> the simulation (i.e. if it must be a 'signal' rather than a 'generic')
    >> than the only limitation will be that the string name will need to be a
    >> fixed size. Even that limitation can be less onerous if you simply use
    >> a loooooong string size, null terminate the string and then have the
    >> memory model construct the file name by looking for the null
    >> termination.
    >>
    >> Even better, if you're using standard bitmap file formats like .BMP for
    >> the exchange than you can create read/write BMP file procedures which
    >> you will no doubt use somewhere down the road and not be tied to this
    >> particular memory model instance.

    >
    > Seconded.
    >
    > For other readers (as I know both KJ and Tricky know this) when I do
    > this, I use ASCII-PGM files, as I've found accessing binary files (like
    > BMP) to be non-portable across simulators. If this doesn't matter to
    > you, by all means use BMP :)
    >


    My approach has been to perform binary I/O through an unofficial
    "portability layer".
    Modelsim and Xilinx ISIM (10.3) are the two I have experience of.

    ISIM insists on reading a short undocumented* header before the actual
    data. To satisfy this, I have simple scripts to separate header and file
    (using "head" and "tail) from ISIM output files, and to "cat" a header
    onto any binary file before I read it into ISIM.

    The other difference is endian-ness; I set a boolean flag ("is_isim")
    which controls end-swapping in both input/output routines.

    (* Xilinx refused to provide any documentation on the header despite a
    Webcase specifically asking for it)

    - Brian
    Brian Drummond, Apr 11, 2011
    #7
  8. Tricky

    JimLewis Guest

    Re: Can anyone think of a workaround - Ideally I want to pass anaccess type into an entity (not for synthesis)

    On Apr 8, 8:12 am, Tricky <> wrote:
    > Im building a model of a memory interface. The entity mimics the
    > interface of the normal memory interface with multiple request,
    > address, ack and data valid lines, one set per channel. Internally I
    > have a protected type that handles the memory modelling (dynamically
    > creating memory locations as they are accessed so I dont have a
    > monstrous 256Mbyte array declared) and another protected that handles
    > the read queue.
    >
    > As this is modelling a memory in a video system, I want to be able to
    > dump whole images (ie bypassing the whole interface) into memory, for
    > example if Im only testing the other bits of the design on the read
    > side of the interface. I have everything I need for reading/writing
    > bitmaps to specific array types, but I just need to get these arrays
    > into this entity.
    >

    In the past, I have used a separate transaction type of interface to
    handle this. It was real basic - send a memory word at a time.
    However, in VHDL-2008, you should be able to access the
    shared variable of the memory with an external name and use the
    methods provided by your protected type. Have not tried this
    application of external names, but I intend to soon.

    Best,
    Jim
    JimLewis, Apr 26, 2011
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Balu
    Replies:
    1
    Views:
    415
    Juan T. Llibre
    Feb 24, 2006
  2. Balu
    Replies:
    1
    Views:
    349
    darrel
    Feb 25, 2006
  3. Replies:
    0
    Views:
    333
  4. Replies:
    1
    Views:
    452
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Aug 16, 2006
  5. markla
    Replies:
    1
    Views:
    545
    Steven Cheng
    Oct 6, 2008
Loading...

Share This Page