mirror of
https://github.com/supleed2/ELEC50010-IAC-CW.git
synced 2024-11-10 01:35:49 +00:00
General structure of bus memory
Read and Write logic to be added
This commit is contained in:
parent
4be3149300
commit
f5fea77ea7
|
@ -12,8 +12,8 @@ module mips_cpu_bus_memory( //Avalon memory mapped bus controller (slave)
|
||||||
parameter INSTR_INIT_FILE = "";
|
parameter INSTR_INIT_FILE = "";
|
||||||
parameter DATA_INIT_FILE = "";
|
parameter DATA_INIT_FILE = "";
|
||||||
|
|
||||||
reg [31:0] data_memory [0:63]; // location 0x00001000 onwards
|
logic [31:0] data_memory [0:63]; // location 0x00001000 onwards
|
||||||
reg [31:0] instr_memory [0:63]; // location 0xBFC00000 onwards
|
logic [31:0] instr_memory [0:63]; // location 0xBFC00000 onwards
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
for (integer i=0; i<$size(data_memory); i++) begin //Initialise data to zero by default
|
for (integer i=0; i<$size(data_memory); i++) begin //Initialise data to zero by default
|
||||||
|
@ -45,4 +45,25 @@ initial begin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
always_ff @(posedge read or posedge write) begin
|
||||||
|
waitrequest <= 1;
|
||||||
|
end
|
||||||
|
|
||||||
|
always_ff @(posedge clk) begin
|
||||||
|
if (waitrequest) begin
|
||||||
|
if (read) begin
|
||||||
|
// read code
|
||||||
|
end else if (write) begin
|
||||||
|
// write code
|
||||||
|
end else begin
|
||||||
|
waitrequest = 1'bx;
|
||||||
|
readdata = 32'hxxxxxxxx;
|
||||||
|
end
|
||||||
|
end else begin
|
||||||
|
waitrequest = 1'b0;
|
||||||
|
readdata = 32'h00000000;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
endmodule
|
endmodule
|
Loading…
Reference in a new issue