-
Notifications
You must be signed in to change notification settings - Fork 0
/
mem_sdram_interface.v
67 lines (53 loc) · 1.27 KB
/
mem_sdram_interface.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
`timescale 1ns / 1ps
// control register
module mem_sdram_interface (
// inputs:
clk,
reset_n,
writedata,
read,
write,
byteenable,
chipselect,
address,
mem_rst,
// outputs:
readdata,
mem_splat,
cc);
output [ 31: 0] readdata;
output mem_splat;
input mem_rst;
input [ 31: 0] writedata;
input [31:0] cc;
input [3:0] byteenable;
input clk, reset_n, read, write, chipselect, address;
wire [ 31: 0] readdata;
reg state_splat = 0;
reg [31:0] regcc = 0;
reg wd;
assign mem_splat = state_splat;
wire wr_strobe;
assign wr_strobe = chipselect && write;
wire rst = ~reset_n || mem_rst;
always @(posedge mem_rst) begin
regcc <= cc;
end
always @(posedge clk or posedge rst) begin
if (rst == 1) begin
state_splat = 0;
wd = 0;
end
else if (clk) begin
if (wr_strobe) begin
state_splat <= writedata ? 1 : 0;
wd <= writedata[0];
end
end
end
assign readdata[31] = reset_n;
assign readdata[30] = mem_rst;
assign readdata[29] = state_splat;
assign readdata[28:1] = regcc[31:4];
assign readdata[0] = wd;
endmodule