Skip to content

Commit

Permalink
ADD: Print BlackBox
Browse files Browse the repository at this point in the history
  • Loading branch information
iansseijelly committed Jan 16, 2025
1 parent c25af3e commit 7667eae
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/main/resources/vsrc/BytePrinter.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module BytePrinter
#(
parameter FILE_NAME = "byte_printer.txt"
)
(
input clk,
input reset,
input in_valid,
input[7:0] in_byte
);

`ifdef VCS

integer file;

initial begin
file = $fopen(FILE_NAME, "w");
if (file == 0) begin
$display("Failed to open byte_printer.txt");
$finish;
end
end

always @(posedge clk) begin
if (in_valid & ~reset) begin
$fwrite(file, "%c", in_byte);
end
end

final begin
$fclose(file);
end

`endif

endmodule

0 comments on commit 7667eae

Please # to comment.