* 0x00004000. rdata and ready must be driven to zero if the
* address is not within the range of this module.
*/
- wire decode = (addr & ~32'h00003FFF) == 32'h00004000;
- wire [13:2] ramaddr = addr & 14'h3FFC; /* mask off lower two bits
- * for word alignment */
+ wire decode = (bus_addr & ~32'h00003FFF) == 32'h00000000;
+ /* verilator lint_off WIDTH */
+ wire [13:2] ramaddr = bus_addr & 32'h3FFC; /* mask off lower two bits
+ * for word alignment */
+ /* verilator lint_on WIDTH */
reg [31:0] data [0:(16384 / 4 - 1)];
--- /dev/null
+module BusArbiter(
+ input [7:0] bus_req,
+ output reg [7:0] bus_ack);
+
+ always @(*)
+ casez (bus_req)
+ 8'b00000000: bus_ack = 8'b00000000;
+ 8'b???????1: bus_ack = 8'b00000001;
+ 8'b??????10: bus_ack = 8'b00000010;
+ 8'b?????100: bus_ack = 8'b00000100;
+ 8'b????1000: bus_ack = 8'b00001000;
+ 8'b???10000: bus_ack = 8'b00010000;
+ 8'b??100000: bus_ack = 8'b00100000;
+ 8'b?1000000: bus_ack = 8'b01000000;
+ 8'b10000000: bus_ack = 8'b10000000;
+ endcase
+endmodule
input stall,
input jmp,
- input [31:0] jmppc;
+ input [31:0] jmppc,
output wire bubble,
output wire [31:0] insn,
output reg [31:0] pc);
reg [31:0] prevpc;
initial
- prevpc <= 32'h0;
+ prevpc = 32'hFFFFFFFC; /* ugh... the first pc we request will be this +4 */
always @(negedge Nrst)
- prevpc <= 32'h0;
+ prevpc <= 32'hFFFFFFFC;
always @(*)
if (!Nrst)
- pc <= 32'h0;
+ pc = 32'hFFFFFFFC;
else if (stall) /* don't change any internal state */
- pc <= prevpc;
+ pc = prevpc;
else if (jmp)
- pc <= jmppc;
+ pc = jmppc;
else
- pc <= prevpc + 32'h4;
+ pc = prevpc + 32'h4;
assign bubble = stall | rd_wait;
assign rd_addr = pc;
assign insn = rd_data;
always @(posedge clk)
- prevpc <= pc;
+ if (!rd_wait || !Nrst)
+ prevpc <= pc;
endmodule
end
reg [3:0] cache_fill_pos = 0;
+ assign bus_req = rd_req && !cache_hit; /* xxx, needed for Verilator */
always @(*)
- if (rd_req && !cache_hit) begin
- bus_req = 1;
- if (bus_ack) begin
- bus_addr = {rd_addr[31:6], cache_fill_pos[3:0], 2'b00 /* reads are 32-bits */};
- bus_rd = 1;
- end
+ if (rd_req && !cache_hit && bus_ack) begin
+ bus_addr = {rd_addr[31:6], cache_fill_pos[3:0], 2'b00 /* reads are 32-bits */};
+ bus_rd = 1;
end else begin
- bus_req = 0;
bus_addr = 0;
bus_rd = 0;
end
always @(posedge clk)
if (rd_req && !cache_hit) begin
if (bus_ready) begin /* Started the fill, and we have data. */
- cache_data[rd_idx][cache_fill_pos] = bus_data;
+ cache_data[rd_idx][cache_fill_pos] <= bus_rdata;
cache_fill_pos <= cache_fill_pos + 1;
if (cache_fill_pos == 15) begin /* Done? */
- cache_tags[rd_idx] = rd_tag;
- cache_valid[rd_idx] = 1;
+ cache_tags[rd_idx] <= rd_tag;
+ cache_valid[rd_idx] <= 1;
end
end
end
+++ /dev/null
-module BusArbiter(
- input [7:0] bus_req,
- output reg [7:0] bus_ack);
-
- always @(*)
- casex (bus_req)
- 8'b00000000: bus_ack <= 8'b00000000;
- 8'bxxxxxxx1: bus_ack <= 8'b00000001;
- 8'bxxxxxx10: bus_ack <= 8'b00000010;
- 8'bxxxxx100: bus_ack <= 8'b00000100;
- 8'bxxxx1000: bus_ack <= 8'b00001000;
- 8'bxxx10000: bus_ack <= 8'b00010000;
- 8'bxx100000: bus_ack <= 8'b00100000;
- 8'bx1000000: bus_ack <= 8'b01000000;
- 8'b10000000: bus_ack <= 8'b10000000;
- endcase
-endmodule
wire [31:0] bus_wdata;
wire bus_rd, bus_wr;
wire bus_ready;
-
- wire bus_req_icache = bus_req[`BUS_ICACHE];
+
+ wire bus_req_icache;
+ assign bus_req = {7'b0, bus_req_icache};
wire bus_ack_icache = bus_ack[`BUS_ICACHE];
+
wire [31:0] bus_addr_icache;
wire [31:0] bus_wdata_icache;
wire bus_rd_icache;
.bus_addr(bus_addr_icache), .bus_rdata(bus_rdata),
.bus_wdata(bus_wdata_icache), .bus_rd(bus_rd_icache),
.bus_wr(bus_wr_icache), .bus_ready(bus_ready));
-
+
BlockRAM blockram(
.clk(clk),
.bus_addr(bus_addr), .bus_rdata(bus_rdata_blockram),