cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
mhafiz
Level II

How to select patterns based on segments of strings

Hi,

I'm a new user of JSL. In order to group a large number of  pins and adding a new columns for those groups, I'm thinking to use JSL. I got to know how to do that for first consecutive characters (e.g. for DDR0CH0CKN... I know how to filter it using DDR0...) but if I'm to do that using segments like 'DDR0' and 'CK', what would be an efficient way to do that? 

 

FYI: One way, I know, is to use a manually created file and then use update command to match pins to pin groups (not an efficient way). I tried patMatch/regex etc. but could not get the desired result.

 

For your convenience, I've attached .jmp file where I want to have a column called "Desired_Pin_Group" for the pins.

 

I appreciate your cooperation.

 

Regards,

 

Hafiz.

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to select patterns based on segments of strings

Here is a script that will do what you want, given the example you gave.  If you have a lot more pin combinations that require exception processing this may not be the best way to handle this.

Names Default To Here( 1 );
dt = Current Data Table();
dt << New Column( "Generated Pin Group", character );

For Each Row(
// Get the first part of the group name
	First = Lowercase( Substr( :Pin, 1, 4 ) );

// Handle exceptions like the below case
	If( First == "ddrr",
		First = "ddr0"
	);

// Now attach the "_"
	First = First || "_";

// Now add the second part based upon the given complexities

	// Handle the clk
	If(
		Contains( :Pin, "_CK" ) > 0 & Contains( :Pin, "_CKE" ) == 0, First = First || "clk", 
	// Handle the vref
		Contains( :Pin, "_VREF" ) > 0, First = First || "vref", 
	// Handle the cke
		Contains( :Pin, "_CKE" ) > 0, First = First || "cke", 
	// Handle the reset
		Contains( :Pin, "RESET" ) > 0, First = First || "Reset"
	);
	:Generated Pin Group = First;
);

If you want to do this as a formula for a column, it is just a simple change

First = Lowercase( Substr( :Pin, 1, 4 ) );
If( First == "ddrr",
	First = "ddr0"
);
First = First || "_";
If(
	Contains( :Pin, "_CK" ) > 0 & Contains( :Pin, "_CKE" ) == 0,
		First = First || "clk",
	Contains( :Pin, "_VREF" ) > 0, First = First || "vref",
	Contains( :Pin, "_CKE" ) > 0, First = First || "cke",
	Contains( :Pin, "RESET" ) > 0, First = First || "Reset"
);
First;
Jim

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: How to select patterns based on segments of strings

Here is a script that will do what you want, given the example you gave.  If you have a lot more pin combinations that require exception processing this may not be the best way to handle this.

Names Default To Here( 1 );
dt = Current Data Table();
dt << New Column( "Generated Pin Group", character );

For Each Row(
// Get the first part of the group name
	First = Lowercase( Substr( :Pin, 1, 4 ) );

// Handle exceptions like the below case
	If( First == "ddrr",
		First = "ddr0"
	);

// Now attach the "_"
	First = First || "_";

// Now add the second part based upon the given complexities

	// Handle the clk
	If(
		Contains( :Pin, "_CK" ) > 0 & Contains( :Pin, "_CKE" ) == 0, First = First || "clk", 
	// Handle the vref
		Contains( :Pin, "_VREF" ) > 0, First = First || "vref", 
	// Handle the cke
		Contains( :Pin, "_CKE" ) > 0, First = First || "cke", 
	// Handle the reset
		Contains( :Pin, "RESET" ) > 0, First = First || "Reset"
	);
	:Generated Pin Group = First;
);

If you want to do this as a formula for a column, it is just a simple change

First = Lowercase( Substr( :Pin, 1, 4 ) );
If( First == "ddrr",
	First = "ddr0"
);
First = First || "_";
If(
	Contains( :Pin, "_CK" ) > 0 & Contains( :Pin, "_CKE" ) == 0,
		First = First || "clk",
	Contains( :Pin, "_VREF" ) > 0, First = First || "vref",
	Contains( :Pin, "_CKE" ) > 0, First = First || "cke",
	Contains( :Pin, "RESET" ) > 0, First = First || "Reset"
);
First;
Jim
mhafiz
Level II

Re: How to select patterns based on segments of strings

Thanks for your quick response. The script is quite ok for the .jmp file that I gave previously. But, unfortunately it's not that straightforward. The number of pins is in the range of 150-200 and those are grouped within 15-20 groups. Please have a look at the newly attached .jmp file, it's closer to the real scenario. Just have a look from 22-27 and 81-83. Those 2 groups have DDR_Y in common, but they are filtered based on other phrases within the string. The logic is something like: if :Pin=='DDR_Y' && Pin != NC :Desired_Pin_Group=ddr_dq_ch0 else :Desired_Pin_Group=ddr_ctrl. The distinguishing criteria between the groups (81-83) and (93-96) are even more complex. One needs to search the last phrases.

 

Your cooperation is highly appreciated.

 

Hafiz.

Re: How to select patterns based on segments of strings

JMP provides an entire pattern matching suite of functions and constructs that you might find useful here. See Help > Books > Scripting Guide. Then search for this section in the book.

mhafiz
Level II

Re: How to select patterns based on segments of strings

Hi txnelson,

 

I used the concept of the conditional statement that you provided and could solve my issue. Rather than converting to lowercase, I added a new column in the table and put the pin name directly using parenthesis, as:

 

dt <<New Column("Match_Pin_Grp", Character, Nominal,
Formula(
If(Contains(:Pin, "_CK")>0 & Contains(:Pin,"DDR0") & Contains(:Pin, "_CKE")==0,"ddr0_clk",
Contains(:Pin, "_CK")>0 & Contains(:Pin,"DDR1") & Contains(:Pin, "_CKE")==0,"ddr1_clk",

 

However, I'm accepting it as a solution to the problem.

Thanks for your help.

 

Regards,

Hafiz.

txnelson
Super User

Re: How to select patterns based on segments of strings

Hafiz,

I am happy that I have been able to help you solve your problem.

Jim