forked from tzzcl/lab06
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoadProcess.v
35 lines (33 loc) · 913 Bytes
/
LoadProcess.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module LoadProcess (
input RegWr,
input [31:0] Din,
input [1:0] LoadType, LoadByte,
output reg [31:0] Dout,
output reg [3:0] Rd_byte_w_en
);
always @ (*)
begin
case(LoadType)
2'b10: begin Dout = Din; Rd_byte_w_en = 4'b1111; end
2'b01:
begin
case(LoadByte)
2'b00: begin Dout = Din; Rd_byte_w_en = 4'b1111; end
2'b01: begin Dout = Din << 8; Rd_byte_w_en = 4'b1110; end
2'b10: begin Dout = Din << 16; Rd_byte_w_en = 4'b1100; end
2'b11: begin Dout = Din << 24; Rd_byte_w_en = 4'b1000; end
endcase
end
2'b11:
begin
case(LoadByte)
2'b00: begin Dout = Din >> 24; Rd_byte_w_en = 4'b0001; end
2'b01: begin Dout = Din >> 16; Rd_byte_w_en = 4'b0011; end
2'b10: begin Dout = Din >> 8; Rd_byte_w_en = 4'b0111; end
2'b11: begin Dout = Din; Rd_byte_w_en = 4'b1111; end
endcase
end
default: begin Dout = Din; Rd_byte_w_en = {4{RegWr}}; end
endcase
end
endmodule