Skip to content

Commit

Permalink
(fix): Attempted to implement APB Manager (4/19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Auryny268 authored and rishyak committed Apr 23, 2024
1 parent fabbe2d commit b14a50a
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
67 changes: 67 additions & 0 deletions rtl/apb/devices/APBManager.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Used GenericBusManager.sv as template for outline

/**
@brief Manager that uses the GenericBus protocol directly as the transmission
protocol
@input device managing device
@input bus bus to managed
*/

module APBManager (
APBCommon_if bus,
APBCommon_if bridge
);
always_comb begin
bridge.rData = bus.rData;
bridge.subError <= bus.subError;
end

always_ff @(posedge bridge.clk, negedge bridge.nReset) begin
if (!bridge.nReset) begin
bus.write <= 0;
bus.addr <= 0;
bus.wData <= 0;
bus.prot <= 0;
bus.enable <= 0;

/**
- Alert subordinate that we're writing to it
- Set up write and enable
- Check ready signal
**/
end else if (!bus.ready || !bus.enable) begin // wake up bus
bus.sel[bridge.sel] <= 1;
end else if (bus.ready && !bus.enable) begin
bus.enable <= 1;
bus.write <= bridge.write;
bus.addr <= bridge.addr;
bus.prot <= bridge.prot;
bus.wData <= bridge.wData;
end else if (bus.subError) begin
bus.enable = 0;
end
end
endmodule

/**
APB Interface Signals
NEED TO GIVE DIRECTION -> Logic just says we care about variable
input [AddrWidth-1:0] addr; // Address bus
input [3:0] prot; // protected piece of mail
output [PrphNum-1:0] selectors; // sending a bit on the selector on bus where peripherals live;
think as array of subordinates live (bit will let subordinate to get ready) -> Read APB Spec for more detail
// To know where each subordinate lives, address is sent to decoder &
decoder tells us which subordinate we need to talk to in array
output enable; // Bit that tells us if person is getting multiple "packages"
output write;
inout [DataWidth - 1:0] wData; // 1 of 2 Data Buses
inout(?) [DataWidth/8 - 1:0] strb; // Ignore bc AHB ignores strobe
input ready;
inout [DataWidth - 1:0] rData; // 2 of 2 Data buses
input subError;
My APB will support up to 8 subordinates
**/
12 changes: 12 additions & 0 deletions rtl/apb/interfaces/APBCommon_if.sv
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ interface APBCommon_if #(
output write,
output wData
);

modport manager(
input addr,
input prot,
output selectors,
output enable,
inout wData,
inout strb,
input ready,
inout rData,
input subError
);

endinterface

Expand Down

0 comments on commit b14a50a

Please sign in to comment.