-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomputer_8bit.sv
138 lines (126 loc) · 3.31 KB
/
computer_8bit.sv
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
`timescale 10ns/10ps
module computer_8bit (
input clock_50,
//input [3:0]key,
output logic [17:0]ledr,
output logic [8:0]ledg,
input ps2_dat,
input ps2_clk,
output logic [7:0]vga_b,
output logic vga_blank_n, // to D2A chip, active low
output logic vga_clk, // latch the RGBs and put 'em on the DACs
output logic [7:0]vga_g,
output logic vga_hs, // DB19 pin, active low
output logic [7:0]vga_r,
output logic vga_sync_n, // to D2A chip, active low
output logic vga_vs); // DB19 pin, active low
wire cpu_phi;
wire mem_phi;
wire vid_phi;
reg res;
reg so;
reg rdy;
reg nmi;
reg irq;
reg [7:0]cpu_dbi;
wire [7:0]cpu_dbo;
wire rw;
wire sync;
wire [15:0]cpu_adr;
wire [15:0]vid_adr;
wire [7:0]vid_dbi;
wire [7:0]ram_dbo;
wire [7:0]rom_dbo;
reg [22:0] count;
logic heartbeat;
logic [7:0] kbd;
logic [7:0] kbd_strb;
logic kbd_clr;
clock_divider clock_divider (
.clock_50,
.cpu_phi,
.mem_phi,
.vid_phi);
address_decode address_decode (
.kbd (kbd),
.kbd_strb (kbd_strb),
.kbd_clr (kbd_clr),
.cpu_adr,
.cpu_dbi,
.ram_dbo,
.rom_dbo,
.phi (mem_phi));
mainrom rom (
.addr (cpu_adr),
.clk (mem_phi),
.ce (1'd1),
.q (rom_dbo));
ram #(8,16) ram (
.data_a (cpu_dbo),
.data_b (8'd0),
.addr_a (cpu_adr),
.addr_b (vid_adr),
.we_a (rw),
.we_b (1'd0),
.clk_a (mem_phi),
.clk_b (vid_phi),
.q_a (ram_dbo),
.q_b (vid_dbi));
vdp vdp (
.clock_50 (clock_50),
.clk (vid_phi),
.vga_b (vga_b),
.vga_blank_n (vga_blank_n), // to D2A chip, active low
.vga_clk (vga_clk), // latch the RGBs and put 'em on the DACs
.vga_g (vga_g),
.vga_hs (vga_hs), // DB19 pin, active low
.vga_r (vga_r),
.vga_sync_n (vga_sync_n), // to D2A chip, active low
.vga_vs (vga_vs), // DB19 pin, active low
.txt_adr (vid_adr),
.txt_q (vid_dbi),
.res (res));
ps2ctrlr ps2ctrlr (
.clock (clock_50),
.ps2_dat_in (ps2_dat),
.ps2_clk_in (ps2_clk),
.kbd_clr (kbd_clr),
.res (res),
.kbd (kbd),
.kbd_strb (kbd_strb));
chip_6502 cpu (
.clk (clock_50), // FPGA clock
.phi (cpu_phi), // 6502 clock
.res (res),
.so (so),
.rdy (rdy),
.nmi (nmi),
.irq (irq),
.dbi (cpu_dbi), // cpu data bus in
.dbo (cpu_dbo), // cpu data bus out
.rw (rw),
.sync (sync),
.ab (cpu_adr)); // cpu address bus
// The left-hand side of a continuous assignment must be a structural
// net expression. That is, it must be a net or a concatentation of
// nets, and any index expressions must be constant.
assign ledr[15:0] = cpu_adr;
//assign res = key[0]; //normaly high
assign ledg[7:0] = cpu_dbo;
assign ledg[8] = heartbeat;
// Module Item(s)
always @ (posedge clock_50) begin
if (!res) begin
heartbeat <= 0;
end else begin
so = 1;
rdy = 1;
nmi = 1;
irq = 1;
count++;
if (count == 0) begin
heartbeat <= !heartbeat;
end
end
end //always
endmodule