Get value from a text file (newbie)

Discussion in 'VHDL' started by smu, Aug 19, 2003.

  1. smu

    smu Guest

    Hello,

    I have a question about the possibility to read some informations in a text
    file.

    For example, I have a entity 'scaler'. Can I do something like

    architecture Behavioral of scaler0 is
    component scaler
    generic ( ???)
    port ( clr : in std_logic; clk : in std_logic; d : in
    std_logic_vector(15 downto 0);
    q : out std_logic_vector(15 downto 0));
    end component;
    begin
    scaler0_c : scaler
    generic map ( ??? => 'filename of file containing initialisation
    data')
    port map (......
    ......
    end Behavioral;


    Thank you in advance

    smu
    smu, Aug 19, 2003
    #1
    1. Advertising

  2. smu a écrit :
    > Hello,
    >
    > I have a question about the possibility to read some informations in a text
    > file.
    >


    Yes you can. Here is a simple exemple:

    entity A is
    generic(FILENAME: String := "foo.dat");
    port(K: out Integer);
    end entity A;

    use STD.TEXTIO.all;

    architecture ARC of A is
    file INITFILE: Text open READ_MODE is FILENAME;
    begin
    INITP: process
    variable L: Line;
    variable V: Integer;
    begin
    K <= 0;
    wait for 1 ns;
    READLINE(INITFILE, L);
    READ(L, V);
    K <= V;
    wait;
    end process INITP;
    end architecture ARC;

    entity ATB is
    end entity ATB;

    use STD.TEXTIO.all;

    architecture SIM of ATB is
    signal K: Integer;
    begin
    IA: entity WORK.A(ARC)
    generic map(FILENAME => "bar.txt")
    port map(K => K);
    MONITOR: process(K)
    variable L: Line;
    begin
    WRITE(L, K);
    WRITE(L, String'(" @ "));
    WRITE(L, NOW);
    WRITELINE(OUTPUT, L);
    end process MONITOR;
    end architecture SIM;

    Best regards,
    --
    Renaud Pacalet, ENST, 46 rue Barrault 75634 Paris Cedex 13
    ###### Tel. : 01 45 81 78 08 | Fax : 01 45 80 40 36 ######
    # Fight Spam! Join EuroCAUCE: http://www.euro.cauce.org/ #
    Renaud Pacalet, Aug 20, 2003
    #2
    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. pexito
    Replies:
    0
    Views:
    341
    pexito
    Aug 28, 2003
  2. Fredrik Lundh
    Replies:
    0
    Views:
    576
    Fredrik Lundh
    Nov 18, 2005
  3. AAJ
    Replies:
    0
    Views:
    621
  4. JJ Harrison

    Newbie: Changing value of css value.

    JJ Harrison, Oct 5, 2003, in forum: Javascript
    Replies:
    4
    Views:
    85
    Lasse Reichstein Nielsen
    Oct 5, 2003
  5. VUNETdotUS
    Replies:
    25
    Views:
    452
    Thomas 'PointedEars' Lahn
    Nov 10, 2007
Loading...

Share This Page