// ----- // // Copyright (c) 2024 Mahesh Asolkar // // 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. // // ----- class seq_base extends uvm_sequence; testbench_env tb_env; `uvm_object_utils(seq_base) // ------------------------------------------------------------ function new(string name = "seq_base"); super.new(name); endfunction // ------------------------------------------------------------ function void set_handles(testbench_env env); tb_env = env; endfunction // ------------------------------------------------------------ virtual task body(); bit ok = uvm_config_db#(testbench_env)::get(m_sequencer, "", "tb_env", tb_env); endtask endclass // ---------------------------------------------------------------------- class seq_basic extends seq_base; `uvm_object_utils(seq_basic) // ------------------------------------------------------------ function new(string name = "seq_basic"); super.new(name); endfunction // ------------------------------------------------------------ virtual task body(); super.body(); `uvm_info("body", $sformatf("Initiating stimulus ..."), UVM_LOW) fork begin d_stimulus(tb_env.tb_if.d1_if, 1); end begin d_stimulus(tb_env.tb_if.d2_if, 2); end join `uvm_info("body", $sformatf("Stimulus done."), UVM_LOW) endtask // ------------------------------------------------------------ task d_stimulus(virtual design_if d_if, int inst_n); `uvm_info("d_stimulus", $sformatf("Inst-%0d: Initiating stimulus...", inst_n), UVM_LOW); repeat(20) @(negedge tb_env.tb_if.clk); d_if.data_in = {inst_n[15:0], 16'hd1}; `uvm_info("d_stimulus", $sformatf("Inst-%0d: Driving data_in=0x%h", inst_n, d_if.data_in), UVM_LOW); repeat(50) @(negedge tb_env.tb_if.clk); d_if.data_in = {inst_n[15:0], 16'hd2}; `uvm_info("d_stimulus", $sformatf("Inst-%0d: Driving data_in=0x%h", inst_n, d_if.data_in), UVM_LOW); repeat(20) @(negedge tb_env.tb_if.clk); `uvm_info("d_stimulus", $sformatf("Inst-%0d: ... stimulus done", inst_n), UVM_LOW); endtask endclass // ---------------------------------------------------------------------- class seq_reset extends seq_base; `uvm_object_utils(seq_reset) // ------------------------------------------------------------ function new(string name = "seq_reset"); super.new(name); endfunction // ------------------------------------------------------------ virtual task body(); super.body(); `uvm_info("body", $sformatf("Initiating reset..."), UVM_LOW) tb_env.tb_if.rst_n = 0; repeat(10) @(posedge tb_env.tb_if.clk); tb_env.tb_if.rst_n = 1; `uvm_info("body", $sformatf("Reset done."), UVM_LOW) endtask endclass