OpenCores
URL https://opencores.org/ocsvn/6809_6309_compatible_core/6809_6309_compatible_core/trunk

Subversion Repositories 6809_6309_compatible_core

[/] [6809_6309_compatible_core/] [trunk/] [syn/] [lattice/] [CC3_top.v] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ale500
/*
2
 * Synthesis top Module for the MC6809/HD6309 compatible core.
3
 * This top module has been tested in the MachXO2-7000HE breakout board
4
 * (c) 2013 R.A. Paz Schmidt rapazschmidt@gmail.com
5
 * Distributed under the terms of the Lesser GPL
6
 *
7
 * Implemented using diamond 2.1
8
 */
9
 
10
module CC3_top(
11
        input wire clk40_i,
12
        /* CPU Bus */
13
        output wire cpuclk_o,
14
        output wire reset_o,
15 10 ale500
        output wire [18:0] addr_o,
16 2 ale500
        output wire oen_o,
17
        output wire wen_o,
18
        output wire cen_o,
19 10 ale500
        inout wire [15:0] data_io,
20 2 ale500
        output wire [5:0] state_o,
21
        /* Debug */
22
        output wire [7:0] leds_o,
23
        /* VGA output */
24
        output wire hsync_o,
25
        output wire vsync_o,
26
        output wire red_o,
27
        output wire green_o,
28 10 ale500
        output wire blue_o,
29
        /* logic analyzer probe */
30
        output wire [5:0] laddr_o,
31
        output wire loen_o,
32
        output wire lwen_o,
33
        output wire lcen_o,
34
        output wire [7:0] ldata_io
35 2 ale500
 
36
        );
37
 
38
reg cpu_clk, clk_div2;
39
reg [3:0] reset_cnt;
40
reg [7:0] leds_r;
41
 
42
/* CPU IO */
43
wire [15:0] cpu0_addr_o, cpu1_addr_o;
44
wire [7:0] cpu0_data_in, cpu0_data_out, cpu1_data_in, cpu1_data_out;
45
wire cpu0_we, cpu0_oe, cpu1_we, cpu1_oe, cpu_reset;
46
wire [5:0] cpu0_state;
47 10 ale500
/* Memory */
48
wire bios_en, video_en, extram_en;
49
wire [7:0] data_from_bios, data_from_video;
50
 
51
assign bios_en = cpu0_addr_o[15:12] == 4'hf;
52
assign video_en = cpu0_addr_o[15:12] == 4'he;
53
assign extram_en = !(bios_en | video_en);
54
 
55
assign cpu0_data_in = bios_en ? data_from_bios:
56
                     video_en ? data_from_video:data_io[7:0];
57
 
58
wire debug_data;
59
 
60 2 ale500
/* Module io */
61
 
62 10 ale500
assign addr_o = { 3'b000, cpu0_addr_o };
63
assign data_io = { 8'hzz, cpu0_we ? cpu0_data_out:8'hzz };
64
 
65 2 ale500
assign leds_o = leds_r;
66
 
67
assign oen_o = !cpu0_oe;
68 10 ale500
assign wen_o = !cpu0_we;
69
assign cen_o = !extram_en;// !(extram_en & (cpu0_oe | cpu0_we));
70 2 ale500
assign cpuclk_o = cpu_clk;
71
assign reset_o = cpu_reset;
72 10 ale500
assign state_o = /*{ bios_en, video_en, extram_en };*/cpu0_state;
73
/* logic analyzer probe */
74
assign laddr_o = cpu0_addr_o[5:0]; //debug_data[15:9];
75
assign ldata_io = data_io[7:0];//cpu0_we ? cpu0_data_out:cpu0_data_in;//debug_data[7:0];
76
assign loen_o = !cpu0_oe;
77
assign lwen_o = !cpu0_we;
78
assign lcen_o = ! (extram_en & (cpu0_oe | cpu0_we));
79 2 ale500
 
80 10 ale500
`ifdef SERIAL_DEBUG
81
reg [7:0] div;
82
 
83 2 ale500
always @(posedge clk40_i)
84 10 ale500
        begin
85
                if (!cpu_reset)
86
                        begin
87
                                if (div == 65)
88
                                        div <= 0;
89
                                else
90
                                        div <= div + 1;
91
                        end
92
        end
93 2 ale500
 
94 10 ale500
always @(posedge clk40_i)
95
        if (div < 8'h2)
96
                cpu_clk <= 1'b1;
97
        else
98
                cpu_clk <= 1'b0;
99
`else
100
 
101
reg div;
102
 
103
always @(posedge clk40_i)
104
        div <= ~div;
105
 
106
always @(posedge div)
107
        cpu_clk <= ~cpu_clk;
108
 
109
`endif
110 2 ale500
assign cpu_reset = reset_cnt != 4'd14;
111
 
112 10 ale500
always @(posedge clk40_i)
113 2 ale500
        begin
114
                if (reset_cnt != 4'd14)
115
                        reset_cnt <= reset_cnt + 4'h1;
116
                if (cpu0_we)
117 10 ale500
                        leds_r <= cpu0_data_out[7:0];
118 2 ale500
        end
119
 
120
 
121
MC6809_cpu cpu0(
122
        .cpu_clk(cpu_clk),
123
        .cpu_reset(cpu_reset),
124
        .cpu_nmi_n(1'b0),
125
        .cpu_irq_n(1'b0),
126
        .cpu_firq_n(1'b0),
127
        .cpu_state_o(cpu0_state),
128
        .cpu_we_o(cpu0_we),
129
        .cpu_oe_o(cpu0_oe),
130
        .cpu_addr_o(cpu0_addr_o),
131
        .cpu_data_i(cpu0_data_in),
132 10 ale500
        .cpu_data_o(cpu0_data_out),
133
        .debug_clk(clk40_i),
134
        .debug_data_o(debug_data)
135 2 ale500
        );
136
 
137
/* Memory */
138
 
139 7 ale500
 
140
 
141 2 ale500
bios2k bios(
142
        .DataInA(cpu0_data_out[7:0]),
143
        .DataInB(cpu1_data_out[7:0]),
144
        .AddressA(cpu0_addr_o[10:0]),
145
        .AddressB(cpu1_addr_o[10:0]),
146
        .ClockA(clk40_i),
147
        .ClockB(clk40_i),
148 7 ale500
    .ClockEnA((cpu0_oe | cpu_we) & bios_en),
149 2 ale500
        .ClockEnB(1'b0),
150 7 ale500
        .WrA(cpu0_we & bios_en),
151 2 ale500
        .WrB(1'b0),//cpu1_we), 
152
        .ResetA(1'b0),
153
        .ResetB(1'b0),
154 7 ale500
        .QA(data_from_bios),
155 2 ale500
        .QB()
156
        );
157
 
158 13 ale500
/* 80x38 VGA Controller, using 40 MHz clock, 800x600@60 Hz timing */
159 7 ale500
vgatext textctrl(
160
        .CLK(clk40_i),
161
        .RESET(cpu_reset),
162
        .HSYNC(hsync_o),
163
        .VSYNC(vsync_o),
164
        .RED(red_o),
165
        .GREEN(green_o),
166
        .BLUE(blue_o),
167
        .CPU_CLK(clk40_i),
168
        .CPU_ADDR(cpu0_addr_o[11:0]),
169
        .CPU_OE_EN(cpu0_oe & video_en),
170
        .CPU_WR_EN(cpu0_we & video_en),
171
        .CPU_DATA_O(cpu0_data_out),
172
        .CPU_DATA_I(data_from_video)
173
        );
174 2 ale500
 
175
 
176
 
177
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.