VHDL code in Latex

Discussion in 'VHDL' started by Enes Erdin, Aug 1, 2009.

  1. Enes Erdin

    Enes Erdin Guest

    Hi,

    Recently I am trying to put some VHDL codes in a report written by
    Latex. Although I have found some information about how to do it I
    could not apply it in the report. My aim is not to use the Verbatim
    style, I want to write some piece of code and add caption to it. For
    that purpose listing package seems to be the most suitable package for
    doing it but it does not truly represent the code. I wonder how you
    guys are doing such things. The page which I mostly used about this
    was http://en.wikibooks.org/wiki/LaTeX/Packages/Listings and if you
    are interested, I can also send my "wrong compiling" piece of writing.

    Thanks in advance,

    Enes.
     
    Enes Erdin, Aug 1, 2009
    #1
    1. Advertising

  2. Enes Erdin

    sleeman Guest

    On Aug 1, 7:54 am, Enes Erdin <> wrote:
    > Hi,
    >
    > Recently I am trying to put some VHDL codes in a report written by
    > Latex. Although I have found some information about how to do it I
    > could not apply it in the report. My aim is not to use the Verbatim
    > style, I want to write some piece of code and add caption to it. For
    > that purpose listing package seems to be the most suitable package for
    > doing it but it does not truly represent the code. I wonder how you
    > guys are doing such things. The page which I mostly used about this
    > washttp://en.wikibooks.org/wiki/LaTeX/Packages/Listingsand if you
    > are interested, I can also send my "wrong compiling" piece of writing.
    >
    > Thanks in advance,
    >
    > Enes.


    I've always used verbatim mode... so thanks for the pointer to
    listings! If this is a smallish piece of custom formatting I've
    always been afraid to learn how to get Latex to do it. Instead, I just
    postprocessed externally to eps (for example, highlighting in emacs
    and using postscript-print-buffer), then pulled the eps into the LaTex
    doc. Obviously, that won't work if you have a multi-page listing,
    though.

    What do you mean by "does not truly represent the code"? That the
    highlighting isn't in the style that you want? Or that it's grossly
    corrupted? You might also have more luck asking in a LaTex group than
    a VHDL group.

    - Kenn
     
    sleeman, Aug 1, 2009
    #2
    1. Advertising

  3. Enes Erdin

    Enes Erdin Guest

    Thank you for the post,

    sleeman <> wrote:

    > I just postprocessed externally to eps (for example, highlighting
    > in emacs and using postscript-print-buffer), then pulled the eps
    > into the LaTex doc.


    This is a good idea. But what about the captions, do they appear as a
    "figure" caption?

    > What do you mean by "does not truly represent the code"? That the
    > highlighting isn't in the style that you want? Or that it's grossly
    > corrupted?


    The most annoying thing is, for example, I write

    a <= b;
    or
    a := b;

    in the output it appears for both of them as

    a = b

    highlighting is a luxury for me now :)

    Thanks,

    Enes.
     
    Enes Erdin, Aug 1, 2009
    #3
  4. Enes Erdin wrote:
    > Hi,
    >
    > Recently I am trying to put some VHDL codes in a report written by
    > Latex. Although I have found some information about how to do it I
    > could not apply it in the report. My aim is not to use the Verbatim
    > style, I want to write some piece of code and add caption to it. For
    > that purpose listing package seems to be the most suitable package for
    > doing it but it does not truly represent the code.


    If if the exact rendering is important,
    crop and save a screenshot as mycode.png,
    then include include it something like:

    \includegraphics{mycode.png}


    -- Mike Treseler
     
    Mike Treseler, Aug 1, 2009
    #4
  5. Enes Erdin <> writes:

    > style, I want to write some piece of code and add caption to it. For
    > that purpose listing package seems to be the most suitable package for


    I usually use the listings package for this purpose:


    \usepackage{listings}
    \lstset{
    language=VHDL,
    basicstyle=\tiny\ttfamily}


    \begin{lstlisting}
    architecture rtl of whatever is
    -- etc...

    begin

    -- etc...

    end rtl;
    \end{lstlisting}

    What I like is the ability to grab a section from a file:

    \begin{figure}[hf]
    \lstinputlisting[first=13,last=21]{fft.vhd}
    \caption{\label{fig:fftentity}Sample FFT Entity }
    \end{figure}

    This way you can keep your code valid and in sync with the document.

    However, you have to keep track of the line numbers. In the past I've
    added some comments in the file and used grep and friends to extract
    this information, but it was not very elegant. It should be possible
    to do it in a more elegant way from latex itself.

    Then there's the lgrind package, but I don't know if there is a
    lgrindef file for VHDL. I've used it with other languages, even though
    it's quite some time ago.


    Petter

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is top-posting such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
     
    Petter Gustad, Aug 3, 2009
    #5
  6. Petter Gustad <> writes:

    > However, you have to keep track of the line numbers. In the past I've
    > added some comments in the file and used grep and friends to extract
    > this information, but it was not very elegant. It should be possible
    > to do it in a more elegant way from latex itself.


    You mean like the method described in section 5.7 of the listings
    documentation? It needs some work, but it is a proof of concept. To
    bad that Brooks doesn't seem to be working on this any more. I sent
    him a patch two years ago (SystemVerilog and Verilog 2005 support)
    that hasn't been included, yet.

    Regards
    Marcus


    --
    note that "property" can also be used as syntaxtic sugar to reference
    a property, breaking the clean design of verilog; [...]

    (seen on http://www.veripool.com/verilog-mode_news.html)
     
    Marcus Harnisch, Aug 3, 2009
    #6
  7. Marcus Harnisch <> writes:

    > You mean like the method described in section 5.7 of the listings
    > documentation? It needs some work, but it is a proof of concept. To


    I was not aware of this feature. Either it's a later addition, or I've
    completely missed it when I first looked at the listings package long
    time ago. Thank you for making me aware of it.

    Petter
    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is top-posting such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
     
    Petter Gustad, Aug 3, 2009
    #7
    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. ivo welch
    Replies:
    4
    Views:
    807
    ivo welch
    Dec 26, 2003
  2. Marcus Beyer

    from XHTML to PDF in Java: LaTeX 3?

    Marcus Beyer, Nov 19, 2003, in forum: Java
    Replies:
    1
    Views:
    4,049
    Marcus Beyer
    Nov 20, 2003
  3. Michael Friendly

    translating LaTeX to XML

    Michael Friendly, Apr 2, 2004, in forum: XML
    Replies:
    1
    Views:
    600
    Patrick TJ McPhee
    Apr 4, 2004
  4. John Hunter
    Replies:
    7
    Views:
    560
    John Hunter
    Jul 7, 2004
  5. afd
    Replies:
    1
    Views:
    8,365
    Colin Paul Gloster
    Mar 23, 2007
Loading...

Share This Page