forked from ultraembedded/cores
-
Notifications
You must be signed in to change notification settings - Fork 0
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
9fd1be4
commit b348763
Showing
3 changed files
with
90 additions
and
15 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
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,48 @@ | ||
#ifndef SPDIF_VPI_H | ||
#define SPDIF_VPI_H | ||
|
||
#include "sc_vpi_module.h" | ||
|
||
class spdif_vpi: public sc_vpi_module | ||
{ | ||
public: | ||
sc_in <bool> clk_i; | ||
sc_in <bool> rst_i; | ||
sc_in <bool> audio_clk_i; | ||
sc_out <bool> spdif_o; | ||
sc_in <sc_uint<32> > sample_i; | ||
sc_out <bool> sample_req_o; | ||
|
||
void read_outputs(void) | ||
{ | ||
sc_vpi_module_read_output_int(spdif_o, "spdif_o"); | ||
sc_vpi_module_read_output_int(sample_req_o, "sample_req_o"); | ||
} | ||
|
||
void write_inputs(void) | ||
{ | ||
sc_vpi_module_write_input_int(clk_i, "clk_i"); | ||
sc_vpi_module_write_input_int(rst_i, "rst_i"); | ||
sc_vpi_module_write_input_int(audio_clk_i, "audio_clk_i"); | ||
sc_vpi_module_write_input_int(sample_i, "sample_i"); | ||
} | ||
|
||
spdif_vpi(sc_module_name name): | ||
sc_vpi_module(name) | ||
, clk_i ("clk_i") | ||
, rst_i ("rst_i") | ||
, audio_clk_i ("audio_clk_i") | ||
, spdif_o ("spdif_o") | ||
, sample_i ("sample_i") | ||
, sample_req_o ("sample_req_o") | ||
{ | ||
register_signal("clk_i"); | ||
register_signal("rst_i"); | ||
register_signal("audio_clk_i"); | ||
register_signal("spdif_o"); | ||
register_signal("sample_i"); | ||
register_signal("sample_req_o"); | ||
} | ||
}; | ||
|
||
#endif |
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,40 @@ | ||
`timescale 1ns / 1ns | ||
|
||
//----------------------------------------------------------------- | ||
// Module: Auto generated top | ||
//----------------------------------------------------------------- | ||
module tb_top(); | ||
|
||
reg clk_i; | ||
reg rst_i; | ||
reg audio_clk_i; | ||
wire spdif_o; | ||
reg [31:0] sample_i; | ||
wire sample_req_o; | ||
|
||
//----------------------------------------------------------------- | ||
// DUT | ||
//----------------------------------------------------------------- | ||
spdif dut | ||
( | ||
.clk_i(clk_i) | ||
, .rst_i(rst_i) | ||
, .audio_clk_i(audio_clk_i) | ||
, .spdif_o(spdif_o) | ||
, .sample_i(sample_i) | ||
, .sample_req_o(sample_req_o) | ||
); | ||
|
||
//----------------------------------------------------------------- | ||
// Trace | ||
//----------------------------------------------------------------- | ||
initial | ||
begin | ||
if (`TRACE) | ||
begin | ||
$dumpfile("waveform.vcd"); | ||
$dumpvars(0,tb_top); | ||
end | ||
end | ||
|
||
endmodule |