-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPCM_MM_reg.sv.bak
53 lines (41 loc) · 1.06 KB
/
PCM_MM_reg.sv.bak
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
module PCM_MM_reg(input clk, reset, resolved, cpu_write,
input [19:0] addr,
input [15:0] data_in, cpu_in,
output logic schedule, cpu_ready,
output logic [15:0] cpu_out);
enum logic [1:0] {WAIT, CONFLICT} cur_state, next_state;
logic [19:0] addr_reg;
always_ff @ (posedge Clk or posedge Reset)
begin
if(Reset)
begin
cpu_out <= 16'h0000;
addr_reg <= 16'h0000;
cur_state <= WAIT;
next_state <= WAIT;
end
cur_state <= next_state;
end
always_latch
begin
if(!WAIT)
begin
if(cpu_write)
cpu_out <= cpu_in;
else
cpu_out <= data_in;
end
if(addr_reg != addr)
begin
schedule <= 1'b1;
next_state <= CONFLICT;
end
if(resolved)
begin
next_state <= WAIT;
addr_reg <= addr;
end
if(cur_state == WAIT)
cpu_ready = 1'b1;
end
endmodule