blob: 41017cbc23a8b340bd63ce4a32384053aa7ce784 [file] [log] [blame]
lowRISC Contributors802543a2019-08-31 12:12:56 +01001// 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:
6class ${name}_scoreboard extends cip_base_scoreboard #(
7% else:
8class ${name}_scoreboard extends dv_base_scoreboard #(
9% endif
10 .CFG_T(${name}_env_cfg),
Udi Jonnalagaddadf4350b2020-03-13 16:55:17 -070011% if has_ral:
lowRISC Contributors802543a2019-08-31 12:12:56 +010012 .RAL_T(${name}_reg_block),
Udi Jonnalagaddadf4350b2020-03-13 16:55:17 -070013% endif
lowRISC Contributors802543a2019-08-31 12:12:56 +010014 .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 Chen3e2978a2021-01-08 09:36:40 -080037% if has_alerts:
38 // TODO: remove once support alert checking
39 do_alert_check = 0;
40% endif
lowRISC Contributors802543a2019-08-31 12:12:56 +010041 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 Yangc2a8fc92021-04-06 17:37:34 -070067 virtual task process_tl_access(tl_seq_item item, tl_channels_e channel, string ral_name);
lowRISC Contributors802543a2019-08-31 12:12:56 +010068 uvm_reg csr;
Cindy Chen11491532019-09-05 08:21:40 -070069 bit do_read_check = 1'b1;
70 bit write = item.is_write();
Srikrishna Iyere42009b2020-11-05 16:22:42 -080071 uvm_reg_addr_t csr_addr = ral.get_word_aligned_addr(item.a_addr);
Weicai Yang698d6762019-10-15 14:07:05 -070072
Srikrishna Iyer1cffbcc2020-06-29 16:43:16 -070073 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 Contributors802543a2019-08-31 12:12:56 +010078 // if access was to a valid csr, get the csr handle
Weicai Yang6a2bdce2021-04-07 14:08:03 -070079 if (csr_addr inside {cfg.csr_addrs[ral_name]}) begin
Cindy Chen11491532019-09-05 08:21:40 -070080 csr = ral.default_map.get_reg_by_offset(csr_addr);
lowRISC Contributors802543a2019-08-31 12:12:56 +010081 `DV_CHECK_NE_FATAL(csr, null)
82 end
Srikrishna Iyer627f7822020-01-15 21:39:29 -080083 else begin
Weicai Yang698d6762019-10-15 14:07:05 -070084 `uvm_fatal(`gfn, $sformatf("Access unexpected addr 0x%0h", csr_addr))
lowRISC Contributors802543a2019-08-31 12:12:56 +010085 end
86
Srikrishna Iyer1cffbcc2020-06-29 16:43:16 -070087 // 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 Contributors802543a2019-08-31 12:12:56 +010090 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 Iyer1cffbcc2020-06-29 16:43:16 -070097 "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 Contributors802543a2019-08-31 12:12:56 +0100107 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 Iyer1cffbcc2020-06-29 16:43:16 -0700113 if (data_phase_read) begin
lowRISC Contributors802543a2019-08-31 12:12:56 +0100114 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 Chen3d265a62019-12-12 17:18:02 -0800118 void'(csr.predict(.value(item.d_data), .kind(UVM_PREDICT_READ)));
lowRISC Contributors802543a2019-08-31 12:12:56 +0100119 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
133endclass