|
@@ -24,7 +24,7 @@ module mailbox_wb #(
|
|
|
output reg wb_ack,
|
|
|
|
|
|
// Flattened custom hardware side (RTL)
|
|
|
- output wire [16*DW-1:0] registers_flat // Flattened register array (16 registers of 16 bits each)
|
|
|
+ output wire [16*16-1:0] registers_flat // Flattened register array (16 registers of 16 bits each)
|
|
|
);
|
|
|
|
|
|
// Internal registers (16 registers, each 16 bits wide)
|
|
@@ -39,51 +39,57 @@ module mailbox_wb #(
|
|
|
registers_array[i] <= 16'h0; // Reset all registers to 0
|
|
|
end
|
|
|
end else begin
|
|
|
- // Handle Wishbone communication
|
|
|
- wb_ack <= wb_cyc;
|
|
|
+ // Default no ack
|
|
|
+ wb_ack <= 1'b0;
|
|
|
+
|
|
|
+ if (wb_cyc) begin
|
|
|
+ // Write operation (if write enable is active) // wb_stb would
|
|
|
+ // help here
|
|
|
+ if (wb_we) begin
|
|
|
+ case (wb_addr)
|
|
|
+ 4'b0000: registers_array[0] <= wb_wdata[15:0]; // Only use lower 16 bits
|
|
|
+ 4'b0001: registers_array[1] <= wb_wdata[15:0];
|
|
|
+ 4'b0010: registers_array[2] <= wb_wdata[15:0];
|
|
|
+ 4'b0011: registers_array[3] <= wb_wdata[15:0];
|
|
|
+ 4'b0100: registers_array[4] <= wb_wdata[15:0];
|
|
|
+ 4'b0101: registers_array[5] <= wb_wdata[15:0];
|
|
|
+ 4'b0110: registers_array[6] <= wb_wdata[15:0];
|
|
|
+ 4'b0111: registers_array[7] <= wb_wdata[15:0];
|
|
|
+ 4'b1000: registers_array[8] <= wb_wdata[15:0];
|
|
|
+ 4'b1001: registers_array[9] <= wb_wdata[15:0];
|
|
|
+ 4'b1010: registers_array[10] <= wb_wdata[15:0];
|
|
|
+ 4'b1011: registers_array[11] <= wb_wdata[15:0];
|
|
|
+ 4'b1100: registers_array[12] <= wb_wdata[15:0];
|
|
|
+ 4'b1101: registers_array[13] <= wb_wdata[15:0];
|
|
|
+ 4'b1110: registers_array[14] <= wb_wdata[15:0];
|
|
|
+ 4'b1111: registers_array[15] <= wb_wdata[15:0];
|
|
|
+ endcase
|
|
|
+ end
|
|
|
|
|
|
- // Write operation (if write enable is active)
|
|
|
- if (wb_we && wb_cyc) begin
|
|
|
+ // Read operation (read the correct register based on address)
|
|
|
case (wb_addr)
|
|
|
- 4'b0000: registers_array[0] <= wb_wdata[15:0]; // Only use lower 16 bits
|
|
|
- 4'b0001: registers_array[1] <= wb_wdata[15:0];
|
|
|
- 4'b0010: registers_array[2] <= wb_wdata[15:0];
|
|
|
- 4'b0011: registers_array[3] <= wb_wdata[15:0];
|
|
|
- 4'b0100: registers_array[4] <= wb_wdata[15:0];
|
|
|
- 4'b0101: registers_array[5] <= wb_wdata[15:0];
|
|
|
- 4'b0110: registers_array[6] <= wb_wdata[15:0];
|
|
|
- 4'b0111: registers_array[7] <= wb_wdata[15:0];
|
|
|
- 4'b1000: registers_array[8] <= wb_wdata[15:0];
|
|
|
- 4'b1001: registers_array[9] <= wb_wdata[15:0];
|
|
|
- 4'b1010: registers_array[10] <= wb_wdata[15:0];
|
|
|
- 4'b1011: registers_array[11] <= wb_wdata[15:0];
|
|
|
- 4'b1100: registers_array[12] <= wb_wdata[15:0];
|
|
|
- 4'b1101: registers_array[13] <= wb_wdata[15:0];
|
|
|
- 4'b1110: registers_array[14] <= wb_wdata[15:0];
|
|
|
- 4'b1111: registers_array[15] <= wb_wdata[15:0];
|
|
|
+ 4'b0000: wb_rdata <= {16'h0, registers_array[0]}; // Place 16-bit value in lower half of 32-bit bus
|
|
|
+ 4'b0001: wb_rdata <= {16'h0, registers_array[1]};
|
|
|
+ 4'b0010: wb_rdata <= {16'h0, registers_array[2]};
|
|
|
+ 4'b0011: wb_rdata <= {16'h0, registers_array[3]};
|
|
|
+ 4'b0100: wb_rdata <= {16'h0, registers_array[4]};
|
|
|
+ 4'b0101: wb_rdata <= {16'h0, registers_array[5]};
|
|
|
+ 4'b0110: wb_rdata <= {16'h0, registers_array[6]};
|
|
|
+ 4'b0111: wb_rdata <= {16'h0, registers_array[7]};
|
|
|
+ 4'b1000: wb_rdata <= {16'h0, registers_array[8]};
|
|
|
+ 4'b1001: wb_rdata <= {16'h0, registers_array[9]};
|
|
|
+ 4'b1010: wb_rdata <= {16'h0, registers_array[10]};
|
|
|
+ 4'b1011: wb_rdata <= {16'h0, registers_array[11]};
|
|
|
+ 4'b1100: wb_rdata <= {16'h0, registers_array[12]};
|
|
|
+ 4'b1101: wb_rdata <= {16'h0, registers_array[13]};
|
|
|
+ 4'b1110: wb_rdata <= {16'h0, registers_array[14]};
|
|
|
+ 4'b1111: wb_rdata <= {16'h0, registers_array[15]};
|
|
|
+ default: wb_rdata <= 32'hDEAD_BEEF; // Default error value
|
|
|
endcase
|
|
|
- end
|
|
|
|
|
|
- // Read operation (read the correct register based on address)
|
|
|
- case (wb_addr)
|
|
|
- 4'b0000: wb_rdata <= {16'h0, registers_array[0]}; // Place 16-bit value in lower half of 32-bit bus
|
|
|
- 4'b0001: wb_rdata <= {16'h0, registers_array[1]};
|
|
|
- 4'b0010: wb_rdata <= {16'h0, registers_array[2]};
|
|
|
- 4'b0011: wb_rdata <= {16'h0, registers_array[3]};
|
|
|
- 4'b0100: wb_rdata <= {16'h0, registers_array[4]};
|
|
|
- 4'b0101: wb_rdata <= {16'h0, registers_array[5]};
|
|
|
- 4'b0110: wb_rdata <= {16'h0, registers_array[6]};
|
|
|
- 4'b0111: wb_rdata <= {16'h0, registers_array[7]};
|
|
|
- 4'b1000: wb_rdata <= {16'h0, registers_array[8]};
|
|
|
- 4'b1001: wb_rdata <= {16'h0, registers_array[9]};
|
|
|
- 4'b1010: wb_rdata <= {16'h0, registers_array[10]};
|
|
|
- 4'b1011: wb_rdata <= {16'h0, registers_array[11]};
|
|
|
- 4'b1100: wb_rdata <= {16'h0, registers_array[12]};
|
|
|
- 4'b1101: wb_rdata <= {16'h0, registers_array[13]};
|
|
|
- 4'b1110: wb_rdata <= {16'h0, registers_array[14]};
|
|
|
- 4'b1111: wb_rdata <= {16'h0, registers_array[15]};
|
|
|
- default: wb_rdata <= 32'hDEAD_BEEF; // Default error value
|
|
|
- endcase
|
|
|
+ // Acknowledge for exactly 1 cycle
|
|
|
+ wb_ack <= 1'b1;
|
|
|
+ end
|
|
|
end
|
|
|
end
|
|
|
|