forked from aignacio/axi_dma
-
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.
Signed-off-by: Anderson Ignacio <[email protected]>
- Loading branch information
Showing
19 changed files
with
452 additions
and
37 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 |
---|---|---|
|
@@ -32,3 +32,4 @@ output_temp/ | |
riscof_work/ | ||
riscv-arch-test/ | ||
~$* | ||
docs/.** |
Binary file not shown.
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -3,10 +3,10 @@ | |
* License : MIT license <Check LICENSE> | ||
* Author : Anderson Ignacio da Silva (aignacio) <[email protected]> | ||
* Date : 06.06.2022 | ||
* Last Modified Date: 10.06.2022 | ||
* Last Modified Date: 12.06.2022 | ||
*/ | ||
module axi_dma_wrapper | ||
import utils_pkg::*; | ||
import dma_utils_pkg::*; | ||
( | ||
input clk, | ||
input rst, | ||
|
@@ -30,8 +30,8 @@ module axi_dma_wrapper | |
logic [`DMA_NUM_DESC-1:0] dma_desc_en; | ||
|
||
s_dma_desc_t [`DMA_NUM_DESC-1:0] dma_desc; | ||
s_dma_cmd_in_t dma_cmd_in; | ||
s_dma_cmd_in_t dma_cmd_out; | ||
s_dma_control_t dma_ctrl; | ||
s_dma_status_t dma_stats; | ||
s_dma_error_t dma_error; | ||
|
||
always_comb begin | ||
|
@@ -81,20 +81,29 @@ module axi_dma_wrapper | |
.o_rid (), | ||
.o_rdata (dma_csr_miso_o.rdata), | ||
.o_rresp (dma_csr_miso_o.rresp), | ||
.o_dma_control_go (dma_cmd_in.go), | ||
.o_dma_control_abort (dma_cmd_in.abort), | ||
.i_dma_status_done (dma_cmd_out.done), | ||
.o_dma_control_go (dma_ctrl.go), | ||
.o_dma_control_max_burst (dma_ctrl.max_burst), | ||
.o_dma_control_abort (dma_ctrl.abort_req), | ||
.i_dma_status_done (dma_stats.done), | ||
.i_dma_error_error_trig (dma_stats.error), | ||
.i_dma_error_error_addr (dma_error.addr), | ||
.i_dma_error_error_type (dma_error.type_err), | ||
.i_dma_error_error_src (dma_error.src), | ||
.i_dma_error_error_trig (dma_cmd_out.error), | ||
.o_dma_descriptor_src_addr (dma_desc_src_vec), | ||
.o_dma_descriptor_dest_addr (dma_desc_dst_vec), | ||
.o_dma_descriptor_num_bytes (dma_desc_num_bytes_vec), | ||
.o_dma_descriptor_num_bytes (dma_desc_byt_vec), | ||
.o_dma_descriptor_write_mode(dma_desc_wr_mod), | ||
.o_dma_descriptor_read_mode (dma_desc_rd_mod), | ||
.o_dma_descriptor_enable (dma_desc_en) | ||
); | ||
/* verilator lint_on WIDTH */ | ||
|
||
dma_func_wrapper u_dma_func_wrapper( | ||
.clk (clk), | ||
.rst (rst), | ||
// From/To CSRs | ||
.dma_ctrl_i (dma_ctrl), | ||
.dma_desc_i (dma_desc), | ||
.dma_stats_o(dma_stats) | ||
); | ||
endmodule |
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,90 @@ | ||
/** | ||
* File : dma_fifo.sv | ||
* License : MIT license <Check LICENSE> | ||
* Author : Anderson Ignacio da Silva (aignacio) <[email protected]> | ||
* Date : 10.06.2022 | ||
* Last Modified Date: 12.06.2022 | ||
*/ | ||
module dma_fifo | ||
import dma_utils_pkg::*; | ||
#( | ||
parameter int SLOTS = `DMA_FIFO_DEPTH, | ||
parameter int WIDTH = `AXI_DATA_WIDTH | ||
)( | ||
input clk, | ||
input rst, | ||
input write_i, | ||
input read_i, | ||
input [WIDTH-1:0] data_i, | ||
output logic [WIDTH-1:0] data_o, | ||
output logic error_o, | ||
output logic full_o, | ||
output logic empty_o, | ||
output logic [$clog2(SLOTS>1?SLOTS:2):0] ocup_o, | ||
output logic [$clog2(SLOTS>1?SLOTS:2):0] free_o | ||
); | ||
`define MSB_SLOT $clog2(SLOTS>1?SLOTS:2) | ||
|
||
logic [SLOTS-1:0] [WIDTH-1:0] fifo_ff; | ||
logic [`MSB_SLOT:0] write_ptr_ff; | ||
logic [`MSB_SLOT:0] read_ptr_ff; | ||
logic [`MSB_SLOT:0] next_write_ptr; | ||
logic [`MSB_SLOT:0] next_read_ptr; | ||
logic [`MSB_SLOT:0] fifo_ocup; | ||
|
||
always_comb begin | ||
next_read_ptr = read_ptr_ff; | ||
next_write_ptr = write_ptr_ff; | ||
if (SLOTS == 1) begin | ||
empty_o = (write_ptr_ff == read_ptr_ff); | ||
full_o = (write_ptr_ff[0] != read_ptr_ff[0]); | ||
data_o = empty_o ? '0 : fifo_ff[0]; | ||
end | ||
else begin | ||
empty_o = (write_ptr_ff == read_ptr_ff); | ||
full_o = (write_ptr_ff[`MSB_SLOT-1:0] == read_ptr_ff[`MSB_SLOT-1:0]) && | ||
(write_ptr_ff[`MSB_SLOT] != read_ptr_ff[`MSB_SLOT]); | ||
data_o = empty_o ? '0 : fifo_ff[read_ptr_ff[`MSB_SLOT-1:0]]; | ||
end | ||
|
||
if (write_i && ~full_o) | ||
next_write_ptr = write_ptr_ff + 'd1; | ||
|
||
if (read_i && ~empty_o) | ||
next_read_ptr = read_ptr_ff + 'd1; | ||
|
||
error_o = (write_i && full_o) || (read_i && empty_o); | ||
fifo_ocup = write_ptr_ff - read_ptr_ff; | ||
fifo_space = SLOTS - fifo_ocup; | ||
ocup_o = fifo_ocup; | ||
end | ||
|
||
always_ff @ (posedge clk) begin | ||
if (rst) begin | ||
write_ptr_ff <= '0; | ||
read_ptr_ff <= '0; | ||
end | ||
else begin | ||
write_ptr_ff <= next_write_ptr; | ||
read_ptr_ff <= next_read_ptr; | ||
if (write_i && ~full_o) | ||
if (SLOTS == 1) begin | ||
fifo_ff[0] <= data_i; | ||
end | ||
else begin | ||
fifo_ff[write_ptr_ff[`MSB_SLOT-1:0]] <= data_i; | ||
end | ||
end | ||
end | ||
|
||
`ifndef NO_ASSERTIONS | ||
initial begin | ||
illegal_fifo_slot : assert (2**$clog2(SLOTS) == SLOTS) | ||
else $error("FIFO Slots must be power of 2"); | ||
|
||
min_fifo_size : assert (SLOTS >= 1) | ||
else $error("FIFO size of SLOTS defined is illegal!"); | ||
end | ||
`endif | ||
|
||
endmodule |
Oops, something went wrong.