-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmstatus_reg.v
35 lines (32 loc) · 908 Bytes
/
mstatus_reg.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 mstatus_reg( input clk_in,rst_in,wr_en_in,data_wr_3_in,data_wr_7_in,mie_clear_in,mie_set_in,
input [11:0] csr_addr_in,
output [31:0] mstatus_out,
output reg mie_out
);
parameter MSTATUS = 12'h300;
reg mpie_out;
assign mstatus_out = {19'b0, 2'b11, 3'b0, mpie_out, 3'b0 , mie_out, 3'b0};
always @(posedge clk_in)
begin
if(rst_in)
begin
mie_out <= 1'b0;
mpie_out <= 1'b1;
end
else if(csr_addr_in == MSTATUS && wr_en_in)
begin
mie_out <= data_wr_3_in;
mpie_out <= data_wr_7_in;
end
else if(mie_clear_in == 1'b1)
begin
mpie_out <= mie_out;
mie_out <= 1'b0;
end
else if(mie_set_in == 1'b1)
begin
mie_out <= mpie_out;
mpie_out <= 1'b1;
end
end
endmodule