Please complete the incomplete code below based on the DMA v1.1 Specification. Output…
- User
Please complete the incomplete code below based on the DMA v1.1 Specification. Output the entire code. Only fill in the “fill your code here” parts, and absolutely do not touch the rest or add anything else. Do not add any variables or make other modifications. // Below is the content of DMAC/RTL/DMAC_CFG.sv module DMAC_CFG ( input wire clk, input wire rst_n, // n means active low // AMBA APB interface input wire psel_i, input wire penable_i, input wire [11:0] paddr_i, input wire pwrite_i, input wire [31:0] pwdata_i, output reg pready_o, output reg [31:0] prdata_o, output reg pslverr_o, // configuration registers output reg [31:0] src_addr_o, output reg [31:0] dst_addr_o, output reg [15:0] byte_len_o, output wire start_o, input wire done_i ); // Configuration register to read/write reg [31:0] src_addr; reg [31:0] dst_addr; reg [15:0] byte_len; //---------------------------------------------------------- // Write //---------------------------------------------------------- // an APB write occurs when PSEL & PENABLE & PWRITE // clk : -------------------- // psel : --------_________________________ // penable : ----______________________ // pwrite : --------__________________________ // wren : ----______________________ // // DMA start command must be asserted when APB writes 1 to the DMA_CMD // register // clk : -------------------- // psel : --------__________________________ // penable : ----______________________ // pwrite : --------__________________________ // paddr : |DMA_CMD| // pwdata : | 1 | // start : ----______________________ wire wren; assign wren = // fill your code here always @(posedge clk) begin // fill // your // code // here end wire start; assign start = // fill your code here // Read reg [31:0] rdata; //---------------------------------------------------------- // READ //---------------------------------------------------------- // an APB read occurs when PSEL & PENABLE & !PWRITE // To make read data a direct output from register, // this code shall buffer the muxed read data into a register // in the SETUP cycle (PSEL & !PENABLE) // clk : -------------------- // psel : __________________________ // penable : ______________________ // pwrite : ________________________________________ // reg update : ______________________________ // always @(posedge clk) begin // fill // your // code // here end // output assignments assign pready_o = 1'b1; assign prdata_o = rdata; assign pslverr_o = 1'b0; assign src_addr_o = src_addr; assign dst_addr_o = dst_addr; assign byte_len_o = byte_len; assign start_o = start; endmodule // End DMAC/RTL/DMAC_CFG.sv // Below is the content of DMAC/SIM/TB/DMAC_CFG_TB.sv define DST_ADDR 32'h104 define STAT_ADDR 32'h110 define TIMEOUT_CYCLE 10000000 module DMAC_CFG_TB (); reg clk; reg rst_n; // clock generation initial begin clk = 1'b0; forever #10 clk = !clk; end // reset generation initial begin rst_n = 1'b0; // active at time 0 repeat (3) @(posedge clk); // after 3 cycles, rst_n = 1'b1; // release the reset end // enable waveform dump initial begin $dumpvars(0, u_DUT); $dumpfile("dump.vcd"); end // timeout initial begin #SRC_ADDR, data); if (data===0) $display("DMA_SRC(pass): %x", data); else begin $display("DMA_SRC(fail): %x", data); @(posedge clk); $finish; end apb_if.read(LEN_ADDR, data); if (data===0) $display("DMA_LEN(pass): %x", data); else begin $display("DMA_LEN(fail): %x", data); @(posedge clk); $finish; end apb_if.read(SRC_ADDR, test_vector); apb_if.read(DST_ADDR, test_vector); apb_if.read(LEN_ADDR, test_vector); apb_if.read(START_ADDR, test_vector); $display("---------------------------------------------------"); $display("Wait for a DMA completion"); $display("---------------------------------------------------"); data = 0; while (data != 1) begin apb_if.read(`STAT_ADDR, data); repeat (100) @(posedge clk); $write("."); end $display(""); @(posedge clk); $display("---------------------------------------------------"); $display("DMA completed"); $display("---------------------------------------------------"); $finish; end DMAC_CFG u_DUT ( .clk (clk), .rst_n (rst_n), // APB interface .psel_i (apb_if.psel), .penable_i (apb_if.penable), .paddr_i (apb_if.paddr[11:0]), .pwrite_i (apb_if.pwrite), .pwdata_i (apb_if.pwdata), .pready_o (apb_if.pready), .prdata_o (apb_if.prdata), .pslverr_o (apb_if.pslverr), .src_addr_o (/* FLOATING FLOATING FLOATING FLOATING */), .done_i (1'b1) ); endmodule // End of DMAC/SIM/TB/DMAC_CFG_TB.sv
- Assistant