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, prev_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;
52 reg [5:0] offset, prev_offset, offset_sel;
61 outbubble <= next_outbubble;
62 out_write_reg <= next_write_reg;
63 out_write_num <= next_write_num;
64 out_write_data <= next_write_data;
65 notdone <= next_notdone;
66 inc_next <= next_inc_next;
69 started <= next_started;
70 prev_offset <= offset;
80 wr_data = 32'hxxxxxxxx;
81 busaddr = 32'hxxxxxxxx;
84 next_write_reg = write_reg;
85 next_write_num = write_num;
86 next_write_data = write_data;
88 next_outbubble = inbubble;
91 next_started = started;
95 `DECODE_LDRSTR_UNDEFINED: begin end
98 next_outbubble = rw_wait;
99 outstall = rw_wait | notdone;
101 addr = insn[23] ? op0 + op1 : op0 - op1; /* up/down select */
102 raddr = insn[24] ? op0 : addr; /* pre/post increment */
103 busaddr = {raddr[31:2], 2'b0};
107 /* rotate to correct position */
108 align_s1 = raddr[1] ? {rd_data[15:0], rd_data[31:16]} : rd_data;
109 align_s2 = raddr[0] ? {align_s1[7:0], align_s1[31:8]} : align_s1;
110 /* select byte or word */
111 align_rddata = insn[22] ? {24'b0, align_s2[7:0]} : align_s2;
114 wr_data = insn[22] ? {4{op2[7:0]}} : op2; /* XXX need to actually store just a byte */
116 else if(!inc_next) begin
117 next_write_reg = 1'b1;
118 next_write_num = insn[15:12];
119 next_write_data = align_rddata;
120 next_inc_next = 1'b1;
122 else if(insn[21]) begin
123 next_write_reg = 1'b1;
124 next_write_num = insn[19:16];
125 next_write_data = addr;
127 next_notdone = rw_wait & insn[20] & insn[21];
130 `DECODE_LDMSTM: begin
134 // next_regs = insn[23] ? op1[15:0] : op1[0:15];
135 /** verilator can suck my dick */
136 next_regs = insn[23] ? op1[15:0] : {op1[0], op1[1], op1[2], op1[3], op1[4], op1[5], op1[6], op1[7],
137 op1[8], op1[9], op1[10], op1[11], op1[12], op1[13], op1[14], op1[15]};
141 else if(inc_next) begin
143 next_write_reg = 1'b1;
144 next_write_num = insn[19:16];
145 next_write_data = insn[23] ? op0 + {26'b0, prev_offset} : op0 - {26'b0, prev_offset};
149 else if(rw_wait) begin
156 16'b???????????????1: begin
158 next_regs = {regs[15:1], 1'b0};
160 16'b??????????????10: begin
162 next_regs = {regs[15:2], 2'b0};
164 16'b?????????????100: begin
166 next_regs = {regs[15:3], 3'b0};
168 16'b????????????1000: begin
170 next_regs = {regs[15:4], 4'b0};
172 16'b???????????10000: begin
174 next_regs = {regs[15:5], 5'b0};
176 16'b??????????100000: begin
178 next_regs = {regs[15:6], 6'b0};
180 16'b?????????1000000: begin
182 next_regs = {regs[15:7], 7'b0};
184 16'b????????10000000: begin
186 next_regs = {regs[15:8], 8'b0};
188 16'b???????100000000: begin
190 next_regs = {regs[15:9], 9'b0};
192 16'b??????1000000000: begin
194 next_regs = {regs[15:10], 10'b0};
196 16'b?????10000000000: begin
198 next_regs = {regs[15:11], 11'b0};
200 16'b????100000000000: begin
202 next_regs = {regs[15:12], 12'b0};
204 16'b???1000000000000: begin
206 next_regs = {regs[15:13], 13'b0};
208 16'b??10000000000000: begin
210 next_regs = {regs[15:14], 14'b0};
212 16'b?100000000000000: begin
214 next_regs = {regs[15], 15'b0};
216 16'b1000000000000000: begin
225 cur_reg = insn[23] ? 4'hF - cur_reg : cur_reg;
226 offset = prev_offset + 6'h4;
227 offset_sel = insn[24] ? offset : prev_offset;
228 raddr = insn[23] ? op0 + {26'b0, offset_sel} : op0 - {26'b0, offset_sel};
231 next_write_reg = 1'b1;
232 next_write_num = cur_reg;
233 next_write_data = rd_data;
239 next_inc_next = next_regs == 16'b0;
240 next_notdone = ~next_inc_next | (rw_wait & insn[20] & insn[21]);
241 busaddr = {raddr[31:2], 2'b0};