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

Run Bathtub as a default sequence #128

Merged
merged 4 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
352 changes: 203 additions & 149 deletions src/bathtub_pkg/bathtub.svh

Large diffs are not rendered by default.

131 changes: 131 additions & 0 deletions src/bathtub_pkg/bathtub_sequence.svh
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
MIT License

Copyright (c) 2024 William L. Moore

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

`ifndef __BATHTUB_SEQUENCE_SVH
`define __BATHTUB_SEQUENCE_SVH

`include "uvm_macros.svh"

import uvm_pkg::*;

typedef class bathtub;

class bathtub_sequence extends uvm_sequence;
protected bathtub bt;
protected bit sequence_call_pre_post;
protected uvm_phase phase;

function new (string name="bathtub_sequence");
super.new(name);
this.bt = null;
this.sequence_call_pre_post = 1'b0;
endfunction : new

`uvm_object_utils(bathtub_sequence)

virtual function void configure (bathtub bt);
this.bt = bt;
endfunction : configure


`ifndef UVM_VERSION_1_0

virtual task pre_start ();
super.pre_start();

`ifdef UVM_VERSION_1_1
phase = starting_phase;
`elsif UVM_POST_VERSION_1_1
phase = get_starting_phase();
`else
phase = get_starting_phase();
`endif

if (phase == null) return;

phase.raise_objection(this);
endtask : pre_start

`endif // UVM_VERSION_1_0

virtual task pre_body ();

`ifdef UVM_VERSION_1_0

phase = starting_phase;
if (phase != null) begin
phase.raise_objection(this);
end

`endif // UVM_VERSION_1_0

super.pre_body();
sequence_call_pre_post = 1'b1;

endtask : pre_body

virtual task body ();

precondition_bt_not_null : assert (bt != null) else
`uvm_fatal("NULL_VAR", "bt is null")

bt.configure(
get_sequencer(),
this,
get_priority(),
sequence_call_pre_post
);

bt.run_test(phase);
endtask : body

`ifdef UVM_VERSION_1_0

virtual task post_body ();
if (phase == null) return;

phase.drop_objection(this);
endtask : post_body

`else // UVM_VERSION_1_0

virtual task post_start ();
if (phase == null) return;

phase.drop_objection(this);
endtask : post_start

`endif // UVM_VERSION_1_0

virtual function bathtub get_bathtub_object ();
return this.bt;
endfunction : get_bathtub_object

endclass : bathtub_sequence

`ifndef __BATHTUB_SVH
`include "bathtub_pkg/bathtub.svh"
`endif // __BATHTUB_SVH

`endif // __BATHTUB_SEQUENCE_SVH
2 changes: 2 additions & 0 deletions src/bathtub_pkg/step_definition_interface.svh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ typedef interface class feature_sequence_interface;
typedef interface class rule_sequence_interface;
typedef interface class scenario_sequence_interface;

`ifndef __BATHTUB_PKG_SVH
`include "bathtub_pkg/bathtub_pkg.svh"
`endif

(* doc$markdown = "\
\ Interface class for the user's step definition classes.\n\
Expand Down
2 changes: 2 additions & 0 deletions src/bathtub_pkg/step_static_attributes_interface.svh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ SOFTWARE.
`ifndef __STEP_STATIC_ATTRIBUTES_INTERFACE_SVH
`define __STEP_STATIC_ATTRIBUTES_INTERFACE_SVH

`ifndef __BATHTUB_PKG_SVH
`include "bathtub_pkg/bathtub_pkg.svh"
`endif

import uvm_pkg::*;

Expand Down
13 changes: 11 additions & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,23 @@ def simulator_from_name(name):
def uvm_versions_from_config():
for simulator in test_config['simulators']:
for uvm_version in simulator['uvm_versions']:
yield {'simulator': simulator_from_name(simulator['name']), 'uvm_home': uvm_version, 'is_builtin': True}
opts = ''
if simulator['name'] == 'Xcelium' and '1800.2-2020-1.0' in uvm_version:
opts.append('+define+UVM_USE_PROCESS_CONTAINER')
yield {'name': simulator['name'], 'uvm_home': uvm_version, 'is_builtin': True, 'opts': ' '.join(opts)}

for uvm_version in test_config['uvm_versions']:
for simulator in test_config['simulators']:
yield {'simulator': simulator_from_name(simulator['name']), 'uvm_home': uvm_version, 'is_builtin': False}
opts = []
if simulator['name'] == 'Xcelium':
opts.append('-uvmnocdnsextra')
if simulator['name'] == 'Xcelium' and '1800.2-2020-1.0' in uvm_version:
opts.append('+define+UVM_USE_PROCESS_CONTAINER')
yield {'name': simulator['name'], 'uvm_home': uvm_version, 'is_builtin': False, 'opts': ' '.join(opts)}

@pytest.fixture(params=uvm_versions_from_config())
def uvm_version(request):
request.param['simulator'] = simulator_from_name(request.param['name'])
return request.param

@pytest.fixture
Expand Down
1 change: 1 addition & 0 deletions test/dependency_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
classes_under_test = [
"bathtub_pkg/bathtub.svh",
"bathtub_pkg/bathtub_pkg.svh",
"bathtub_pkg/bathtub_sequence.svh",
"bathtub_pkg/bathtub_utils.svh",
"bathtub_pkg/context_sequence.svh",
"bathtub_pkg/feature_sequence.svh",
Expand Down
14 changes: 11 additions & 3 deletions test/e2e/basic/basic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@

test_path = Path(os.path.dirname(__file__))

@pytest.mark.parametrize("testname, features", [('basic_test', ['basic.feature'])])
def test_basic_e2e(tmp_path, simulator, testname, features):
@pytest.mark.parametrize("testname, features", [('basic_test', ['basic.feature']),
('basic_sequence_test', ['basic.feature']),
('basic_sequence_start_test', ['basic.feature']),
])
def test_basic_e2e(tmp_path, uvm_version, testname, features):
"""Basic end-to-end test"""

simulator.uvm().extend_args([
simulator = uvm_version['simulator']
uvm_home = uvm_version['uvm_home']
version_opts = uvm_version['opts']

simulator.uvm(uvm_home).extend_args([
version_opts,
'-f ' + str(test_path / 'basic.f'),
'-incdir $BATHTUB_VIP_DIR/test/e2e/basic',
'-incdir $BATHTUB_VIP_DIR/test/e2e/basic/tests',
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/basic/basic_tests.svh
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ SOFTWARE.
*/

typedef class basic_test;
typedef class basic_sequence_test;
`include "basic_test.svh"
`include "basic_sequence_test.svh"
`include "basic_sequence_start_test.svh"
68 changes: 68 additions & 0 deletions test/e2e/basic/tests/basic_sequence_start_test.svh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
MIT License

Copyright (c) 2024 William L. Moore

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

`ifndef __BASIC_SEQUENCE_START_TEST_SVH
`define __BASIC_SEQUENCE_START_TEST_SVH

typedef class basic_env;

class basic_sequence_start_test extends uvm_test;
`uvm_component_utils(basic_sequence_start_test)
basic_env env; // uvm_env containing the virtual sequencer
bathtub_pkg::bathtub bathtub;

function new(string name = "basic_sequence_start_test", uvm_component parent = null);
super.new(name, parent);
endfunction : new

virtual function void build_phase(uvm_phase phase);
bathtub = bathtub_pkg::bathtub::type_id::create("bathtub", this);
super.build_phase(phase);
env = basic_env::type_id::create("env", this);
endfunction : build_phase

virtual task main_phase(uvm_phase phase);
uvm_sequence_base bathtub_seq;

bathtub_seq = bathtub.as_sequence();

`ifdef UVM_VERSION_1_0
bathtub_seq.starting_phase = phase;
`elsif UVM_VERSION_1_1
bathtub_seq.starting_phase = phase;
`elsif UVM_POST_VERSION_1_1
bathtub_seq.set_starting_phase(phase);
`else
bathtub_seq.set_starting_phase(phase);
`endif

bathtub_seq.start(env.seqr);
endtask : main_phase

endclass : basic_sequence_start_test

`include "basic_env.svh"

`endif // __BASIC_SEQUENCE_START_TEST_SVH

53 changes: 53 additions & 0 deletions test/e2e/basic/tests/basic_sequence_test.svh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
MIT License

Copyright (c) 2024 William L. Moore

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

`ifndef __BASIC_SEQUENCE_TEST_SVH
`define __BASIC_SEQUENCE_TEST_SVH

typedef class basic_env;

class basic_sequence_test extends uvm_test;
`uvm_component_utils(basic_sequence_test)
basic_env env; // uvm_env containing the virtual sequencer
bathtub_pkg::bathtub bathtub;

function new(string name = "basic_sequence_test", uvm_component parent = null);
super.new(name, parent);
endfunction : new

virtual function void build_phase(uvm_phase phase);
bathtub = bathtub_pkg::bathtub::type_id::create("bathtub", this);
super.build_phase(phase);
env = basic_env::type_id::create("env", this);

uvm_config_db#(uvm_sequence_base)::set(this, "env.seqr.main_phase",
"default_sequence", bathtub.as_sequence());
endfunction : build_phase

endclass : basic_sequence_test

`include "basic_env.svh"

`endif // __BASIC_SEQUENCE_TEST_SVH