Hitman450 has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, I want to use perl to generate a VHDL code, I have a design that has some generic parameters and I want to generate a code that takes these parameters and generate the code for me,is there any chance to do this properly on perl ?! I am totally new to perl, and in fact I do not know how to do this on perl. one hint about the parameters, one parameter has only one value, but the other has several values. I cannot wait to get a reply ! Hitman

Replies are listed 'Best First'.
Re: perl to generate VHDL code
by Corion (Patriarch) on Jan 08, 2011 at 20:58 UTC

    Have you looked at Template or any of the other templating systems? Using those, you can write your code and have it generate more code.

Re: perl to generate VHDL code
by toolic (Bishop) on Jan 08, 2011 at 21:27 UTC
    I am totally new to perl
    You might find perlintro helpful in getting started with the basics.

    In addition to Corion's advice, if you want to randomize your parameters, you could use rand or Data::Random.

    If you want more specific advice, post a small sample of the output VHDL code you want, along with some example parameter types.

    Update: it's always a good idea to search CPAN to see if you can leverage work done by others. In this case, however, it looks like there are only VHDL parsers, not generators.

Re: perl to generate VHDL code
by oko1 (Deacon) on Jan 08, 2011 at 23:19 UTC

    In addition to Corion's advice, you'll also want to check out the documentation (perldsc) regarding Perl's data structures. Yes, Perl does indeed have ways to contain multiple values in a single variable.

    # Array @a = (1, 2, 3); # Hash %h = (param1 => 100, param2 => 200); # Reference to array $r = [ 1, 2, 3 ]; # Hash of lists (HoL) - probably what you need %h = ( param1 => "ABC", param2 => [ "value1", "value2", "value3" ] );
    -- 
    Education is not the filling of a pail, but the lighting of a fire.
     -- W. B. Yeats