Comparison of 2 files and generating the output based on comparison

D

Deepu

Hi All,

I need some help for a scenario explained below.

File A has content as below:

-from logic.blocka.reg* -to logic.blockb.temp_reg*
-from logic.blockb.reg* -to logic.blockc.*reg*
-from logic.blockc.*reg* -to logic.blockb.reg*

File B has content as below:

tb/device/logic/blocka/reg_0/Q
tb/device/logic/blocka/reg_1/Q
tb/device/logic/blocka/reg_2/Q
tb/device/logic/blocka/reg_3/Q
tb/device/logic/blockb/reg_0/Q
tb/device/logic/blockb/reg_1/Q
tb/device/logic/blockc/ff_reg_0/Q
tb/device/logic/blockc/ff_reg_1/Q

tb/device/logic/blockb/temp_reg_0/D
tb/device/logic/blockb/temp_reg_1/D
tb/device/logic/blockb/temp_reg_2/D
tb/device/logic/blockb/temp_reg_3/D
tb/device/logic/blockc/ff1_reg_0/D
tb/device/logic/blockc/ff1_reg_1/D
tb/device/logic/blockb/reg_0/D
tb/device/logic/blockb/reg_1/D


Now i need to look into File A and for 1st line for example

"-from logic.blocka.reg* -to logic.blockb.temp_reg*"

Look into File B for the path name after 'from' and 'to' and then
prepare an output as below:


always @ (tb.device.logic.blocka.reg_0.Q)
begin
@ (tb.device.logic.blockb.temp_reg_0.D);
end

always @ (tb.device.logic.blocka.reg_1.Q)
begin
@ (tb.device.logic.blockb.temp_reg_0.D);
end

always @ (tb.device.logic.blocka.reg_2.Q)
begin
@ (tb.device.logic.blockb.temp_reg_0.D);
end

always @ (tb.device.logic.blocka.reg_3.Q)
begin
@ (tb.device.logic.blockb.temp_reg_0.D);
end


Thanks for your time..
 
C

ccc31807

I need some help for a scenario explained below.

This is a typical data munging task. Pseudo code for your script is as
follows, at least as a first step:

open file A
for each line in file A
- split the line
- stuff the values into a suitable data structure (perhaps %A)
close file A

open file B
for each line in file B
- split the line
- stuff the values into a suitable data structure (perhaps %B)
close file B

iterate through %A
- if there is a match with an element of %B, print

From the appearance of your data, you could probably throw away the
first three directories, tb, device, and logic. It strikes me that (as
a first try) you might want to replace the delimiter in each line to a
common delimiter, perhaps a colon, save the whole thing as a string,
and then use a regular expression to match against the string.

From there, you can optimize, perhaps by just saving the values in the
first file as an array of strings, and directly match the values in
the second file without using a second data structure. This depends on
the nature of your data, and if your data is sorted in some kind of
way, the task become much easier.

Your question isn't a Perl question as such, but more of a general
question applicable to whatever language you would want to use,
although Perl can certainly handle this task with ease and speed.

CC.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top