-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapb_decoder.v
More file actions
33 lines (28 loc) · 960 Bytes
/
apb_decoder.v
File metadata and controls
33 lines (28 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// APB Decoder Module
// Decodes address and generates PSEL for each slave
module apb_decoder #(
parameter ADDR_WIDTH = 32,
parameter NUM_SLAVES = 4
)(
input wire [ADDR_WIDTH-1:0] PADDR,
input wire PSEL, // Master PSEL
output reg [NUM_SLAVES-1:0] slave_sel // One-hot slave select
);
// Address ranges for each slave (can be parameterized)
// Slave 0: 0x0000_0000 - 0x0000_0FFF
// Slave 1: 0x0000_1000 - 0x0000_1FFF
// Slave 2: 0x0000_2000 - 0x0000_2FFF
// Slave 3: 0x0000_3000 - 0x0000_3FFF
always @(*) begin
slave_sel = 0;
if (PSEL) begin
case (PADDR[15:12])
4'h0: slave_sel[0] = 1'b1;
4'h1: slave_sel[1] = 1'b1;
4'h2: slave_sel[2] = 1'b1;
4'h3: slave_sel[3] = 1'b1;
default: slave_sel = 0; // No slave selected
endcase
end
end
endmodule