]> Joshua Wise's Git repositories - firearm.git/blame - Fetch.v
Memory: Add work-around for Xilinx bug in MULT.
[firearm.git] / Fetch.v
CommitLineData
bd073175
JW
1module Fetch(
2 input clk,
3 input Nrst,
4
5 output wire [31:0] rd_addr,
6 output wire rd_req,
7 input rd_wait,
8 input [31:0] rd_data,
9
10 input stall,
11 input jmp,
45fa96c0 12 input [31:0] jmppc,
90ff449a
JW
13 output reg bubble = 1,
14 output reg [31:0] insn = 0,
6318a7e8
JW
15 output reg [31:0] pc = 32'hFFFFFFFC);
16
ac3ae95a 17 reg qjmp = 0; /* A jump has been queued up while we were waiting. */
6318a7e8 18 reg [31:0] qjmppc;
d43b0ab9
JW
19 always @(posedge clk or negedge Nrst)
20 if (!Nrst)
21 qjmp <= 0;
22 else if ((rd_wait || stall) && jmp)
6318a7e8 23 {qjmp,qjmppc} <= {jmp, jmppc};
ae185fc4 24 else if (!rd_wait && !stall && qjmp) /* It has already been intoed. */
6318a7e8
JW
25 {qjmp,qjmppc} <= {1'b0, 32'hxxxxxxxx};
26
27 reg [31:0] reqpc;
6318a7e8 28
523d1613 29 /* Output latch logic */
6318a7e8
JW
30 assign rd_addr = reqpc;
31 assign rd_req = 1;
d43b0ab9 32 always @(posedge clk or negedge Nrst)
6318a7e8 33 if (!Nrst) begin
6318a7e8 34 bubble <= 1;
523d1613
JW
35 insn <= 0;
36 pc <= 32'h00000000;
37 end else if (!stall) begin
38 bubble <= (jmp || qjmp || rd_wait);
90ff449a 39 insn <= rd_data;
523d1613
JW
40 pc <= reqpc;
41 end
42
43 always @(posedge clk or negedge Nrst)
44 if (!Nrst)
45 reqpc <= 0;
46 else if (!stall && !rd_wait) begin
47 if (qjmp)
48 reqpc <= qjmppc;
49 else if (jmp)
50 reqpc <= jmppc;
51 else
52 reqpc <= reqpc + 4;
90ff449a 53 end
bd073175 54endmodule
This page took 0.0744 seconds and 4 git commands to generate.