Skip to content

Commit

Permalink
scoreboard: Updated monitor
Browse files Browse the repository at this point in the history
- Changed axi monitor to only monitor read or write operations based on a parameter
- Requires the use of 2 monitors for both read and write

Signed-off-by: Istvan-Zsolt Szekely <[email protected]>
  • Loading branch information
IstvanZsSzekely committed Mar 6, 2024
1 parent bb9ff6b commit 21daab3
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 51 deletions.
37 changes: 33 additions & 4 deletions common/sv/scoreboard.sv
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ package scoreboard_pkg;

event end_of_first_cycle;
event byte_streams_empty;
event stop_scoreboard;

// constructor
function new(input string name);
Expand Down Expand Up @@ -78,6 +79,13 @@ package scoreboard_pkg;

endtask: run

// stop scoreboard
task stop();
this.enabled = 0;
->>stop_scoreboard;
#1step;
endtask: stop

// set sink type
function void set_sink_type(input bit sink_type);

Expand Down Expand Up @@ -111,15 +119,24 @@ package scoreboard_pkg;
logic [7:0] source_byte;

forever begin
this.source_monitor.wait_for_transaction_event();
fork begin
fork
this.source_monitor.wait_for_transaction_event();
@stop_scoreboard;
join_any
disable fork;
end join
if (this.enabled == 0)
break;

this.source_monitor.get_key();
for (int i=0; i<this.source_monitor.mailbox.num(); ++i) begin
this.source_monitor.mailbox.get(source_byte);
this.source_monitor.mailbox.put(source_byte);
this.source_byte_stream.push_front(source_byte);
end
this.source_byte_stream_size += this.source_monitor.mailbox.num();
`INFO(("Source transaction received, size: %d - %d", this.source_monitor.mailbox.num(), this.source_byte_stream_size));
`INFOV(("Source transaction received, size: %d - %d", this.source_monitor.mailbox.num(), this.source_byte_stream_size), 200);
this.source_monitor.put_key();
end

Expand All @@ -131,15 +148,25 @@ package scoreboard_pkg;
logic [7:0] sink_byte;

forever begin
this.sink_monitor.wait_for_transaction_event();
fork begin
fork
this.sink_monitor.wait_for_transaction_event();
@stop_scoreboard;
join_any
disable fork;
end join

if (this.enabled == 0)
break;

this.sink_monitor.get_key();
for (int i=0; i<this.sink_monitor.mailbox.num(); ++i) begin
this.sink_monitor.mailbox.get(sink_byte);
this.sink_monitor.mailbox.put(sink_byte);
this.sink_byte_stream.push_front(sink_byte);
end
this.sink_byte_stream_size += this.sink_monitor.mailbox.num();
`INFO(("Sink transaction received, size: %d - %d", this.sink_monitor.mailbox.num(), this.sink_byte_stream_size));
`INFOV(("Sink transaction received, size: %d - %d", this.sink_monitor.mailbox.num(), this.sink_byte_stream_size), 200);
this.sink_monitor.put_key();
end

Expand All @@ -154,6 +181,8 @@ package scoreboard_pkg;
`INFOV(("Scoreboard started"), 100);

forever begin : tx_path
if (this.enabled == 0)
break;
if ((this.source_byte_stream_size > 0) &&
(this.sink_byte_stream_size > 0)) begin
source_byte = this.source_byte_stream.pop_back();
Expand Down
62 changes: 27 additions & 35 deletions common/sv/x_monitor.sv
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ package x_monitor_pkg;
semaphore semaphore_key;
event transaction_event;

bit enabled;

// constructor
function new(input string name);
super.new(name);
Expand All @@ -33,30 +35,43 @@ package x_monitor_pkg;

// event functions
task transaction_captured();
->this.transaction_event;
->>this.transaction_event;
endtask

task wait_for_transaction_event();
@this.transaction_event;
endtask

// run task
task run();

fork
this.enabled = 1;
get_transaction();
join_none

endtask /* run */

// virtual functions
virtual function void set_sink_type(input bit sink_type);
endfunction

virtual function bit get_sink_type();
endfunction

virtual task run();
endtask

virtual task get_transaction();
endtask

endclass

typedef enum bit {
READ_OP = 1'b0,
WRITE_OP = 1'b1
} operation_type_t;

class x_axi_monitor #( type T, bit operation_type ) extends x_monitor;
class x_axi_monitor #( type T, operation_type_t operation_type ) extends x_monitor;
// operation type: 1 - write
// 0 - read

// analysis port from the monitor
xil_analysis_port #(axi_monitor_transaction) axi_ap;
Expand All @@ -66,8 +81,7 @@ package x_monitor_pkg;
int axi_byte_stream_size;

// counters and synchronizers
bit enabled;
event end_of_first_cycle;
// event end_of_first_cycle;

// constructor
function new(input string name, T agent);
Expand All @@ -84,16 +98,6 @@ package x_monitor_pkg;

endfunction /* new */

// run task
virtual task run();

fork
this.enabled = 1;
get_transaction();
join_none

endtask /* run */

// collect data from the DDR interface, all WRITE transaction are coming
// from the ADC and all READ transactions are going to the DAC
virtual task get_transaction();
Expand All @@ -107,23 +111,22 @@ package x_monitor_pkg;
this.get_key();
if (this.axi_ap.get_item_cnt() > 0) begin
this.axi_ap.get(transaction);
if (transaction.get_cmd_type() == operation_type) begin // WRITE
if (bit'(transaction.get_cmd_type()) == bit'(operation_type)) begin
this.put_key();
num_bytes = transaction.get_data_width()/8;
for (int i=0; i<(transaction.get_len()+1); i++) begin
data_beat = transaction.get_data_beat(i);
for (int j=0; j<num_bytes; j++) begin
axi_byte = data_beat[j*8+:8];
// put each beat into byte queues
if (transaction.get_cmd_type() == 1'b1) begin // WRITE
this.mailbox.put(axi_byte);
this.axi_byte_stream_size++;
end
this.mailbox.put(axi_byte);
this.axi_byte_stream_size++;
end
if (transaction.get_cmd_type() == 1'b1)
`INFOV(("Caught a transaction: %d", this.axi_byte_stream_size), 100);
this.transaction_captured();
#1step;
#1step;
this.mailbox.flush();
this.axi_byte_stream_size = 0;
end
Expand Down Expand Up @@ -155,8 +158,7 @@ package x_monitor_pkg;
// int all_transfer_size;

// counters and synchronizers
bit enabled;
event end_of_first_cycle;
// event end_of_first_cycle;

// constructor
function new(input string name, T agent);
Expand All @@ -172,16 +174,6 @@ package x_monitor_pkg;

endfunction /* new */

// run task
virtual task run();

fork
this.enabled = 1;
get_transaction();
join_none

endtask /* run */

// set sink type
virtual function void set_sink_type(input bit sink_type);

Expand Down Expand Up @@ -220,7 +212,7 @@ package x_monitor_pkg;
axi_byte = data_beat[j*8+:8];
this.mailbox.put(axi_byte);
end
`INFOV(("Caught a TX AXI4 stream transaction: %d", this.mailbox.num()), 100);
`INFOV(("Caught an AXI4 stream transaction: %d", this.mailbox.num()), 100);

// this.all_transfer_size += this.transfer_size;

Expand Down
24 changes: 12 additions & 12 deletions scoreboard/environment.sv
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ package environment_pkg;

x_axis_monitor #(`AGENT(test_harness, adc_src_axis_0, mst_t)) adc_src_axis_0_mon;
x_axis_monitor #(`AGENT(test_harness, dac_dst_axis_0, slv_t)) dac_dst_axis_0_mon;
x_axi_monitor #(`AGENT(test_harness, adc_dst_axi_pt_0, passthrough_mem_t)) adc_dst_axi_pt_0_mon;
x_axi_monitor #(`AGENT(test_harness, dac_src_axi_pt_0, passthrough_mem_t)) dac_src_axi_pt_0_mon;
x_axi_monitor #(`AGENT(test_harness, adc_dst_axi_pt_0, passthrough_mem_t), WRITE_OP) adc_dst_axi_pt_0_mon;
x_axi_monitor #(`AGENT(test_harness, dac_src_axi_pt_0, passthrough_mem_t), READ_OP) dac_src_axi_pt_0_mon;

x_axis_monitor #(`AGENT(test_harness, adc_src_axis_1, mst_t)) adc_src_axis_1_mon;
x_axis_monitor #(`AGENT(test_harness, dac_dst_axis_1, slv_t)) dac_dst_axis_1_mon;
x_axi_monitor #(`AGENT(test_harness, adc_dst_axi_pt_1, passthrough_mem_t)) adc_dst_axi_pt_1_mon;
x_axi_monitor #(`AGENT(test_harness, dac_src_axi_pt_1, passthrough_mem_t)) dac_src_axi_pt_1_mon;
x_axi_monitor #(`AGENT(test_harness, adc_dst_axi_pt_1, passthrough_mem_t), WRITE_OP) adc_dst_axi_pt_1_mon;
x_axi_monitor #(`AGENT(test_harness, dac_src_axi_pt_1, passthrough_mem_t), READ_OP) dac_src_axi_pt_1_mon;

scoreboard scoreboard_tx0;
scoreboard scoreboard_rx0;
Expand Down Expand Up @@ -185,17 +185,17 @@ package environment_pkg;
adc_src_axis_seq_0.start();
adc_src_axis_seq_1.start();

scoreboard_tx0.set_source_stream(dac_src_axi_pt_0_mon, dac_src_axi_pt_0_mon.tx_mailbox);
scoreboard_tx0.set_sink_stream(dac_dst_axis_0_mon, dac_dst_axis_0_mon.x_mailbox);
scoreboard_tx0.set_source_stream(dac_src_axi_pt_0_mon);
scoreboard_tx0.set_sink_stream(dac_dst_axis_0_mon);

scoreboard_rx0.set_source_stream(adc_src_axis_0_mon, adc_src_axis_0_mon.x_mailbox);
scoreboard_rx0.set_sink_stream(adc_dst_axi_pt_0_mon, adc_dst_axi_pt_0_mon.rx_mailbox);
scoreboard_rx0.set_source_stream(adc_src_axis_0_mon);
scoreboard_rx0.set_sink_stream(adc_dst_axi_pt_0_mon);

scoreboard_tx1.set_source_stream(dac_src_axi_pt_1_mon, dac_src_axi_pt_1_mon.tx_mailbox);
scoreboard_tx1.set_sink_stream(dac_dst_axis_1_mon, dac_dst_axis_1_mon.x_mailbox);
scoreboard_tx1.set_source_stream(dac_src_axi_pt_1_mon);
scoreboard_tx1.set_sink_stream(dac_dst_axis_1_mon);

scoreboard_rx1.set_source_stream(adc_src_axis_1_mon, adc_src_axis_1_mon.x_mailbox);
scoreboard_rx1.set_sink_stream(adc_dst_axi_pt_1_mon, adc_dst_axi_pt_1_mon.rx_mailbox);
scoreboard_rx1.set_source_stream(adc_src_axis_1_mon);
scoreboard_rx1.set_sink_stream(adc_dst_axi_pt_1_mon);

endtask

Expand Down

0 comments on commit 21daab3

Please sign in to comment.