Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to check if a value is in a specific bin #57

Open
rhead-12345 opened this issue May 24, 2021 · 3 comments
Open

Add function to check if a value is in a specific bin #57

rhead-12345 opened this issue May 24, 2021 · 3 comments

Comments

@rhead-12345
Copy link

rhead-12345 commented May 24, 2021

I have the following Bins, created as objects to give a simple reference:

    constant BIN_RUNT_FRAMES         : CovBinType := GenBin(16,                         63,                           1);    -- Short frames
    constant BIN_SHORT_FRAMES        : CovBinType := GenBin(64,                         79                             );    -- Shortest frames, covering all word width positions (16 bytes per word)
    constant BIN_STANDARD_FRAMES     : CovBinType := GenBin(80,                         ETHERNET_FRAME_SIZE_MAX-16-1, 1);    -- All standard Ethernet lengths
    constant BIN_LARGE_FRAMES        : CovBinType := GenBin(ETHERNET_FRAME_SIZE_MAX-16, ETHERNET_FRAME_SIZE_MAX        );    -- Longest standard ethernet lengths, covering all word width positions (16 bytes per word)
    constant BIN_JUMBO_FRAMES        : CovBinType := GenBin(ETHERNET_FRAME_SIZE_MAX+1,  9000,                         1);    -- Jumbo Frames

...

-- add the coverage
cov.AddBins("Runt Frames    ", G_N_HITS_PER_COV_PT, BIN_RUNT_FRAMES    );
cov.AddBins("Short Frames   ", G_N_HITS_PER_COV_PT, BIN_SHORT_FRAMES   );
cov.AddBins("Standard Frames", G_N_HITS_PER_COV_PT, BIN_STANDARD_FRAMES);
cov.AddBins("Large Frames   ", G_N_HITS_PER_COV_PT, BIN_LARGE_FRAMES   );
cov.AddBins("Jumbo Frames   ", G_N_HITS_PER_COV_PT, BIN_JUMBO_FRAMES   );

When I get the coverage, I cant work out if there is a simple method to check if a value returned from cov.randCovPoint is in a specific Bin, other than checking the ranges of all the bins. something like

testPoint := cov.randCovPoint;

if isInBin(testPoint, BIN_RUNT_FRAMES) then
  -- Generate Runt Frame
elsif isInBin(testPoint, BIN_SHORT_FRAMES) then
  -- generate short frame

--etc

Currently, I can work around this by matching a testPoint to a bin name.
Maybe the name labels could also be added to the CovBinType as an unconstrained string?

@JimLewis
Copy link
Member

JimLewis commented May 24, 2021

Thanks for submitting issues with use cases.

A superset of this has been in the planning for some time. My plan was to do it against the coverage model cov and not against objects of CovBinType. Maybe we need a bin name and a group name - OTOH, maybe group name should be done like case 2 below.

There will be an update this summer. Working towards being able to create a UCIS - just like SV. After that point, we will be able to do something like this.

For the mean time, I have two ideas for you if you are not already doing them.

  1. From where you are at now:
testPoint := cov.randCovPoint ;
testName := cov.GetBinName(cov.GetLastIndex) ;  -- Last Index randomly generated

case testName is    -- you conveniently made them all the same length
  when "Runt Frames    "   => 
    -- Generate Runt Frame 

  when "Short Frames   "   => 
    -- Generate Short Frame 
  1. Add frame type information to your coverage model.
type FrameType is (RUNT, SHORT, STANDARD, LARGE, JUMBO) ; 

cov.AddCross("Runt Frames    ", G_N_HITS_PER_COV_PT, FrameType'Pos(RUNT),     BIN_RUNT_FRAMES    );
cov.AddCross("Short Frames   ", G_N_HITS_PER_COV_PT, FrameType'Pos(SHORT),    BIN_SHORT_FRAMES   );
cov.AddCross("Standard Frames", G_N_HITS_PER_COV_PT, FrameType'Pos(STANDARD), BIN_STANDARD_FRAMES);
cov.AddCross("Large Frames   ", G_N_HITS_PER_COV_PT, FrameType'Pos(LARGE),    BIN_LARGE_FRAMES   );
cov.AddCross("Jumbo Frames   ", G_N_HITS_PER_COV_PT, FrameType'Pos(JUMBO),    BIN_JUMBO_FRAMES   );

(Frame_Int, testPoint) := cov.randCovPoint ;

case FrameType'Val(Frame_Int) is    
  when RUNT   => 
    -- Generate Runt Frame 

  when SHORT   => 
    -- Generate Short Frame 

@rhead-12345
Copy link
Author

Thanks @JimLewis
Something along the lines of the first had occured to me (making them all the same length looks nicer in writeBin)
The second is interesting - I might give that a go.

@JimLewis
Copy link
Member

JimLewis commented Jun 9, 2021

As I review this again, of course isInBin is a possible and perhaps even easy thing to write, however, its expense will increase as the number of individual bins in each item increase. So searching bins like BIN_RUNT_FRAMES is going to be inexpensive since there is only one bin, but searching bins like BIN_SHORT_FRAMES and BIN_LARGE_FRAMES is going to be similar to 1 above.

Solution 2 above is going to be a much more efficient solution.

If someone writes an isInBin, I would accept a pull request for it, but based on priority (I would rank this item low compared to other work), I don't think I will have the time in the next 3 months at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants