AMBA
AMBA
APB:
State diagram:
The state diagram, shown can be used to represent the activity of the
peripheral bus.
Operation of the state machine is through the three states described
below:
IDLE The default state for the peripheral bus.
SETUP When a transfer is required the bus moves into the SETUP
where the appropriate select signal, PSELx, is asserted. The
only remains in the SETUP state for one clock cycle and will
always move to the ENABLE state on the next rising edge of
ENABL In the ENABLE state the enable signal, PENABLE is
E The address, write and select signals all remain stable during
transition from the SETUP to ENABLE state.
The ENABLE state also only lasts for a single clock cycle and
after this state the bus will return to the IDLE state if no
transfers are required. Alternatively, if another transfer is to
follow then the bus will move directly to the SETUP state.
It is acceptable for the address, write and select signals to
during a transition from the ENABLE to SETUP states.
Verilog code :
Verilog code :
module apb_slave
#(
addrWidth = 8,
dataWidth = 32
)
(
input clk,
input rst_n,
input [addrWidth-1:0] paddr,
input pwrite,
input psel,
input penable,
input [dataWidth-1:0] pwdata,
output logic [dataWidth-1:0] prdata
);
else begin
apb_st <= R_ENABLE;
end
end
end
W_ENABLE : begin
// write pwdata to memory
if (psel && penable && pwrite) begin
mem[paddr] <= pwdata;
end
// return to SETUP
apb_st <= SETUP;
end
R_ENABLE : begin
// read prdata from memory
if (psel && penable && !pwrite) begin
prdata <= mem[paddr];
end
// return to SETUP
apb_st <= SETUP;
end
endcase
end
end
Endmodule
EMACS editor:
EMACS editor:
Emacs the extensible, customizable, self-documenting real-time display
editor