2023-12-03 19:24:12 +00:00
|
|
|
/* Wishbone_driver.v - Implements a classic wishbone master that maps directly in memory space
|
|
|
|
|
|
|
|
This file is part of the 9086 project.
|
|
|
|
|
|
|
|
Copyright (c) 2023 Efthymios Kritikos
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
module Wishbone_memory_driver (
|
|
|
|
input wire clock,
|
|
|
|
input wire reset_n,
|
|
|
|
|
|
|
|
input wire [19:0] address,
|
|
|
|
input wire [15:0] data_bus_in,
|
|
|
|
output reg [15:0] data_bus_out,
|
2023-12-05 02:49:28 +00:00
|
|
|
output wire wait_state,
|
2023-12-03 19:24:12 +00:00
|
|
|
input read_n,
|
|
|
|
input write_n,
|
|
|
|
input chip_select_n,
|
2023-12-05 02:49:28 +00:00
|
|
|
input BHE,
|
2023-12-03 19:24:12 +00:00
|
|
|
|
|
|
|
input wire wb_mem_ack,
|
|
|
|
output wire [24:0] wb_mem_adr,
|
2023-12-05 02:49:28 +00:00
|
|
|
output reg wb_mem_cyc,
|
2023-12-03 19:24:12 +00:00
|
|
|
/* verilator lint_off UNUSEDSIGNAL */
|
|
|
|
// I don't yet use the upper word
|
|
|
|
input wire [31:0] wb_mem_data_r,
|
|
|
|
/* verilator lint_on UNUSEDSIGNAL */
|
|
|
|
output wire [31:0] wb_mem_data_w,
|
|
|
|
input wire wb_mem_err,
|
|
|
|
output wire [3:0] wb_mem_sel,
|
2023-12-05 02:49:28 +00:00
|
|
|
output reg wb_mem_stb,
|
2023-12-03 19:24:12 +00:00
|
|
|
output wire wb_mem_we
|
|
|
|
);
|
|
|
|
|
2023-12-05 02:49:28 +00:00
|
|
|
assign wb_mem_adr={6'd0,address[19:1]};
|
|
|
|
assign wb_mem_sel={2'b11,!BHE,!address[0]};
|
2023-12-03 19:24:12 +00:00
|
|
|
|
2023-12-05 02:49:28 +00:00
|
|
|
always @(posedge clock)begin
|
|
|
|
wb_mem_cyc<=( (!read_n||!write_n)^(wb_mem_ack) )&(!chip_select_n);
|
|
|
|
wb_mem_stb<=( (!read_n||!write_n)^(wb_mem_ack) )&(!chip_select_n);
|
2023-12-03 19:24:12 +00:00
|
|
|
end
|
|
|
|
|
2023-12-05 02:49:28 +00:00
|
|
|
always @(posedge wb_mem_ack)begin
|
|
|
|
data_bus_out=wb_mem_data_r[15:0];
|
2023-12-03 19:24:12 +00:00
|
|
|
end
|
2023-12-05 02:49:28 +00:00
|
|
|
assign wb_mem_data_w={16'd0,data_bus_in};
|
|
|
|
|
|
|
|
assign wait_state=( (!read_n||!write_n)^(wb_mem_ack) )&(!chip_select_n);
|
|
|
|
|
|
|
|
assign wb_mem_we=read_n;
|
2023-12-03 19:24:12 +00:00
|
|
|
|
|
|
|
endmodule
|