diff --git a/tb/agents/fu_if/fu_if_agent.svh b/tb/agents/fu_if/fu_if_agent.svh index 37062cb6e..4ea15f9d2 100644 --- a/tb/agents/fu_if/fu_if_agent.svh +++ b/tb/agents/fu_if/fu_if_agent.svh @@ -40,4 +40,4 @@ class fu_if_agent extends uvm_component; m_monitor.m_cfg = m_cfg; endfunction: connect_phase -endclass : fu_if_agent \ No newline at end of file +endclass : fu_if_agent diff --git a/tb/agents/fu_if/fu_if_monitor.svh b/tb/agents/fu_if/fu_if_monitor.svh index cbade6a9c..2b510f618 100644 --- a/tb/agents/fu_if/fu_if_monitor.svh +++ b/tb/agents/fu_if/fu_if_monitor.svh @@ -43,19 +43,18 @@ class fu_if_monitor extends uvm_component; forever begin : cmd_loop longint result; - // using clocking blocks this is possible - @(negedge fu.pck) - cmd.operator = fu.pck.operator; cmd.operand_a = fu.pck.operand_a; cmd.operand_b = fu.pck.operand_b; cmd.operand_c = fu.pck.operand_c; cmd.result = fu.pck.result; + + @(fu.pck) $cast(cloned_item, cmd.clone()); ap.write(cloned_item); - + end : cmd_loop endtask : run_phase endclass : fu_if_monitor diff --git a/tb/agents/fu_if/fu_if_seq_item.svh b/tb/agents/fu_if/fu_if_seq_item.svh index bd7ac4221..17db3989a 100644 --- a/tb/agents/fu_if/fu_if_seq_item.svh +++ b/tb/agents/fu_if/fu_if_seq_item.svh @@ -69,7 +69,7 @@ class fu_if_seq_item extends uvm_sequence_item; $sformat(s, "%s\n", super.convert2string()); // Convert to string function reusing s: - $sformat(s, "%s\n operator\t%0h\n operandA\t%0h\n operandB\t%0b\n operandC\t%0h\n", s, operator, operand_a, operand_b, operand_c); + $sformat(s, "%s\n operator\t%0h\n operandA\t%0h\n operandB\t%0h\n operandC\t%0h\n result\t%0h\n", s, operator, operand_a, operand_b, operand_c, result); return s; endfunction:convert2string diff --git a/tb/env/alu_env.svh b/tb/env/alu_env.svh index 93efaac0b..34f7a3f13 100644 --- a/tb/env/alu_env.svh +++ b/tb/env/alu_env.svh @@ -13,7 +13,7 @@ class alu_env extends uvm_env; fu_if_agent m_fu_if_agent; fu_if_sequencer m_fu_if_sequencer; alu_env_config m_cfg; - + alu_scoreboard m_scoreboard; //------------------------------------------ // Methods //------------------------------------------ @@ -37,10 +37,13 @@ class alu_env extends uvm_env; // Get sequencer m_fu_if_sequencer = fu_if_sequencer::type_id::create("m_fu_if_sequencer", this); + // create scoreboard + m_scoreboard = alu_scoreboard::type_id::create("m_scoreboard", this); + endfunction:build_phase function void connect_phase(uvm_phase phase); m_fu_if_sequencer = m_fu_if_agent.m_sequencer; - + m_fu_if_agent.m_monitor.ap.connect(m_scoreboard.item_export); endfunction: connect_phase -endclass : alu_env \ No newline at end of file +endclass : alu_env diff --git a/tb/env/alu_env_pkg.sv b/tb/env/alu_env_pkg.sv index e9646c7db..06a7a8b39 100644 --- a/tb/env/alu_env_pkg.sv +++ b/tb/env/alu_env_pkg.sv @@ -8,8 +8,10 @@ package alu_env_pkg; `include "uvm_macros.svh" // Testbench related imports import fu_if_agent_pkg::*; + import ariane_pkg::*; // Includes for the config for the environment `include "alu_env_config.svh" + `include "alu_scoreboard.svh" // Includes the environment `include "alu_env.svh" endpackage diff --git a/tb/env/alu_scoreboard.svh b/tb/env/alu_scoreboard.svh new file mode 100644 index 000000000..a7e89dec6 --- /dev/null +++ b/tb/env/alu_scoreboard.svh @@ -0,0 +1,31 @@ +class alu_scoreboard extends uvm_scoreboard; + + `uvm_component_utils(alu_scoreboard); + + uvm_analysis_imp#(fu_if_seq_item, alu_scoreboard) item_export; + + bit [63:0] result; + function new(string name, uvm_component parent); + super.new(name, parent); + endfunction : new + + function void build_phase(uvm_phase phase); + super.build_phase(phase); + item_export = new("item_export", this); + endfunction : build_phase + + virtual function void write (fu_if_seq_item seq_item); + seq_item.print(); + result = 64'b0; + + case (alu_op'(seq_item.operator)) + add: + result = seq_item.operand_a + seq_item.operand_b; + endcase + + if (result != seq_item.result) + `uvm_error("ALU Scoreboard", $sformatf("Result: %0h, Expected %0h", seq_item.result, result)) + + endfunction : write; + +endclass : alu_scoreboard diff --git a/tb/test/alu_lib_pkg.sv b/tb/test/alu_lib_pkg.sv index f01a3451f..ff4d92811 100644 --- a/tb/test/alu_lib_pkg.sv +++ b/tb/test/alu_lib_pkg.sv @@ -9,7 +9,6 @@ package alu_lib_pkg; import fu_if_agent_pkg::*; import alu_env_pkg::*; import alu_sequence_pkg::*; - // Test based includes like base test class and specializations of it // ---------------- // Base test class