Skip to content

Commit 3fde7c7

Browse files
ADI AMD agent abstractization (#171)
Signed-off-by: Istvan-Zsolt Szekely <istvan.szekely@analog.com>
1 parent 8547c89 commit 3fde7c7

File tree

71 files changed

+1634
-1395
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1634
-1395
lines changed

library/drivers/common/scoreboard.sv

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ package scoreboard_pkg;
6161

6262
virtual function void update(input data_type data [$]);
6363
this.info($sformatf("Data received: %d", data.size()), ADI_VERBOSITY_MEDIUM);
64-
while (data.size()) begin
65-
this.byte_stream.push_back(data.pop_front());
66-
end
6764

6865
if (this.scoreboard_ref.get_enabled()) begin
66+
while (data.size()) begin
67+
this.byte_stream.push_back(data.pop_front());
68+
end
69+
6970
this.scoreboard_ref.compare_transaction();
7071
end
7172
endfunction: update
@@ -168,12 +169,13 @@ package scoreboard_pkg;
168169
data_type source_byte;
169170
data_type sink_byte;
170171

172+
this.byte_streams_empty_sig = 0;
173+
171174
if (this.enabled == 0)
172175
return;
173176

174177
while ((this.subscriber_source.get_size() > 0) &&
175178
(this.subscriber_sink.get_size() > 0)) begin
176-
byte_streams_empty_sig = 0;
177179
source_byte = this.subscriber_source.get_data();
178180
if (this.sink_type == CYCLIC)
179181
this.subscriber_source.put_data(source_byte);

library/drivers/common/scoreboard_pack.sv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,13 @@ package scoreboard_pack_pkg;
8282
int outer_loop = (this.mode == CPACK) ? this.channels : this.samples;
8383
int inner_loop = (this.mode == CPACK) ? this.samples : this.channels;
8484

85+
this.byte_streams_empty_sig = 0;
86+
8587
if (this.enabled == 0)
8688
return;
8789

8890
while ((this.subscriber_source.get_size() > 0) &&
8991
(this.subscriber_sink.get_size() >= this.channels*this.samples*this.width/8)) begin
90-
byte_streams_empty_sig = 0;
9192
for (int i=0; i<this.channels*this.samples*this.width/8; i++) begin
9293
sink_byte_stream_block[i] = this.subscriber_sink.get_data();
9394
end

library/includes/Makeinclude_axi.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
####################################################################################
44

55
# All test-bench dependencies except test programs
6+
SV_DEPS += $(TB_LIBRARY_PATH)/vip/vip_agent_typedef_pkg.sv
67
SV_DEPS += $(TB_LIBRARY_PATH)/vip/amd/axi/adi_axi_agent.sv
78
SV_DEPS += $(TB_LIBRARY_PATH)/vip/amd/axi/m_axi_sequencer.sv
89
SV_DEPS += $(TB_LIBRARY_PATH)/vip/amd/axi/s_axi_sequencer.sv

library/includes/Makeinclude_axis.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
####################################################################################
44

55
# All test-bench dependencies except test programs
6+
SV_DEPS += $(TB_LIBRARY_PATH)/vip/vip_agent_typedef_pkg.sv
67
SV_DEPS += $(TB_LIBRARY_PATH)/vip/amd/axis/adi_axis_agent.sv
78
SV_DEPS += $(TB_LIBRARY_PATH)/vip/amd/axis/m_axis_sequencer.sv
89
SV_DEPS += $(TB_LIBRARY_PATH)/vip/amd/axis/s_axis_sequencer.sv

library/includes/sp_include_axi.tcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
# Add test files to the project
3737
adi_sim_project_files [list \
38+
"$ad_tb_dir/library/vip/vip_agent_typedef_pkg.sv" \
3839
"$ad_tb_dir/library/vip/amd/axi/adi_axi_agent.sv" \
3940
"$ad_tb_dir/library/vip/amd/axi/m_axi_sequencer.sv" \
4041
"$ad_tb_dir/library/vip/amd/axi/s_axi_sequencer.sv" \

library/includes/sp_include_axis.tcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
# Add test files to the project
3737
adi_sim_project_files [list \
38+
"$ad_tb_dir/library/vip/vip_agent_typedef_pkg.sv" \
3839
"$ad_tb_dir/library/vip/amd/axis/adi_axis_agent.sv" \
3940
"$ad_tb_dir/library/vip/amd/axis/m_axis_sequencer.sv" \
4041
"$ad_tb_dir/library/vip/amd/axis/s_axis_sequencer.sv" \

library/utilities/test_harness_env.sv

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ package test_harness_env_pkg;
4444
import watchdog_pkg::*;
4545

4646

47-
class test_harness_env #(int `AXI_VIP_PARAM_ORDER(mng), int `AXI_VIP_PARAM_ORDER(ddr)) extends adi_environment;
47+
class test_harness_env #(`AXI_VIP_PARAM_DECL(mng), `AXI_VIP_PARAM_DECL(ddr)) extends adi_environment;
4848

4949
// Agents
5050
adi_axi_master_agent #(`AXI_VIP_PARAM_ORDER(mng)) mng;
@@ -95,8 +95,8 @@ package test_harness_env_pkg;
9595
task start();
9696
this.simulation_watchdog.start();
9797

98-
this.mng.agent.start_master();
99-
this.ddr.agent.start_slave();
98+
this.mng.start_master();
99+
this.ddr.start_slave();
100100

101101
this.sys_clk_vip_if.start_clock();
102102
this.dma_clk_vip_if.start_clock();
@@ -107,8 +107,8 @@ package test_harness_env_pkg;
107107
// Stop subroutine
108108
//============================================================================
109109
task stop();
110-
this.mng.agent.stop_master();
111-
this.ddr.agent.stop_slave();
110+
this.mng.stop_master();
111+
this.ddr.stop_slave();
112112

113113
this.sys_clk_vip_if.stop_clock();
114114
this.dma_clk_vip_if.stop_clock();

library/utilities/utils.svh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@
4848
// Help build VIP parameter name e.g. test_harness_dst_axis_vip_0_VIP_DATA_WIDTH
4949
`define GETPARAM(th,vip,param) th``_``vip``_0_``param
5050

51+
// Help link AMD AXI and AXIS VIPs to ADI Environment VIPs
52+
`define LINK(top,env,inst) \
53+
top``.pre_link_agent(``env``.``inst``); \
54+
env``.``inst`` = ``top``; \
55+
top``.post_link_agent(``env``.``inst``);
56+
5157
// Macros used in Simulation files during simulation
5258
`define INFO(m,v) \
5359
PrintInfo($sformatf("%s", \

library/vip/amd/axi/adi_axi_agent.sv

Lines changed: 146 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -45,77 +45,152 @@ package adi_axi_agent_pkg;
4545
import m_axi_sequencer_pkg::*;
4646
import s_axi_sequencer_pkg::*;
4747
import adi_axi_monitor_pkg::*;
48+
import vip_agent_typedef_pkg::*;
4849

50+
class adi_axi_agent_base extends adi_agent;
4951

50-
class adi_axi_master_agent #(int `AXI_VIP_PARAM_ORDER(master)) extends adi_agent;
52+
m_axi_sequencer_base master_sequencer;
53+
s_axi_sequencer_base slave_sequencer;
54+
adi_axi_monitor_base monitor;
55+
56+
local agent_typedef agent_type;
57+
58+
function new(
59+
input string name,
60+
input agent_typedef agent_type,
61+
input adi_environment parent = null);
62+
63+
super.new(name, parent);
64+
65+
this.agent_type = agent_type;
66+
endfunction: new
67+
68+
virtual task start_master();
69+
if (agent_type == SLAVE) begin
70+
this.fatal($sformatf("Agent is in slave mode!"));
71+
end
72+
endtask: start_master
73+
74+
virtual task start_slave();
75+
if (agent_type == MASTER) begin
76+
this.fatal($sformatf("Agent is in master mode!"));
77+
end
78+
endtask: start_slave
79+
80+
virtual task start_monitor();
81+
if (agent_type != PASSTHROUGH) begin
82+
this.fatal($sformatf("Agent is not in passthrough mode!"));
83+
end
84+
endtask: start_monitor
85+
86+
virtual task stop_master();
87+
if (agent_type == SLAVE) begin
88+
this.fatal($sformatf("Agent is in slave mode!"));
89+
end
90+
endtask: stop_master
91+
92+
virtual task stop_slave();
93+
if (agent_type == MASTER) begin
94+
this.fatal($sformatf("Agent is in master mode!"));
95+
end
96+
endtask: stop_slave
97+
98+
virtual task stop_monitor();
99+
if (agent_type != PASSTHROUGH) begin
100+
this.fatal($sformatf("Agent is not in passthrough mode!"));
101+
end
102+
endtask: stop_monitor
103+
104+
endclass: adi_axi_agent_base
105+
106+
107+
class adi_axi_master_agent #(int `AXI_VIP_PARAM_ORDER(master)) extends adi_axi_agent_base;
51108

52109
axi_mst_agent #(`AXI_VIP_PARAM_ORDER(master)) agent;
53-
m_axi_sequencer #(`AXI_VIP_PARAM_ORDER(master)) sequencer;
110+
m_axi_sequencer #(`AXI_VIP_PARAM_ORDER(master)) master_sequencer;
54111
adi_axi_monitor #(`AXI_VIP_PARAM_ORDER(master)) monitor;
55112

56113
function new(
57114
input string name,
58115
virtual interface axi_vip_if #(`AXI_VIP_IF_PARAMS(master)) master_vip_if,
59116
input adi_environment parent = null);
60117

61-
super.new(name, parent);
118+
super.new(name, MASTER, parent);
62119

63120
this.agent = new("Agent", master_vip_if);
64-
this.sequencer = new("Sequencer", this.agent.wr_driver, this.agent.rd_driver, this);
121+
this.master_sequencer = new("Master Sequencer", this.agent.wr_driver, this.agent.rd_driver, this);
65122
this.monitor = new("Monitor TX", this.agent.monitor, this);
66123
endfunction: new
67124

68-
task start();
69-
this.agent.start_master();
70-
endtask: start
125+
function void pre_link_agent(adi_axi_agent_base adi_axi_agent);
126+
this.name = adi_axi_agent.name;
127+
this.parent = adi_axi_agent.parent;
128+
endfunction: pre_link_agent
71129

72-
task run();
73-
this.monitor.run();
74-
endtask: run
130+
function void post_link_agent(adi_axi_agent_base adi_axi_agent);
131+
adi_axi_agent.master_sequencer = this.master_sequencer;
132+
adi_axi_agent.monitor = this.monitor;
133+
endfunction: post_link_agent
75134

76-
task stop();
77-
this.monitor.stop();
135+
virtual task start_master();
136+
super.start_master();
137+
this.agent.start_master();
138+
this.monitor.start();
139+
endtask: start_master
140+
141+
virtual task stop_master();
142+
super.stop_master();
78143
this.agent.stop_master();
79-
endtask: stop
144+
this.monitor.stop();
145+
endtask: stop_master
80146

81147
endclass: adi_axi_master_agent
82148

83149

84-
class adi_axi_slave_mem_agent #(int `AXI_VIP_PARAM_ORDER(slave)) extends adi_agent;
150+
class adi_axi_slave_mem_agent #(int `AXI_VIP_PARAM_ORDER(slave)) extends adi_axi_agent_base;
85151

86152
axi_slv_mem_agent #(`AXI_VIP_PARAM_ORDER(slave)) agent;
87-
s_axi_sequencer #(`AXI_VIP_PARAM_ORDER(slave)) sequencer;
153+
s_axi_sequencer #(`AXI_VIP_PARAM_ORDER(slave)) slave_sequencer;
88154
adi_axi_monitor #(`AXI_VIP_PARAM_ORDER(slave)) monitor;
89155

90156
function new(
91157
input string name,
92158
virtual interface axi_vip_if #(`AXI_VIP_IF_PARAMS(slave)) slave_vip_if,
93159
input adi_environment parent = null);
94160

95-
super.new(name, parent);
161+
super.new(name, SLAVE, parent);
96162

97163
this.agent = new("Agent", slave_vip_if);
98-
this.sequencer = new("Sequencer", this.agent.mem_model, this);
164+
this.slave_sequencer = new("Slave Sequencer", this.agent.mem_model, this);
99165
this.monitor = new("Monitor TX", this.agent.monitor, this);
100166
endfunction: new
101167

102-
task start();
103-
this.agent.start_slave();
104-
endtask: start
168+
function void pre_link_agent(adi_axi_agent_base adi_axi_agent);
169+
this.name = adi_axi_agent.name;
170+
this.parent = adi_axi_agent.parent;
171+
endfunction: pre_link_agent
105172

106-
task run();
107-
this.monitor.run();
108-
endtask: run
173+
function void post_link_agent(adi_axi_agent_base adi_axi_agent);
174+
adi_axi_agent.slave_sequencer = this.slave_sequencer;
175+
adi_axi_agent.monitor = this.monitor;
176+
endfunction: post_link_agent
109177

110-
task stop();
111-
this.monitor.stop();
178+
virtual task start_slave();
179+
super.start_slave();
180+
this.agent.start_slave();
181+
this.monitor.start();
182+
endtask: start_slave
183+
184+
virtual task stop_slave();
185+
super.stop_slave();
112186
this.agent.stop_slave();
113-
endtask: stop
187+
this.monitor.stop();
188+
endtask: stop_slave
114189

115190
endclass: adi_axi_slave_mem_agent
116191

117192

118-
class adi_axi_passthrough_mem_agent #(int `AXI_VIP_PARAM_ORDER(passthrough)) extends adi_agent;
193+
class adi_axi_passthrough_mem_agent #(int `AXI_VIP_PARAM_ORDER(passthrough)) extends adi_axi_agent_base;
119194

120195
axi_passthrough_mem_agent #(`AXI_VIP_PARAM_ORDER(passthrough)) agent;
121196
m_axi_sequencer #(`AXI_VIP_PARAM_ORDER(passthrough)) master_sequencer;
@@ -127,27 +202,60 @@ package adi_axi_agent_pkg;
127202
virtual interface axi_vip_if #(`AXI_VIP_IF_PARAMS(passthrough)) passthrough_vip_if,
128203
input adi_environment parent = null);
129204

130-
super.new(name, parent);
205+
super.new(name, PASSTHROUGH, parent);
131206

132207
this.agent = new("Agent", passthrough_vip_if);
133-
this.master_sequencer = new("Slave Sequencer", this.agent.mst_wr_driver, this.agent.mst_rd_driver, this);
208+
this.master_sequencer = new("Master Sequencer", this.agent.mst_wr_driver, this.agent.mst_rd_driver, this);
134209
this.slave_sequencer = new("Slave Sequencer", this.agent.mem_model, this);
135210
this.monitor = new("Monitor TX", this.agent.monitor, this);
136211
endfunction: new
137212

138-
task start();
139-
this.warning($sformatf("Start must called manually in the test program or environment"));
140-
endtask: start
213+
function void pre_link_agent(adi_axi_agent_base adi_axi_agent);
214+
this.name = adi_axi_agent.name;
215+
this.parent = adi_axi_agent.parent;
216+
endfunction: pre_link_agent
141217

142-
task run();
143-
this.monitor.run();
144-
endtask: run
218+
function void post_link_agent(adi_axi_agent_base adi_axi_agent);
219+
adi_axi_agent.master_sequencer = this.master_sequencer;
220+
adi_axi_agent.slave_sequencer = this.slave_sequencer;
221+
adi_axi_agent.monitor = this.monitor;
222+
endfunction: post_link_agent
145223

146-
task stop();
224+
virtual task start_master();
225+
super.start_master();
226+
this.agent.start_master();
227+
this.monitor.start();
228+
endtask: start_master
229+
230+
virtual task start_slave();
231+
super.start_slave();
232+
this.agent.start_slave();
233+
this.monitor.start();
234+
endtask: start_slave
235+
236+
virtual task start_monitor();
237+
super.start_monitor();
238+
this.agent.start_monitor();
239+
this.monitor.start();
240+
endtask: start_monitor
241+
242+
virtual task stop_master();
243+
super.stop_master();
244+
this.agent.stop_master();
147245
this.monitor.stop();
246+
endtask: stop_master
247+
248+
virtual task stop_slave();
249+
super.stop_slave();
148250
this.agent.stop_slave();
149-
this.agent.stop_master();
150-
endtask: stop
251+
this.monitor.stop();
252+
endtask: stop_slave
253+
254+
virtual task stop_monitor();
255+
super.stop_monitor();
256+
this.agent.stop_monitor();
257+
this.monitor.stop();
258+
endtask: stop_monitor
151259

152260
endclass: adi_axi_passthrough_mem_agent
153261

0 commit comments

Comments
 (0)