SummerCart64/fw/rtl/cpu/cpu_wrapper.sv

51 lines
1.2 KiB
Systemverilog
Raw Normal View History

2021-08-20 19:51:55 +02:00
module cpu_wrapper (
if_system.sys sys,
2021-08-15 21:49:02 +02:00
if_cpu_bus.cpu bus
);
2021-08-20 19:51:55 +02:00
typedef enum bit [0:0] {
S_IDLE,
S_WAITING
} e_bus_state;
2021-08-15 21:49:02 +02:00
e_bus_state state;
2021-08-20 19:51:55 +02:00
logic mem_la_read;
logic mem_la_write;
2021-08-15 21:49:02 +02:00
2021-08-20 19:51:55 +02:00
always_ff @(posedge sys.clk) begin
2021-08-15 21:49:02 +02:00
bus.request <= 1'b0;
2021-08-20 19:51:55 +02:00
if (sys.reset) begin
2021-08-15 21:49:02 +02:00
state <= S_IDLE;
end else begin
if (state == S_IDLE && (mem_la_read || mem_la_write)) begin
state <= S_WAITING;
bus.request <= 1'b1;
end
if (state == S_WAITING && bus.ack) begin
state <= S_IDLE;
end
end
end
picorv32 #(
.ENABLE_COUNTERS(0),
.ENABLE_COUNTERS64(0),
.TWO_STAGE_SHIFT(0),
.CATCH_MISALIGN(0),
.CATCH_ILLINSN(0),
2021-08-20 19:51:55 +02:00
.PROGADDR_RESET({4'(sc64::ID_CPU_BOOTLOADER), 28'h000_0000})
2021-08-15 21:49:02 +02:00
) cpu_inst (
2021-08-20 19:51:55 +02:00
.clk(sys.clk),
.resetn(~sys.reset),
2021-08-15 21:49:02 +02:00
.mem_addr(bus.address),
.mem_wdata(bus.wdata),
.mem_wstrb(bus.wmask),
.mem_ready(bus.ack),
.mem_rdata(bus.rdata),
.mem_la_read(mem_la_read),
.mem_la_write(mem_la_write)
);
endmodule