1
0
mirror of https://github.com/aolofsson/oh.git synced 2025-01-30 02:32:53 +08:00
oh/emesh/hdl/emesh_monitor.v

67 lines
1.6 KiB
Coq
Raw Permalink Normal View History

/*******************************************************************************
* Function: EMESH Transaction Monitor
* Author: Andreas Olofsson
* License: MIT (see LICENSE file in OH! repository)
*
******************************************************************************/
/* verilator lint_off STMTDLY */
module emesh_monitor
# (parameter PW = 104, // packet width
2022-06-18 08:51:24 -04:00
parameter FILENAME = "UNDEFINED", // filename
parameter ENABLE = 0 // enable block
)
(
//clock and reset
input clk,
input nreset,
//monitors transaction on the wire
input dut_valid,
input [PW-1:0] dut_packet,
input ready_in
);
2022-06-18 08:51:24 -04:00
generate
if(ENABLE)
begin
//core name for trace
reg [31:0] ftrace;
reg [255:0] tracefile;
2022-06-18 08:51:24 -04:00
initial
begin
#10
$sformat(tracefile,"%0s_%0h%s",FILENAME);
ftrace = $fopen({tracefile}, "w");
end
2022-06-18 08:51:24 -04:00
always @ (posedge clk)
if(nreset & dut_valid & ready_in)
if (PW==112) begin: p112
$fwrite(ftrace, "%h_%h_%h_%h\n",
dut_packet[110:80],
dut_packet[79:48],
dut_packet[47:16],
dut_packet[15:0]);
end
else if (PW==144) begin: p144
$fwrite(ftrace, "%h_%h_%h_%h\n",
dut_packet[143:112],
dut_packet[111:48],
dut_packet[47:16],
dut_packet[15:0]);
end
else if (PW==208) begin: p208
$fwrite(ftrace, "%h_%h_%h_%h_%h\n",
dut_packet[207:144],
dut_packet[143:112],
dut_packet[111:48],
dut_packet[47:16],
dut_packet[15:0]);
end
2022-06-18 08:51:24 -04:00
end
endgenerate
endmodule // emesh_monitor