This repository has been archived by the owner on Feb 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
top.v
92 lines (82 loc) · 1.5 KB
/
top.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
module top (input clk48,
output rgb_led0_r,
output rgb_led0_g,
output rgb_led0_b,
output rst_n,
input usr_btn
);
reg [31:0] led_reg = 0;
assign rgb_led0_r = ~led_reg[20];
assign rgb_led0_g = ~led_reg[21];
assign rgb_led0_b = ~led_reg[22];
reg rst = 1;
reg btn = 0;
reg btn_n = 1;
always @(posedge clk48) begin
btn <= usr_btn;
end
always @(posedge clk48) begin
btn_n <= ~btn;
rst <= btn_n;
if (rst) begin
led_reg <= 0;
end else if (mem_d_rstrb) begin
led_reg <= led_reg + 1;
end
end
wire [31:0] rst_vector = 0;
wire [31:0] mem_i_addr;
wire mem_i_rstrb;
wire [31:0] mem_i_rdata;
wire mem_i_rbusy;
reg [31:0] mem_i_wdata;
reg [3:0] mem_i_wmask;
reg mem_i_wstrb;
wire mem_i_wbusy;
initial begin
mem_i_wdata <= 0;
mem_i_wmask <= 0;
mem_i_wstrb <= 0;
end
wire [31:0] mem_d_addr;
wire [31:0] mem_d_wdata;
wire [3:0] mem_d_wmask;
wire mem_d_wstrb;
wire mem_d_rstrb;
wire [31:0] mem_d_rdata;
wire mem_d_rbusy;
wire mem_d_wbusy;
rv32i cpu(rst, clk48,
mem_i_addr,
mem_i_rstrb,
mem_i_rdata,
mem_i_rbusy,
mem_d_addr,
mem_d_wdata,
mem_d_wmask,
mem_d_wstrb,
mem_d_rstrb,
mem_d_rdata,
mem_d_rbusy,
mem_d_wbusy,
rst_vector
);
ram rom(rst, clk48,
mem_i_addr,
mem_i_wmask,
mem_i_rstrb,
mem_i_wstrb,
mem_i_rdata,
mem_i_wdata,
mem_i_rbusy,
mem_i_wbusy);
ram ram(rst, clk48,
mem_d_addr,
mem_d_wmask,
mem_d_rstrb,
mem_d_wstrb,
mem_d_rdata,
mem_d_wdata,
mem_d_rbusy,
mem_d_wbusy);
endmodule