-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_cpu_basys3.v
More file actions
54 lines (40 loc) · 826 Bytes
/
simple_cpu_basys3.v
File metadata and controls
54 lines (40 loc) · 826 Bytes
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
`timescale 1ns / 1ps
module simple_cpu_basys3 (
input clk,
input [15:0] sw,
input btnC,
input btnU,
input btnL,
input btnR,
input btnD,
output [15:0] led,
output [6:0] seg,
output [3:0] an
);
wire rst = btnR;
reg [27:0] clk_divider;
always @(posedge clk or posedge rst) begin
if (rst)
clk_divider <= {64{1'b0}};
else
clk_divider <= clk_divider + 1;
end
wire cpu_clk = sw[15] ? clk_divider[27] : clk ;
assign led[15] = cpu_clk;
assign led[14:8] = 7'd0;
wire [7:0] program_counter;
simple_cpu cpu
(.clk(cpu_clk),
.rst(rst),
.io_in(sw[7:0]),
.io_out(led[7:0]),
.program_counter(program_counter)
);
hex_driver hex
(.clk (clk),
.rst (rst),
.data_in ({8'h00, program_counter}),
.seg (seg),
.an (an)
);
endmodule