-
Notifications
You must be signed in to change notification settings - Fork 6
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
design: working on memory sub #24
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,71 @@ | |
@note See https://github.com/NYU-Processor-Design/nyu-mem | ||
*/ | ||
|
||
module SubMemCtrl( | ||
AHBCommon_if.subordinate sub, | ||
MemCommon_if.memCtrl mem | ||
/** | ||
@brief Subordinate to interface witht he memory controller | ||
|
||
@note See https://github.com/NYU-Processor-Design/nyu-mem | ||
*/ | ||
|
||
module SubMemCtrl #( | ||
parameter ADDR_WIDTH = 32, // Address width | ||
parameter DATA_WIDTH = 32 // Data width | ||
)( | ||
input wire HCLK, // clock | ||
input wire HRESETn, // reset | ||
input wire [ADDR_WIDTH-1:0] HADDR, // address | ||
input wire HWRITE, // write | ||
input wire [1:0] HTRANS, // transfer | ||
input wire [2:0] HSIZE, // tranfer size | ||
input wire [DATA_WIDTH-1:0] HWDATA, // write data | ||
output wire [DATA_WIDTH-1:0] HRDATA, // read data | ||
output wire HREADY, // transfer ready | ||
output wire [1:0] HRESP, // transfer response | ||
// Memory Controller Interface | ||
output wire [ADDR_WIDTH-1:0] MemAddr, // Memory address | ||
output wire MemWrite, // Memory write enable | ||
output wire [DATA_WIDTH-1:0] MemWData, // Memory write data | ||
input wire [DATA_WIDTH-1:0] MemRData, // Memory read data | ||
output wire MemReq, // Memory request signal | ||
input wire MemReady // Memory ready signal | ||
); | ||
// General subordinate logic follows | ||
|
||
reg [DATA_WIDTH-1:0] internalRData; | ||
reg internalReady; | ||
reg [1:0] internalResp; | ||
Comment on lines
+36
to
+38
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. I don't understand why these should be "internal" to the controller subordinate. |
||
|
||
assign HRDATA = internalRData; | ||
assign HREADY = internalReady; | ||
assign HRESP = internalResp; | ||
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. Response statuses are in an enum ( |
||
|
||
assign MemAddr = HADDR; | ||
assign MemWrite = HWRITE && (HTRANS[1] && HREADY); // init write | ||
assign MemWData = HWDATA; | ||
assign MemReq = HTRANS[1] && HREADY; // Transfer request signal | ||
|
||
// AHB to Memory Controller Interface Logic | ||
always @(posedge HCLK or negedge HRESETn) begin | ||
if (!HRESETn) begin | ||
internalRData <= 0; | ||
internalReady <= 0; | ||
internalResp <= 2'b00; // OKAY | ||
end else begin | ||
internalReady <= MemReady; | ||
if (MemReady) begin | ||
if (HWRITE) begin | ||
// handle write | ||
internalResp <= 2'b00; // OKAY | ||
end else begin | ||
// handle read | ||
internalRData <= MemRData; | ||
internalResp <= 2'b00; // OKAY | ||
end | ||
end else begin | ||
internalResp <= 2'b01; // WAIT state | ||
end | ||
end | ||
end | ||
|
||
endmodule | ||
|
||
|
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.
All of this has been defined in the two interfaces,
AHBCommon_if
andMemCommon_if
. You can seeSubDummy.sv
to review usage.We want them in an interface so other teams know how to interface with our code. For example, the memory team can use
MemCommon_if
as a blueprint to make their modules.To get started, define your module as follows