lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 1 | // Copyright lowRISC contributors. |
| 2 | // Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 3 | // SPDX-License-Identifier: Apache-2.0 |
| 4 | |
| 5 | % if is_cip: |
| 6 | class ${name}_scoreboard extends cip_base_scoreboard #( |
| 7 | % else: |
| 8 | class ${name}_scoreboard extends dv_base_scoreboard #( |
| 9 | % endif |
| 10 | .CFG_T(${name}_env_cfg), |
Udi Jonnalagadda | df4350b | 2020-03-13 16:55:17 -0700 | [diff] [blame] | 11 | % if has_ral: |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 12 | .RAL_T(${name}_reg_block), |
Udi Jonnalagadda | df4350b | 2020-03-13 16:55:17 -0700 | [diff] [blame] | 13 | % endif |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 14 | .COV_T(${name}_env_cov) |
| 15 | ); |
| 16 | `uvm_component_utils(${name}_scoreboard) |
| 17 | |
| 18 | // local variables |
| 19 | |
| 20 | // TLM agent fifos |
| 21 | % for agent in env_agents: |
| 22 | uvm_tlm_analysis_fifo #(${agent}_item) ${agent}_fifo; |
| 23 | % endfor |
| 24 | |
| 25 | // local queues to hold incoming packets pending comparison |
| 26 | % for agent in env_agents: |
| 27 | ${agent}_item ${agent}_q[$]; |
| 28 | % endfor |
| 29 | |
| 30 | `uvm_component_new |
| 31 | |
| 32 | function void build_phase(uvm_phase phase); |
| 33 | super.build_phase(phase); |
| 34 | % for agent in env_agents: |
| 35 | ${agent}_fifo = new("${agent}_fifo", this); |
| 36 | % endfor |
Cindy Chen | 3e2978a | 2021-01-08 09:36:40 -0800 | [diff] [blame] | 37 | % if has_alerts: |
| 38 | // TODO: remove once support alert checking |
| 39 | do_alert_check = 0; |
| 40 | % endif |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 41 | endfunction |
| 42 | |
| 43 | function void connect_phase(uvm_phase phase); |
| 44 | super.connect_phase(phase); |
| 45 | endfunction |
| 46 | |
| 47 | task run_phase(uvm_phase phase); |
| 48 | super.run_phase(phase); |
| 49 | fork |
| 50 | % for agent in env_agents: |
| 51 | process_${agent}_fifo(); |
| 52 | % endfor |
| 53 | join_none |
| 54 | endtask |
| 55 | % for agent in env_agents: |
| 56 | |
| 57 | virtual task process_${agent}_fifo(); |
| 58 | ${agent}_item item; |
| 59 | forever begin |
| 60 | ${agent}_fifo.get(item); |
| 61 | `uvm_info(`gfn, $sformatf("received ${agent} item:\n%0s", item.sprint()), UVM_HIGH) |
| 62 | end |
| 63 | endtask |
| 64 | % endfor |
| 65 | % if is_cip: |
| 66 | |
Weicai Yang | c2a8fc9 | 2021-04-06 17:37:34 -0700 | [diff] [blame] | 67 | virtual task process_tl_access(tl_seq_item item, tl_channels_e channel, string ral_name); |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 68 | uvm_reg csr; |
Cindy Chen | 1149153 | 2019-09-05 08:21:40 -0700 | [diff] [blame] | 69 | bit do_read_check = 1'b1; |
| 70 | bit write = item.is_write(); |
Srikrishna Iyer | e42009b | 2020-11-05 16:22:42 -0800 | [diff] [blame] | 71 | uvm_reg_addr_t csr_addr = ral.get_word_aligned_addr(item.a_addr); |
Weicai Yang | 698d676 | 2019-10-15 14:07:05 -0700 | [diff] [blame] | 72 | |
Srikrishna Iyer | 1cffbcc | 2020-06-29 16:43:16 -0700 | [diff] [blame] | 73 | bit addr_phase_read = (!write && channel == AddrChannel); |
| 74 | bit addr_phase_write = (write && channel == AddrChannel); |
| 75 | bit data_phase_read = (!write && channel == DataChannel); |
| 76 | bit data_phase_write = (write && channel == DataChannel); |
| 77 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 78 | // if access was to a valid csr, get the csr handle |
Weicai Yang | 6a2bdce | 2021-04-07 14:08:03 -0700 | [diff] [blame] | 79 | if (csr_addr inside {cfg.csr_addrs[ral_name]}) begin |
Cindy Chen | 1149153 | 2019-09-05 08:21:40 -0700 | [diff] [blame] | 80 | csr = ral.default_map.get_reg_by_offset(csr_addr); |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 81 | `DV_CHECK_NE_FATAL(csr, null) |
| 82 | end |
Srikrishna Iyer | 627f782 | 2020-01-15 21:39:29 -0800 | [diff] [blame] | 83 | else begin |
Weicai Yang | 698d676 | 2019-10-15 14:07:05 -0700 | [diff] [blame] | 84 | `uvm_fatal(`gfn, $sformatf("Access unexpected addr 0x%0h", csr_addr)) |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 85 | end |
| 86 | |
Srikrishna Iyer | 1cffbcc | 2020-06-29 16:43:16 -0700 | [diff] [blame] | 87 | // if incoming access is a write to a valid csr, then make updates right away |
| 88 | if (addr_phase_write) begin |
| 89 | void'(csr.predict(.value(item.a_data), .kind(UVM_PREDICT_WRITE), .be(item.a_mask))); |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 90 | end |
| 91 | |
| 92 | // process the csr req |
| 93 | // for write, update local variable and fifo at address phase |
| 94 | // for read, update predication at address phase and compare at data phase |
| 95 | case (csr.get_name()) |
| 96 | // add individual case item for each csr |
Srikrishna Iyer | 1cffbcc | 2020-06-29 16:43:16 -0700 | [diff] [blame] | 97 | "intr_state": begin |
| 98 | // FIXME |
| 99 | do_read_check = 1'b0; |
| 100 | end |
| 101 | "intr_enable": begin |
| 102 | // FIXME |
| 103 | end |
| 104 | "intr_test": begin |
| 105 | // FIXME |
| 106 | end |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 107 | default: begin |
| 108 | `uvm_fatal(`gfn, $sformatf("invalid csr: %0s", csr.get_full_name())) |
| 109 | end |
| 110 | endcase |
| 111 | |
| 112 | // On reads, if do_read_check, is set, then check mirrored_value against item.d_data |
Srikrishna Iyer | 1cffbcc | 2020-06-29 16:43:16 -0700 | [diff] [blame] | 113 | if (data_phase_read) begin |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 114 | if (do_read_check) begin |
| 115 | `DV_CHECK_EQ(csr.get_mirrored_value(), item.d_data, |
| 116 | $sformatf("reg name: %0s", csr.get_full_name())) |
| 117 | end |
Cindy Chen | 3d265a6 | 2019-12-12 17:18:02 -0800 | [diff] [blame] | 118 | void'(csr.predict(.value(item.d_data), .kind(UVM_PREDICT_READ))); |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 119 | end |
| 120 | endtask |
| 121 | % endif |
| 122 | |
| 123 | virtual function void reset(string kind = "HARD"); |
| 124 | super.reset(kind); |
| 125 | // reset local fifos queues and variables |
| 126 | endfunction |
| 127 | |
| 128 | function void check_phase(uvm_phase phase); |
| 129 | super.check_phase(phase); |
| 130 | // post test checks - ensure that all local fifos and queues are empty |
| 131 | endfunction |
| 132 | |
| 133 | endclass |