1 `include "ARM_Constants.v"
8 output reg [31:0] busaddr,
12 output reg [31:0] wr_data,
15 /* regfile interface */
16 output reg [3:0] st_read,
27 input [3:0] write_num,
28 input [31:0] write_data,
33 output reg [31:0] outpc,
34 output reg [31:0] outinsn,
35 output reg out_write_reg = 1'b0,
36 output reg [3:0] out_write_num = 4'bxxxx,
37 output reg [31:0] out_write_data = 32'hxxxxxxxx
40 reg [31:0] addr, raddr, next_regdata;
41 reg [3:0] next_regsel, cur_reg, prev_reg;
42 reg next_writeback, next_notdone, next_inc_next;
43 reg [31:0] align_s1, align_s2, align_rddata;
47 wire [3:0] next_write_num;
48 wire [31:0] next_write_data;
50 reg [15:0] regs, next_regs;
51 reg started = 1'b0, next_started;
60 outbubble <= next_outbubble;
61 out_write_reg <= next_write_reg;
62 out_write_num <= next_write_num;
63 out_write_data <= next_write_data;
64 notdone <= next_notdone;
65 inc_next <= next_inc_next;
68 started <= next_started;
77 wr_data = 32'hxxxxxxxx;
78 busaddr = 32'hxxxxxxxx;
81 next_write_reg = write_reg;
82 next_write_num = write_num;
83 next_write_data = write_data;
85 next_outbubble = inbubble;
88 next_started = started;
91 `DECODE_LDRSTR_UNDEFINED: begin end
94 next_outbubble = rw_wait;
95 outstall = rw_wait | notdone;
97 addr = insn[23] ? op0 + op1 : op0 - op1; /* up/down select */
98 raddr = insn[24] ? op0 : addr; /* pre/post increment */
99 busaddr = {raddr[31:2], 2'b0};
103 /* rotate to correct position */
104 align_s1 = raddr[1] ? {rd_data[15:0], rd_data[31:16]} : rd_data;
105 align_s2 = raddr[0] ? {align_s1[7:0], align_s1[31:8]} : align_s1;
106 /* select byte or word */
107 align_rddata = insn[22] ? {24'b0, align_s2[7:0]} : align_s2;
110 wr_data = insn[22] ? {4{op2[7:0]}} : op2; /* XXX need to actually store just a byte */
112 else if(!inc_next) begin
113 next_write_reg = 1'b1;
114 next_write_num = insn[15:12];
115 next_write_data = align_rddata;
116 next_inc_next = 1'b1;
118 else if(insn[21]) begin
119 next_write_reg = 1'b1;
120 next_write_num = insn[19:16];
121 next_write_data = addr;
123 next_notdone = rw_wait & insn[20] & insn[21];
126 `DECODE_LDMSTM: begin
130 next_regs = op1[15:0];
133 else if(inc_next) begin
135 next_write_reg = 1'b1;
136 next_write_num = insn[19:16];
137 next_write_data = op0;
141 else if(rw_wait) begin
147 16'b???????????????1: begin
149 next_regs = regs & 16'b1111111111111110;
151 16'b??????????????10: begin
153 next_regs = regs & 16'b1111111111111100;
155 16'b?????????????100: begin
157 next_regs = regs & 16'b1111111111111000;
159 16'b????????????1000: begin
161 next_regs = regs & 16'b1111111111110000;
163 16'b???????????10000: begin
165 next_regs = regs & 16'b1111111111100000;
167 16'b??????????100000: begin
169 next_regs = regs & 16'b1111111111000000;
171 16'b?????????1000000: begin
173 next_regs = regs & 16'b1111111110000000;
175 16'b????????10000000: begin
177 next_regs = regs & 16'b1111111100000000;
179 16'b???????100000000: begin
181 next_regs = regs & 16'b1111111000000000;
183 16'b??????1000000000: begin
185 next_regs = regs & 16'b1111110000000000;
187 16'b?????10000000000: begin
189 next_regs = regs & 16'b1111100000000000;
191 16'b????100000000000: begin
193 next_regs = regs & 16'b1111000000000000;
195 16'b???1000000000000: begin
197 next_regs = regs & 16'b1110000000000000;
199 16'b??10000000000000: begin
201 next_regs = regs & 16'b1100000000000000;
203 16'b?100000000000000: begin
205 next_regs = regs & 16'b1000000000000000;
207 16'b1000000000000000: begin
216 next_inc_next = next_regs == 16'b0;
217 next_notdone = ~next_inc_next | (rw_wait & insn[20] & insn[21]);