Skip to content

Commit

Permalink
Logger update (#128)
Browse files Browse the repository at this point in the history
* logger: Updated logger

- Added a reporter and a component base classes to instantiate from
- Feature to get path from which hierarchy was reporting called
- Added separate logging options for elaborated code
- Updated class inheritance to support hierarchy level logging
- Updated libraries to use the appropriate reporting functions
- Updated testbenches

Signed-off-by: Istvan-Zsolt Szekely <[email protected]>
  • Loading branch information
IstvanZsSzekely authored Nov 20, 2024
1 parent d992856 commit b6f0bb1
Show file tree
Hide file tree
Showing 75 changed files with 1,188 additions and 1,103 deletions.
14 changes: 10 additions & 4 deletions library/drivers/common/mailbox.sv
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package mailbox_pkg;

import logger_pkg::*;

class mailbox_c #(type T);
class mailbox_c #(type T) extends adi_component;

T queue[$];

Expand All @@ -13,7 +13,13 @@ package mailbox_pkg;
event q_event;

// constructor
function new(int size_max = 0);
function new(
input string name,
input int size_max = 0,
input adi_component parent = null);

super.new(name, parent);

this.size_max = size_max;
endfunction

Expand All @@ -36,14 +42,14 @@ package mailbox_pkg;
return 1;
endfunction

task put(T element);
task put(input T element);
if (this.size_max == this.num() && this.size_max != 0)
@this.q_event;
this.queue.push_front(element);
->this.q_event;
endtask

function int try_put(T element);
function int try_put(input T element);
if (this.size_max == this.num() && this.size_max != 0)
return 0;
this.queue.push_front(element);
Expand Down
20 changes: 11 additions & 9 deletions library/drivers/common/scoreboard.sv
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package scoreboard_pkg;
import x_monitor_pkg::*;
import mailbox_pkg::*;

class scoreboard extends xil_component;
class scoreboard extends adi_component;

typedef enum bit { CYCLIC=0, ONESHOT } sink_type_t;
protected sink_type_t sink_type;
Expand All @@ -35,9 +35,11 @@ package scoreboard_pkg;
protected event sink_transaction_event;

// constructor
function new(input string name);
function new(
input string name,
input adi_component parent = null);

super.new(name);
super.new(name, parent);

this.enabled = 0;
this.sink_type = ONESHOT;
Expand Down Expand Up @@ -88,7 +90,7 @@ package scoreboard_pkg;
if (!this.enabled) begin
this.sink_type = sink_type_t'(sink_type);
end else begin
`ERROR(("ERROR Scoreboard: Can not configure sink_type while scoreboard is running."));
this.error($sformatf("Can not configure sink_type while scoreboard is running."));
end

endfunction: set_sink_type
Expand Down Expand Up @@ -137,7 +139,7 @@ package scoreboard_pkg;
this.source_byte_stream.push_front(source_byte);
end
this.source_byte_stream_size += this.source_monitor.mailbox.num();
`INFOV(("Source transaction received, size: %d - %d", this.source_monitor.mailbox.num(), this.source_byte_stream_size), 200);
this.info($sformatf("Source transaction received, size: %d - %d", this.source_monitor.mailbox.num(), this.source_byte_stream_size), ADI_VERBOSITY_MEDIUM);
->>source_transaction_event;
this.source_monitor.put_key();
end
Expand Down Expand Up @@ -168,7 +170,7 @@ package scoreboard_pkg;
this.sink_byte_stream.push_front(sink_byte);
end
this.sink_byte_stream_size += this.sink_monitor.mailbox.num();
`INFOV(("Sink transaction received, size: %d - %d", this.sink_monitor.mailbox.num(), this.sink_byte_stream_size), 200);
this.info($sformatf("Sink transaction received, size: %d - %d", this.sink_monitor.mailbox.num(), this.sink_byte_stream_size), ADI_VERBOSITY_MEDIUM);
->>sink_transaction_event;
this.sink_monitor.put_key();
end
Expand All @@ -181,7 +183,7 @@ package scoreboard_pkg;
logic [7:0] source_byte;
logic [7:0] sink_byte;

`INFOV(("Scoreboard started"), 100);
this.info($sformatf("Started"), ADI_VERBOSITY_MEDIUM);

forever begin : tx_path
if (this.enabled == 0)
Expand All @@ -196,9 +198,9 @@ package scoreboard_pkg;
this.source_byte_stream_size--;
sink_byte = this.sink_byte_stream.pop_back();
this.sink_byte_stream_size--;
`INFOV(("Scoreboard source-sink data: exp %h - rcv %h", source_byte, sink_byte), 100);
this.info($sformatf("Source-sink data: exp %h - rcv %h", source_byte, sink_byte), ADI_VERBOSITY_MEDIUM);
if (source_byte != sink_byte) begin
`ERROR(("Scoreboard failed at: exp %h - rcv %h", source_byte, sink_byte));
this.error($sformatf("Failed at: exp %h - rcv %h", source_byte, sink_byte));
end
end else begin
if ((this.source_byte_stream_size == 0) &&
Expand Down
11 changes: 6 additions & 5 deletions library/drivers/common/scoreboard_pack.sv
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ package scoreboard_pack_pkg;
input int channels,
input int samples,
input int width,
input pack_type mode);
input pack_type mode,
input adi_component parent = null);

super.new(name);
super.new(name, parent);

this.channels = channels;
this.samples = samples;
Expand All @@ -50,7 +51,7 @@ package scoreboard_pack_pkg;
int outer_loop = (this.mode == CPACK) ? this.channels : this.samples;
int inner_loop = (this.mode == CPACK) ? this.samples : this.channels;

`INFOV(("Scoreboard started"), 100);
this.info($sformatf("Scoreboard started"), 100);

forever begin : tx_path
if (this.enabled == 0)
Expand All @@ -71,9 +72,9 @@ package scoreboard_pack_pkg;
else
this.source_byte_stream_size--;
sink_byte = sink_byte_stream_block[(outer_loop*j+i)*this.width/8+k];
`INFOV(("Scoreboard source-sink data: exp %h - rcv %h", source_byte, sink_byte), 100);
this.info($sformatf("Scoreboard source-sink data: exp %h - rcv %h", source_byte, sink_byte), 100);
if (source_byte != sink_byte) begin
`ERROR(("Scoreboard failed at: exp %h - rcv %h", source_byte, sink_byte));
this.error($sformatf("Scoreboard failed at: exp %h - rcv %h", source_byte, sink_byte));
end
end
end
Expand Down
18 changes: 11 additions & 7 deletions library/drivers/common/watchdog.sv
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,30 @@ package watchdog_pkg;

import logger_pkg::*;

class watchdog;
class watchdog extends adi_component;

protected event stop_event;
protected bit [31:0] timer;
protected string message;


function new(
bit [31:0] timer,
string message);
input string name,
input bit [31:0] timer,
input string message,
input adi_component parent = null);

super.new(name, parent);

this.timer = timer;
this.message = message;
endfunction

function void update_message(string message);
function void update_message(input string message);
this.message = message;
endfunction: update_message

function void update_timer(bit [31:0] timer);
function void update_timer(input bit [31:0] timer);
this.timer = timer;
endfunction: update_timer

Expand All @@ -77,12 +81,12 @@ package watchdog_pkg;
fork
begin
#(this.timer*1ns);
`ERROR(("Watchdog timer timed out! %s", this.message));
this.error($sformatf("Watchdog timer timed out! %s", this.message));
end
@this.stop_event;
join_any
disable fork;
`INFOV(("Watchdog timer reset. %s", this.message), 100);
this.info($sformatf("Watchdog timer reset. %s", this.message), ADI_VERBOSITY_MEDIUM);
end
join_none
endtask: start
Expand Down
31 changes: 20 additions & 11 deletions library/drivers/common/x_monitor.sv
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package x_monitor_pkg;
import logger_pkg::*;
import mailbox_pkg::*;

class x_monitor extends xil_component;
class x_monitor extends adi_component;

mailbox_c #(logic [7:0]) mailbox;
protected semaphore semaphore_key;
Expand All @@ -17,10 +17,13 @@ package x_monitor_pkg;
protected bit enabled;

// constructor
function new(input string name);
super.new(name);
function new(
input string name,
input adi_component parent = null);

super.new(name, parent);

this.mailbox = new;
this.mailbox = new("Mailbox", 0, this);
this.semaphore_key = new(1);
endfunction

Expand Down Expand Up @@ -81,9 +84,12 @@ package x_monitor_pkg;
protected int axi_byte_stream_size;

// constructor
function new(input string name, T agent);
function new(
input string name,
input T agent,
input adi_component parent = null);

super.new(name);
super.new(name, parent);

this.enabled = 0;

Expand Down Expand Up @@ -124,7 +130,7 @@ package x_monitor_pkg;
this.axi_byte_stream_size++;
end
end
`INFOV(("Caught an AXI4 transaction: %d", this.axi_byte_stream_size), 100);
this.info($sformatf("Caught an AXI4 transaction: %d", this.axi_byte_stream_size), ADI_VERBOSITY_MEDIUM);
this.transaction_captured();
#1step;
#1step;
Expand Down Expand Up @@ -154,9 +160,12 @@ package x_monitor_pkg;
protected T agent;

// constructor
function new(input string name, T agent);
function new(
input string name,
input T agent,
input adi_component parent = null);

super.new(name);
super.new(name, parent);

this.enabled = 0;
this.tx_sink_type = CYCLIC;
Expand All @@ -172,7 +181,7 @@ package x_monitor_pkg;
if (!this.enabled) begin
this.tx_sink_type = sink_type_t'(sink_type);
end else begin
`ERROR(("ERROR Scoreboard: Can not configure sink_type while scoreboard is running."));
this.error($sformatf("ERROR Scoreboard: Can not configure sink_type while scoreboard is running."));
end

endfunction
Expand Down Expand Up @@ -205,7 +214,7 @@ package x_monitor_pkg;
if (keep_beat[j+:1] || !this.agent.vif_proxy.C_XIL_AXI4STREAM_SIGNAL_SET[XIL_AXI4STREAM_SIGSET_POS_KEEP])
this.mailbox.put(axi_byte);
end
`INFOV(("Caught an AXI4 stream transaction: %d", this.mailbox.num()), 100);
this.info($sformatf("Caught an AXI4 stream transaction: %d", this.mailbox.num()), ADI_VERBOSITY_MEDIUM);
this.transaction_captured();
#1step;
this.mailbox.flush();
Expand Down
9 changes: 7 additions & 2 deletions library/drivers/data_offload/data_offload_api.sv
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ package data_offload_api_pkg;
// -----------------
//
// -----------------
function new(string name, reg_accessor bus, bit [31:0] base_address);
super.new(name, bus, base_address);
function new(
input string name,
input reg_accessor bus,
input bit [31:0] base_address,
input adi_component parent = null);

super.new(name, bus, base_address, parent);
endfunction

// -----------------
Expand Down
Loading

0 comments on commit b6f0bb1

Please sign in to comment.