Fetch: qjmp is for queueing up jumps while rd_waiting, not while stalled.
[firearm.git] / BlockRAM.v
CommitLineData
2f8f0594
JW
1module BlockRAM(
2 input clk,
3 input [31:0] bus_addr,
4 output wire [31:0] bus_rdata,
5 input [31:0] bus_wdata,
6 input bus_rd,
7 input bus_wr,
8 output wire bus_ready
9 );
10
11 /* This module is mapped in physical memory from 0x00000000 to
12 * 0x00004000. rdata and ready must be driven to zero if the
13 * address is not within the range of this module.
14 */
f7c52af4 15 wire decode = bus_addr[31:14] == 18'b0;
666ceb03 16 wire [13:0] ramaddr = {bus_addr[13:2], 2'b0}; /* mask off lower two bits
45fa96c0 17 * for word alignment */
666ceb03 18
90ff449a 19 reg [31:0] data [(16384 / 4 - 1):0];
2f8f0594 20
90ff449a 21 reg [31:0] temprdata = 0;
eacc5bf1 22 reg [13:0] lastread = 14'h3FFF;
2f8f0594
JW
23 assign bus_rdata = (bus_rd && decode) ? temprdata : 32'h0;
24
25 assign bus_ready = decode &&
26 (bus_wr || (bus_rd && (lastread == ramaddr)));
27
90ff449a
JW
28 initial
29 $readmemh("ram.hex", data);
30
2f8f0594
JW
31 always @(posedge clk)
32 begin
33 if (bus_wr && decode)
eacc5bf1 34 data[ramaddr[13:2]] <= bus_wdata;
2f8f0594
JW
35
36 /* This is not allowed to be conditional -- stupid Xilinx
37 * blockram. */
eacc5bf1 38 temprdata <= data[ramaddr[13:2]];
2f8f0594
JW
39 lastread <= ramaddr;
40 end
41endmodule
This page took 0.027844 seconds and 4 git commands to generate.