Skip to content
This repository was archived by the owner on Sep 4, 2023. It is now read-only.

Commit d9fa26b

Browse files
committed
Update sys.
1 parent 36e6911 commit d9fa26b

13 files changed

+556
-781
lines changed

Genesis.qpf

+1-30
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,2 @@
1-
# -------------------------------------------------------------------------- #
2-
#
3-
# Copyright (C) 2017 Intel Corporation. All rights reserved.
4-
# Your use of Intel Corporation's design tools, logic functions
5-
# and other software and tools, and its AMPP partner logic
6-
# functions, and any output files from any of the foregoing
7-
# (including device programming or simulation files), and any
8-
# associated documentation or information are expressly subject
9-
# to the terms and conditions of the Intel Program License
10-
# Subscription Agreement, the Intel Quartus Prime License Agreement,
11-
# the Intel MegaCore Function License Agreement, or other
12-
# applicable license agreement, including, without limitation,
13-
# that your use is for the sole purpose of programming logic
14-
# devices manufactured by Intel and sold by Intel or its
15-
# authorized distributors. Please refer to the applicable
16-
# agreement for further details.
17-
#
18-
# -------------------------------------------------------------------------- #
19-
#
20-
# Quartus Prime
21-
# Version 16.1.2 Build 203 01/18/2017 SJ Standard Edition
22-
# Date created = 22:22:04 June 17, 2017
23-
#
24-
# -------------------------------------------------------------------------- #
25-
26-
QUARTUS_VERSION = "16.1"
27-
DATE = "22:22:04 June 17, 2017"
28-
29-
# Revisions
30-
1+
QUARTUS_VERSION = "17.0"
312
PROJECT_REVISION = "Genesis"

Genesis.qsf

+26-351
Large diffs are not rendered by default.

Genesis.sv

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//============================================================================
22
// FPGAGen port to MiSTer
3-
// Copyright (c) 2017,2018 Sorgelig
3+
// Copyright (c) 2017-2019 Sorgelig
44
//
55
// YM2612 implementation by Jose Tejada Gomez. Twitter: @topapate
66
// Original Genesis code: Copyright (c) 2010-2013 Gregory Estrade ([email protected])
@@ -64,7 +64,9 @@ module emu
6464
output [15:0] AUDIO_R,
6565
output AUDIO_S, // 1 - signed audio samples, 0 - unsigned
6666
output [1:0] AUDIO_MIX, // 0 - no mix, 1 - 25%, 2 - 50%, 3 - 100% (mono)
67-
input TAPE_IN,
67+
68+
//ADC
69+
inout [3:0] ADC_BUS,
6870

6971
// SD-SPI
7072
output SD_SCK,
@@ -117,6 +119,7 @@ module emu
117119
input OSD_STATUS
118120
);
119121

122+
assign ADC_BUS = 'Z;
120123
assign USER_OUT = '1;
121124
assign {UART_RTS, UART_TXD, UART_DTR} = 0;
122125
assign {SD_SCK, SD_MOSI, SD_CS} = 'Z;

Genesis_Q13.qpf

-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
1-
#
2-
# please keep this file read-only!
3-
# Quartus changes this file everytime revision is switched,
4-
# and it will be marked as changed with every commit.
5-
#
6-
71
QUARTUS_VERSION = "13.1"
8-
DATE = "23:13:02 April 27, 2017"
9-
10-
# Revisions
11-
122
PROJECT_REVISION = "Genesis_Q13"

Genesis_Q13.qsf

+16-352
Large diffs are not rendered by default.

files.qip

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
set_global_assignment -name QIP_FILE FX68K/fx68k.qip
2+
set_global_assignment -name QIP_FILE T80/T80.qip
3+
set_global_assignment -name QIP_FILE jt12/jt12.qip
4+
set_global_assignment -name QIP_FILE jt89/jt89.qip
5+
set_global_assignment -name SYSTEMVERILOG_FILE cheatcodes.sv
6+
set_global_assignment -name SYSTEMVERILOG_FILE EEPROM_STM95.sv
7+
set_global_assignment -name VHDL_FILE bram.vhd
8+
set_global_assignment -name SYSTEMVERILOG_FILE ddram.sv
9+
set_global_assignment -name VERILOG_FILE audio_iir_filter.v
10+
set_global_assignment -name VERILOG_FILE genesis_lpf.v
11+
set_global_assignment -name VHDL_FILE vdp_common.vhd
12+
set_global_assignment -name VHDL_FILE vdp.vhd
13+
set_global_assignment -name VERILOG_FILE gen_io.v
14+
set_global_assignment -name SYSTEMVERILOG_FILE teamplayer.sv
15+
set_global_assignment -name VERILOG_FILE fourway.v
16+
set_global_assignment -name SYSTEMVERILOG_FILE multitap.sv
17+
set_global_assignment -name SYSTEMVERILOG_FILE system.sv
18+
set_global_assignment -name SYSTEMVERILOG_FILE Genesis.sv

sys/ltc2308.sv

+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
//============================================================================
2+
//
3+
// LTC2308 controller
4+
// Copyright (C) 2019 Sorgelig
5+
//
6+
//
7+
// This program is free software; you can redistribute it and/or modify it
8+
// under the terms of the GNU General Public License as published by the Free
9+
// Software Foundation; either version 2 of the License, or (at your option)
10+
// any later version.
11+
//
12+
// This program is distributed in the hope that it will be useful, but WITHOUT
13+
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14+
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15+
// more details.
16+
//
17+
// You should have received a copy of the GNU General Public License along
18+
// with this program; if not, write to the Free Software Foundation, Inc.,
19+
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20+
//
21+
//============================================================================
22+
23+
24+
// NUM_CH 1..8
25+
// Sampling rate = ADC_RATE/NUM_CH
26+
// ADC_RATE max is ~500KHz
27+
// CLK_RATE max is ~80MHz
28+
module ltc2308 #(parameter NUM_CH = 2, ADC_RATE = 96000, CLK_RATE = 50000000)
29+
(
30+
input reset,
31+
input clk,
32+
33+
inout [3:0] ADC_BUS,
34+
35+
output reg dout_sync, // toggle with every ADC round
36+
output reg [(NUM_CH*12)-1:0] dout // 12 bits per channel (unsigned)
37+
);
38+
39+
localparam TCONV = CLK_RATE/625000;
40+
41+
reg sck;
42+
wire sdo = cfg[5];
43+
44+
assign ADC_BUS[3] = sck;
45+
wire sdi = ADC_BUS[2];
46+
assign ADC_BUS[1] = sdo;
47+
assign ADC_BUS[0] = convst;
48+
49+
reg convst;
50+
reg [5:0] cfg;
51+
52+
reg [31:0] sum;
53+
wire [31:0] next_sum = sum + ADC_RATE;
54+
55+
reg [2:0] pin;
56+
wire [2:0] next_pin = (pin == (NUM_CH-1)) ? 3'd0 : (pin + 1'd1);
57+
58+
always @(posedge clk) begin
59+
reg [7:0] tconv;
60+
reg [3:0] bitcnt;
61+
reg [10:0] adcin;
62+
63+
convst <= 0;
64+
65+
if(reset) begin
66+
sum <= 0;
67+
tconv <= 0;
68+
bitcnt <= 0;
69+
sck <= 0;
70+
cfg <= 0;
71+
dout <= 0;
72+
pin <= NUM_CH[2:0]-1'd1;
73+
end
74+
else begin
75+
sum <= next_sum;
76+
if(next_sum >= CLK_RATE) begin
77+
sum <= next_sum - CLK_RATE;
78+
tconv <= TCONV[7:0];
79+
convst <= 1;
80+
bitcnt <= 12;
81+
cfg <= {1'b1, next_pin[0], next_pin[2:1], 1'b1, 1'b0};
82+
if(!next_pin) dout_sync <= ~dout_sync;
83+
end
84+
85+
if(tconv) tconv <= tconv - 1'd1;
86+
else if(bitcnt) begin
87+
sck <= ~sck;
88+
89+
if(sck) cfg <= cfg<<1;
90+
else begin
91+
adcin <= {adcin[9:0],sdi};
92+
bitcnt <= bitcnt - 1'd1;
93+
if(bitcnt == 1) begin
94+
dout[pin*12 +:12] <= {adcin,sdi};
95+
pin <= next_pin;
96+
end
97+
end
98+
end
99+
else sck <= 0;
100+
end
101+
end
102+
103+
endmodule
104+
105+
module ltc2308_tape #(parameter HIST_LOW = 16, HIST_HIGH = 64, ADC_RATE = 48000, CLK_RATE = 50000000)
106+
(
107+
input reset,
108+
input clk,
109+
110+
inout [3:0] ADC_BUS,
111+
output reg dout,
112+
output active
113+
);
114+
115+
wire [11:0] adc_data;
116+
wire adc_sync;
117+
ltc2308 #(1, ADC_RATE, CLK_RATE) adc
118+
(
119+
.reset(reset),
120+
.clk(clk),
121+
122+
.ADC_BUS(ADC_BUS),
123+
.dout(adc_data),
124+
.dout_sync(adc_sync)
125+
);
126+
127+
always @(posedge clk) begin
128+
reg [13:0] data1,data2,data3,data4, sum;
129+
reg adc_sync_d;
130+
131+
adc_sync_d<=adc_sync;
132+
if(adc_sync_d ^ adc_sync) begin
133+
data1 <= data2;
134+
data2 <= data3;
135+
data3 <= data4;
136+
data4 <= adc_data;
137+
138+
sum <= data1+data2+data3+data4;
139+
140+
if(sum[13:2]<HIST_LOW) dout <= 0;
141+
if(sum[13:2]>HIST_HIGH) dout <= 1;
142+
end
143+
end
144+
145+
assign active = |act;
146+
147+
reg [1:0] act;
148+
always @(posedge clk) begin
149+
reg [31:0] onesec;
150+
reg old_dout;
151+
152+
onesec <= onesec + 1;
153+
if(onesec>CLK_RATE) begin
154+
onesec <= 0;
155+
if(act) act <= act - 1'd1;
156+
end
157+
158+
old_dout <= dout;
159+
if(old_dout ^ dout) act <= 2;
160+
end
161+
162+
endmodule

sys/pll_q13.qip

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) pll.v ]
2+
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) pll/pll_0002.v ]
3+
set_global_assignment -name QIP_FILE [file join $::quartus(qip_path) pll/pll_0002.qip ]
4+
set_global_assignment -name QIP_FILE [file join $::quartus(qip_path) pll_hdmi_q13.qip ]
5+
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) pll_hdmi_cfg.v ]
6+
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) pll_hdmi_cfg/altera_pll_reconfig_core.v ]
7+
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) pll_hdmi_cfg/altera_pll_reconfig_top.v ]

sys/pll_q17.qip

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
set_global_assignment -name QIP_FILE [file join $::quartus(qip_path) pll.qip ]
2+
set_global_assignment -name QIP_FILE [file join $::quartus(qip_path) pll_hdmi.qip ]
3+
set_global_assignment -name QIP_FILE [file join $::quartus(qip_path) pll_hdmi_cfg.qip ]

sys/sys.qip

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1+
set_global_assignment -name QIP_FILE [join [list $::quartus(qip_path) pll_q [regexp -inline {[0-9]+} $quartus(version)] .qip] {}]
12
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) sys_top.v ]
23
set_global_assignment -name SDC_FILE [file join $::quartus(qip_path) sys_top.sdc ]
3-
set_global_assignment -name QIP_FILE [file join $::quartus(qip_path) pll.qip ]
4-
set_global_assignment -name QIP_FILE [file join $::quartus(qip_path) pll_hdmi.qip ]
5-
set_global_assignment -name QIP_FILE [file join $::quartus(qip_path) pll_hdmi_cfg.qip ]
64
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) ascal.vhd ]
75
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) pll_hdmi_adj.vhd ]
86
set_global_assignment -name SYSTEMVERILOG_FILE [file join $::quartus(qip_path) hq2x.sv ]
@@ -17,10 +15,9 @@ set_global_assignment -name SYSTEMVERILOG_FILE [file join $::quartus(qip_path) a
1715
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) i2s.v ]
1816
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) spdif.v ]
1917
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) audio_out.v ]
18+
set_global_assignment -name SYSTEMVERILOG_FILE [file join $::quartus(qip_path) ltc2308.sv ]
2019
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) sigma_delta_dac.v ]
2120
set_global_assignment -name SYSTEMVERILOG_FILE [file join $::quartus(qip_path) hdmi_config.sv ]
2221
set_global_assignment -name SYSTEMVERILOG_FILE [file join $::quartus(qip_path) sysmem.sv ]
2322
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) sd_card.v ]
2423
set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) hps_io.v ]
25-
set_instance_assignment -name HPS_LOCATION HPSINTERFACEPERIPHERALSPIMASTER_X52_Y72_N111 -entity sys_top -to spi
26-
set_instance_assignment -name HPS_LOCATION HPSINTERFACEPERIPHERALUART_X52_Y67_N111 -entity sys_top -to uart

0 commit comments

Comments
 (0)