Writing std_logic_vector?

Discussion in 'VHDL' started by Philipp, Nov 21, 2008.

  1. Philipp

    Philipp Guest

    Hi

    I am wondering if there is any way that I can write a
    std_logic_vector(31 downto 0) into a file and there is should
    be written then as a HEX value? Is there something like

    val = ABC(31 downto 0);
    write(s, hex'(val));

    Thanks
    Philipp, Nov 21, 2008
    #1
    1. Advertising

  2. Philipp

    KJ Guest

    On Nov 21, 12:38 pm, Philipp <> wrote:
    > Hi
    >
    > I am wondering if there is any way that I can write a
    > std_logic_vector(31 downto 0) into a file and there is should
    > be written then as a HEX value? Is there something like
    >
    >   val = ABC(31 downto 0);
    >   write(s, hex'(val));
    >
    > Thanks


    Google for 'image_pkg' and Ben Cohen. That should produce a VHDL file
    with a package that converts different types into a string. He has
    both an 'image' and a 'heximage' function for std_logic_vector types.
    Image produces a character for every bit in the vector (i.e. when
    displayed/written it will look like binary). Heximage produces a
    hexadecimal formatted string.
    http://www.google.com/search?hl=en&q=image_pkg Ben Cohen

    Once you've got a string you can use standard text I/O facilities to
    write out your file.

    Kevin Jennings
    KJ, Nov 21, 2008
    #2
    1. Advertising

  3. Philipp

    Guest

    On 21 נובמבר, 21:04, Jonathan Bromley <>
    wrote:
    > On Fri, 21 Nov 2008 17:38:07 +0000, Philipp <> wrote:
    > >I am wondering if there is any way that I can write a
    > >std_logic_vector(31 downto 0) into a file and there is should
    > >be written then as a HEX value? Is there something like

    >
    > > val = ABC(31 downto 0);
    > > write(s, hex'(val));

    >
    > KJ is right, but you could also consider using the
    > std_logic_textio package - originally from Synopsys,
    > but fully supported by all serious simulators and,
    > indeed, now incorporated into the latest VHDL standard.
    >
    > library ieee;
    > use ieee.std_logic_1164.all; -- as usual
    > use std.textio.all; -- as usual
    > use ieee.std_logic_textio.all; -- this is the new part
    >
    > ....
    > variable v: std_logic_vector (31 downto 0);
    > variable L: line;
    > ....
    > write(L, v); -- writes 32 characters for the 32 bits
    > hwrite(L, v); -- writes 8 hex digits or Xs
    >
    > read() and hread() too.
    >
    > Note that the value or variable must be an exact multiple
    > of 4 elements, or else hwrite() won't work.
    > --
    > Jonathan Bromley, Consultant
    >
    > DOULOS - Developing Design Know-how
    > VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services
    >
    > Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
    > ://www.MYCOMPANY.com
    >
    > The contents of this message may contain personal views which
    > are not the views of Doulos Ltd., unless specifically stated.


    Hi
    I have a nice example of an AHB monitor. It monitors the data on an
    AHB and writes a nice log.
    h--p://bknpk.no-ip.biz/AHB_MON/ahb_mon_1.html

    The code is available at:
    h--p://bknpk.no-ip.biz/cgi-bin/InputForm_1.pl
    AHB monitor.
    -->file instantiation example:mcore.vhd

    -->file the monitor:mon.vhd
    , Nov 21, 2008
    #3
  4. Philipp

    Tricky Guest

    On 21 Nov, 19:04, Jonathan Bromley <>
    wrote:
    > On Fri, 21 Nov 2008 17:38:07 +0000, Philipp <> wrote:
    > >I am wondering if there is any way that I can write a
    > >std_logic_vector(31 downto 0) into a file and there is should
    > >be written then as a HEX value? Is there something like

    >
    > >  val = ABC(31 downto 0);
    > >  write(s, hex'(val));

    >
    > KJ is right, but you could also consider using the
    > std_logic_textio package - originally from Synopsys,
    > but fully supported by all serious simulators and,
    > indeed, now incorporated into the latest VHDL standard.
    >
    > library ieee;
    > use ieee.std_logic_1164.all;  -- as usual
    > use std.textio.all;           -- as usual
    > use ieee.std_logic_textio.all; -- this is the new part
    >
    > ....
    >   variable v: std_logic_vector (31 downto 0);
    >   variable L: line;
    > ....
    >   write(L, v);  -- writes 32 characters for the 32 bits
    >   hwrite(L, v); -- writes 8 hex digits or Xs
    >
    > read() and hread() too.
    >
    > Note that the value or variable must be an exact multiple
    > of 4 elements, or else hwrite() won't work.
    > --
    > Jonathan Bromley, Consultant
    >
    > DOULOS - Developing Design Know-how
    > VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services
    >
    > Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
    > ://www.MYCOMPANY.com
    >
    > The contents of this message may contain personal views which
    > are not the views of Doulos Ltd., unless specifically stated.


    You forgot to mention ORead/OWrite if octal is your fettish.
    Tricky, Nov 24, 2008
    #4
  5. Philipp

    Tricky Guest

    On 21 Nov, 19:04, Jonathan Bromley <>
    wrote:
    > On Fri, 21 Nov 2008 17:38:07 +0000, Philipp <> wrote:
    > >I am wondering if there is any way that I can write a
    > >std_logic_vector(31 downto 0) into a file and there is should
    > >be written then as a HEX value? Is there something like

    >
    > >  val = ABC(31 downto 0);
    > >  write(s, hex'(val));

    >
    > KJ is right, but you could also consider using the
    > std_logic_textio package - originally from Synopsys,
    > but fully supported by all serious simulators and,
    > indeed, now incorporated into the latest VHDL standard.
    >
    > library ieee;
    > use ieee.std_logic_1164.all;  -- as usual
    > use std.textio.all;           -- as usual
    > use ieee.std_logic_textio.all; -- this is the new part
    >
    > ....
    >   variable v: std_logic_vector (31 downto 0);
    >   variable L: line;
    > ....
    >   write(L, v);  -- writes 32 characters for the 32 bits
    >   hwrite(L, v); -- writes 8 hex digits or Xs
    >
    > read() and hread() too.
    >
    > Note that the value or variable must be an exact multiple
    > of 4 elements, or else hwrite() won't work.
    > --
    > Jonathan Bromley, Consultant
    >
    > DOULOS - Developing Design Know-how
    > VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services
    >
    > Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
    > ://www.MYCOMPANY.com
    >
    > The contents of this message may contain personal views which
    > are not the views of Doulos Ltd., unless specifically stated.


    Also, forgot to add:
    Currently Hread/hwrite only works with busses that are multplies of 4
    long, but I seem to remember something being mentioned that they were
    dropping this restriction?
    Tricky, Nov 24, 2008
    #5
    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. Jeremy Pyle
    Replies:
    3
    Views:
    52,674
    Mike Treseler
    Jun 28, 2003
  2. Mike
    Replies:
    3
    Views:
    3,054
    Mike Treseler
    Jul 9, 2003
  3. Willem Oosthuizen

    Array of std_logic_vector

    Willem Oosthuizen, Jul 9, 2003, in forum: VHDL
    Replies:
    3
    Views:
    35,512
    mathukutty
    Feb 26, 2010
  4. Pedro Claro

    character to std_logic_vector

    Pedro Claro, Jul 30, 2003, in forum: VHDL
    Replies:
    7
    Views:
    19,547
    Ruudiculus
    Oct 21, 2009
  5. Thomas Rouam
    Replies:
    6
    Views:
    1,126
Loading...

Share This Page