Hi all..
i have three input files as follows...
file1 is common_modify.vhd which has following lines of codes
sum_1_SUM0_0 : XOR3
port map(A => b_c, B => a_c, C => c_c, Y => sum_c);
a_pad : INBUF
port map(PAD => a, Y => a_c);
sum_1_CO0_i : MAJ3
port map(A => a_c, B => c_c, C => b_c, Y => N_5);
file2 is nets.txt which has following lines of codes
a_c
b_c
c_c
file3 is enabled_nets.txt which has following lines of codes
a_e
b_e
c_e
i want my perl script to search for a_c, b_c, c_c (file2)
at inputs (A or B or C, not in Y) in common_modify.vhd file
and replace them by a_, b_e, c_e (i.e. file3)...Here is the
perl code i wrote, but it is not modifying as i want...
open (IN1, "<common_modify.vhd") or die;
open (IN2, "<nets.txt") or die;
open (IN3, "<enabled_nets.txt") or die;
open (OUT, ">output_file.vhd") or die;
my @nets = <IN2>;
my @enabled_nets = <IN3>;
while (<IN1>) {
foreach $i (0..$#nets){
print OUT if (s/\=\>\s+$nets[$i]\,/\=\>
$enabled_nets[$i]\,/);
}
}
my output file need to be as follows...
sum_1_SUM0_0 : XOR3
port map(A => b_e, B => a_e, C => c_e, Y => sum_c);
a_pad : INBUF
port map(PAD => a, Y => a_c);
sum_1_CO0_i : MAJ3
port map(A => a_e, B => c_e, C => b_e, Y => N_5);
Please correct the mistakes in the code.. Thank you all for your patience to read my post.....
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.