diff --git a/.gitignore b/.gitignore
index ecc8043..bf52556 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@ jtag.cdf
greybox_tmp/cbx_args.txt
*/greybox_tmp/cbx_args.txt
changes.txt
+rtl/config_inc.sv
diff --git a/COCO3_Comp.xlsx b/COCO3_Comp.xlsx
index 5e8843b..5c809e2 100644
Binary files a/COCO3_Comp.xlsx and b/COCO3_Comp.xlsx differ
diff --git a/CoCo3.qsf b/CoCo3.qsf
index c29a323..507797f 100644
--- a/CoCo3.qsf
+++ b/CoCo3.qsf
@@ -9,9 +9,9 @@
# --------------------------------------------------------------------------
set_global_assignment -name TOP_LEVEL_ENTITY sys_top
-set_global_assignment -name PARTITION_NETLIST_TYPE SOURCE -section_id Top
-set_global_assignment -name PARTITION_FITTER_PRESERVATION_LEVEL PLACEMENT_AND_ROUTING -section_id Top
-set_global_assignment -name PARTITION_COLOR 16764057 -section_id Top
+#set_global_assignment -name PARTITION_NETLIST_TYPE SOURCE -section_id Top
+#set_global_assignment -name PARTITION_FITTER_PRESERVATION_LEVEL PLACEMENT_AND_ROUTING -section_id Top
+#set_global_assignment -name PARTITION_COLOR 16764057 -section_id Top
set_global_assignment -name LAST_QUARTUS_VERSION "17.0.2 Lite Edition"
@@ -73,9 +73,9 @@ set_location_assignment PIN_U9 -to ADC_CONVST
set_location_assignment PIN_V10 -to ADC_SCK
set_location_assignment PIN_AC4 -to ADC_SDI
set_location_assignment PIN_AD4 -to ADC_SDO
-set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to ARDUINO_IO[*]
-set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to ARDUINO_IO[*]
-set_instance_assignment -name CURRENT_STRENGTH_NEW "MAXIMUM CURRENT" -to ARDUINO_IO[*]
+#set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to ARDUINO_IO[*]
+#set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to ARDUINO_IO[*]
+#set_instance_assignment -name CURRENT_STRENGTH_NEW "MAXIMUM CURRENT" -to ARDUINO_IO[*]
set_location_assignment PIN_U14 -to IO_SCL
set_location_assignment PIN_AG9 -to IO_SDA
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to IO_S*
@@ -163,7 +163,7 @@ set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to HDMI_TX_D[*]
set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to HDMI_TX_DE
set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to HDMI_TX_HS
set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to HDMI_TX_VS
-set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to HDMI_TX_CLK
+#set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to HDMI_TX_CLK
set_location_assignment PIN_U10 -to HDMI_I2C_SCL
set_location_assignment PIN_AA4 -to HDMI_I2C_SDA
set_location_assignment PIN_T13 -to HDMI_I2S
@@ -231,8 +231,6 @@ set_hps_location_assignment HPSINTERFACEPERIPHERALSPIMASTER_X52_Y72_N111 -to spi
set_hps_location_assignment HPSINTERFACEPERIPHERALUART_X52_Y67_N111 -to uart
set_hps_location_assignment HPSINTERFACEPERIPHERALI2C_X52_Y60_N111 -to hdmi_i2c
set_global_assignment -name PRE_FLOW_SCRIPT_FILE "quartus_sh:sys/build_id.tcl"
-set_global_assignment -name CDF_FILE jtag.cdf
-set_global_assignment -name QIP_FILE sys/sys.qip
source sys/sys_analog.tcl
set_location_assignment PIN_AF25 -to SDIO_DAT[0]
set_location_assignment PIN_AF23 -to SDIO_DAT[1]
@@ -283,6 +281,22 @@ set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to LED_*
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to BTN_*
set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to BTN_*
source files.qip
+
+set_global_assignment -name ENABLE_SIGNALTAP OFF
+set_global_assignment -name OPTIMIZATION_MODE "AGGRESSIVE PERFORMANCE"
+set_global_assignment -name USE_SIGNALTAP_FILE Video_Explorer2.stp
+set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to USER_IO[2]
+set_global_assignment -name PARTITION_NETLIST_TYPE SOURCE -section_id Top
+set_global_assignment -name PARTITION_FITTER_PRESERVATION_LEVEL PLACEMENT_AND_ROUTING -section_id Top
+set_global_assignment -name PARTITION_COLOR 16764057 -section_id Top
+set_global_assignment -name CDF_FILE jtag.cdf
+set_global_assignment -name QIP_FILE sys/sys.qip
+set_global_assignment -name VERILOG_FILE rtl/Mister_Video_GIMEX.v
+set_global_assignment -name VERILOG_FILE rtl/pll.v -library pll
+set_global_assignment -name VERILOG_FILE rtl/pll/pll_0002.v -library pll
+set_global_assignment -name SYSTEMVERILOG_FILE rtl/Cassette_Write.sv
+set_global_assignment -name SYSTEMVERILOG_FILE rtl/config.sv
+set_global_assignment -name SYSTEMVERILOG_FILE rtl/Auto_Run.sv
set_global_assignment -name VHDL_FILE rtl/sram/coco_ram.vhd
set_global_assignment -name VHDL_FILE rtl/rom/coco_rom_cart.vhd
set_global_assignment -name VHDL_FILE rtl/rom/coco3_char_rom.vhd
@@ -300,7 +314,6 @@ set_global_assignment -name VERILOG_FILE rtl/cassette.v
set_global_assignment -name VERILOG_FILE rtl/rtc.sv
set_global_assignment -name VERILOG_FILE rtl/AMW.v
set_global_assignment -name VERILOG_FILE rtl/square_gen.v
-set_global_assignment -name VERILOG_FILE rtl/config.v
set_global_assignment -name SYSTEMVERILOG_FILE rtl/fdc.sv
set_global_assignment -name SYSTEMVERILOG_FILE rtl/sdc.sv
set_global_assignment -name SYSTEMVERILOG_FILE rtl/sdc_top.sv
@@ -315,135 +328,5 @@ set_global_assignment -name VHDL_FILE rtl/rom/coco_rom_32K.vhd
set_global_assignment -name VHDL_FILE rtl/rom/coco_rom_8K.vhd
set_global_assignment -name VHDL_FILE rtl/rom/coco_rom_16.vhd
set_global_assignment -name SDC_FILE rtl/CoCo3FPGA.sdc
-
-set_global_assignment -name SIGNALTAP_FILE Video_Explorer.stp
-set_global_assignment -name SIGNALTAP_FILE rom_Exploror.stp1
-set_global_assignment -name SOURCE_FILE rom_Exploror.stp1
-set_global_assignment -name SIGNALTAP_FILE Serial.stp
-set_global_assignment -name SIGNALTAP_FILE AMW.stp
-set_global_assignment -name SIGNALTAP_FILE HD.stp
-set_global_assignment -name SIGNALTAP_FILE reset.stp
-set_global_assignment -name SIGNALTAP_FILE Vsync.stp
-set_global_assignment -name ENABLE_SIGNALTAP ON
-set_global_assignment -name OPTIMIZATION_MODE "HIGH PERFORMANCE EFFORT"
-set_global_assignment -name USE_SIGNALTAP_FILE Video_Explorer2.stp
set_global_assignment -name VERILOG_FILE rtl/mc6809glb/mc6809glb.v
-set_global_assignment -name SIGNALTAP_FILE Video_Explorer2.stp
-set_global_assignment -name SLD_NODE_CREATOR_ID 110 -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_ENTITY_NAME sld_signaltap -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_RAM_BLOCK_TYPE=AUTO" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_NODE_INFO=805334528" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_POWER_UP_TRIGGER=0" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_STORAGE_QUALIFIER_INVERSION_MASK_LENGTH=0" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_ATTRIBUTE_MEM_MODE=OFF" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_STATE_FLOW_USE_GENERATED=0" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_STATE_BITS=11" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_BUFFER_FULL_STOP=1" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_CURRENT_RESOURCE_WIDTH=1" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_INCREMENTAL_ROUTING=1" -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[0] -to auto_signaltap_0|gnd -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[3] -to auto_signaltap_0|gnd -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[5] -to auto_signaltap_0|vcc -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[16] -to auto_signaltap_0|vcc -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[28] -to auto_signaltap_0|vcc -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[31] -to auto_signaltap_0|gnd -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_TRIGGER_LEVEL=3" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_TRIGGER_IN_ENABLED=0" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_TRIGGER_PIPELINE=0" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_COUNTER_PIPELINE=0" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_ADVANCED_TRIGGER_ENTITY=basic,1,basic,1,basic,1," -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_TRIGGER_LEVEL_PIPELINE=1" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_ENABLE_ADVANCED_TRIGGER=0" -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[2] -to auto_signaltap_0|gnd -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[21] -to auto_signaltap_0|gnd -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[22] -to auto_signaltap_0|gnd -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[30] -to auto_signaltap_0|gnd -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_clk -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|clk_sample" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[0] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|CASS_REWIND_RECORD" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[0] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|CASS_REWIND_RECORD" -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[6] -to auto_signaltap_0|vcc -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[12] -to auto_signaltap_0|gnd -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[17] -to auto_signaltap_0|gnd -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[18] -to auto_signaltap_0|gnd -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_RAM_PIPELINE=1" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_SEGMENT_SIZE=2048" -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[13] -to auto_signaltap_0|vcc -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[19] -to auto_signaltap_0|vcc -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_SAMPLE_DEPTH=2048" -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[8] -to auto_signaltap_0|gnd -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[25] -to auto_signaltap_0|vcc -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[1] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|MOTOR_ON" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[2] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|blk_type[0]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[3] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|blk_type[1]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[4] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|blk_type[2]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[5] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|blk_type[3]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[6] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|blk_type[4]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[7] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|blk_type[5]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[8] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|blk_type[6]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[9] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|blk_type[7]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[10] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[0]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[11] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[1]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[12] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[2]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[13] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[3]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[14] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[4]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[15] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[5]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[16] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[6]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[17] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[7]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[18] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[8]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[19] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_data_in[0]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[20] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_data_in[1]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[21] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_data_in[2]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[22] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_data_in[3]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[23] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_data_in[4]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[24] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_data_in[5]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[25] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_data_in[6]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[26] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_data_in[7]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_trigger_in[27] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|look_for_sync" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[1] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|MOTOR_ON" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[2] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|blk_type[0]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[3] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|blk_type[1]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[4] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|blk_type[2]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[5] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|blk_type[3]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[6] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|blk_type[4]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[7] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|blk_type[5]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[8] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|blk_type[6]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[9] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|blk_type[7]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[10] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[0]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[11] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[1]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[12] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[2]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[13] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[3]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[14] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[4]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[15] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[5]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[16] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[6]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[17] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[7]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[18] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_address[8]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[19] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_data_in[0]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[20] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_data_in[1]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[21] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_data_in[2]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[22] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_data_in[3]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[23] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_data_in[4]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[24] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_data_in[5]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[25] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_data_in[6]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[26] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|buf_data_in[7]" -section_id auto_signaltap_0
-set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_data_in[27] -to "emu:emu|coco3fpga:coco3|Cassette_Write:CoCo3_Cassette_Write|look_for_sync" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_DATA_BITS=28" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_TRIGGER_BITS=28" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_STORAGE_QUALIFIER_BITS=28" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_INVERSION_MASK=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" -section_id auto_signaltap_0
-set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_INVERSION_MASK_LENGTH=277" -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[1] -to auto_signaltap_0|gnd -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[4] -to auto_signaltap_0|vcc -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[7] -to auto_signaltap_0|vcc -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[9] -to auto_signaltap_0|vcc -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[10] -to auto_signaltap_0|vcc -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[11] -to auto_signaltap_0|gnd -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[14] -to auto_signaltap_0|gnd -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[15] -to auto_signaltap_0|vcc -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[20] -to auto_signaltap_0|vcc -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[23] -to auto_signaltap_0|vcc -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[24] -to auto_signaltap_0|vcc -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[26] -to auto_signaltap_0|gnd -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[27] -to auto_signaltap_0|vcc -section_id auto_signaltap_0
-set_instance_assignment -name POST_FIT_CONNECT_TO_SLD_NODE_ENTITY_PORT crc[29] -to auto_signaltap_0|vcc -section_id auto_signaltap_0
-set_global_assignment -name SLD_FILE db/Video_Explorer2_auto_stripped.stp
set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top
\ No newline at end of file
diff --git a/CoCo3.sv b/CoCo3.sv
index e8f6fd4..54ca372 100644
--- a/CoCo3.sv
+++ b/CoCo3.sv
@@ -1,6 +1,6 @@
//============================================================================
// CoCo3 port to MiSTer
-// Copyright (c) 2019 Alan Steremberg - alanswx
+// Copyright (c) 2019 Alan Steremberg - alanswx, Stan Hodge - MasterS3263827
//
//
//============================================================================
@@ -189,6 +189,8 @@ assign VIDEO_ARY = (!ar) ? 12'd3 : 12'd0;
`include "build_id.v"
+`include "build_id_num.v"
+
localparam CONF_STR = {
"COCO3;UART19200:9600:4800:2400:1200:300;",
"-;",
@@ -252,7 +254,7 @@ localparam CONF_STR = {
"J,Button1,Button2;",
"jn,A,B;",
"v,51;",
- "V,v",`BUILD_DATE
+ "V,v",{`BUILD_DATE,"-",`BUILD_NUMBER}
};
// Status bits Directory
@@ -277,7 +279,7 @@ assign clk_sys=CLK_57;
wire pll_locked, pll2_locked;
wire CLK_114, CLK_57, CLK_28, CLK_14;
-
+assign VGA_DISABLE = 1'b0;
pll pll
(
@@ -317,6 +319,7 @@ wire [21:0] gamma_bus;
assign CLK_VIDEO = clk_sys;
wire [64:0] RTC;
+wire [15:0] sdram_sz;
// SD - 7 drives [4 fdc, 2 sdc and 1 cass_wr] 512 size blocks [the wd1793 translates to a 256 byte sector size]
hps_io #(.CONF_STR(CONF_STR),.PS2DIV(2400), .VDNUM(7), .BLKSZ(2)) hps_io
@@ -342,6 +345,8 @@ hps_io #(.CONF_STR(CONF_STR),.PS2DIV(2400), .VDNUM(7), .BLKSZ(2)) hps_io
.ioctl_dout(ioctl_data),
.ioctl_index(ioctl_index),
+ .sdram_sz(sdram_sz),
+
// SD block level interface
.img_mounted(img_mounted), // signaling that new image has been mounted
@@ -455,7 +460,9 @@ wire Programmed_EE;
EE_Cold_Bt COCO3_EE_Cold_Bt (
.CLK(CLK_14),
+ .RESET(1'b0),
+// .Display_EE(1'b0), // from MISTer subsystem
.Display_EE(easter_egg), // from MISTer subsystem
.Cold_Boot(AMW_ACK), // from AMW system
@@ -474,11 +481,15 @@ wire [7:0] r;
wire [7:0] g;
wire [7:0] b;
-wire easter_egg = ~status[10];
+wire easter_egg = status[10];
wire [31:0] probe;
assign USER_OUT[6:0] = probe[6:0];
+wire [71:0] Config_Data;
+
+assign Config_Data = {`BUILD_DATE, `BUILD_NUMBER};
+
coco3fpga coco3 (
// CLOCKS
@@ -522,7 +533,7 @@ coco3fpga coco3 (
// R1, L2, R2, L1
.P_SWITCH(~{coco_joy2[4],coco_joy1[5],coco_joy2[5],coco_joy1[4]}),
.SWITCH(switch),
- .SOUND_OUT(cocosound),
+// .SOUND_OUT(cocosound),
.SOUND_LEFT(audio_left),
.SOUND_RIGHT(AUDIO_R),
@@ -533,6 +544,9 @@ coco3fpga coco3 (
.ioctl_index(ioctl_index),
.ioctl_wr(ioctl_wr),
+// SDRAM Info
+ .sdram_sz(sdram_sz),
+
// SD block level interface
.img_mounted(img_mounted), // signaling that new image has been mounted
@@ -580,6 +594,7 @@ coco3fpga coco3 (
.RTC(RTC),
.AMW_Trigger(coldboot | mpi_reset | mem_reset),
+// .AMW_Trigger(coldboot),
.AMW_ACK(AMW_ACK),
.F_Turbo(F_Turbo),
@@ -587,6 +602,8 @@ coco3fpga coco3 (
.Mem_Size(Mem_Size),
.AUTO_MODE(Auto_Mode),
+
+ .Config_Data(Config_Data),
.UART_TXD(UART_TXD),
.UART_RXD(UART_RXD),
@@ -598,7 +615,7 @@ coco3fpga coco3 (
assign status_set = 1'b0;
-wire [5:0] cocosound;
+//wire [5:0] cocosound;
wire [2:0] turbo_speed = status[34:32];
wire [2:0] assigned_turbo_speed;
@@ -741,7 +758,7 @@ cassette cassette(
.sdram_addr(ram_addr),
.sdram_data(ram_data_o),
- .sdram_rd(ram_rd), // Not connected for sram
+// .sdram_rd(ram_rd), // Not connected for sram
.data(casdout)
);
diff --git a/Video_Explorer2.stp b/Video_Explorer2.stp
index 92c69d7..368f217 100644
--- a/Video_Explorer2.stp
+++ b/Video_Explorer2.stp
@@ -277,7 +277,7 @@ trigger;]]>
- 11100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000011100101010101010111100000001110010101010101011110000000111001010101010101111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100000000001010100011110001110000000000101010001111000111000000000010101000111100011100100000001010100011110001111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111111001010101111111101111111111100101010111111110111111111110010101011111111011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111101010101000000000011111111110101010100000000001111111111010101010000000000111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111111111111111101010101111111111111111111110101010111111111111111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111101111111111010101011111111110111111111101010101111111111011111111110101010111111111
+ 11100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000101101001101010101111000000010110100110101010111100000001011010011010101011110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001110000000011101001001111000111000000001110100100111100011100000000111010010011110001111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111111111010011111111101111111111111101001111111110111111111111110100111111111011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111100001100100000000011111111110000110010000000001111111111000011001000000000111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111111111111111000110011111111111111111111100011001111111111111111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111101111111110001100111111111110111111111000110011111111111011111111100011001111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111T111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
diff --git a/build_id_num.v b/build_id_num.v
new file mode 100644
index 0000000..8cb8441
--- /dev/null
+++ b/build_id_num.v
@@ -0,0 +1 @@
+`define BUILD_NUMBER "004"
\ No newline at end of file
diff --git a/changes.txt b/changes.txt
index fb37177..7c8df2a 100644
--- a/changes.txt
+++ b/changes.txt
@@ -1,3 +1,39 @@
+1. Added support for cassette save. To use: A) You have to have a file [anyname.cas]
+ which is larger than needed. B) Select the file through the UI Menu 'Save
+ Cassette'. C)Set 'Cass Rwd=0 / Rec=1' to 1. D) Issue your 'CSAVE "NAME"'
+ E) When done, set 'Cass Rwd=0 / Rec=1' to 0 to complete the write. The file can
+ now be loaded or copied. Note a dummy file of a specific size can be created in
+ the MiSTer SSH shell in the /media/fat/games/coco3 with the command:
+ 'truncate -s 65536 tapefileame.cas'. [Note do NOT use over 65536 file length]
+2. Fixed serial interrupt [6551] to not be functional on slot 3 [carts].
+3. Modification of sys_top.v to override use of USER_IO for HDMI - so it can be used
+ for logic analyzer debug. This will only occur when `define Config_Debug is
+ enabled in config.v.
+4. Fixed MUGS of powerup issue occurring on some MiSTer units.
+5. Fixed incorrect application of GIME_IRQ on legacy interrupts. Fixed race condition
+ on reading IRQ status vs clearing the interrupt.
+6. Improved Castle of Tharoggad. App now loads but locks as the graphics animate. This
+ change improved mmu usage through to CARTS.
+7. Builds now keep track of multiple builds in the same date. It shows as V240512-001 in
+ the menus. Its also exposed to BASIC and a boot.vhd which can be enabled to autorun is
+ supplied in the archive to show how it works.
+8. Additionally, on the boot.vhd disk, is a program which demonstrated how to load a font -
+ IBMFONT.BAS. Run it and it maps a font much like the IBM font to the 80 column format.
+ Also, a file called TESTRTC.BAS pulls the MiSTer RTC values exposed in BASIC to display
+ a clock.
+9. Large improvement in the Timer function. Code closer emulates COCO3 Timer. Fixes
+ Sliphead cart.
+10. In the 20231023 release the wd1773 instances were reduced to 1 for the FDC and one for
+ the FDC. This saved space but introduced a bug when using multiple drives at the same
+ time - like a copy command. This change was removed and the copy command works again.
+
+To Do...
+1. Add Speech / Music cart
+2. Fix Castle of Tharoggad
+
+
+
+
1. Changed PIA 2 addressing to align with real CoCo3 hardware and end at FF2F.
2. Re-arranged MiSTer drive LUNs to support future auto-boot from SDC drive 0.
3. Added 'Auto Run' feature. You must use slot 2 [SDC]. Take your floppy or HD
diff --git a/docs/Boot.vhd b/docs/Boot.vhd
new file mode 100644
index 0000000..1652653
Binary files /dev/null and b/docs/Boot.vhd differ
diff --git a/docs/CoCo3FPGA.docx b/docs/CoCo3FPGA.docx
index b8a4bb6..bb17c58 100644
Binary files a/docs/CoCo3FPGA.docx and b/docs/CoCo3FPGA.docx differ
diff --git a/docs/CoCo3FPGA.pdf b/docs/CoCo3FPGA.pdf
index 8d3a1d7..5ddb61d 100644
Binary files a/docs/CoCo3FPGA.pdf and b/docs/CoCo3FPGA.pdf differ
diff --git a/docs/~$Co3FPGA.docx b/docs/~$Co3FPGA.docx
new file mode 100644
index 0000000..0084083
Binary files /dev/null and b/docs/~$Co3FPGA.docx differ
diff --git a/files.qip b/files.qip
index bff3037..50b4210 100644
--- a/files.qip
+++ b/files.qip
@@ -21,7 +21,7 @@ set_global_assignment -name SYSTEMVERILOG_FILE rtl/Cassette_Write.sv
set_global_assignment -name VERILOG_FILE rtl/rtc.sv
set_global_assignment -name VERILOG_FILE rtl/AMW.v
set_global_assignment -name VERILOG_FILE rtl/square_gen.v
-set_global_assignment -name VERILOG_FILE rtl/config.v
+set_global_assignment -name SYSTEMVERILOG_FILE rtl/config.sv
set_global_assignment -name SYSTEMVERILOG_FILE rtl/fdc.sv
set_global_assignment -name SYSTEMVERILOG_FILE rtl/sdc.sv
set_global_assignment -name SYSTEMVERILOG_FILE rtl/sdc_top.sv
diff --git a/releases/CoCo3_20240514.rbf b/releases/CoCo3_20240514.rbf
new file mode 100644
index 0000000..e9856ba
Binary files /dev/null and b/releases/CoCo3_20240514.rbf differ
diff --git a/rtl/Cassette_Write.sv b/rtl/Cassette_Write.sv
index 828db36..bfeea47 100644
--- a/rtl/Cassette_Write.sv
+++ b/rtl/Cassette_Write.sv
@@ -82,8 +82,6 @@ module Cassette_Write(
);
-assign sd_blk_cnt = 6'd0;
-
// Create 16x sample clock for the 2400 Baud rate...
// ~26us based on 1.78Mhz [562 ns]- divide by 46....
@@ -115,35 +113,38 @@ begin
end
end
-// Mounted SD Image [for the cass]
+// Mounted SD Image [for the cass]
+// This is not used and only here for completeness
-reg drive_wp;
-reg [31:0] drive_size;
+//reg drive_wp;
+//reg [31:0] drive_size;
-always @(negedge img_mounted)
-begin
- drive_wp <= img_readonly;
- drive_size <= img_size[31:0]; //Size / 256 on [31:8]
-end
+//always @(negedge img_mounted)
+//begin
+// drive_wp <= img_readonly;
+// drive_size <= img_size[31:0]; //Size / 256 on [31:8]
+//end
+
+// Set to 1 512 byte block per r/w
+assign sd_blk_cnt = 6'd0;
// Byte Receiver
-reg [15:0] incomming_reg;
+reg [15:0] incomming_reg;
-reg [5:0] bit_time;
-reg [2:0] bit_count;
-reg wave_negative;
+reg [5:0] bit_time;
+reg [2:0] bit_count;
+reg wave_negative;
-localparam time_out = 6'h3f;
-localparam wave_zero_level = 6'd32;
-localparam bit_time_1 = 6'd22;
-//localparam sync = 15'b010_1010_1001_1110; // Pre shift $553C
-localparam sync = 15'b0111_1000_1010_101; // Pre shift $553C [L -> R]
-localparam sync_proper = 8'h3C;
-localparam leader = 8'h55;
-localparam pre_rollover = 9'h1FF;
-localparam rollover = 9'h000;
+localparam time_out = 6'h3f;
+localparam wave_zero_level = 6'd32;
+localparam bit_time_1 = 6'd22;
+localparam sync = 15'b0111_1000_1010_101; // Pre shift $553C [L -> R]
+localparam sync_proper = 8'h3C;
+localparam leader = 8'h55;
+localparam pre_rollover = 9'h1FF;
+localparam rollover = 9'h000;
reg byte_clk;
reg look_for_sync;
@@ -151,36 +152,37 @@ reg flush_end, flush_end_que;
reg sd_hold;
reg pre_roll;
reg [7:0] blk_type;
+reg [7:0] protocol_data_count;
+reg gap;
+// Buffer interface
wire [8:0] buf_address;
wire [7:0] buf_data_in;
wire [7:0] buf_data_out;
wire buf_write;
-reg [7:0] protocol_data_count;
-
-localparam st_beg0 = 4'd0;
-localparam st_start = 4'd1;
-localparam st_st1 = 4'd2;
-localparam st_st2 = 4'd3;
-localparam st_st3 = 4'd4;
-localparam st_wr = 4'd5;
-localparam st_wr1 = 4'd6;
+// State Mach states
+localparam st_beg0 = 4'd0;
+localparam st_start = 4'd1;
+localparam st_st1 = 4'd2;
+localparam st_st2 = 4'd3;
+localparam st_wr = 4'd4;
+localparam st_wr1 = 4'd5;
reg [3:0] st_state;
reg [3:0] state_stack;
-localparam p_sync = 3'd0;
-localparam p_blk_type = 3'd1;
-localparam p_len = 3'd2;
-localparam p_dta = 3'd3;
-localparam p_cksum = 3'd4;
+localparam p_sync = 3'd0;
+localparam p_blk_type = 3'd1;
+localparam p_len = 3'd2;
+localparam p_dta = 3'd3;
+localparam p_cksum = 3'd4;
reg [2:0] p_state;
-localparam sd_wr_st = 2'd0;
-localparam sd_wr_st1 = 2'd1;
-localparam sd_wr_st2 = 2'd2;
+localparam sd_wr_st = 2'd0;
+localparam sd_wr_st1 = 2'd1;
+localparam sd_wr_st2 = 2'd2;
reg [1:0] sd_wr_state;
@@ -210,6 +212,7 @@ begin
sd_wr_state <= sd_wr_st;
sd_hold <= 1'b0;
pre_roll <= 1'b0;
+ gap <= 1'b0;
end
else
begin
@@ -248,6 +251,7 @@ begin
sd_wr_state <= sd_wr_st;
sd_hold <= 1'b0;
pre_roll <= 1'b0;
+ gap <= 1'b0;
end
byte_clk <= 1'b0;
@@ -265,7 +269,7 @@ begin
if ((DTOA_CODE >= wave_zero_level) && wave_negative)
begin
// Initially we are not collecting the leader bytes just collecting them and
-// waiting for the sync $$553C. The write to file stage will automatically
+// waiting for the sync $3C55. The write to file stage will automatically
// write the 128 leader bytes befor we start transfering data.
if (!look_for_sync)
begin
@@ -301,7 +305,7 @@ begin
begin
buf_address <= 9'b000000000;
buf_data_in <= leader;
- protocol_data_count <= 8'h7f; // We will use this to count the 128 bytes
+ protocol_data_count <= 8'h80; // We will use this to count the 128 bytes
st_state <= st_start;
end
@@ -363,6 +367,8 @@ begin
state_stack <= st_st1; // We come back here
st_state <= st_wr; // Write a byte
p_state <= p_dta;
+ if ((blk_type == 8'h00) & (protocol_data_count == 8'h05) & (incomming_reg[15:8] == 8'hff))
+ gap <= 1'b1;
if (protocol_data_count == 8'h01)
p_state <= p_cksum;
end
@@ -390,24 +396,13 @@ begin
st_st2:
begin
buf_data_in <= leader;
- if (blk_type == 8'h00)
- protocol_data_count <= 8'h7f; // We will use this to count the 128 bytes
+ if ((blk_type == 8'h00) || gap)
+ protocol_data_count <= 8'h80; // We will use this to count the 128 bytes
else
- protocol_data_count <= 8'h01; // We will use this to count the 128 bytes
+ protocol_data_count <= 8'h02; // We will use this to count the 2 bytes
st_state <= st_start; // No, don't write any more - were done
end
- st_st3:
- begin
- state_stack <= st_st3; // We come back here
- st_state <= st_wr; // Write a byte
- protocol_data_count <= protocol_data_count - 1'b1;
- if (protocol_data_count == 8'h00) // 128 bytes
- begin
- st_state <= st_st1; // No, don't write any more - were done
- end
- end
-
// Perform the byte writes to the buffer
// This acts like a sub routine....
st_wr:
diff --git a/rtl/CoCo3FPGA.sdc b/rtl/CoCo3FPGA.sdc
index 0cf8b3a..730290d 100644
--- a/rtl/CoCo3FPGA.sdc
+++ b/rtl/CoCo3FPGA.sdc
@@ -5,6 +5,7 @@ create_clock -period 1000.000 -name img_mounted[2] [get_nodes emu:emu|hps_io:hps
create_clock -period 1000.000 -name img_mounted[1] [get_nodes emu:emu|hps_io:hps_io|img_mounted[1]]
create_clock -period 1000.000 -name img_mounted[0] [get_nodes emu:emu|hps_io:hps_io|img_mounted[0]]
create_clock -period 1000.000 -name RESET_N [get_nodes emu:emu|coco3fpga:coco3|RESET_N]
+create_clock -period 1000.000 -name NMISample2 [get_nodes emu:emu|coco3fpga:coco3|mc6809x:GLBCPU09|NMISample2]
#set_false_path -from [get_nodes sysmem_lite:sysmem|sysmem_HPS_fpga_interfaces:fpga_interfaces|clocks_resets~FF_4365]
#create_clock -period 17.46 -name PH_2 [get_nodes emu:emu|coco3fpga:coco3|PH_2_RAW]
#create_clock -period 1000.000 -name CLK_6551[4] [get_nodes emu:emu|coco3fpga:coco3|CLK_6551[4]]
diff --git a/rtl/EE_Cold_Bt.v b/rtl/EE_Cold_Bt.v
index 8382fb5..cbc30bf 100644
--- a/rtl/EE_Cold_Bt.v
+++ b/rtl/EE_Cold_Bt.v
@@ -55,6 +55,7 @@
module EE_Cold_Bt(
input CLK,
+input RESET,
input Display_EE, // from MISTer subsystem
input Cold_Boot, // from MISTer subsystem
@@ -106,105 +107,117 @@ assign Start_Display_EE = ((Display_EE == 1'b1) & (Display_EE_D == 1'b0));
assign Start_Cold_Boot = ((Cold_Boot == 1'b1) & (Cold_Boot_D == 1'b0));
-always @(posedge CLK)
+always @ (posedge CLK or posedge RESET)
begin
-
- Display_EE_D <= Display_EE;
- Cold_Boot_D <= Cold_Boot;
-
- next_instruction <= 1'b0;
-
- if (Start_Display_EE)
+ if(RESET)
begin
- prog <= EE_PROG;
+ Display_EE_D <= 1'b0;
+ Cold_Boot_D <= 1'b0;
+ EE <= 1'b1;
+ N_RESET <= 1'b1;
+ prog <= 48'h000000000000;
+ next_instruction <= 1'b0;
+ timer <= 24'h000000;
end
-
- if (Start_Cold_Boot)
+ else
begin
- prog <= Cold_Boot_PROG;
- end
+ Display_EE_D <= Display_EE;
+ Cold_Boot_D <= Cold_Boot;
- if (next_instruction)
- prog[43:0] <= prog[47:4];
+ next_instruction <= 1'b0;
- case(inst)
-
- inst_NULL:;
-
- inst_START:
- begin
- if (!next_instruction)
+ if (Start_Display_EE)
begin
- timer <= 24'h000000; // clear timer
- next_instruction <= 1'b1;
+ prog <= EE_PROG;
end
- end
- inst_EE_ACTIVE:
- begin
- if (!next_instruction)
+ if (Start_Cold_Boot)
begin
- EE <= 1'b0;
- next_instruction <= 1'b1;
+ prog <= Cold_Boot_PROG;
end
- end
-
- inst_EE_INACTIVE:
- begin
- if (!next_instruction)
- begin
- EE <= 1'b1;
- next_instruction <= 1'b1;
- end
- end
- inst_RESET_ACTIVE:
- begin
- if (!next_instruction)
- begin
- N_RESET <= 1'b0;
- next_instruction <= 1'b1;
- end
- end
+ if (next_instruction)
+ prog[43:0] <= prog[47:4];
+
+ case(inst)
- inst_RESET_INACTIVE:
- begin
- if (!next_instruction)
- begin
- N_RESET <= 1'b1;
- next_instruction <= 1'b1;
- end
- end
-
- inst_SHORT_TIMER:
- begin
- if (!next_instruction)
- begin
- timer <= timer + 1'b1;
- if (timer==SHORT_TIME)
+ inst_NULL:;
+
+ inst_START:
begin
- next_instruction <= 1'b1;
- timer <= 24'h000000; // clear timer
+ if (!next_instruction)
+ begin
+ timer <= 24'h000000; // clear timer
+ next_instruction <= 1'b1;
+ end
end
- end
- end
- inst_LONG_TIMER:
- begin
- if (!next_instruction)
- begin
- timer <= timer + 1'b1;
- if (timer==LONG_TIME)
+ inst_EE_ACTIVE:
begin
- next_instruction <= 1'b1;
- timer <= 24'h000000; // clear timer
+ if (!next_instruction)
+ begin
+ EE <= 1'b0;
+ next_instruction <= 1'b1;
+ end
end
- end
+
+ inst_EE_INACTIVE:
+ begin
+ if (!next_instruction)
+ begin
+ EE <= 1'b1;
+ next_instruction <= 1'b1;
+ end
+ end
+
+ inst_RESET_ACTIVE:
+ begin
+ if (!next_instruction)
+ begin
+ N_RESET <= 1'b0;
+ next_instruction <= 1'b1;
+ end
+ end
+
+ inst_RESET_INACTIVE:
+ begin
+ if (!next_instruction)
+ begin
+ N_RESET <= 1'b1;
+ next_instruction <= 1'b1;
+ end
+ end
+
+ inst_SHORT_TIMER:
+ begin
+ if (!next_instruction)
+ begin
+ timer <= timer + 1'b1;
+ if (timer==SHORT_TIME)
+ begin
+ next_instruction <= 1'b1;
+ timer <= 24'h000000; // clear timer
+ end
+ end
+ end
+
+ inst_LONG_TIMER:
+ begin
+ if (!next_instruction)
+ begin
+ timer <= timer + 1'b1;
+ if (timer==LONG_TIME)
+ begin
+ next_instruction <= 1'b1;
+ timer <= 24'h000000; // clear timer
+ end
+ end
+ end
+
+ default:;
+
+ endcase
end
-
- default:;
-
- endcase
end
endmodule
diff --git a/rtl/Mister_Video.v b/rtl/Mister_Video.v
index 8b176d3..35f1f36 100644
--- a/rtl/Mister_Video.v
+++ b/rtl/Mister_Video.v
@@ -1827,15 +1827,25 @@ always @ (negedge MASTER_CLK)
// Adjust HSYNC here
**************************************************************************************/
// Width from 87 GIME 5.08 uS = 73 clocks
- 11'd751: // 824 - 751 = 73 (approx 5.09 uS)
+// 11'd751: // 824 - 751 = 73 (approx 5.09 uS)
+// begin
+// HSYNC_N <= 1'b0; // Turn on Sync
+// PIXEL_COUNT <= 11'd752;
+// end
+// 11'd810: // End of SYNC start of front porch 804 + 80 - 1, End of Sync to Video = 167 816 + 167 =
+// begin
+// HSYNC_N <= 1'b1; // SYNC OFF
+// PIXEL_COUNT <= 11'd811;
+// end
+ 11'd752: // 824 - 751 = 73 (approx 5.09 uS)
begin
HSYNC_N <= 1'b0; // Turn on Sync
- PIXEL_COUNT <= 11'd752;
+ PIXEL_COUNT <= 11'd753;
end
- 11'd810: // End of SYNC start of front porch 804 + 80 - 1, End of Sync to Video = 167 816 + 167 =
+ 11'd811: // End of SYNC start of front porch 804 + 80 - 1, End of Sync to Video = 167 816 + 167 =
begin
HSYNC_N <= 1'b1; // SYNC OFF
- PIXEL_COUNT <= 11'd811;
+ PIXEL_COUNT <= 11'd812;
end
/**************************************************************************************
* End of HSYNC adjustment
diff --git a/rtl/cassette.v b/rtl/cassette.v
index e63b23f..51c99ab 100644
--- a/rtl/cassette.v
+++ b/rtl/cassette.v
@@ -6,16 +6,16 @@ module cassette(
input rewind,
input en,
- output reg [24:0] sdram_addr,
+ output reg [15:0] sdram_addr,
input [7:0] sdram_data,
- output reg sdram_rd,
+// output reg sdram_rd,
- output data,
- output [2:0] status
+ output data
+// output [2:0] status
);
-assign status = state;
+//assign status = state;
reg old_en;
reg ffrewind;
@@ -60,25 +60,25 @@ always @(posedge clk) begin
end
NEXT: begin
state <= READ1;
- sdram_rd <= 1'b0;
+// sdram_rd <= 1'b0;
if (seq == 24'h553c00) name <= 1'd1;
if (seq == 24'h555555 && name) begin
name <= 1'd0;
state <= WAIT;
hold <= 19'd445000; // 0.5s
- sdram_addr <= sdram_addr - 25'd3;
+ sdram_addr <= sdram_addr - 16'd3;
end
if (seq == 24'h553cff) eof <= 2'd1;
if (seq == 24'h00ff55 && eof == 2'd1) eof <= 2'd2;
if (~en) state <= IDLE;
end
READ1: begin
- sdram_rd <= 1'b1;
+// sdram_rd <= 1'b1;
state <= READ2;
end
READ2: begin
ibyte <= sdram_data;
- sdram_rd <= 1'b0;
+// sdram_rd <= 1'b0;
state <= READ3;
sq_start <= 1'b1;
end
@@ -88,14 +88,14 @@ always @(posedge clk) begin
end
READ4: begin
seq <= { seq[15:0], sdram_data };
- sdram_addr <= sdram_addr + 25'd1;
+ sdram_addr <= sdram_addr + 16'd1;
state <= eof == 2'd2 ? IDLE : NEXT;
end
endcase
if (ffrewind ^ rewind) begin
seq <= 24'd0;
- sdram_addr <= 25'd0;
+ sdram_addr <= 16'd0;
state <= IDLE;
eof <= 2'd0;
end
diff --git a/rtl/coco3fpga.sv b/rtl/coco3fpga.sv
index 45fa79d..14e7040 100644
--- a/rtl/coco3fpga.sv
+++ b/rtl/coco3fpga.sv
@@ -71,8 +71,6 @@
//
////////////////////////////////////////////////////////////////////////////////
-// Define Config features
-`include "../rtl/config.v"
module coco3fpga(
@@ -95,7 +93,7 @@ output reg [7:0] BLUE,
output reg H_SYNC,
output reg V_SYNC,
-output reg VGA_SYNC_N,
+//output reg VGA_SYNC_N,
output PIX_CLK,
output HBLANK,
output VBLANK,
@@ -117,13 +115,13 @@ output UART_DTR,
input UART_DSR,
-output [5:0] SOUND_OUT,
+//output [5:0] SOUND_OUT,
output [15:0] SOUND_LEFT,
output [15:0] SOUND_RIGHT,
// CoCo Joystick
// Needs removal.... ???
-input [3:0] PADDLE_CLK,
+//input [3:0] PADDLE_CLK,
input [3:0] P_SWITCH,
// joystick input
// digital for buttons
@@ -145,6 +143,9 @@ input ioctl_download,
input ioctl_wr,
input [15:0] ioctl_index,
+// SDRAM Info
+input [15:0] sdram_sz,
+
// SD block level interface
input [6:0] img_mounted, // signaling that new image has been mounted
input img_readonly, // mounted as read only. valid only for active bit in img_mounted
@@ -202,7 +203,9 @@ input F_Turbo,
input [2:0] turbo_speed,
output [2:0] assigned_turbo_speed,
input [2:0] Mem_Size,
-input [1:0] AUTO_MODE
+input [1:0] AUTO_MODE,
+
+input [71:0] Config_Data
);
@@ -229,6 +232,10 @@ parameter BOARD_TYPE = 8'h01; // No Riser - 2M
////////////////////////////////////////////////////////////////////////////////
+// Define Config features
+
+reg [7:0] i_val;
+`include "../rtl/config.sv"
reg [15:0] RAM0_DATA_I;
@@ -250,7 +257,9 @@ reg CLK3_57MHZ;
wire EF;
wire PH_2;
+`ifndef CoCo3_CYC_ACC_6809
reg PH_2_RAW;
+`endif
reg RESET_N;
reg [6:0] CPU_RESET_SM;
reg CPU_RESET;
@@ -284,7 +293,7 @@ reg MMU_TR;
reg [3:0] TMR_MSB;
reg [7:0] TMR_LSB;
wire TMR_RST;
-reg TMR_ENABLE;
+reg [1:0] TMR_ENABLE;
reg [15:0] VIDEO_BUFFER;
reg GRMODE;
reg BLINK;
@@ -362,7 +371,7 @@ wire CART_SEL;
reg [5:0] DTOA_CODE;
reg [5:0] SOUND_DTOA;
-assign SOUND_OUT = SOUND_DTOA; // AJS - hook up sound directly
+//assign SOUND_OUT = SOUND_DTOA; // AJS - hook up sound directly
wire [7:0] SOUND;
wire [18:0] DAC_LEFT;
@@ -383,6 +392,12 @@ wire H_FLAG;
reg [3:0] SWITCH_L;
+wire RST_FF00_N;
+wire RST_FF02_N;
+//reg RST_FF20_N;
+wire RST_FF22_N;
+wire RST_FF92_N;
+wire RST_FF93_N;
wire CPU_IRQ_N;
wire CPU_FIRQ_N;
reg [2:0] DIV_7;
@@ -552,19 +567,13 @@ reg ANALOG;
wire VDAC_EN;
wire [15:0] VDAC_OUT;
-reg RST_FF00_N;
-reg RST_FF02_N;
-//reg RST_FF20_N;
-reg RST_FF22_N;
-reg RST_FF92_N;
-reg RST_FF93_N;
-reg TMR_RST_N;
wire CART_INT_N;
reg CART_INT_N_D;
wire VSYNC_INT_N;
reg VSYNC_INT_N_D;
wire HSYNC_INT_N;
reg HSYNC_INT_N_D;
+wire TMR_RESET_N;
reg TIMER_INT_N;
reg TIMER_INT_N_D;
wire KEY_INT_N;
@@ -641,8 +650,9 @@ wire [7:0] CART_DATA;
wire clk_sys;
reg hold;
+`ifndef CoCo3_CYC_ACC_6809
reg cpu_ena;
-
+`endif
wire [4:0] CENT; // BIN Values
wire [6:0] YEAR;
@@ -677,7 +687,7 @@ rtc #(50000000) CC3_rtc(
// Probe's defined
//assign PROBE[6:0] = {CART1_POL, CART1_BUF_RESET_N, CART1_FIRQ_STAT_N, CART1_CLK_N, CART1_FIRQ_N, RESET_N, PH_2};
//assign PROBE[7:0] = {1'b0, CART1_POL, CART1_FIRQ_N, CART1_FIRQ_BUF[0], CART1_CLK_N_D, CART1_FIRQ_RESET_N, CART1_CLK_N, PH_2};
-assign PROBE[7:0] = {2'b00, cache_hit, COCO3_ROM_WRITE, ioctl_wr, ioctl_download, ioctl_index[7], ioctl_index[6]};
+assign PROBE[7:0] = {1'b0, TMR_CLK, DATA_IN[5], RST_FF93_N_SFT[0], RST_FF93_N, !TIMER3_FIRQ_N, VSYNC_INT_N, TIMER_INT_N};
assign PROBE[15:8] = 8'h00;
assign PROBE[23:16] = 8'h00;
//assign PROBE[31:24] = {3'b000, DATA_OUT[3], MOTOR, DRIVE_SEL_EXT[0], HDD_EN, ADDRESS[0]};
@@ -742,12 +752,15 @@ assign RAM_CS = (ADDRESS[15:0]== 16'hFFE8) ? 1'b1: // GART
assign ROM_SEL = (ADDRESS[15:4] == 12'b111111111111) ? 1'b1: // Enable for Vectors
(ADDRESS[15:9] == 7'b1111111) ? 1'b0: // Disabled for FE00 - FFFF
- ({ROM[1], RAM, BLOCK_ADDRESS[11:2], ADDRESS[14]} == 13'b0000000011110) ? 1'b1: // Enabled Read, 16K Int, Page 7, x1 $78000-$7BFFF
+// (CART_SEL == 1'b1) ? 1'b0:
+ ({ROM[1], RAM, BLOCK_ADDRESS[11:1]} == 13'b0000000011110) ? 1'b1: // Enabled Read, 16K Int, Page 7, x1 $78000-$7BFFF
+// ({ROM[1], RAM, BLOCK_ADDRESS[11:2], ADDRESS[14]} == 13'b0000000011110) ? 1'b1: // Enabled Read, 16K Int, Page 7, x1 $78000-$7BFFF
({ROM, RAM, BLOCK_ADDRESS[11:2]} == 13'b1000000001111) ? 1'b1: // Enabled 32K int, Page 7, x $78000-$7FFFF
1'b0;
assign CART_SEL = (ADDRESS[15:8] == 8'b11111111) ? 1'b0: // Disabled for FF00 - FFFF
- ({ROM[1], RAM, BLOCK_ADDRESS[11:2], ADDRESS[14]} == 13'b0000000011111) ? 1'b1: // Enabled Read, 16K Cart, Page 7, x1 $7C000-$7FEFF
+// ({ROM[1], RAM, BLOCK_ADDRESS[11:2], ADDRESS[14]} == 13'b0000000011111) ? 1'b1: // Enabled Read, 16K Cart, Page 7, x1 $7C000-$7FEFF
+ ({ROM[1], RAM, BLOCK_ADDRESS[11:1]} == 13'b0000000011111) ? 1'b1: // Enabled Read, 16K Cart, Page 7, x1 $7C000-$7FEFF
({ROM, RAM, BLOCK_ADDRESS[11:2]} == 13'b1100000001111) ? 1'b1: // Enabled 32K Cart, Page 7, x1 $78000-$7FEFF
1'b0;
@@ -789,6 +802,7 @@ localparam [5:0] BOOT = 6'd0;
wire COCO3_ROM_WRITE = (ioctl_index[7:0] == {BOOT0, BOOT}) & ioctl_wr;
wire COCO3_DISKROM_WRITE = (ioctl_index[7:0] == {BOOT1, BOOT}) & ioctl_wr;
+wire COCO3_CART_WRITE = (ioctl_index[5:0] == 6'd1) & ioctl_wr & !cart_lock;
COCO_ROM_32K CC3_ROM(
@@ -810,10 +824,10 @@ COCO_ROM_8K CC3_DISK_ROM(
);
-assign FLASH_DATA = ENA_PAK ? CART_DATA:
- (FLASH_ADDRESS[15] == 1'b0) ? COCO3_ROM_DATA:
- (FLASH_ADDRESS[15:13] == 3'b100) ? COCO3_DISK_ROM_DATA:
- 8'b00000000;
+assign FLASH_DATA = ENA_PAK ? CART_DATA:
+ (FLASH_ADDRESS[15] == 1'b0) ? COCO3_ROM_DATA:
+ (FLASH_ADDRESS[15:13] == 3'b100) ? COCO3_DISK_ROM_DATA:
+ 8'b00000000;
COCO_ROM_CART CC3_ROM_CART(
@@ -822,7 +836,7 @@ COCO_ROM_CART CC3_ROM_CART(
.CLK(~clk_sys),
.WR_ADDR(ioctl_addr[16:0]),
.WR_DATA(ioctl_data[7:0]),
-.WRITE((ioctl_index[5:0] == 6'd1) & ioctl_wr)
+.WRITE(COCO3_CART_WRITE)
);
wire SDC_EN_CS;
@@ -882,10 +896,138 @@ begin
end
-`ifdef Config_Debug
- wire [7:0] Config_FLAG = `Config_Debug_FLAG;
- wire [7:0] Config_Debug_Value = `Config_Debug_Value;
-`endif
+wire [3:0] Config_FLAG = `Config_Debug_FLAG;
+wire [7:0] Build_Info;
+reg [3:0] Build_Info_Count;
+reg Build_Info_Read, Build_Info_Read_Delay;
+
+reg [3:0] i_count;
+
+always @(negedge clk_sys or negedge RESET_N)
+begin
+ if(!RESET_N)
+ begin
+ i_count <= 4'b0000;
+ i_val <= 8'h00;
+ end
+ else
+ begin
+ if ( !(i_count == 4'b1000))
+ i_count <= i_count + 1'b1;
+ case(i_count)
+ 4'b0001:
+ begin
+ `ifdef Feat_1
+ i_val <= i_val + FEATURE_1;
+ `endif
+ end
+ 4'b0010:
+ begin
+ `ifdef Feat_2
+ i_val <= i_val + FEATURE_2;
+ `endif
+ end
+ 4'b0011:
+ begin
+ `ifdef Feat_3
+ i_val <= i_val + FEATURE_3;
+ `endif
+ end
+ 4'b0100:
+ begin
+ `ifdef Feat_4
+ i_val <= i_val + FEATURE_4;
+ `endif
+ end
+ 4'b0101:
+ begin
+ `ifdef Feat_5
+ i_val <= i_val + FEATURE_5;
+ `endif
+ end
+ 4'b0110:
+ begin
+ `ifdef Feat_6
+ i_val <= i_val + FEATURE_6;
+ `endif
+ end
+ 4'b0111:
+ begin
+ `ifdef Feat_7
+ i_val <= i_val + FEATURE_7;
+ `endif
+ end
+ default:;
+ endcase
+ end
+end
+
+always @(negedge clk_sys or negedge RESET_N)
+begin
+ if(!RESET_N)
+ begin
+ Build_Info_Count <= 4'b0000;
+ Build_Info <= 8'h00;
+ Build_Info_Read <= 1'b0;
+ Build_Info_Read_Delay <= 1'b0;
+ end
+ else
+ begin
+ Build_Info_Read <= 1'b0;
+ Build_Info_Read_Delay <= Build_Info_Read;
+ if (Build_Info_Read_Delay)
+ Build_Info_Count <= Build_Info_Count + 1'b1;
+
+ case (Build_Info_Count)
+ 4'd0:
+ Build_Info <= Config_Data[71:64]; // Year MSB
+ 4'd1:
+ Build_Info <= Config_Data[63:56]; // Year LSB
+ 4'd2:
+ Build_Info <= Config_Data[55:48]; // Month MSB
+ 4'd3:
+ Build_Info <= Config_Data[47:40]; // Month LSB
+ 4'd4:
+ Build_Info <= Config_Data[39:32]; // Day MSB
+ 4'd5:
+ Build_Info <= Config_Data[31:24]; // Day LSB
+ 4'd6:
+ Build_Info <= Config_Data[23:16]; // Daily Build ID
+ 4'd7:
+ Build_Info <= Config_Data[15:8]; // Daily Build ID
+ 4'd8:
+ Build_Info <= Config_Data[7:0]; // Daily Build ID
+ 4'd9:
+ `ifdef Config_Debug
+ Build_Info <= {4'b1111, Config_FLAG};
+ `else
+ Build_Info <= {4'b0000, Config_FLAG};
+ `endif
+ 4'd10:
+ Build_Info <= i_val;
+ 4'd11:
+ Build_Info <= {Config_FLAG, sdram_sz[15], 1'b0, sdram_sz[1:0]};
+ 4'd12:
+ Build_Info <= Version_Hi;
+ 4'd13:
+ Build_Info <= (Version_Lo + BOARD_TYPE);
+
+ default:
+ Build_Info <= 8'h00;
+ endcase
+
+ if(PH_2)
+ begin
+ case ({RW_N,ADDRESS})
+ 17'h1FFEF:
+ begin
+ Build_Info_Read <= 1'b1;
+ end
+ default:;
+ endcase
+ end
+ end
+end
assign DATA_IN =
@@ -896,35 +1038,22 @@ assign DATA_IN =
HDD_EN ? DATA_HDD:
RS232_EN ? DATA_RS232:
SLOT3_HW ? {5'b00000, ROM_BANK}:
-// FF00, FF04, FF08, FF0C
-({ADDRESS[15:5], ADDRESS[1:0]} == 13'b1111111100000) ? DATA_REG1:
-// FF01, FF05, FF09, FF0D
-({ADDRESS[15:5], ADDRESS[1:0]} == 13'b1111111100001) ? {!HSYNC1_IRQ_BUF[1], 3'b011, SEL[0], DDR1, HSYNC1_POL, HSYNC1_IRQ_INT}:
-// FF02, FF06, FF0A, FF0E
-({ADDRESS[15:5], ADDRESS[1:0]} == 13'b1111111100010) ? DATA_REG2:
-// FF03, FF07, FF0B, FF0F
-({ADDRESS[15:5], ADDRESS[1:0]} == 13'b1111111100011) ? {!VSYNC1_IRQ_BUF[1], 3'b011, SEL[1], DDR2, VSYNC1_POL, VSYNC1_IRQ_INT}:
+// FF00, FF04, FF08, FF0C, FF10, FF14, FF18, FF1C
+({ADDRESS[15:5], ADDRESS[1:0]} == 13'b11111111000_00) ? DATA_REG1:
+// FF01, FF05, FF09, FF0D, FF11, FF15, FF19, FF1D
+({ADDRESS[15:5], ADDRESS[1:0]} == 13'b11111111000_01) ? {!HSYNC1_IRQ_BUF[1], 3'b011, SEL[0], DDR1, HSYNC1_POL, HSYNC1_IRQ_INT}:
+// FF02, FF06, FF0A, FF0E, FF12, FF16, FF1A, FF1E
+({ADDRESS[15:5], ADDRESS[1:0]} == 13'b11111111000_10) ? DATA_REG2:
+// FF03, FF07, FF0B, FF0F, FF13, FF17, FF1B, FF1F
+({ADDRESS[15:5], ADDRESS[1:0]} == 13'b11111111000_11) ? {!VSYNC1_IRQ_BUF[1], 3'b011, SEL[1], DDR2, VSYNC1_POL, VSYNC1_IRQ_INT}:
// FF20, FF24, FF28, FF2C
-({ADDRESS[15:4], ADDRESS[1:0]} == 14'b11111111001000) ? DATA_REG3:
+({ADDRESS[15:4], ADDRESS[1:0]} == 14'b111111110010_00) ? DATA_REG3:
// FF21, FF25, FF29, FF2D
-({ADDRESS[15:4], ADDRESS[1:0]} == 14'b11111111001001) ? {4'b0011, CAS_MTR, DDR3, 2'b00}: // CD_POL, CD_INT}:
+({ADDRESS[15:4], ADDRESS[1:0]} == 14'b111111110010_01) ? {4'b0011, CAS_MTR, DDR3, 2'b00}: // CD_POL, CD_INT}:
// FF22, FF26, FF2A, FF2E
-({ADDRESS[15:4], ADDRESS[1:0]} == 14'b11111111001010) ? DATA_REG4:
+({ADDRESS[15:4], ADDRESS[1:0]} == 14'b111111110010_10) ? DATA_REG4:
// FF23, FF27, FF2B, FF2F
-({ADDRESS[15:4], ADDRESS[1:0]} == 14'b11111111001011) ? {!CART1_FIRQ_BUF[1], 3'b011, SOUND_EN, DDR4, CART1_POL, CART1_FIRQ_INT}:
-// HiRes Joystick
-// ({PDL,ADDRESS} == 17'h0FF60) ? PADDLE_LATCH_0[11:4]:
-// ({PDL,ADDRESS} == 17'h0FF61) ? {PADDLE_LATCH_0[3:0],4'b0000}:
-// ({PDL,ADDRESS} == 17'h0FF62) ? PADDLE_LATCH_1[11:4]:
-// ({PDL,ADDRESS} == 17'h0FF63) ? {PADDLE_LATCH_1[3:0],4'b0000}:
-// ({PDL,ADDRESS} == 17'h1FF60) ? PADDLE_LATCH_2[11:4]:
-// ({PDL,ADDRESS} == 17'h1FF61) ? {PADDLE_LATCH_2[3:0],4'b0000}:
-// ({PDL,ADDRESS} == 17'h1FF62) ? PADDLE_LATCH_3[11:4]:
-// ({PDL,ADDRESS} == 17'h1FF63) ? {PADDLE_LATCH_3[3:0],4'b0000}:
-// (ADDRESS == 16'hFF6C) ? {(!WF_RDFIFO_RDEMPTY & WF_IRQ_EN),
-// 5'b00000,
-// !WF_RDFIFO_RDEMPTY, // 1 = data available
-// WF_WRFIFO_WRFULL}: // 1 = Write FIFO Full
+({ADDRESS[15:4], ADDRESS[1:0]} == 14'b111111110010_11) ? {!CART1_FIRQ_BUF[1], 3'b011, SOUND_EN, DDR4, CART1_POL, CART1_FIRQ_INT}:
(ADDRESS == 16'hFF70) ? {1'b0, GART_WRITE[22:16]}: // 2MB
(ADDRESS == 16'hFF71) ? { GART_WRITE[15:8]}:
@@ -932,19 +1061,8 @@ assign DATA_IN =
(ADDRESS == 16'hFF74) ? {1'b0, GART_READ[22:16]}:
(ADDRESS == 16'hFF75) ? { GART_READ[15:8]}:
(ADDRESS == 16'hFF76) ? { GART_READ[7:0]}:
- (ADDRESS == 16'hFF7F) ? {2'b11, MPI_CTS, 2'b00, MPI_SCS}:
-// (ADDRESS == 16'hFF80) ? {CK_DONE_BUF[1],
-// CK_FAIL,
-// CK_STATE}:
-// (ADDRESS == 16'hFF81) ? CK_DATA_IN:
-// (ADDRESS == 16'hFF84) ? {SDRAM_READY_BUF[1], 3'b000, SDRAM_STATE, SDRAM_READ}:
-// (ADDRESS == 16'hFF85) ? SDRAM_DOUT[7:0]:
-// (ADDRESS == 16'hFF86) ? SDRAM_DOUT[15:8]:
-// (ADDRESS == 16'hFF87) ? {1'b0, SDRAM_ADDR[21:15]}:
-// (ADDRESS == 16'hFF88) ? SDRAM_ADDR[14:7]:
-// (ADDRESS == 16'hFF87) ? BUFF_DATA[15:8]:
-// (ADDRESS == 16'hFF88) ? BUFF_DATA[7:0]:
+ (ADDRESS == 16'hFF7F) ? {2'b11, MPI_CTS, 2'b00, MPI_SCS}:
(ADDRESS == 16'hFF8E) ? GPIO_DIR:
(ADDRESS == 16'hFF8F) ? GPIO:
@@ -955,14 +1073,14 @@ assign DATA_IN =
(ADDRESS == 16'hFF93) ? {2'b00, !TIMER3_FIRQ_N, !HSYNC3_FIRQ_N, !VSYNC3_FIRQ_N, 1'b0, !KEY3_FIRQ_N, !CART3_FIRQ_N}:
(ADDRESS == 16'hFF94) ? {4'h0,TMR_MSB}:
(ADDRESS == 16'hFF95) ? TMR_LSB:
-// (ADDRESS == 16'hFF98) ? {GRMODE, HRES[3], DESCEN, MONO, 1'b0, LPR}:
-// (ADDRESS == 16'hFF99) ? {HLPR, LPF, HRES[2:0], CRES}:
-// (ADDRESS == 16'hFF9A) ? {2'b00, PALETTE[16][5:0]}:
-// (ADDRESS == 16'hFF9B) ? {2'b00, SAM_EXT, SCRN_START_HSB}: // 4 extra bits for 8MB. Real hardware can't read back!!
-// (ADDRESS == 16'hFF9C) ? {4'h0,VERT_FIN_SCRL}:
-// (ADDRESS == 16'hFF9D) ? SCRN_START_MSB:
-// (ADDRESS == 16'hFF9E) ? SCRN_START_LSB:
-// (ADDRESS == 16'hFF9F) ? {HVEN,HOR_OFFSET}:
+ (ADDRESS == 16'hFF98) ? {GRMODE, HRES[3], 3'b000, LPR}:
+ (ADDRESS == 16'hFF99) ? {HLPR, LPF, HRES[2:0], CRES}:
+ (ADDRESS == 16'hFF9A) ? {2'b00, PALETTE[16][5:0]}:
+ (ADDRESS == 16'hFF9B) ? {SAM_EXT[2], SCRN_START_HSB[4],SAM_EXT[1:0],SCRN_START_HSB[3:0]}: // 4 extra bits for 8MB. Real hardware can't read back!!
+ (ADDRESS == 16'hFF9C) ? {4'h0,VERT_FIN_SCRL}:
+ (ADDRESS == 16'hFF9D) ? SCRN_START_MSB:
+ (ADDRESS == 16'hFF9E) ? SCRN_START_LSB:
+ (ADDRESS == 16'hFF9F) ? {HVEN,HOR_OFFSET}:
(ADDRESS == 16'hFFA0) ? SAM00[7:0]:
(ADDRESS == 16'hFFA1) ? SAM01[7:0]:
(ADDRESS == 16'hFFA2) ? SAM02[7:0]:
@@ -1004,37 +1122,10 @@ assign DATA_IN =
(ADDRESS == 16'hFFC6) ? {2'b00, MIN}:
(ADDRESS == 16'hFFC7) ? {2'b00, SEC}:
- (ADDRESS == 16'hFFCC) ? {KEY[51],KEY[52],KEY[72],KEY[71],
- KEY[28],KEY[27],KEY[30],KEY[29]}:
- (ADDRESS == 16'hFFCD) ? {KEY[70],KEY[69],KEY[65],KEY[66],
- KEY[67],KEY[68],2'b00}:
- (ADDRESS == 16'hFFCE) ? {KEY[61],KEY[60],KEY[59],KEY[58],
- KEY[57],KEY[56],KEY[54],KEY[53]}:
- (ADDRESS == 16'hFFCF) ? {V_SYNC,VBLANK,H_SYNC,HBLANK,
- KEY[0],KEY[64],KEY[63],KEY[62]}:
+ (ADDRESS == 16'hFFD9) ? {5'h00, RATE_PGM}:
- `ifdef Config_Debug
- (ADDRESS == 16'hFFF0) ? Config_FLAG:
- (ADDRESS == 16'hFFF1) ? Config_Debug_Value:
- `else
- (ADDRESS == 16'hFFF0) ? Version_Hi:
- (ADDRESS == 16'hFFF1) ? (Version_Lo + BOARD_TYPE):
- `endif
- (ADDRESS == 16'hFFF2) ? 8'hFE:
- (ADDRESS == 16'hFFF3) ? 8'hEE:
- (ADDRESS == 16'hFFF4) ? 8'hFE:
- (ADDRESS == 16'hFFF5) ? 8'hF1:
- (ADDRESS == 16'hFFF6) ? 8'hFE:
- (ADDRESS == 16'hFFF7) ? 8'hF4:
- (ADDRESS == 16'hFFF8) ? 8'hFE:
- (ADDRESS == 16'hFFF9) ? 8'hF7:
- (ADDRESS == 16'hFFFA) ? 8'hFE:
- (ADDRESS == 16'hFFFB) ? 8'hFA:
- (ADDRESS == 16'hFFFC) ? 8'hFE:
- (ADDRESS == 16'hFFFD) ? 8'hFD:
- (ADDRESS == 16'hFFFE) ? 8'h8C:
- (ADDRESS == 16'hFFFF) ? 8'h1B:
- 8'h55;
+ (ADDRESS == 16'hFFEF) ? Build_Info:
+ 8'hAA;
assign DATA_REG1 = !DDR1 ? DD_REG1:
KEYBOARD_IN;
@@ -1150,15 +1241,18 @@ assign cache_hit = (sdram_cpu_addr[24:1] == sdram_cpu_addr_L[24:1]);
reg cpu_cycle_ena;
+
always @(negedge clk_sys or negedge RESET_N)
begin
if(!RESET_N)
begin
CLK <= 6'h00;
SWITCH_L <= 3'b000;
+`ifndef CoCo3_CYC_ACC_6809
PH_2_RAW <= 1'b0;
- hold <= 1'b0;
cpu_ena <= 1'b0;
+`endif
+ hold <= 1'b0;
end_hold <= 1'b0;
RAM0_BE0_L <= 1'b0;
RAM0_BE1_L <= 1'b0;
@@ -1201,7 +1295,9 @@ begin
begin
// kill end hold and cpu_ena for the read memory hold
end_hold <= 1'b0;
+`ifndef CoCo3_CYC_ACC_6809
cpu_ena <= 1'b0;
+`endif
end
if (sdram_cpu_ack)
@@ -1217,19 +1313,23 @@ begin
begin
SWITCH_L <= {assigned_turbo_speed, (RATE | F_Turbo)}; // Normal speed
CLK <= 6'h01;
+`ifndef CoCo3_CYC_ACC_6809
PH_2_RAW <= 1'b1;
-
+`endif
if (~(hold | end_hold)) // Make sure we are not in a cycle before starting one....
// If we are still in one - we skip this cpu_enable cycle
begin
+`ifndef CoCo3_CYC_ACC_6809
cpu_ena <= 1'b1;
-
+`endif
cpu_cycle_ena <= 1'b1; // Default cycle
if (AMW_EN) // Automated Memory Write ?
begin
AMW_WR <= 1'b1;
+`ifndef CoCo3_CYC_ACC_6809
cpu_ena <= 1'b0; // Kill cpu enable
+`endif
cpu_cycle_ena <= 1'b0; // Kill (defer) cycle based on memory transaction
@@ -1296,11 +1396,14 @@ begin
end
6'h01:
begin
+`ifndef CoCo3_CYC_ACC_6809
PH_2_RAW <= 1'b0;
-
+`endif
// if we are not in a memory read [hold] then terminate cpu_ena - just like PH_2
+`ifndef CoCo3_CYC_ACC_6809
if (!hold)
cpu_ena <= 1'b0;
+`endif
CLK <= 6'h02;
end
6'h05: // 64/6 = 9.55
@@ -1351,22 +1454,18 @@ begin
end
-
+//
+// This is the reset in which includes the MiSTer button, system reset, cold boot reset [frm EE_cold_bt].
+// Here we add the keyboard reset and turn it positive.
+//
assign RESET_P = !BUTTON_N[3] // Button
- | RESET; // CTRL-ALT-DEL or CTRL-ALT-INS
+ | RESET; // CTRL-ALT-DEL or CTRL-ALT-INS from Keyboard
-reg first_time = 1'b1;
-// Make sure all resets are enabled for a long enough time to allow voltages to settle
always @ (posedge clk_sys)
begin
if (RESET)
MUGS <= RESET_INS; //This is holding a across a reset to activate the Easter Egg
- if (first_time)
- begin
- MUGS <= 1'b0;
- first_time = 1'b0;
- end
end
always @ (posedge clk_sys or posedge RESET_P)
@@ -1383,12 +1482,16 @@ begin
begin
case (RESET_SM)
25'h0800000: // time = 143 mS
+ // Take away RESET_N
+ // Leave CPU_RESET Asserted
begin
RESET_N <= 1'b1;
CPU_RESET <= 1'b1;
RESET_SM <= RESET_SM + 1'b1;
end
25'h1000000: // time = 286 mS
+ // Take away RESET_N & CPU_RESET
+ // Stop RESET_SM count
begin
RESET_N <= 1'b1;
CPU_RESET <= 1'b0;
@@ -1644,32 +1747,31 @@ sdc_top coco_sdc_top(
reg cart_firq_enable;
reg firq_trig;
-reg [15:0] firq_tmr;
+reg cart_lock;
always @(negedge clk_sys or negedge RESET_N)
begin
if(!RESET_N)
begin
firq_trig <= 1'b0;
- firq_tmr <= 16'h0000;
cart_firq_enable <= 1'b1;
+ cart_lock <= 1'b0;
end
else
begin
- if (firq_trig)
- if (~(firq_tmr == 16'hffff))
- firq_tmr = firq_tmr + 1'b1;
- else
- cart_firq_enable <= SWITCH[4] & ~ioctl_download;
-
- if ((ioctl_index[5:0] == 6'd1) & ioctl_wr)
- begin
+ if ((ioctl_index[5:0] == 6'd1) & ioctl_download)
firq_trig <= 1'b1;
- firq_tmr <= 16'h0000;
- end
+
+ if (firq_trig)
+ if (!ioctl_download)
+ begin
+ cart_firq_enable <= 1'b0;
+ cart_lock <= 1'b1;
+ end
end
end
+
//***********************************************************************
// Interrupt Sources
//***********************************************************************
@@ -1685,13 +1787,11 @@ begin
if (PH_2)
case (MPI_SCS)
2'b00:
- CART_INT_IN_N <= (!CART_INT_IN_N )
- &(SER_IRQ);
+ CART_INT_IN_N <= (SER_IRQ);
2'b01:
CART_INT_IN_N <= (SER_IRQ);
2'b10:
- CART_INT_IN_N <= (!CART_INT_IN_N | cart_firq_enable)
- &(SER_IRQ);
+ CART_INT_IN_N <= (!CART_INT_IN_N | cart_firq_enable);
2'b11:
CART_INT_IN_N <= (SER_IRQ);
endcase
@@ -1717,90 +1817,92 @@ assign KEY_INT_N = (KEYBOARD_IN == 8'hFF);
//***********************************************************************
// Interrupt Latch RESETs
+// This code delays the asynchronus clears by 3 clocks to prevent race
+// condition of reading and clearing at the same time.
//***********************************************************************
+reg [2:0] RST_FF00_N_SFT, RST_FF02_N_SFT, RST_FF22_N_SFT, RST_FF92_N_SFT, RST_FF93_N_SFT;
+
+assign RST_FF00_N = RST_FF00_N_SFT[2];
+assign RST_FF02_N = RST_FF02_N_SFT[2];
+assign RST_FF22_N = RST_FF22_N_SFT[2];
+assign RST_FF92_N = RST_FF92_N_SFT[2];
+assign RST_FF93_N = RST_FF93_N_SFT[2];
+
+wire [7:0] FF93_Value;
+assign FF93_Value = {2'b00, !TIMER3_FIRQ_N, !HSYNC3_FIRQ_N, !VSYNC3_FIRQ_N, 1'b0, !KEY3_FIRQ_N, !CART3_FIRQ_N};
+
+
always @(negedge clk_sys or negedge RESET_N)
begin
if(!RESET_N)
begin
- RST_FF00_N <= 1'b1;
- RST_FF02_N <= 1'b1;
-// RST_FF20_N <= 1'b1;
- RST_FF22_N <= 1'b1;
- RST_FF92_N <= 1'b1;
- RST_FF93_N <= 1'b1;
- TMR_RST_N <= 1'b1;
+ RST_FF00_N_SFT <= 3'b111;
+ RST_FF02_N_SFT <= 3'b111;
+ RST_FF22_N_SFT <= 3'b111;
+ RST_FF92_N_SFT <= 3'b111;
+ RST_FF93_N_SFT <= 3'b111;
end
else
begin
+ RST_FF00_N_SFT[0] <= 1'b1;
+ RST_FF02_N_SFT[0] <= 1'b1;
+ RST_FF22_N_SFT[0] <= 1'b1;
+ RST_FF92_N_SFT[0] <= 1'b1;
+ RST_FF93_N_SFT[0] <= 1'b1;
+
+ RST_FF00_N_SFT[2:1] <= RST_FF00_N_SFT[1:0];
+ RST_FF02_N_SFT[2:1] <= RST_FF02_N_SFT[1:0];
+ RST_FF22_N_SFT[2:1] <= RST_FF22_N_SFT[1:0];
+ RST_FF92_N_SFT[2:1] <= RST_FF92_N_SFT[1:0];
+ RST_FF93_N_SFT[2:1] <= RST_FF93_N_SFT[1:0];
+
if (PH_2)
+ begin
+
case({RW_N,ADDRESS})
- 17'h1FF00:
- RST_FF00_N <= 1'b0;
- 17'h1FF04:
- RST_FF00_N <= 1'b0;
- 17'h1FF08:
- RST_FF00_N <= 1'b0;
- 17'h1FF0C:
- RST_FF00_N <= 1'b0;
- 17'h1FF10:
- RST_FF00_N <= 1'b0;
- 17'h1FF14:
- RST_FF00_N <= 1'b0;
- 17'h1FF18:
- RST_FF00_N <= 1'b0;
+ 17'h1FF00,
+ 17'h1FF04,
+ 17'h1FF08,
+ 17'h1FF0C,
+ 17'h1FF10,
+ 17'h1FF14,
+ 17'h1FF18,
17'h1FF1C:
- RST_FF00_N <= 1'b0;
- 17'h1FF02:
- RST_FF02_N <= 1'b0;
- 17'h1FF06:
- RST_FF02_N <= 1'b0;
- 17'h1FF0A:
- RST_FF02_N <= 1'b0;
- 17'h1FF0E:
- RST_FF02_N <= 1'b0;
- 17'h1FF12:
- RST_FF02_N <= 1'b0;
- 17'h1FF16:
- RST_FF02_N <= 1'b0;
- 17'h1FF1A:
- RST_FF02_N <= 1'b0;
+ RST_FF00_N_SFT[0] <= 1'b0;
+
+ 17'h1FF02,
+ 17'h1FF06,
+ 17'h1FF0A,
+ 17'h1FF0E,
+ 17'h1FF12,
+ 17'h1FF16,
+ 17'h1FF1A,
17'h1FF1E:
- RST_FF02_N <= 1'b0;
- 17'h1FF22:
- RST_FF22_N <= 1'b0;
- 17'h1FF26:
- RST_FF22_N <= 1'b0;
- 17'h1FF2A:
- RST_FF22_N <= 1'b0;
- 17'h1FF2E:
- RST_FF22_N <= 1'b0;
- 17'h0FF22:
- RST_FF22_N <= 1'b0;
- 17'h0FF26:
- RST_FF22_N <= 1'b0;
- 17'h0FF2A:
- RST_FF22_N <= 1'b0;
+ RST_FF02_N_SFT[0] <= 1'b0;
+
+ 17'h1FF22,
+ 17'h1FF26,
+ 17'h1FF2A,
+ 17'h1FF2E,
+ 17'h0FF22,
+ 17'h0FF26,
+ 17'h0FF2A,
17'h0FF2E:
- RST_FF22_N <= 1'b0;
+ RST_FF22_N_SFT[0] <= 1'b0;
+
17'h1FF92:
- RST_FF92_N <= 1'b0;
+ RST_FF92_N_SFT[0] <= 1'b0;
+
17'h1FF93:
- RST_FF93_N <= 1'b0;
- 17'h0FF94:
- TMR_RST_N <= 1'b0;
- 17'h0FF95:
- TMR_RST_N <= 1'b0;
- default:
- begin
- RST_FF00_N <= 1'b1;
- RST_FF02_N <= 1'b1;
-// RST_FF20_N <= 1'b1;
- RST_FF22_N <= 1'b1;
- RST_FF92_N <= 1'b1;
- RST_FF93_N <= 1'b1;
- TMR_RST_N <= 1'b1;
- end
+ begin
+ if (!(FF93_Value == 8'h00))
+ RST_FF93_N_SFT[0] <= 1'b0;
+ end
+
+ default:;
+
endcase
+ end
end
end
@@ -2116,6 +2218,7 @@ begin
end
end
+
// Timer int for COCO3
// Output TIMER3_FIRQ_N
// Status TIMER3_FIRQ_STAT_N
@@ -2350,18 +2453,22 @@ begin
end
-assign CPU_IRQ_N = ( GIME_IRQ | (HSYNC1_IRQ_N & VSYNC1_IRQ_N))
- & (!GIME_IRQ | (TIMER3_IRQ_N & HSYNC3_IRQ_N & VSYNC3_IRQ_N & KEY3_IRQ_N & CART3_IRQ_N));
-assign CPU_FIRQ_N = ( GIME_FIRQ | (CART1_FIRQ_N))
- & (!GIME_FIRQ | (TIMER3_FIRQ_N & HSYNC3_FIRQ_N & VSYNC3_FIRQ_N & KEY3_FIRQ_N & CART3_FIRQ_N));
+//assign CPU_IRQ_N = ( GIME_IRQ | (HSYNC1_IRQ_N & VSYNC1_IRQ_N))
+// & (!GIME_IRQ | (TIMER3_IRQ_N & HSYNC3_IRQ_N & VSYNC3_IRQ_N & KEY3_IRQ_N & CART3_IRQ_N));
+//assign CPU_FIRQ_N = ( GIME_FIRQ | (CART1_FIRQ_N))
+// & (!GIME_FIRQ | (TIMER3_FIRQ_N & HSYNC3_FIRQ_N & VSYNC3_FIRQ_N & KEY3_FIRQ_N & CART3_FIRQ_N));
+
+assign CPU_IRQ_N = HSYNC1_IRQ_N & VSYNC1_IRQ_N
+ & (!GIME_IRQ | (TIMER3_IRQ_N & HSYNC3_IRQ_N & VSYNC3_IRQ_N & CART3_IRQ_N));
+
+assign CPU_FIRQ_N = CART1_FIRQ_N
+ & (!GIME_FIRQ | (TIMER3_FIRQ_N & HSYNC3_FIRQ_N & VSYNC3_FIRQ_N & CART3_FIRQ_N));
+
// Timer
-//assign TMR_CLK = !TIMER_INS ? (!H_SYNC_N | !H_FLAG):
-// CLK3_57MHZ; // 50 MHz / 14 = 3.57 MHz
-assign TMR_CLK = !TIMER_INS ? !H_SYNC_N:
+assign TMR_CLK = !TIMER_INS ? HSYNC_INT_N:
CLK3_57MHZ; // 14.32Mhz... /4
-//assign CLK3_57MHZ = DIV_14;
reg [1:0] DIV_4;
reg CLK_14_D;
@@ -2391,52 +2498,148 @@ begin
end
end
+assign TMR_RESET_N = TMR_ENABLE[1]; // Already == 0 when RESET_N is 0
-
-always @(negedge clk_sys or negedge TMR_RST_N)
+always @ (negedge clk_sys or negedge RESET_N)
begin
- if(!TMR_RST_N)
- begin
- TIMER_INT_N <= 1'b1;
- BLINK <= 1'b1;
- TIMER <= 13'h1FFF;
- end
- else
- begin
- if (TMR_CLK == 1'b0 && TMR_CLK_D == 1'b1)
+ if(!RESET_N)
+ begin
+ TMR_ENABLE <= 2'b00;
+ end
+ else
+ begin
+ if(PH_2)
+ begin
+ case ({RW_N,ADDRESS})
+ 17'h0FF94:
+ begin
+ TMR_ENABLE <= 2'b01;
+ end
+ default:
+ begin
+ TMR_ENABLE <= {TMR_ENABLE[0],TMR_ENABLE[0]}; // This is a write
+ end
+ endcase
+ end
+ end
+end
+
+reg TIMER_LOAD;
+
+always @(negedge clk_sys or negedge TMR_RESET_N)
+begin
+ if(!TMR_RESET_N)
+ begin
+ TIMER_INT_N <= 1'b1;
+ BLINK <= 1'b0;
+ TIMER <= 13'h1FFF;
+ TIMER_LOAD <= 1'b1;
+ end
+ else
+ begin
+// This turns out being TIMER + 1 as in Sockmaster's GIME Reference 1987 GIME
+// 0 to TMR_MSB,TMR_LSB (0 to TMR_MSB,TMR_LSB is really counts + 1)
+
+ if (TIMER_LOAD)
begin
- if(!TMR_ENABLE)
- begin
- TIMER_INT_N <= 1'b1;
- BLINK <= 1'b1;
- TIMER <= 13'h1FFF;
- end
- else
- begin
- case (TIMER)
- 13'h0000:
- begin
- TIMER_INT_N <= 1'b0;
- BLINK <= !BLINK;
- TIMER <= 13'h1FFF;
- end
- 13'h1FFF: //Maybe this should be 1XXX
- begin
+ TIMER <= {1'b0,TMR_MSB,TMR_LSB};
+ TIMER_LOAD <= 1'b0;
+ end
+
+ if (TMR_CLK == 1'b0 && TMR_CLK_D == 1'b1)
+ begin
+ case (TIMER)
+ 13'h0000:
+ begin
+ if(({TMR_MSB,TMR_LSB} == 12'h000))
+ begin
+ TIMER_INT_N <= 1'b0;
+ TIMER <= 13'h0000;
+ BLINK <= 1'b0;
+ end
+ else
+ begin
+ TIMER_INT_N <= 1'b1;
+ TIMER <= {1'b0,TMR_MSB,TMR_LSB};
+ BLINK <= !BLINK;
+ end
+ end
+ 13'h0001:
+ begin
+ TIMER_INT_N <= 1'b0;
+ TIMER <= 13'h0000;
+ end
+ default:
+ begin
+ if(TIMER[12])
+ TIMER <= {1'b0,TMR_MSB,TMR_LSB};
+ else
+ TIMER <= TIMER - 1'b1;
+ end
+ endcase
+ end
+ end
+end
+
+
+
+//reg TIMER_LOAD;
+
+//always @(negedge clk_sys or negedge TMR_RESET_N)
+//begin
+// if(!TMR_RESET_N)
+// begin
+// TIMER_INT_N <= 1'b1;
+// BLINK <= 1'b0;
+// TIMER <= 13'h1FFF;
+// TIMER_LOAD <= 1'b1;
+// end
+// else
+// begin
+
// This turns out being TIMER + 2 as in Sockmaster's GIME Reference 1986 GIME
// 0 to TIMER-1 (0 to TIMER is really TIMER counts + 1)
// This timer goes from 0 directly to 1FFF where it loads the timer count and decrements from there
// So 1FFF to TIMER to 0 is TIMER + 2 counts
- TIMER_INT_N <= 1'b1;
- if({TMR_MSB,TMR_LSB} != 12'h000)
- TIMER <= {1'b0,TMR_MSB,TMR_LSB};
- end
- default:
- TIMER <= TIMER - 1'b1;
- endcase
- end
- end
- end
-end
+
+// if (TIMER_LOAD)
+// begin
+// TIMER <= {1'b0,TMR_MSB,TMR_LSB};
+// TIMER_LOAD <= 1'b0;
+// end
+
+// if (!TIMER_INT_N)
+// begin
+// TIMER_INT_N <= 1'b1;
+// TIMER <= {1'b0,TMR_MSB,TMR_LSB};
+// end
+
+// if (TMR_CLK == 1'b0 && TMR_CLK_D == 1'b1)
+// begin
+
+// case (TIMER)
+// 13'h0000:
+// begin
+// if(({TMR_MSB,TMR_LSB} == 12'h000))
+// begin
+// TIMER_INT_N <= 1'b0;
+// TIMER <= 13'h0000;
+// BLINK <= 1'b0;
+// end
+// else
+// begin
+// TIMER_INT_N <= 1'b0;
+// BLINK <= !BLINK;
+// end
+// end
+// default:
+// begin
+// TIMER <= TIMER - 1'b1;
+// end
+// endcase
+// end
+// end
+//end
reg sync_rst1;
@@ -2517,7 +2720,6 @@ begin
CART3_FIRQ_INT <= 1'b0;
// FF94
TMR_MSB <= 4'h0;
- TMR_ENABLE <= 1'b0;
// FF95
TMR_LSB <= 8'h00;
// FF98
@@ -2824,7 +3026,6 @@ begin
16'hFF94:
begin
TMR_MSB <= DATA_OUT[3:0];
- TMR_ENABLE <= 1'b1;
end
16'hFF95:
begin
@@ -3635,7 +3836,7 @@ begin
// RED[3:0] <= 4'B0000;
// GREEN[3:0] <= 4'B0000;
// BLUE[3:0] <= 4'B0000;
- VGA_SYNC_N <= 1'b1;
+// VGA_SYNC_N <= 1'b1;
MISTER_HBLANK_D[3] <= ~HBORDER;
MISTER_HBLANK_D[2:0] <= MISTER_HBLANK_D[3:1];
diff --git a/rtl/config.v b/rtl/config.sv
similarity index 67%
rename from rtl/config.v
rename to rtl/config.sv
index 312e384..f4fae05 100644
--- a/rtl/config.v
+++ b/rtl/config.sv
@@ -61,23 +61,47 @@
// This file is a configuration definition file. The CoCo3FPGA for MiSTer source files
// can be built into multiple objects which have mutually exclusive features.
-`include "../RTL/config_inc.v"
+`define Config_Debug_FLAG 4'hA
+localparam [7:0] FEATURE_1 = 8'h01;
+localparam [7:0] FEATURE_2 = 8'h02;
+localparam [7:0] FEATURE_3 = 8'h04;
+localparam [7:0] FEATURE_4 = 8'h08;
+localparam [7:0] FEATURE_5 = 8'h10;
+localparam [7:0] FEATURE_6 = 8'h20;
+localparam [7:0] FEATURE_7 = 8'h40;
+localparam [7:0] FEATURE_8 = 8'h80;
-// If defined the Config_Debug sets the FEATURE MASKS all OR'd together which appears on COCO space at FFF1 & (FFF0 = 0x55 as a debug flag)
-//`define Config_Debug
+// This is used for hardware debugging - it overrides the USER_IO to be user_out direct.
+// It should be commented out for release
+//`define Config_Debug
// Feature list - note only FEATURE_1 - FEATURE_8 are supported
///////////////////////////////////////////////////////////////////////////////////////////////////////////
-`set_feature(CoCo3_Horz_INT_FIX, FEATURE_1) // Connection of the horz int to the Mister CoCo3 V5 rasterizer
+// `set_feature(CoCo3_Horz_INT_FIX,Feat_1) // Connection of the horz int to the Mister CoCo3 V5 rasterizer
+ `define CoCo3_Horz_INT_FIX
+ `define Feat_1
-//`set_feature(CoCo3_Vert_INT_FIX, FEATURE_2) // Connection of the vert int to the Mister CoCo3 V5 rasterizer
+// `set_feature(CoCo3_Vert_INT_FIX,Feat_2) // Connection of the vert int to the Mister CoCo3 V5 rasterizer
+// `define CoCo3_Vert_INT_FIX
+// `define Feat_2
-`set_feature(CoCo3_CYC_ACC_6809, FEATURE_3) // Use cycle accurate 6809
+// `set_feature(CoCo3_CYC_ACC_6809,Feat_3) // Use cycle accurate 6809
+ `define CoCo3_CYC_ACC_6809
+ `define Feat_3
-`set_feature(CoCo3_sdc_override_size, FEATURE_4) // Define static size value
+// `set_feature(CoCo3_sdc_override_size,Feat_4) // Define static size value
+ `define CoCo3_sdc_override_size
+ `define Feat_4
-`set_feature(CoCo3_sdc_fix_os9_driver, FEATURE_5) // fix sdc query disk size issue in llcocosdc driver in multipak enviroment
+// `set_feature(CoCo3_sdc_fix_os9_driver,Feat_5) // fix sdc query disk size issue in llcocosdc driver in multipak enviroment
+ `define CoCo3_sdc_fix_os9_driver
+ `define Feat_5
-`set_feature(CoCo3_disable_GART_in_GIMEX, FEATURE_6)// Disable GIMEX ram transfers [GIMEX detection in OS( EOU]
+// `set_feature(CoCo3_disable_GART_in_GIMEX,Feat_6) // Disable GIMEX ram transfers [GIMEX detection in OS9 EOU]
+ `define CoCo3_disable_GART_in_GIMEX
+ `define Feat_6
+
+// `set_feature(CoCo3_Select_GIMEX_RAST,Feat_7) // Use GIMEX Rasterizer Engine
+// `define CoCo3_Select_GIMEX_RAST
+// `define Feat_7
-//`set_feature(CoCo3_Select_GIMEX_RAST, FEATURE_7) // Use GIMEX Rasterizer Engine
diff --git a/rtl/config_inc.v b/rtl/config_inc.v
deleted file mode 100644
index 3daf7f6..0000000
--- a/rtl/config_inc.v
+++ /dev/null
@@ -1,123 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-// Project Name: CoCo3FPGA Version 5.x.x
-// File Name: config_inc.v
-//
-// CoCo3 in an FPGA
-//
-////////////////////////////////////////////////////////////////////////////////
-//
-// CPU section copyrighted by John Kent
-//
-////////////////////////////////////////////////////////////////////////////////
-//
-// Color Computer 3 compatible system on a chip
-//
-// Version : 5.x
-//
-// Copyright (c) 2008 Gary Becker (gary_l_becker@yahoo.com)
-//
-// All rights reserved
-//
-// Redistribution and use in source and synthezised forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// Redistributions in synthesized form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-//
-// Neither the name of the author nor the names of other contributors may
-// be used to endorse or promote products derived from this software without
-// specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//
-// Please report bugs to the author, but before you do so, please
-// make sure that this is not a derivative work and that
-// you have the latest version of this file.
-//
-////////////////////////////////////////////////////////////////////////////////
-// Gary Becker
-// gary_L_becker@yahoo.com
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-// MISTer Conversion by Stan Hodge and Alan Steremberg (& Gary Becker)
-// stan.pda@gmail.com
-//
-////////////////////////////////////////////////////////////////////////////////
-
-// This file is a configuration definition include file. The CoCo3FPGA for MiSTer source files
-// can be built into multiple objects which have mutually exclusive features.
-
-`define Config_Debug_Value (`config_num_1 | `config_num_2 | `config_num_3 | `config_num_4 | `config_num_5 | `config_num_6 | `config_num_7 | `config_num_8)
-`define Config_Debug_FLAG 8'h55
-`define FEATURE_1 8'h01
-`define FEATURE_2 8'h02
-`define FEATURE_3 8'h04
-`define FEATURE_4 8'h08
-`define FEATURE_5 8'h10
-`define FEATURE_6 8'h20
-`define FEATURE_7 8'h40
-`define FEATURE_8 8'h80
-`define config_num_1 8'h00
-`define config_num_2 8'h00
-`define config_num_3 8'h00
-`define config_num_4 8'h00
-`define config_num_5 8'h00
-`define config_num_6 8'h00
-`define config_num_7 8'h00
-`define config_num_8 8'h00
-
-`define set_feature(Feat_Name, Feat_Mask) \
-`define Feat_Name \
-`ifndef config_value_1 \
- `define config_value_1 Feat_Mask \
- `define config_num_1 Feat_Mask \
-`else \
- `ifndef config_value_2 \
- `define config_value_2 Feat_Mask \
- `define config_num_2 Feat_Mask \
- `else \
- `ifndef config_value_3 \
- `define config_value_3 Feat_Mask \
- `define config_num_3 Feat_Mask \
- `else \
- `ifndef config_value_4 \
- `define config_value_4 Feat_Mask \
- `define config_num_4 Feat_Mask \
- `else \
- `ifndef config_value_5 \
- `define config_value_5 Feat_Mask \
- `define config_num_5 Feat_Mask \
- `else \
- `ifndef config_value_6 \
- `define config_value_6 Feat_Mask \
- `define config_num_6 Feat_Mask \
- `else \
- `ifndef config_value_7 \
- `define config_value_7 Feat_Mask \
- `define config_num_7 Feat_Mask \
- `else \
- `ifndef config_value_8 \
- `define config_value_8 Feat_Mask \
- `define config_num_8 Feat_Mask \
- `endif \
- `endif \
- `endif \
- `endif \
- `endif \
- `endif \
- `endif \
-`endif
diff --git a/rtl/fdc.sv b/rtl/fdc.sv
index 4a9b8a0..4aff17e 100644
--- a/rtl/fdc.sv
+++ b/rtl/fdc.sv
@@ -135,6 +135,10 @@ wire [3:0] DRIVE_SEL_EXT_PRE = {DATA_IN[6], DATA_IN[2:0]};
reg [2:0] drive_index;
// SD blk system is a array of 4 systems - one for each drive.
+// To keep disk track memory, we created 4 wd1793's to match the sd block interfaces
+// For the interface back to the coco - we need to isolate the wd1793 the computer is talking
+// to and route those feedback signals back to the coco. This is accomplished via the drive
+// select. 'drive_index' identifies which controller is addressd.
always @(negedge FF40_CLK or negedge RESET_N)
@@ -178,7 +182,7 @@ begin
4'b1001:
drive_index <= 3'd1;
default:
- drive_index <= 3'd0; // Illegal
+ drive_index <= 3'd1; // Illegal
endcase
end
end
@@ -208,12 +212,13 @@ wire DRQ[4];
wire selected_DRQ;
wire selected_INTRQ;
-wire WR;
-wire RD;
-wire RD_E;
+wire WR[4];
+wire RD[4];
+wire RD_E[4];
//wire CE;
wire HALT_EN_RST;
wire [7:0] DATA_1793;
+wire [7:0] dout[4];
reg read;
reg write;
reg read_d;
@@ -225,7 +230,11 @@ reg read1;
reg write1;
reg [1:0] ADDRESS_L;
-assign RD = read || RD_E;
+
+assign RD[0] = (read || RD_E[0]) && (drive_index == 2'd1);
+assign RD[1] = (read || RD_E[1]) && (drive_index == 3'd2);
+assign RD[2] = (read || RD_E[2]) && (drive_index == 3'd3);
+assign RD[3] = (read || RD_E[3]) && (drive_index == 3'd4);
// The idea here is to "stretch" the CPU read and write signals to ensure we catch a 8 mhz enable.
// For writes we will buffer the data out to ensure it does not go away.
@@ -244,8 +253,14 @@ begin
write_d <= 1'b0;
r_w_active <= 1'b0;
clk_8Mhz_enable_found <= 1'b0;
- WR <= 1'b0;
- RD_E <= 1'b0;
+ WR[0] <= 1'b0;
+ WR[1] <= 1'b0;
+ WR[2] <= 1'b0;
+ WR[3] <= 1'b0;
+ RD_E[0] <= 1'b0;
+ RD_E[1] <= 1'b0;
+ RD_E[2] <= 1'b0;
+ RD_E[3] <= 1'b0;
read1 <= 1'b0;
write1 <= 1'b0;
read <= 1'b0;
@@ -278,14 +293,32 @@ begin
begin
// Set Writes
r_w_active <= 1'b1;
- WR <= 1'b1;
+ case (drive_index)
+ 3'd1:
+ WR[0] <= 1'b1;
+ 3'd2:
+ WR[1] <= 1'b1;
+ 3'd3:
+ WR[2] <= 1'b1;
+ 3'd4:
+ WR[3] <= 1'b1;
+ endcase
end
// Synchronus rising edge of read
if ((read == 1'b1) && (read_d == 1'b0))
begin
r_w_active <= 1'b1;
- RD_E <= 1'b1;
+ case (drive_index)
+ 3'd1:
+ RD_E[0] <= 1'b1;
+ 3'd2:
+ RD_E[1] <= 1'b1;
+ 3'd3:
+ RD_E[2] <= 1'b1;
+ 3'd4:
+ RD_E[3] <= 1'b1;
+ endcase
end
// Clears
@@ -298,54 +331,48 @@ begin
clk_8Mhz_enable_found <= 1'b0;
r_w_active <= 1'b0;
- WR <= 1'b0;
+ WR[0] <= 1'b0;
+ WR[1] <= 1'b0;
+ WR[2] <= 1'b0;
+ WR[3] <= 1'b0;
- RD_E <= 1'b0;
+ RD_E[0] <= 1'b0;
+ RD_E[1] <= 1'b0;
+ RD_E[2] <= 1'b0;
+ RD_E[3] <= 1'b0;
end
end
end
-
+// NMI from disk controller
+// Selected INTRQ
+assign selected_INTRQ = (drive_index == 3'd1) ? INTRQ[0]:
+ (drive_index == 3'd2) ? INTRQ[1]:
+ (drive_index == 3'd3) ? INTRQ[2]:
+ (drive_index == 3'd4) ? INTRQ[3]:
+ 1'b0;
assign NMI_09 = DENSITY & selected_INTRQ; // Send NMI if Double Density (Halt Mode)
+// HALT from disk controller
+// Selected DRQ
+assign selected_DRQ = (drive_index == 3'd1) ? DRQ[0]:
+ (drive_index == 3'd2) ? DRQ[1]:
+ (drive_index == 3'd3) ? DRQ[2]:
+ (drive_index == 3'd4) ? DRQ[3]:
+ 1'b1;
+
+
assign HALT = (HALT_EN & ~selected_DRQ);
assign HALT_EN_RST = RESET_N & ~selected_INTRQ; // From controller schematic
-assign sd_lba[0] = wd1793_sd_lba;
-assign sd_lba[1] = wd1793_sd_lba;
-assign sd_lba[2] = wd1793_sd_lba;
-assign sd_lba[3] = wd1793_sd_lba;
-
-assign sd_rd[0] = (drive_index == 3'd1) ? wd1793_sd_rd:
- 1'b0;
-assign sd_rd[1] = (drive_index == 3'd2) ? wd1793_sd_rd:
- 1'b0;
-assign sd_rd[2] = (drive_index == 3'd3) ? wd1793_sd_rd:
- 1'b0;
-assign sd_rd[3] = (drive_index == 3'd4) ? wd1793_sd_rd:
- 1'b0;
-
-assign sd_wr[0] = (drive_index == 3'd1) ? wd1793_sd_wr:
- 1'b0;
-assign sd_wr[1] = (drive_index == 3'd2) ? wd1793_sd_wr:
- 1'b0;
-assign sd_wr[2] = (drive_index == 3'd3) ? wd1793_sd_wr:
- 1'b0;
-assign sd_wr[3] = (drive_index == 3'd4) ? wd1793_sd_wr:
- 1'b0;
-
-assign wd1793_sd_ack = (drive_index == 3'd1) ? sd_ack[0]:
- (drive_index == 3'd2) ? sd_ack[1]:
- (drive_index == 3'd3) ? sd_ack[2]:
- (drive_index == 3'd4) ? sd_ack[3]:
- sd_ack[0]; // default is drive 1
-
-assign sd_buff_din[0] = wd1793_sd_buff_din;
-assign sd_buff_din[1] = wd1793_sd_buff_din;
-assign sd_buff_din[2] = wd1793_sd_buff_din;
-assign sd_buff_din[3] = wd1793_sd_buff_din;
+// Data bus selection
+assign DATA_1793 = (drive_index == 3'd1) ? dout[0]:
+ (drive_index == 3'd2) ? dout[1]:
+ (drive_index == 3'd3) ? dout[2]:
+ (drive_index == 3'd4) ? dout[3]:
+ 8'd0;
// The SD_BLK interface and thus the wd1793 will allways transfer 1 blk. This is blk qty - 1 per spec.
@@ -358,13 +385,6 @@ reg drive_wp[4];
reg [3:0] drive_ready = 4'B0000;
reg [3:0] double_sided = 4'B0000;
reg [23:0] drive_size[4];
-wire [23:0] selected_drive_size;
-wire [31:0] wd1793_sd_lba;
-wire wd1793_sd_rd;
-wire wd1793_sd_wr;
-wire wd1793_sd_ack;
-wire [7:0] wd1793_sd_buff_din;
-wire selected_drive_ready, selected_drive_wp, selected_double_sided;
// As drives are mounted in MISTer this logic saves the write protect and generates ready for
@@ -413,28 +433,6 @@ begin
//double_sided[3]<= img_size > 20'd368600;//20'd368640;
end
-assign selected_drive_size = (drive_index == 3'd1) ? drive_size[0]:
- (drive_index == 3'd2) ? drive_size[1]:
- (drive_index == 3'd3) ? drive_size[2]:
- (drive_index == 3'd4) ? drive_size[3]:
- drive_size[0]; // default is drive 1
-
-assign selected_drive_wp = (drive_index == 3'd1) ? drive_wp[0]:
- (drive_index == 3'd2) ? drive_wp[1]:
- (drive_index == 3'd3) ? drive_wp[2]:
- (drive_index == 3'd4) ? drive_wp[3]:
- drive_wp[0]; // default is drive 1
-
-assign selected_double_sided= (drive_index == 3'd1) ? double_sided[0]:
- (drive_index == 3'd2) ? double_sided[1]:
- (drive_index == 3'd3) ? double_sided[2]:
- double_sided[0]; // default is drive 1
-
-assign selected_drive_ready = (drive_index == 3'd1) ? drive_ready[0]:
- (drive_index == 3'd2) ? drive_ready[1]:
- (drive_index == 3'd3) ? drive_ready[2]:
- (drive_index == 3'd4) ? drive_ready[3]:
- 1'b0; // default is not ready
wd1793 #(1,0) coco_wd1793_0
(
@@ -442,34 +440,160 @@ wd1793 #(1,0) coco_wd1793_0
.ce(ena_8Mhz),
.reset(~RESET_N),
.io_en(1'b1),
- .rd(RD),
- .wr(WR),
+ .rd(RD[0]),
+ .wr(WR[0]),
.addr(ADDRESS_L[1:0]),
.din(DATA_IN_L),
- .dout(DATA_1793),
- .drq(selected_DRQ),
- .intrq(selected_INTRQ),
+ .dout(dout[0]),
+ .drq(DRQ[0]),
+ .intrq(INTRQ[0]),
.img_mounted(1'b0),
.img_mounted_overide(1'b1),
- .img_size(selected_drive_size[19:0]),
+ .img_size(drive_size[0]),
- .sd_lba(wd1793_sd_lba),
- .sd_rd(wd1793_sd_rd),
- .sd_wr(wd1793_sd_wr),
- .sd_ack(wd1793_sd_ack),
+ .sd_lba(sd_lba[0]),
+ .sd_rd(sd_rd[0]),
+ .sd_wr(sd_wr[0]),
+ .sd_ack(sd_ack[0]),
.sd_buff_addr(sd_buff_addr),
.sd_buff_dout(sd_buff_dout),
- .sd_buff_din(wd1793_sd_buff_din),
+ .sd_buff_din(sd_buff_din[0]),
.sd_buff_wr(sd_buff_wr),
- .wp(selected_drive_wp),
+ .wp(drive_wp[0]),
.size_code(3'd5), // 5 is 18 sector x 256 bits COCO standard
- .layout(~selected_double_sided), // 0 = Track-Side-Sector, 1 - Side-Track-Sector
- .side(selected_double_sided & DRIVE_SEL_EXT[3]),
- .ready(selected_drive_ready),
+ .layout(~double_sided[0]), // 0 = Track-Side-Sector, 1 - Side-Track-Sector
+ .side(double_sided[0] & DRIVE_SEL_EXT[3]),
+ .ready(drive_ready[0]),
+
+ .input_active(0), // Section not used
+ .input_addr(0),
+ .input_data(0),
+ .input_wr(0),
+ .buff_din(0)
+);
+
+wd1793 #(1,0) coco_wd1793_1
+(
+ .clk_sys(~CLK),
+ .ce(ena_8Mhz),
+ .reset(~RESET_N),
+ .io_en(1'b1),
+ .rd(RD[1]),
+ .wr(WR[1]),
+ .addr(ADDRESS_L[1:0]),
+ .din(DATA_IN_L),
+ .dout(dout[1]),
+ .drq(DRQ[1]),
+ .intrq(INTRQ[1]),
+
+ .img_mounted(1'b0),
+ .img_mounted_overide(1'b1),
+ .img_size(drive_size[1]),
+
+ .sd_lba(sd_lba[1]),
+ .sd_rd(sd_rd[1]),
+ .sd_wr(sd_wr[1]),
+ .sd_ack(sd_ack[1]),
+
+ .sd_buff_addr(sd_buff_addr),
+ .sd_buff_dout(sd_buff_dout),
+ .sd_buff_din(sd_buff_din[1]),
+ .sd_buff_wr(sd_buff_wr),
+
+ .wp(drive_wp[1]),
+
+ .size_code(3'd5), // 5 is 18 sector x 256 bits COCO standard
+ .layout(~double_sided[1]), // 0 = Track-Side-Sector, 1 - Side-Track-Sector
+ .side(double_sided[1] & DRIVE_SEL_EXT[3]),
+ .ready(drive_ready[1]),
+
+ .input_active(0), // Section not used
+ .input_addr(0),
+ .input_data(0),
+ .input_wr(0),
+ .buff_din(0)
+);
+
+wd1793 #(1,0) coco_wd1793_2
+(
+ .clk_sys(~CLK),
+ .ce(ena_8Mhz),
+ .reset(~RESET_N),
+ .io_en(1'b1),
+ .rd(RD[2]),
+ .wr(WR[2]),
+ .addr(ADDRESS_L[1:0]),
+ .din(DATA_IN_L),
+ .dout(dout[2]),
+ .drq(DRQ[2]),
+ .intrq(INTRQ[2]),
+
+ .img_mounted(1'b0),
+ .img_mounted_overide(1'b1),
+ .img_size(drive_size[2]),
+
+ .sd_lba(sd_lba[2]),
+ .sd_rd(sd_rd[2]),
+ .sd_wr(sd_wr[2]),
+ .sd_ack(sd_ack[2]),
+
+ .sd_buff_addr(sd_buff_addr),
+ .sd_buff_dout(sd_buff_dout),
+ .sd_buff_din(sd_buff_din[2]),
+ .sd_buff_wr(sd_buff_wr),
+
+ .wp(drive_wp[2]),
+
+ .size_code(3'd5), // 5 is 18 sector x 256 bits COCO standard
+ .layout(~double_sided[2]), // 0 = Track-Side-Sector, 1 - Side-Track-Sector
+ .side(double_sided[2] & DRIVE_SEL_EXT[3]),
+ .ready(drive_ready[2]),
+
+ .input_active(0), // Section not used
+ .input_addr(0),
+ .input_data(0),
+ .input_wr(0),
+ .buff_din(0)
+);
+
+wd1793 #(1,0) coco_wd1793_3
+(
+ .clk_sys(~CLK),
+ .ce(ena_8Mhz),
+ .reset(~RESET_N),
+ .io_en(1'b1),
+ .rd(RD[3]),
+ .wr(WR[3]),
+ .addr(ADDRESS_L[1:0]),
+ .din(DATA_IN_L),
+ .dout(dout[3]),
+ .drq(DRQ[3]),
+ .intrq(INTRQ[3]),
+
+ .img_mounted(1'b0),
+ .img_mounted_overide(1'b1),
+ .img_size(drive_size[3]),
+
+ .sd_lba(sd_lba[3]),
+ .sd_rd(sd_rd[3]),
+ .sd_wr(sd_wr[3]),
+ .sd_ack(sd_ack[3]),
+
+ .sd_buff_addr(sd_buff_addr),
+ .sd_buff_dout(sd_buff_dout),
+ .sd_buff_din(sd_buff_din[3]),
+ .sd_buff_wr(sd_buff_wr),
+
+ .wp(drive_wp[3]),
+
+ .size_code(3'd5), // 5 is 18 sector x 256 bits COCO standard
+ .layout(1'b1), // 0 = Track-Side-Sector, 1 - Side-Track-Sector
+ .side(1'b0),
+ .ready(drive_ready[3]),
.input_active(0), // Section not used
.input_addr(0),
diff --git a/rtl/sdc.sv b/rtl/sdc.sv
index 4768e12..4335f54 100644
--- a/rtl/sdc.sv
+++ b/rtl/sdc.sv
@@ -47,8 +47,6 @@
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
-// Define Config features
-`include "../RTL/config.v"
module sdc(
input CLK, // clock
@@ -89,6 +87,9 @@ module sdc(
);
+// Define Config features
+`include "../rtl/config.sv"
+
reg [23:0] LSN;
reg [7:0] command;
reg [7:0] transfer_address;
diff --git a/rtl/sdc_top.sv b/rtl/sdc_top.sv
index 0f4362e..b9c9d46 100644
--- a/rtl/sdc_top.sv
+++ b/rtl/sdc_top.sv
@@ -146,54 +146,27 @@ assign DATA_HDD =
wire [31:0] sdc_sd_lba[2];
wire [31:0] fdc_sd_lba[2];
-wire [31:0] wd1793_sd_lba;
wire [1:0] sdc_sd_rd;
-wire wd1793_sd_rd;
wire [1:0] fdc_sd_rd;
wire [1:0] sdc_sd_wr;
wire [1:0] fdc_sd_wr;
-wire wd1793_sd_wr;
wire [7:0] sdc_sd_buff_din[2];
wire [7:0] fdc_sd_buff_din[2];
wire [7:0] wd1793_sd_buff_din;
-wire wd1793_sd_ack;
wire sdc_HALT;
assign sd_lba[0:1] = SDC_EN ? sdc_sd_lba[0:1]:
fdc_sd_lba[0:1];
-assign fdc_sd_lba[0] = wd1793_sd_lba;
-assign fdc_sd_lba[1] = wd1793_sd_lba;
-
assign sd_rd[1:0] = SDC_EN ? sdc_sd_rd[1:0]:
fdc_sd_rd[1:0];
-assign fdc_sd_rd[0] = (drive_index == 3'd1) ? wd1793_sd_rd:
- 1'b0;
-
-assign fdc_sd_rd[1] = (drive_index == 3'd2) ? wd1793_sd_rd:
- 1'b0;
-
assign sd_wr[1:0] = SDC_EN ? sdc_sd_wr[1:0]:
fdc_sd_wr[1:0];
-assign fdc_sd_wr[0] = (drive_index == 3'd1) ? wd1793_sd_wr:
- 1'b0;
-
-assign fdc_sd_wr[1] = (drive_index == 3'd2) ? wd1793_sd_wr:
- 1'b0;
-
assign sd_buff_din[0:1] = SDC_EN ? sdc_sd_buff_din[0:1]:
fdc_sd_buff_din[0:1];
-assign fdc_sd_buff_din[0] = wd1793_sd_buff_din;
-assign fdc_sd_buff_din[1] = wd1793_sd_buff_din;
-
-
-assign wd1793_sd_ack = (drive_index == 3'd1) ? sd_ack[0]:
- (drive_index == 3'd2) ? sd_ack[1]:
- sd_ack[0]; // default is drive 1
-
sdc coco_sdc(
.CLK(CLK), // clock
@@ -277,13 +250,13 @@ begin
drive_index <= 3'd1;
4'b1011: // This is what the Magic Number $43 does so we select a non-active drive
- drive_index <= 3'd0;
+ drive_index <= 3'd1;
4'b1000: // This is no drive with DS = illegal drive
- drive_index <= 3'd0;
+ drive_index <= 3'd1;
4'b0000: // This is no drive (maybe 0 in ff40) = illegal drive
- drive_index <= 3'd0;
+ drive_index <= 3'd1;
default:
- drive_index <= 3'd0;
+ drive_index <= 3'd1;
endcase
end
end
@@ -310,14 +283,17 @@ end
// Control signals for the wd1793
+wire INTRQ[2];
+wire DRQ[2];
wire selected_DRQ;
wire selected_INTRQ;
-wire WR;
-wire RD;
-wire RD_E;
+wire WR[2];
+wire RD[2];
+wire RD_E[2];
wire HALT_EN_RST;
wire [7:0] DATA_1793;
+wire [7:0] dout[2];
reg read;
reg write;
reg read_d;
@@ -329,7 +305,8 @@ reg read1;
reg write1;
reg [1:0] ADDRESS_L;
-assign RD = (read || RD_E); // Even with no drive selected allow read to the controller
+assign RD[0] = (read || RD_E[0]) && (drive_index == 2'd1);
+assign RD[1] = (read || RD_E[1]) && (drive_index == 3'd2);
// The idea here is to "stretch" the CPU read and write signals to ensure we catch a 8 mhz enable.
// For writes we will buffer the data out to ensure it does not go away.
@@ -350,8 +327,10 @@ begin
write_d <= 1'b0;
r_w_active <= 1'b0;
clk_8Mhz_enable_found <= 1'b0;
- WR <= 1'b0;
- RD_E <= 1'b0;
+ WR[0] <= 1'b0;
+ WR[1] <= 1'b0;
+ RD_E[0] <= 1'b0;
+ RD_E[1] <= 1'b0;
read1 <= 1'b0;
write1 <= 1'b0;
read <= 1'b0;
@@ -383,14 +362,24 @@ begin
begin
// Set Write
r_w_active <= 1'b1;
- WR <= 1'b1;
+ case (drive_index)
+ 3'd1:
+ WR[0] <= 1'b1;
+ 3'd2:
+ WR[1] <= 1'b1;
+ endcase
end
// Synchronus rising edge of read
if ((read == 1'b1) && (read_d == 1'b0))
begin
r_w_active <= 1'b1;
- RD_E <= 1'b1;
+ case (drive_index)
+ 3'd1:
+ RD_E[0] <= 1'b1;
+ 3'd2:
+ RD_E[1] <= 1'b1;
+ endcase
end
// Clears
@@ -402,23 +391,42 @@ begin
begin
clk_8Mhz_enable_found <= 1'b0;
r_w_active <= 1'b0;
- WR <= 1'b0;
- RD_E <= 1'b0;
+ WR[0] <= 1'b0;
+ WR[1] <= 1'b0;
+
+ RD_E[0] <= 1'b0;
+ RD_E[1] <= 1'b0;
end
end
end
// NMI from disk controller
+// Selected INTRQ
+assign selected_INTRQ = (drive_index == 3'd1) ? INTRQ[0]:
+ (drive_index == 3'd2) ? INTRQ[1]:
+ 1'b0;
assign NMI_09 = ~SDC_EN & DENSITY & selected_INTRQ; // Send NMI if Double Density (Halt Mode)
+
+
// HALT from disk controller
+// Selected DRQ
+assign selected_DRQ = (drive_index == 3'd1) ? DRQ[0]:
+ (drive_index == 3'd2) ? DRQ[1]:
+ 1'b1;
+
assign HALT = (~SDC_EN & HALT_EN & ~selected_DRQ) | sdc_HALT;
assign HALT_EN_RST = RESET_N & ~selected_INTRQ; // From controller schematic
+// Data bus selection
+assign DATA_1793 = (drive_index == 3'd1) ? dout[0]:
+ (drive_index == 3'd2) ? dout[1]:
+ 8'd0;
+
// The SD_BLK interface and thus the wd1793 will allways transfer 1 blk. This is blk qty - 1 per spec.
assign sd_blk_cnt[1] = 6'd0;
@@ -428,8 +436,6 @@ reg drive_wp[2];
reg [1:0] drive_ready = 2'b00;
reg [1:0] double_sided = 2'b00;
reg [31:0] drive_size[2];
-wire [31:0] selected_drive_size;
-wire selected_drive_ready, selected_drive_wp, selected_double_sided;
// As drives are mounted in MISTer this logic saves the write protect and generates ready for
// changing drives to the wd1793.
@@ -457,56 +463,83 @@ begin
double_sided[1]<= (img_size > 64'd368600) & (img_size < 64'd740000);//20'd368640;
end
-assign selected_drive_size = (drive_index == 3'd1) ? drive_size[0]:
- (drive_index == 3'd2) ? drive_size[1]:
- drive_size[0]; // default is drive 1
-assign selected_drive_wp = (drive_index == 3'd1) ? drive_wp[0]:
- (drive_index == 3'd2) ? drive_wp[1]:
- drive_wp[0]; // default is drive 1
-
-assign selected_double_sided= (drive_index == 3'd1) ? double_sided[0]:
- (drive_index == 3'd2) ? double_sided[1]:
- double_sided[0]; // default is drive 1
-
-assign selected_drive_ready = (drive_index == 3'd1) ? drive_ready[0]:
- (drive_index == 3'd2) ? drive_ready[1]:
- drive_ready[0]; // default is drive 1
-
-wd1793 #(1,0) coco_wd1793_sdc
+wd1793 #(1,0) coco_wd1793_sdc_0
(
.clk_sys(~CLK),
.ce(ena_8Mhz),
.reset(~RESET_N),
.io_en(1'b1),
- .rd(RD),
- .wr(WR),
+ .rd(RD[0]),
+ .wr(WR[0]),
.addr(ADDRESS_L[1:0]),
.din(DATA_IN_L),
- .dout(DATA_1793),
- .drq(selected_DRQ),
- .intrq(selected_INTRQ),
+ .dout(dout[0]),
+ .drq(DRQ[0]),
+ .intrq(INTRQ[0]),
.img_mounted(1'b0), // Not used when using _override
.img_mounted_overide(1'b1), // Load img_size and layout on each clock
- .img_size(selected_drive_size[19:0]),
+ .img_size(drive_size[0]),
- .sd_lba(wd1793_sd_lba),
- .sd_rd(wd1793_sd_rd),
- .sd_wr(wd1793_sd_wr),
- .sd_ack(wd1793_sd_ack),
+ .sd_lba(fdc_sd_lba[0]),
+ .sd_rd(fdc_sd_rd[0]),
+ .sd_wr(fdc_sd_wr[0]),
+ .sd_ack(sd_ack[0]),
.sd_buff_addr(sd_buff_addr),
.sd_buff_dout(sd_buff_dout),
- .sd_buff_din(wd1793_sd_buff_din),
+ .sd_buff_din(fdc_sd_buff_din[0]),
.sd_buff_wr(sd_buff_wr),
- .wp(selected_drive_wp),
+ .wp(drive_wp[0]),
.size_code(3'd5), // 5 is 18 sector x 256 bits COCO standard
- .layout(~selected_double_sided), // 0 = Track-Side-Sector, 1 - Side-Track-Sector
- .side(selected_double_sided & DRIVE_SEL_EXT[3]),
- .ready(selected_drive_ready),
+ .layout(~double_sided[0]), // 0 = Track-Side-Sector, 1 - Side-Track-Sector
+ .side(double_sided[0] & DRIVE_SEL_EXT[3]),
+ .ready(drive_ready[0]),
+
+ .input_active(0), // Section not used
+ .input_addr(0),
+ .input_data(0),
+ .input_wr(0),
+ .buff_din(0)
+);
+
+wd1793 #(1,0) coco_wd1793_sdc_1
+(
+ .clk_sys(~CLK),
+ .ce(ena_8Mhz),
+ .reset(~RESET_N),
+ .io_en(1'b1),
+ .rd(RD[1]),
+ .wr(WR[1]),
+ .addr(ADDRESS_L[1:0]),
+ .din(DATA_IN_L),
+ .dout(dout[1]),
+ .drq(DRQ[1]),
+ .intrq(INTRQ[1]),
+
+ .img_mounted(1'b0), // Not used when using _override
+ .img_mounted_overide(1'b1), // Load img_size and layout on each clock
+ .img_size(drive_size[1]),
+
+ .sd_lba(fdc_sd_lba[1]),
+ .sd_rd(fdc_sd_rd[1]),
+ .sd_wr(fdc_sd_wr[1]),
+ .sd_ack(sd_ack[1]),
+
+ .sd_buff_addr(sd_buff_addr),
+ .sd_buff_dout(sd_buff_dout),
+ .sd_buff_din(fdc_sd_buff_din[1]),
+ .sd_buff_wr(sd_buff_wr),
+
+ .wp(drive_wp[1]),
+
+ .size_code(3'd5), // 5 is 18 sector x 256 bits COCO standard
+ .layout(~double_sided[1]), // 0 = Track-Side-Sector, 1 - Side-Track-Sector
+ .side(double_sided[1] & DRIVE_SEL_EXT[3]),
+ .ready(drive_ready[1]),
.input_active(0), // Section not used
.input_addr(0),
diff --git a/sys/build_id.tcl b/sys/build_id.tcl
index b43b9d9..712a53f 100644
--- a/sys/build_id.tcl
+++ b/sys/build_id.tcl
@@ -2,13 +2,16 @@
# Build TimeStamp Verilog Module
# Jeff Wiencrot - 8/1/2011
# Sorgelig - 02/11/2019
+# Stan Hodge - 04/22/2024
+
proc generateBuildID_Verilog {} {
# Get the timestamp (see: http://www.altera.com/support/examples/tcl/tcl-date-time-stamp.html)
set buildDate "`define BUILD_DATE \"[clock format [ clock seconds ] -format %y%m%d]\""
- # Create a Verilog file for output
+ # Create a Verilog file(s) for output
set outputFileName "build_id.v"
+ set outputFileNameNum "build_id_num.v"
set fileData ""
if { [file exists $outputFileName]} {
@@ -17,13 +20,35 @@ proc generateBuildID_Verilog {} {
close $outputFile
}
+ set fileData_num ""
+ if { [file exists $outputFileNameNum]} {
+ set outputFile [open $outputFileNameNum "r"]
+ set fileData_num [read $outputFile]
+ close $outputFile
+ }
+
+
if {$buildDate ne $fileData} {
set outputFile [open $outputFileName "w"]
puts -nonewline $outputFile $buildDate
close $outputFile
+
+ set buildnumbervar 1
+
# Send confirmation message to the Messages window
post_message "Generated: [pwd]/$outputFileName: $buildDate"
+ } else {
+ scan $fileData_num "`define BUILD_NUMBER \"%d" buildnumbervar
+ incr buildnumbervar
}
+
+ set buildnumber "`define BUILD_NUMBER \"[format "%03d" $buildnumbervar]\""
+ set outputFile [open $outputFileNameNum "w"]
+ puts -nonewline $outputFile $buildnumber
+ close $outputFile
+
+ post_message "Generated: [pwd]/$outputFileNameNum: $buildnumber"
+
}
# Build CDF file
diff --git a/sys/pll_hdmi/pll_hdmi_0002.qip b/sys/pll_hdmi/pll_hdmi_0002.qip
index 3cb7073..5576ec8 100644
--- a/sys/pll_hdmi/pll_hdmi_0002.qip
+++ b/sys/pll_hdmi/pll_hdmi_0002.qip
@@ -1,2 +1,2 @@
set_instance_assignment -name PLL_COMPENSATION_MODE DIRECT -to "*pll_hdmi_0002*|altera_pll:altera_pll_i*|*"
-set_instance_assignment -name UNFORCE_MERGE_PLL_OUTPUT_COUNTER ON -to "*pll_hdmi_0002*|altera_pll:altera_pll_i*|*"
+#set_instance_assignment -name UNFORCE_MERGE_PLL_OUTPUT_COUNTER ON -to "*pll_hdmi_0002*|altera_pll:altera_pll_i*|*"
diff --git a/sys/sys_top.v b/sys/sys_top.v
index 9cc92a1..ea6c5b9 100644
--- a/sys/sys_top.v
+++ b/sys/sys_top.v
@@ -19,6 +19,9 @@
//
//============================================================================
+// Define Config features - For CoCo use of USER I/O
+//`include "../rtl/config.sv"
+
module sys_top
(
/////////// CLOCK //////////
@@ -1526,7 +1529,24 @@ alsa alsa
`endif
//////////////// User I/O (USB 3.0 connector) /////////////////////////
+// Modifications for use of the CoCo3 with LA
+`ifdef Config_Debug
+//assign USER_IO[0] = !user_out[0] ? 1'b0 : 1'bZ;
+//assign USER_IO[1] = !user_out[1] ? 1'b0 : 1'bZ;
+//assign USER_IO[2] = !user_out[2] ? 1'b0 : 1'bZ;
+//assign USER_IO[3] = !user_out[3] ? 1'b0 : 1'bZ;
+//assign USER_IO[4] = !user_out[4] ? 1'b0 : 1'bZ;
+//assign USER_IO[5] = !user_out[5] ? 1'b0 : 1'bZ;
+//assign USER_IO[6] = !user_out[6] ? 1'b0 : 1'bZ;
+assign USER_IO[0] = user_out[0];
+assign USER_IO[1] = user_out[1];
+assign USER_IO[2] = user_out[2];
+assign USER_IO[3] = user_out[3];
+assign USER_IO[4] = user_out[4];
+assign USER_IO[5] = user_out[5];
+assign USER_IO[6] = user_out[6];
+`else
assign USER_IO[0] = !user_out[0] ? 1'b0 : 1'bZ;
assign USER_IO[1] = !user_out[1] ? 1'b0 : 1'bZ;
assign USER_IO[2] = !(SW[1] ? HDMI_I2S : user_out[2]) ? 1'b0 : 1'bZ;
@@ -1534,6 +1554,7 @@ assign USER_IO[3] = !user_out[3] ? 1'b0 : 1'bZ;
assign USER_IO[4] = !(SW[1] ? HDMI_SCLK : user_out[4]) ? 1'b0 : 1'bZ;
assign USER_IO[5] = !(SW[1] ? HDMI_LRCLK : user_out[5]) ? 1'b0 : 1'bZ;
assign USER_IO[6] = !user_out[6] ? 1'b0 : 1'bZ;
+`endif
assign user_in[0] = USER_IO[0];
assign user_in[1] = USER_IO[1];