-
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
9
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
9 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 48f3ac9
Create bootrom.md
AirPodsRed b41da4a
Create DMA_controller.md
AirPodsRed 0d86f4b
Create SRAM_dualport.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # GamingCPU — DMA Controller | ||
|
|
||
| **Owner:** Evan Eichholz | **RTL Target:** rtl/dma/dma_controller.sv | **Version:** v0. | ||
|
|
||
| ## Purpose & Role | ||
|
|
||
| High-performance Direct Memory Access controller for autonomous data transfers between | ||
| memory and peripherals. Offloads bulk data movement from CPU, enabling concurrent | ||
| computation during video/audio/storage operations. | ||
|
|
||
| ## Design Specifications | ||
|
|
||
| **AXI4 Master** - Full bus master for memory access **Multi-Channel** - 4 independent channels | ||
| with priority arbitration | ||
| **Scatter-Gather** - Linked list descriptor support **Burst Optimization** - Maximum bus | ||
| efficiency **Interrupt Driven** - Completion/error signaling | ||
|
|
||
| ## Implementation Tasks | ||
|
|
||
| ``` | ||
| Task Decision Deliverable | ||
| ``` | ||
| ``` | ||
| Channel Arbitration Fixed priority Bandwidth allocation | ||
| ``` | ||
| ``` | ||
| Descriptor Fetch Hardware managed Automatic chain loading | ||
| ``` | ||
| ``` | ||
| Burst Control Adaptive sizing Optimal bus utilization | ||
| ``` | ||
| ``` | ||
| Error Handling Abort + interrupt Transfer recovery | ||
| ``` | ||
| ``` | ||
| Register Interface AXI-Lite Control/status access | ||
| ``` | ||
| ## Channel Configuration | ||
|
|
||
| ``` | ||
| Channel Priority Use Case Burst Size | ||
| ``` | ||
| ``` | ||
| 0 Highest Video Frame Buffer 16 beats | ||
| ``` | ||
| ``` | ||
| 1 High Audio Sample Stream 8 beats | ||
| ``` | ||
| ``` | ||
| 2 Medium SD Card Storage 4 beats | ||
| ``` | ||
| ``` | ||
| 3 Low General Purpose Configurable | ||
| ``` | ||
| # INTERFACE DEFINITION | ||
|
|
||
| **Module:** dma_controller **Parameters:** CHANNELS = 4, DATA_W = 32 | ||
|
|
||
| **Ports:** | ||
|
|
||
| ``` | ||
| clk_i, rst_ni - Clock and active-low reset | ||
| m_axi_awaddr[31:0] - AXI write address | ||
| m_axi_awlen[7:0] - AXI write burst length | ||
| m_axi_awvalid - AXI write address valid | ||
| ``` | ||
|
|
||
| m_axi_awready - AXI write address ready | ||
| m_axi_araddr[31:0] - AXI read address | ||
| m_axi_arlen[7:0] - AXI read burst length | ||
| m_axi_arvalid - AXI read address valid | ||
| m_axi_arready - AXI read address ready | ||
| s_axi_araddr[31:0] - Control read address | ||
| s_axi_arvalid - Control read valid | ||
| s_axi_arready - Control read ready | ||
| s_axi_awaddr[31:0] - Control write address | ||
| s_axi_awvalid - Control write valid | ||
| s_axi_awready - Control write ready | ||
| irq_done_o[CHANNELS-1:0] - Transfer complete interrupts | ||
| irq_error_o[CHANNELS-1:0] - Error interrupts |
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,70 @@ | ||
| # GamingCPU — SRAM Dualport | ||
|
|
||
| **Owner:** Evan Eichholz **RTL Target:** rtl/mem/sram_dualport.sv | ||
| **Version:** v0. | ||
|
|
||
| ## Purpose & Role | ||
|
|
||
| GamingCPU will implement true dual-port SRAM macro using FPGA block RAM (BRAM) | ||
| primitives. This block will serve as the fundamental building block for all shared, | ||
| concurrent-access memory structures in the SoC by creating a reliable, area-efficient | ||
| memory block that two independent clients can use simultaneously | ||
|
|
||
| ## Design | ||
|
|
||
| **True Dual-Port** - Both ports operate simultaneously, no arbitration | ||
| **FPGA BRAM Mapping** - Use dedicated memory blocks, not flip-flops | ||
| **Byte-Level Writes** - Modify individual bytes without read-modify-write penalty | ||
| **Timing Closure** - Add output registers for better timing | ||
|
|
||
| ## Implementation Tools | ||
|
|
||
| Creating a resource, area-efficient memory block that two independent clients can use | ||
| simultaneously | ||
|
|
||
| ## Design Specifications | ||
|
|
||
| **True Dual-Port** - Both ports operate simultaneously, no arbitration | ||
| **FPGA BRAM Mapping** - Use dedicated memory blocks, not flip-flops | ||
| **Byte-Level Writes** - Modify individual bytes without read-modify-write penalty | ||
| **Timing Closure** - Add output registers for better timing | ||
|
|
||
| # Implementation Tasks | ||
|
|
||
| | **BRAM Instantiation** | Inference vs Direct | Vendor-agnostic RTL | **Port Wiring** | | ||
| Independent access | No coordination logic | **Byte Enables** | Native BRAM support | Per- | ||
| byte write capability | **Output Registers** | OUT_REG=0 vs 1 | Timing vs latency | ||
| trade-off | **Collision Handling** | Read-old-data vs read-new-data | Documented behavior | ||
|
|
||
| # Integration | ||
|
|
||
| | **RAM Handler** | Bus interface wrapper | AXI/TL-UL conversion | **Video Pipeline** | Line | ||
| buffers, framebuffers | Direct memory access | **Audio System** | Sample buffers | | ||
| Streaming data | **CPU/Coprocessors** | Shared data structures | Concurrent access | ||
|
|
||
| # Interface | ||
|
|
||
| ``` | ||
| 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, | ||
| input logic [DATA_W-1:0] port_a_wdata_i, | ||
| input logic port_a_we_i, | ||
| input logic [(DATA_W/8)-1:0] port_a_be_i, | ||
| output logic [DATA_W-1:0] port_a_rdata_o, | ||
| // Port B | ||
| input logic [ADDR_W-1:0] port_b_addr_i, | ||
| input logic [DATA_W-1:0] port_b_wdata_i, | ||
| input logic port_b_we_i, | ||
| input logic [(DATA_W/8)-1:0] port_b_be_i, | ||
| output logic [DATA_W-1:0] port_b_rdata_o | ||
| ); | ||
| ``` |
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,41 @@ | ||
| # GamingCPU — Boot ROM | ||
|
|
||
| ``` | ||
| Owner: [Evan Eichholz] | RTL Target: rtl/mem/boot_rom.sv | Version: v0. | ||
| ``` | ||
| ## Purpose & Role | ||
|
|
||
| ``` | ||
| Initial boot code storage and CPU initialization. Contains the first instructions executed by | ||
| the processor after reset, handling early system setup, peripheral initialization, and FSBL | ||
| (First Stage Boot Loader) loading from storage. | ||
| ``` | ||
| ## Design Specifications | ||
|
|
||
| ``` | ||
| Read-Only Memory - Pre-programmed content, no write capability | ||
| Fixed Address Range - 4KB memory space at hardware-defined base address | ||
| Minimal Latency - Single-cycle read access for immediate execution | ||
| Synchronous Interface - Clocked read operations only | ||
| ``` | ||
| ## Implementation Tasks | ||
|
|
||
| ``` | ||
| Task Decision Deliverable | ||
| Memory Initialization $readmemh from hex file Pre-programmed boot code | ||
| Interface Design Simple read-only port Clean CPU interface | ||
| Address Decoding Full 4KB range No external decoding needed | ||
| Timing Optimization Combinational read Zero-wait-state access | ||
| ``` | ||
| ## INTERFACE DEFINITION | ||
|
|
||
|
|
||
|
|
||
| ``` | ||
| module boot_rom #( parameter int ADDR_W = 12, // 4KB address space | ||
| parameter int DATA_W = 32 // 32-bit instruction width | ||
| )( | ||
| 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 | ||
| ); |
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 | ||
Oops, something went wrong.
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.