-
Notifications
You must be signed in to change notification settings - Fork 4
Ram handler #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AirPodsRed
wants to merge
6
commits into
main
Choose a base branch
from
RAM_Handler
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Ram handler #77
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ed9edba
Update bootrom.sv
AirPodsRed a8ad220
Update sram_dualport.sv
AirPodsRed bea7e70
Update dma_controller.sv
AirPodsRed 3d31ea5
Update dma_pkg.sv
AirPodsRed 320a8a7
Update dma_channel_arbiter.sv
AirPodsRed e160d9c
Create boot_rom_tb.sv
AirPodsRed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,45 +1,93 @@ | ||
| //====================================================================== | ||
| // DMA Controller - Top Level | ||
| // Author: Evan Eichholz | ||
| // Author: Evan Eichholz | ||
| // Description: Multi-channel DMA with scatter-gather support | ||
| // References: specs/registers/dma.yaml, docs/dma_operation.md | ||
| //====================================================================== | ||
|
|
||
| module dma_controller import dma_pkg::*; ( | ||
| // Clock and reset | ||
| module dma_controller | ||
| import dma_pkg::*; | ||
| ( | ||
| input logic clk_i, | ||
| input logic rst_ni, | ||
|
|
||
| // AXI4 Memory Interface (Master) - Write address channel | ||
|
|
||
| output logic [ADDR_W-1:0] m_axi_awaddr_o, | ||
| output logic [7:0] m_axi_awlen_o, | ||
| // ... (other AXI ports - truncated for brevity) | ||
|
|
||
| // AXI4-Lite Control Interface (Slave) | ||
| output logic [2:0] m_axi_awsize_o, | ||
| output logic [1:0] m_axi_awburst_o, | ||
| output logic m_axi_awvalid_o, | ||
| input logic m_axi_awready_i, | ||
|
|
||
| output logic [DATA_W-1:0] m_axi_wdata_o, | ||
| output logic [DATA_W/8-1:0] m_axi_wstrb_o, | ||
| output logic m_axi_wlast_o, | ||
| output logic m_axi_wvalid_o, | ||
| input logic m_axi_wready_i, | ||
|
|
||
| input logic [1:0] m_axi_bresp_i, | ||
| input logic m_axi_bvalid_i, | ||
| output logic m_axi_bready_o, | ||
|
|
||
| output logic [ADDR_W-1:0] m_axi_araddr_o, | ||
| output logic [7:0] m_axi_arlen_o, | ||
| output logic [2:0] m_axi_arsize_o, | ||
| output logic [1:0] m_axi_arburst_o, | ||
| output logic m_axi_arvalid_o, | ||
| input logic m_axi_arready_i, | ||
|
|
||
| input logic [DATA_W-1:0] m_axi_rdata_i, | ||
| input logic [1:0] m_axi_rresp_i, | ||
| input logic m_axi_rlast_i, | ||
| input logic m_axi_rvalid_i, | ||
| output logic m_axi_rready_o, | ||
|
|
||
| input logic [ADDR_W-1:0] s_axi_awaddr_i, | ||
| // ... (other AXI-Lite ports) | ||
|
|
||
| // Interrupt outputs | ||
| input logic s_axi_awvalid_i, | ||
| output logic s_axi_awready_o, | ||
|
|
||
| input logic [DATA_W-1:0] s_axi_wdata_i, | ||
| input logic [DATA_W/8-1:0] s_axi_wstrb_i, | ||
| input logic s_axi_wvalid_i, | ||
| output logic s_axi_wready_o, | ||
|
|
||
| output logic [1:0] s_axi_bresp_o, | ||
| output logic s_axi_bvalid_o, | ||
| input logic s_axi_bready_i, | ||
|
|
||
| input logic [ADDR_W-1:0] s_axi_araddr_i, | ||
| input logic s_axi_arvalid_i, | ||
| output logic s_axi_arready_o, | ||
|
|
||
| output logic [DATA_W-1:0] s_axi_rdata_o, | ||
| output logic [1:0] s_axi_rresp_o, | ||
| output logic s_axi_rvalid_o, | ||
| input logic s_axi_rready_i, | ||
|
|
||
| output logic [N_CHANNELS-1:0] irq_done_o, | ||
| output logic [N_CHANNELS-1:0] irq_error_o, | ||
|
|
||
| // Peripheral request interface | ||
|
|
||
| input logic [N_CHANNELS-1:0] periph_req_i, | ||
| output logic [N_CHANNELS-1:0] periph_ack_o | ||
| ); | ||
|
|
||
| // Internal signals | ||
| dma_regs_t regs_q, regs_d; | ||
| channel_state_e [N_CHANNELS-1:0] channel_state; | ||
| logic [N_CHANNELS-1:0] channel_grant; | ||
| dma_regs_t regs; | ||
| logic [N_CHANNELS-1:0] ch_req; | ||
| logic [N_CHANNELS-1:0] ch_grant; | ||
| logic [CHANNEL_W-1:0] grant_ch; | ||
| logic grant_valid; | ||
| ch_status_t [N_CHANNELS-1:0] ch_status; | ||
| xfer_req_t xfer_req; | ||
| xfer_resp_t xfer_resp; | ||
| desc_fetch_req_t desc_req; | ||
| desc_fetch_resp_t desc_resp; | ||
| irq_type_e [N_CHANNELS-1:0] irq_type; | ||
|
|
||
| // Module instances | ||
| dma_reg_if u_reg_if (.*); | ||
| dma_channel_arbiter u_channel_arbiter (.*); | ||
| dma_desc_fetch u_desc_fetch (.*); | ||
| dma_xfer_engine u_xfer_engine (.*); | ||
| dma_axi_mux u_axi_mux (.*); | ||
| dma_reg_if u_reg_if (.*); | ||
| dma_irq_ctrl u_irq_ctrl (.*); | ||
| dma_status u_status (.*); | ||
|
|
||
| endmodule | ||
| dma_desc_fetch u_desc_fetch (.*); | ||
| dma_xfer_engine u_xfer_engine (.*); | ||
| dma_axi_mux u_axi_mux (.*); | ||
| dma_irq_ctrl u_irq_ctrl (.*); | ||
| dma_status u_status (.*); | ||
|
|
||
| endmodule | ||
This file contains hidden or 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 hidden or 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,57 @@ | ||
| //when the reset is active, data_o should just be all zeroes. Then every reset is inactive and now every 4th period (40 ns) it should first read | ||
| //@0000 at addr_i = 12h'000, | ||
| //0000006F at addr_i = 12h'004, | ||
| //00000013 at addr_i = 12h'008. | ||
|
|
||
| `timescale 1ns / 1ps | ||
|
|
||
| module boot_rom_tb(); | ||
| localparam ADDR_W = 12; | ||
| localparam DATA_W = 32; | ||
|
|
||
| logic clk_i, rst_ni, valid_o; | ||
| logic [ADDR_W-1: 0] addr_i; | ||
| logic [DATA_W-1:0] data_o; | ||
|
|
||
| boot_rom UTT(.clk_i(clk_i), .rst_ni(rst_ni), .valid_o(valid_o), .addr_i(addr_i), .data_o(data_o)); | ||
|
|
||
| initial begin | ||
| forever #10 clk_i = ~clk_i; | ||
| end | ||
|
|
||
| initial begin | ||
| rst_ni = 0; | ||
| addr_i = 0; | ||
|
|
||
| @(posedge clk_i); | ||
| @(posedge clk_i); | ||
| @(posedge clk_i); | ||
| @(posedge clk_i); | ||
|
|
||
| rst_ni = 1; | ||
|
|
||
| @(posedge clk_i); | ||
| @(posedge clk_i); | ||
| @(posedge clk_i); | ||
| @(posedge clk_i); | ||
|
|
||
| addr_i = 12'h000; | ||
|
|
||
| @(posedge clk_i); | ||
| @(posedge clk_i); | ||
| @(posedge clk_i); | ||
| @(posedge clk_i); | ||
|
|
||
| addr_i = 12'h004; | ||
|
|
||
| @(posedge clk_i); | ||
| @(posedge clk_i); | ||
| @(posedge clk_i); | ||
| @(posedge clk_i); | ||
|
|
||
| addr_i = 12'h008; | ||
|
|
||
| end | ||
|
|
||
|
|
||
| endmodule |
This file contains hidden or 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,34 @@ | ||
| module boot_rom #( | ||
| parameter ADDR_W = 12, | ||
| parameter DATA_W = 32 | ||
| )( | ||
| input logic clk_i, | ||
| input logic rst_ni, | ||
| input logic [ADDR_W-1:0] addr_i, | ||
| output logic [DATA_W-1:0] data_o, | ||
| output logic valid_o | ||
| ); | ||
|
|
||
| logic [DATA_W-1:0] rom [0:2**ADDR_W-1]; | ||
|
|
||
| initial begin | ||
| $readmemh("boot_code.mem", rom); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure this data file is specified somewhere, such as the BootROM one-pager. |
||
| end | ||
|
|
||
| logic [DATA_W-1:0] data_q; | ||
| logic valid_q; | ||
|
|
||
| always_ff @(posedge clk_i) begin | ||
| if (!rst_ni) begin | ||
| data_q <= '0; | ||
| valid_q <= 1'b0; | ||
| end else begin | ||
| data_q <= rom[addr_i[ADDR_W-1: 2]]; | ||
| valid_q <= 1'b1; | ||
| end | ||
| end | ||
|
|
||
| assign data_o = data_q; | ||
| assign valid_o = valid_q; | ||
|
|
||
| endmodule | ||
This file contains hidden or 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,54 @@ | ||
| module sram_dualport #( | ||
| parameter int DATA_W = 32, | ||
| parameter int ADDR_W = 10, | ||
| parameter bit OUT_REG = 0 | ||
| ) ( | ||
| input logic clk_i, | ||
| // Port A | ||
| input logic [ADDR_W-1:0] port_a_addr_i, // port a address input | ||
| input logic [DATA_W-1:0] port_a_wdata_i, // port a write data | ||
| input logic port_a_we_i, // port a write enable input, 1 = write, 0 = read | ||
| input logic [(DATA_W/8)-1:0] port_a_be_i, // port a byte write enable input, corresponds to which bytes in mem to be overwritten | ||
| output logic [DATA_W-1:0] port_a_rdata_o, // read data output | ||
| // Port B | ||
| input logic [ADDR_W-1:0] port_b_addr_i, // port b address input | ||
| input logic [DATA_W-1:0] port_b_wdata_i, // port b write data | ||
| input logic port_b_we_i, // port b write enable input, 1 = write, 0 = read | ||
| input logic [(DATA_W/8)-1:0] port_b_be_i, // port b byte write enable input, corresponds to which bytes in mem to be overwritten | ||
| output logic [DATA_W-1:0] port_b_rdata_o // read data output | ||
| ); | ||
|
|
||
| // Shared memory array | ||
| logic [DATA_W-1:0] mem_a [0:(1<<ADDR_W)-1]; | ||
|
|
||
| // Port A - write block | ||
| always_ff @(posedge clk_i) begin | ||
| if (port_a_we_i) begin | ||
| for (int i = 0; i < DATA_W/8; i = i + 1) begin | ||
| if (port_a_be_i[i]) begin | ||
| mem_a[port_a_addr_i][8*i +: 8] <= port_a_wdata_i[8*i +: 8]; | ||
| end | ||
| end | ||
| end | ||
| // Port A - read block | ||
| port_a_rdata_o <= mem_a[port_a_addr_i]; | ||
| end | ||
|
|
||
|
|
||
| // Shared memory array | ||
| logic [DATA_W-1:0] mem_b [0:(1<<ADDR_W)-1]; | ||
|
|
||
| // Port B - write block | ||
| always_ff @(posedge clk_i) begin | ||
| if (port_b_we_i) begin | ||
| for (int i = 0; i < DATA_W/8; i = i + 1) begin | ||
| if (port_b_be_i[i]) begin | ||
| mem_b[port_b_addr_i][8*i +: 8] <= port_b_wdata_i[8*i +: 8]; | ||
| end | ||
| end | ||
| end | ||
| // Port B - read block | ||
| port_b_rdata_o <= mem_b[port_b_addr_i]; | ||
| end | ||
|
|
||
| endmodule |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add full module definitions for these instances to ensure dma_controller works as expected.