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;
42 reg next_writeback, next_notdone, next_inc_next;
43 reg [31:0] align_s1, align_s2, align_rddata;
46 wire [3:0] next_write_num;
47 wire [31:0] next_write_data;
49 reg [15:0] regs, next_regs;
59 out_write_reg <= next_writeback;
60 out_write_num <= next_regsel;
61 out_write_data <= next_regdata;
62 notdone <= next_notdone;
63 inc_next <= next_inc_next;
73 wr_data = 32'hxxxxxxxx;
74 busaddr = 32'hxxxxxxxx;
77 next_write_reg = write_reg;
78 next_write_num = write_num;
79 next_write_data = write_data;
85 `DECODE_LDRSTR_UNDEFINED: begin end
88 outstall = rw_wait | notdone;
90 addr = insn[23] ? op0 + op1 : op0 - op1; /* up/down select */
91 raddr = insn[24] ? op0 : addr; /* pre/post increment */
92 busaddr = {raddr[31:2], 2'b0};
96 /* rotate to correct position */
97 align_s1 = raddr[1] ? {rd_data[15:0], rd_data[31:16]} : rd_data;
98 align_s2 = raddr[0] ? {align_s1[7:0], align_s1[31:8]} : align_s1;
99 /* select byte or word */
100 align_rddata = insn[22] ? {24'b0, align_s2[7:0]} : align_s2;
103 wr_data = insn[22] ? {4{op2[7:0]}} : op2; /* XXX need to actually store just a byte */
105 else if(!inc_next) begin
106 next_write_reg = 1'b1;
107 next_write_num = insn[15:12];
108 next_write_data = align_rddata;
109 next_inc_next = 1'b1;
111 else if(insn[21]) begin
112 next_write_reg = 1'b1;
113 next_write_num = insn[19:16];
114 next_write_data = addr;
116 next_notdone = rw_wait & insn[20] & insn[21];
119 `DECODE_LDMSTM: begin
120 busaddr = {op0[31:2], 2'b0};
129 16'b???????????????1: begin
130 next_regs = regs & 16'b1111111111111110;
132 16'b??????????????10: begin
133 next_regs = regs & 16'b1111111111111100;
135 16'b?????????????100: begin
136 next_regs = regs & 16'b1111111111111000;
138 16'b????????????1000: begin
139 next_regs = regs & 16'b1111111111110000;
141 16'b???????????10000: begin
142 next_regs = regs & 16'b1111111111100000;
144 16'b??????????100000: begin
145 next_regs = regs & 16'b1111111111000000;
147 16'b?????????1000000: begin
148 next_regs = regs & 16'b1111111110000000;
150 16'b????????10000000: begin
151 next_regs = regs & 16'b1111111100000000;
153 16'b???????100000000: begin
154 next_regs = regs & 16'b1111111000000000;
156 16'b??????1000000000: begin
157 next_regs = regs & 16'b1111110000000000;
159 16'b?????10000000000: begin
160 next_regs = regs & 16'b1111100000000000;
162 16'b????100000000000: begin
163 next_regs = regs & 16'b1111000000000000;
165 16'b???1000000000000: begin
166 next_regs = regs & 16'b1110000000000000;
168 16'b??10000000000000: begin
169 next_regs = regs & 16'b1100000000000000;
171 16'b?100000000000000: begin
172 next_regs = regs & 16'b1000000000000000;
174 16'b1000000000000000: begin
180 next_inc_next = next_regs == 16'b0;
181 next_notdone = ~next_inc_next;