Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

How to insert a file with another file with comma separated??

by sumathigokul (Acolyte)
on May 11, 2015 at 12:46 UTC ( [id://1126310]=perlquestion: print w/replies, xml ) Need Help??

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

Hi all..

My original file FA.vhd is as follows...

component MAJ3 port( A : in std_logic := 'U'; enable : in std_logic; B : in std_logic := 'U'; C : in std_logic := 'U'; Y : out std_logic ); end component; signal \GND\, \VCC\, N_5, a_c, b_c, c_c, sum_c, GND_0, VCC_0 : std_logic; begin enable_pad : INBUF port map (PAD => enable, Y => enable_c);

i have one more file enabled_nets.txt that has follwoing lines..

a_e b_e c_e

i want to modify the signal declaration statement in FA.vhd as

signal \GND\, \VCC\, N_5, a_c, b_c, c_c, sum_c, GND_0, VCC_0, a_e, b_e, c_e, enable_c: std_logic;

i.e. i want to include the words in enabled_nets.txt to signal declaration part of FA.vhd as mentioned above, along with this i want to add one more signal enable_c also, and all these word need to be comma separated... Here is the perl script i have written for this... Correct the mistake in it monks.... Thank you all for your valuable time....

open (IN1, "<FA.vhd") or die; open (OUT, ">common_modify.vhd") or die; while (<IN1>) { print OUT; if (/signal/){ open (IN2, "<enabled_nets.txt") or die; my @enabled_nets = <IN2>; chomp @enabled_nets; while (<IN2>) { print OUT ; print OUT ',enable_c,'; } close (IN2); } } close (IN1); close (OUT);

Replies are listed 'Best First'.
Re: How to insert a file with another file with comma separated?? (VHDL)
by toolic (Bishop) on May 11, 2015 at 13:10 UTC
    Have you tried using any of the VHDL parsers on CPAN? There is likely to be some code there that can be adapted for your needs.
Re: How to insert a file with another file with comma separated??
by afoken (Chancellor) on May 11, 2015 at 12:59 UTC
Re: How to insert a file with another file with comma separated??
by pme (Monsignor) on May 11, 2015 at 12:57 UTC
    Hi sumathigokul,

    @enabled_nets holds all the signals from enabled_nets.txt therefore just replace the whole inner while (IN2) with this:

    print OUT join(',', @enabled_nets) . ", enable_c\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1126310]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-23 18:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found