-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c25af3e
commit 7667eae
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |