2021-08-15 21:49:02 +02:00
|
|
|
interface if_cpu_bus #(
|
|
|
|
parameter NUM_DEVICES = 1
|
|
|
|
) (
|
|
|
|
input clk,
|
|
|
|
input reset
|
|
|
|
);
|
2021-08-05 19:50:29 +02:00
|
|
|
|
2021-08-15 21:49:02 +02:00
|
|
|
logic request;
|
|
|
|
logic ack;
|
|
|
|
logic [3:0] wmask;
|
2021-08-05 19:50:29 +02:00
|
|
|
logic [31:0] address;
|
|
|
|
logic [31:0] wdata;
|
|
|
|
logic [31:0] rdata;
|
|
|
|
|
2021-08-15 21:49:02 +02:00
|
|
|
logic device_ack [(NUM_DEVICES - 1):0];
|
|
|
|
logic [31:0] device_rdata [(NUM_DEVICES - 1):0];
|
2021-08-12 21:07:47 +02:00
|
|
|
|
2021-08-15 21:49:02 +02:00
|
|
|
always_comb begin
|
|
|
|
ack = 1'b0;
|
|
|
|
rdata = 32'd0;
|
2021-08-12 21:07:47 +02:00
|
|
|
|
2021-08-15 21:49:02 +02:00
|
|
|
for (integer i = 0; i < NUM_DEVICES; i++) begin
|
|
|
|
ack = ack | device_ack[i];
|
|
|
|
rdata = rdata | device_rdata[i];
|
2021-08-12 21:07:47 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-08-15 21:49:02 +02:00
|
|
|
modport cpu (
|
|
|
|
input clk,
|
|
|
|
input reset,
|
|
|
|
output request,
|
|
|
|
input ack,
|
|
|
|
output wmask,
|
|
|
|
output address,
|
|
|
|
output wdata,
|
|
|
|
input rdata
|
|
|
|
);
|
|
|
|
|
|
|
|
genvar n;
|
|
|
|
generate
|
|
|
|
for (n = 0; n < NUM_DEVICES; n++) begin : at
|
|
|
|
wire device_request = request && address[31:28] == n[3:0];
|
|
|
|
|
|
|
|
modport device (
|
|
|
|
input .clk(clk),
|
|
|
|
input .reset(reset),
|
|
|
|
input .request(device_request),
|
|
|
|
output .ack(device_ack[n]),
|
|
|
|
input .wmask(wmask),
|
|
|
|
input .address(address),
|
|
|
|
input .wdata(wdata),
|
|
|
|
output .rdata(device_rdata[n])
|
|
|
|
);
|
|
|
|
end
|
|
|
|
endgenerate
|
|
|
|
|
|
|
|
endinterface
|