diff --git a/fw/.gitignore b/fw/.gitignore index 34a27b1..9bfa4b7 100644 --- a/fw/.gitignore +++ b/fw/.gitignore @@ -7,3 +7,6 @@ *.rpt *.txt *.sopcinfo +**/*.elf +**/*.bin +**/*.dat diff --git a/fw/SummerCart64.qsf b/fw/SummerCart64.qsf index ea90ada..3b7cea8 100644 --- a/fw/SummerCart64.qsf +++ b/fw/SummerCart64.qsf @@ -46,33 +46,14 @@ set_global_assignment -name LAST_QUARTUS_VERSION "20.1.1 Lite Edition" set_global_assignment -name PROJECT_OUTPUT_DIRECTORY output_files set_global_assignment -name NUM_PARALLEL_PROCESSORS ALL set_global_assignment -name FLOW_ENABLE_POWER_ANALYZER ON -set_global_assignment -name VERILOG_FILE picorv32/picorv32.v -set_global_assignment -name QSYS_FILE rtl/intel/snp/intel_snp.qsys -set_global_assignment -name QIP_FILE rtl/intel/fifo/fifo8.qip -set_global_assignment -name QIP_FILE rtl/intel/pll/intel_pll.qip -set_global_assignment -name SDC_FILE SummerCart64.sdc -set_global_assignment -name SIGNALTAP_FILE stp.stp -set_global_assignment -name SYSTEMVERILOG_FILE btldr/btldr.sv -set_global_assignment -name SYSTEMVERILOG_FILE rtl/cpu/cpu_bus.sv -set_global_assignment -name SYSTEMVERILOG_FILE rtl/cpu/cpu_gpio.sv -set_global_assignment -name SYSTEMVERILOG_FILE rtl/cpu/cpu_i2c.sv -set_global_assignment -name SYSTEMVERILOG_FILE rtl/cpu/cpu_ram.sv -set_global_assignment -name SYSTEMVERILOG_FILE rtl/cpu/cpu_soc.sv -set_global_assignment -name SYSTEMVERILOG_FILE rtl/cpu/cpu_uart.sv -set_global_assignment -name SYSTEMVERILOG_FILE rtl/cpu/cpu_usb.sv -set_global_assignment -name SYSTEMVERILOG_FILE rtl/cpu/cpu_wrapper.sv -set_global_assignment -name SYSTEMVERILOG_FILE rtl/usb/usb_ft1248.sv -set_global_assignment -name SYSTEMVERILOG_FILE rtl/SummerCart64.sv -set_global_assignment -name SYSTEMVERILOG_FILE rtl/system/system.sv -set_global_assignment -name SLD_FILE db/stp_auto_stripped.stp # Pin & Location Assignments # ========================== set_location_assignment PIN_6 -to o_usb_clk -set_location_assignment PIN_7 -to io_usb_miosi[3] -set_location_assignment PIN_8 -to io_usb_miosi[2] -set_location_assignment PIN_10 -to io_usb_miosi[1] -set_location_assignment PIN_11 -to io_usb_miosi[0] +set_location_assignment PIN_7 -to io_usb_miosi[2] +set_location_assignment PIN_8 -to io_usb_miosi[3] +set_location_assignment PIN_10 -to io_usb_miosi[0] +set_location_assignment PIN_11 -to io_usb_miosi[1] set_location_assignment PIN_12 -to i_uart_rxd set_location_assignment PIN_13 -to o_uart_txd set_location_assignment PIN_14 -to i_uart_cts @@ -157,9 +138,9 @@ set_location_assignment PIN_132 -to io_flash_dq[3] set_location_assignment PIN_134 -to o_flash_cs set_location_assignment PIN_135 -to io_flash_dq[1] set_location_assignment PIN_136 -to io_flash_dq[2] -set_location_assignment PIN_138 -to i_usb_powered -set_location_assignment PIN_140 -to i_usb_miso -set_location_assignment PIN_141 -to o_usb_cs +set_location_assignment PIN_138 -to i_usb_pwren +set_location_assignment PIN_140 -to o_usb_cs +set_location_assignment PIN_141 -to i_usb_miso # Classic Timing Assignments # ========================== @@ -223,51 +204,82 @@ set_global_assignment -name OUTPUT_IO_TIMING_FAR_END_VMEAS "HALF SIGNAL SWING" - # Pin & Location Assignments # ========================== - set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to o_usb_clk - set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to o_usb_cs - set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to io_usb_miosi[0] - set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to io_usb_miosi[1] - set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to io_usb_miosi[2] - set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to io_usb_miosi[3] - set_instance_assignment -name FAST_OUTPUT_ENABLE_REGISTER ON -to io_usb_miosi[0] - set_instance_assignment -name FAST_OUTPUT_ENABLE_REGISTER ON -to io_usb_miosi[1] - set_instance_assignment -name FAST_OUTPUT_ENABLE_REGISTER ON -to io_usb_miosi[2] - set_instance_assignment -name FAST_OUTPUT_ENABLE_REGISTER ON -to io_usb_miosi[3] - set_instance_assignment -name FAST_INPUT_REGISTER ON -to io_usb_miosi[0] - set_instance_assignment -name FAST_INPUT_REGISTER ON -to io_usb_miosi[1] - set_instance_assignment -name FAST_INPUT_REGISTER ON -to io_usb_miosi[2] - set_instance_assignment -name FAST_INPUT_REGISTER ON -to io_usb_miosi[3] - set_instance_assignment -name FAST_INPUT_REGISTER ON -to i_usb_miso +set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to o_usb_clk +set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to o_usb_cs +set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to io_usb_miosi[0] +set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to io_usb_miosi[1] +set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to io_usb_miosi[2] +set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to io_usb_miosi[3] +set_instance_assignment -name FAST_OUTPUT_REGISTER ON -to io_n64_pi_ad[*] +set_instance_assignment -name FAST_OUTPUT_ENABLE_REGISTER ON -to io_usb_miosi[0] +set_instance_assignment -name FAST_OUTPUT_ENABLE_REGISTER ON -to io_usb_miosi[1] +set_instance_assignment -name FAST_OUTPUT_ENABLE_REGISTER ON -to io_usb_miosi[2] +set_instance_assignment -name FAST_OUTPUT_ENABLE_REGISTER ON -to io_usb_miosi[3] +set_instance_assignment -name FAST_OUTPUT_ENABLE_REGISTER ON -to io_n64_pi_ad[*] +set_instance_assignment -name FAST_INPUT_REGISTER ON -to io_usb_miosi[0] +set_instance_assignment -name FAST_INPUT_REGISTER ON -to io_usb_miosi[1] +set_instance_assignment -name FAST_INPUT_REGISTER ON -to io_usb_miosi[2] +set_instance_assignment -name FAST_INPUT_REGISTER ON -to io_usb_miosi[3] +set_instance_assignment -name FAST_INPUT_REGISTER ON -to i_usb_miso +set_instance_assignment -name FAST_INPUT_REGISTER ON -to io_n64_pi_ad[*] +set_instance_assignment -name FAST_INPUT_REGISTER ON -to i_n64_pi_aleh +set_instance_assignment -name FAST_INPUT_REGISTER ON -to i_n64_pi_alel +set_instance_assignment -name FAST_INPUT_REGISTER ON -to i_n64_pi_read +set_instance_assignment -name FAST_INPUT_REGISTER ON -to i_n64_pi_write +set_instance_assignment -name FAST_INPUT_REGISTER ON -to i_n64_reset +set_instance_assignment -name FAST_INPUT_REGISTER ON -to i_n64_nmi # Fitter Assignments # ================== - set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to i_n64_nmi - set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to i_n64_pi_aleh - set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to i_n64_pi_alel - set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to i_n64_pi_read - set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to i_n64_pi_write - set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to i_n64_reset - set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to i_n64_si_clk - set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to io_n64_si_dq - set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to o_n64_irq - set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to io_usb_miosi[0] - set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to io_usb_miosi[1] - set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to io_usb_miosi[2] - set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to io_usb_miosi[3] - set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to i_usb_miso +set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to i_n64_nmi +set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to i_n64_pi_aleh +set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to i_n64_pi_alel +set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to i_n64_pi_read +set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to i_n64_pi_write +set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to i_n64_reset +set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to i_n64_si_clk +set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to io_n64_si_dq +set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to o_n64_irq +set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to io_usb_miosi[0] +set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to io_usb_miosi[1] +set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to io_usb_miosi[2] +set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to io_usb_miosi[3] +set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to i_usb_miso +set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to i_usb_pwren # start DESIGN_PARTITION(Top) # --------------------------- # Incremental Compilation Assignments # =================================== - 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_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -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 # end DESIGN_PARTITION(Top) # ------------------------- # end ENTITY(SummerCart64) -# ------------------------ \ No newline at end of file +# ------------------------ +set_global_assignment -name QSYS_FILE rtl/intel/flash/intel_flash.qsys +set_global_assignment -name VERILOG_FILE picorv32/picorv32.v +set_global_assignment -name QSYS_FILE rtl/intel/snp/intel_snp.qsys +set_global_assignment -name QIP_FILE rtl/intel/fifo/fifo8.qip +set_global_assignment -name QIP_FILE rtl/intel/pll/intel_pll.qip +set_global_assignment -name SDC_FILE SummerCart64.sdc +set_global_assignment -name SIGNALTAP_FILE stp.stp +set_global_assignment -name SYSTEMVERILOG_FILE btldr/btldr.sv +set_global_assignment -name SYSTEMVERILOG_FILE rtl/cpu/cpu_bus.sv +set_global_assignment -name SYSTEMVERILOG_FILE rtl/cpu/cpu_gpio.sv +set_global_assignment -name SYSTEMVERILOG_FILE rtl/cpu/cpu_i2c.sv +set_global_assignment -name SYSTEMVERILOG_FILE rtl/cpu/cpu_ram.sv +set_global_assignment -name SYSTEMVERILOG_FILE rtl/cpu/cpu_soc.sv +set_global_assignment -name SYSTEMVERILOG_FILE rtl/cpu/cpu_uart.sv +set_global_assignment -name SYSTEMVERILOG_FILE rtl/cpu/cpu_usb.sv +set_global_assignment -name SYSTEMVERILOG_FILE rtl/cpu/cpu_wrapper.sv +set_global_assignment -name SYSTEMVERILOG_FILE rtl/SummerCart64.sv +set_global_assignment -name SYSTEMVERILOG_FILE rtl/system/system.sv +set_global_assignment -name SYSTEMVERILOG_FILE rtl/n64/n64_pi.sv +set_global_assignment -name SYSTEMVERILOG_FILE rtl/usb/usb_ft1248.sv +set_global_assignment -name SLD_FILE db/stp_auto_stripped.stp +set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top \ No newline at end of file diff --git a/fw/btldr/Makefile b/fw/btldr/Makefile index 2faa367..c907def 100644 --- a/fw/btldr/Makefile +++ b/fw/btldr/Makefile @@ -18,19 +18,19 @@ FLAGS=\ all: btldr.bin btldr.sv print_size btldr.elf: btldr.ld btldr.c - $(CROSS)gcc $(FLAGS) btldr.c -o btldr.elf + @$(CROSS)gcc $(FLAGS) btldr.c -o btldr.elf btldr.bin: btldr.elf - $(CROSS)objcopy -O binary btldr.elf btldr.bin + @$(CROSS)objcopy -O binary btldr.elf btldr.bin btldr.sv: btldr.bin - python3 bin2sv.py btldr.bin btldr_template.sv btldr.sv + @python3 bin2sv.py btldr.bin btldr_template.sv btldr.sv print_size: @echo 'Size of target .elf file:' $(CROSS)size -B btldr.elf clean: - rm -f btldr.sv btldr.bin btldr.elf + @rm -f btldr.sv btldr.bin btldr.elf .PHONY: clean diff --git a/fw/btldr/btldr.bin b/fw/btldr/btldr.bin deleted file mode 100644 index f9e0e9b..0000000 Binary files a/fw/btldr/btldr.bin and /dev/null differ diff --git a/fw/btldr/btldr.c b/fw/btldr/btldr.c index 48bcad4..f8c8257 100644 --- a/fw/btldr/btldr.c +++ b/fw/btldr/btldr.c @@ -2,15 +2,20 @@ int reset_handler (void) { io8_t pointer = &RAM; + uint32_t length = 0; while (!(USB_SR & USB_SR_TXE)); USB_DR = '>'; + for (int i = 0; i < 4; i++) { + while (!(USB_SR & USB_SR_RXNE)); + length |= (USB_DR << (i * 8)); + } + while (1) { - if (USB_SR & USB_SR_RXNE) { - *pointer++ = USB_DR; - } - if ((uint32_t)pointer == (24 * 1024)) { + while (!(USB_SR & USB_SR_RXNE)); + *pointer++ = USB_DR; + if ((uint32_t)pointer == length) { __asm__("call 0"); } } diff --git a/fw/btldr/btldr.elf b/fw/btldr/btldr.elf deleted file mode 100644 index 7a85c72..0000000 Binary files a/fw/btldr/btldr.elf and /dev/null differ diff --git a/fw/btldr/btldr.h b/fw/btldr/btldr.h index a62eb0a..0d77bde 100644 --- a/fw/btldr/btldr.h +++ b/fw/btldr/btldr.h @@ -9,10 +9,6 @@ typedef volatile uint8_t * io8_t; typedef volatile uint32_t * io32_t; #define RAM (*((io8_t) 0x00000000)) -#define GPIO (*((io32_t) 0x20000000)) -#define GPIO_O (*((io8_t) 0x20000000)) -#define GPIO_I (*((io8_t) 0x20000001)) -#define GPIO_OE (*((io8_t) 0x20000002)) #define USB_SR (*((io8_t) 0x40000000)) #define USB_DR (*((io8_t) 0x40000004)) diff --git a/fw/btldr/btldr.ld b/fw/btldr/btldr.ld index e4d28d2..b441721 100644 --- a/fw/btldr/btldr.ld +++ b/fw/btldr/btldr.ld @@ -1,40 +1,16 @@ MEMORY { - ram (rwx) : org = 0x00000000, len = 24k - rom (rx) : org = 0x10000000, len = 1k + rom (rx) : org = 0x10000000, len = 128 } -__stack_pointer = ORIGIN(ram) + LENGTH(ram) - 16; - -ENTRY(reset_handler); +ENTRY(reset_handler) SECTIONS { - .text : + .rom : { . = ALIGN(4); *(.text .text* .rodata .rodata* .srodata .srodata*) . = ALIGN(4); } > rom AT > rom - - .data : - { - . = ALIGN(4); - __data_init_start = LOADADDR(.data); - __data_start = .; - *(.data .data.* .sdata .stada.*); - . = ALIGN(4); - __data_end = .; - } > ram AT > rom - - .bss : - { - . = ALIGN(4); - __bss_start = .; - *(.bss .bss.* .sbss .sbss.*) - . = ALIGN(4); - *(COMMON); - . = ALIGN(4); - __bss_end = .; - } > ram AT > ram } diff --git a/fw/btldr/btldr.sv b/fw/btldr/btldr.sv deleted file mode 100644 index eb95910..0000000 --- a/fw/btldr/btldr.sv +++ /dev/null @@ -1,39 +0,0 @@ -module cpu_bootloader (if_cpu_bus bus); - - always_ff @(posedge bus.clk) begin - bus.ack <= 1'b0; - if (bus.request) begin - bus.ack <= 1'b1; - end - end - - always_comb begin - bus.rdata = 32'd0; - if (bus.ack) begin - case (bus.address[6:2]) - 0: bus.rdata = 32'h40000737; - 1: bus.rdata = 32'h00074783; - 2: bus.rdata = 32'h0027f793; - 3: bus.rdata = 32'hfe078ce3; - 4: bus.rdata = 32'h03e00793; - 5: bus.rdata = 32'h00f70223; - 6: bus.rdata = 32'h400006b7; - 7: bus.rdata = 32'h00000793; - 8: bus.rdata = 32'h00006637; - 9: bus.rdata = 32'h0006c703; - 10: bus.rdata = 32'h00177713; - 11: bus.rdata = 32'h00070a63; - 12: bus.rdata = 32'h0046c703; - 13: bus.rdata = 32'h00178793; - 14: bus.rdata = 32'h0ff77713; - 15: bus.rdata = 32'hfee78fa3; - 16: bus.rdata = 32'hfec792e3; - 17: bus.rdata = 32'hf0000097; - 18: bus.rdata = 32'hfbc080e7; - 19: bus.rdata = 32'hfd9ff06f; - default: bus.rdata = 32'd0; - endcase - end - end - -endmodule diff --git a/fw/btldr/btldr_template.sv b/fw/btldr/btldr_template.sv index 6213568..9ab26aa 100644 --- a/fw/btldr/btldr_template.sv +++ b/fw/btldr/btldr_template.sv @@ -3,7 +3,6 @@ module cpu_bootloader (if_cpu_bus bus); always_ff @(posedge bus.clk) begin bus.ack <= 1'b0; - if (bus.request) begin bus.ack <= 1'b1; end @@ -11,7 +10,6 @@ module cpu_bootloader (if_cpu_bus bus); always_comb begin bus.rdata = 32'd0; - if (bus.ack) begin case (bus.address[6:2]){rom_formatted} default: bus.rdata = 32'd0; diff --git a/fw/cntrllr/Makefile b/fw/cntrllr/Makefile index 2bbb6c3..e94fd7a 100644 --- a/fw/cntrllr/Makefile +++ b/fw/cntrllr/Makefile @@ -17,16 +17,17 @@ FLAGS=\ all: cntrllr.bin print_size cntrllr.elf: cntrllr.ld main.c rtc.c startup.S - $(CROSS)gcc $(FLAGS) -Tcntrllr.ld main.c rtc.c startup.S -o cntrllr.elf + @$(CROSS)gcc $(FLAGS) -Tcntrllr.ld main.c rtc.c startup.S -o cntrllr.elf cntrllr.bin: cntrllr.elf - $(CROSS)objcopy -O binary --gap-fill 0xFF --pad-to 0x6000 cntrllr.elf cntrllr.bin + @$(CROSS)objcopy -O binary --gap-fill 0xFF --pad-to 0x4004 cntrllr.elf cntrllr.bin print_size: @echo 'Size of target .elf file:' - $(CROSS)size -B cntrllr.elf + @$(CROSS)size -B cntrllr.elf + @echo $(shell $(CROSS)size -B cntrllr.elf | awk 'NR==2 { printf "\nTotal memory used: %.2f%%\n",(100/(16*1024))*($$4-4) }') clean: - rm -f cntrllr.bin cntrllr.elf + @rm -f cntrllr.bin cntrllr.elf .PHONY: clean diff --git a/fw/cntrllr/cntrllr.bin b/fw/cntrllr/cntrllr.bin deleted file mode 100644 index a98759d..0000000 Binary files a/fw/cntrllr/cntrllr.bin and /dev/null differ diff --git a/fw/cntrllr/cntrllr.elf b/fw/cntrllr/cntrllr.elf deleted file mode 100644 index aeab554..0000000 Binary files a/fw/cntrllr/cntrllr.elf and /dev/null differ diff --git a/fw/cntrllr/cntrllr.ld b/fw/cntrllr/cntrllr.ld index abf4e9c..ef90444 100644 --- a/fw/cntrllr/cntrllr.ld +++ b/fw/cntrllr/cntrllr.ld @@ -1,23 +1,29 @@ MEMORY { - ram (rwx) : org = 0x00000000, len = 24k + ram (rwx) : org = 0x00000000, len = 16k } +__ram_size = LENGTH(ram); __stack_pointer = ORIGIN(ram) + LENGTH(ram) - 16; ENTRY(reset_handler) SECTIONS { - .memory : + .metadata : + { + KEEP(*(.rodata.metadata)); + } + + .ram ORIGIN(ram) : { . = ALIGN(4); - *(.reset); + *(.text.startup); . = ALIGN(4); *(.text .text* .rodata .rodata* .srodata .srodata*); . = ALIGN(4); *(.bss .bss.* .sbss .sbss.*); . = ALIGN(4); *(.data .data.* .sdata .stada.*); - } > ram + } > ram AT > ram } diff --git a/fw/cntrllr/main.c b/fw/cntrllr/main.c index bc0fde0..28af389 100644 --- a/fw/cntrllr/main.c +++ b/fw/cntrllr/main.c @@ -76,8 +76,8 @@ __NAKED__ int main (void) { while (counter++ < 0x0003FFFF); counter = 0; - if (UART_SR & UART_SR_RXNE) { - rtc_new_data[index++] = UART_DR; + if (USB_SR & USB_SR_RXNE) { + rtc_new_data[index++] = USB_DR; if (index == 7) { index = 0; rtc_set_time(rtc_new_data); diff --git a/fw/cntrllr/startup.S b/fw/cntrllr/startup.S index 929a092..13e8e9e 100644 --- a/fw/cntrllr/startup.S +++ b/fw/cntrllr/startup.S @@ -1,4 +1,8 @@ -.section .reset +.section .rodata.metadata +metadata: + .word __ram_size + +.section .text.startup .global reset_handler reset_handler: la sp, __stack_pointer diff --git a/fw/cntrllr/sys.h b/fw/cntrllr/sys.h index f8aacc4..2119737 100644 --- a/fw/cntrllr/sys.h +++ b/fw/cntrllr/sys.h @@ -17,8 +17,10 @@ typedef volatile uint32_t * io32_t; #define GPIO_OE (*((io8_t) 0x20000002)) #define I2C_SR (*((io8_t) 0x30000000)) #define I2C_DR (*((io8_t) 0x30000004)) -#define UART_SR (*((io8_t) 0x40000000)) -#define UART_DR (*((io8_t) 0x40000004)) +#define USB_SR (*((io8_t) 0x40000000)) +#define USB_DR (*((io8_t) 0x40000004)) +#define UART_SR (*((io8_t) 0x50000000)) +#define UART_DR (*((io8_t) 0x50000004)) #define I2C_SR_START (1 << 0) #define I2C_SR_STOP (1 << 1) @@ -27,6 +29,9 @@ typedef volatile uint32_t * io32_t; #define I2C_SR_BUSY (1 << 4) #define I2C_ADDR_READ (1 << 0) +#define USB_SR_RXNE (1 << 0) +#define USB_SR_TXE (1 << 1) + #define UART_SR_RXNE (1 << 0) #define UART_SR_TXE (1 << 1) diff --git a/fw/cntrllr/time.dat b/fw/cntrllr/time.dat deleted file mode 100644 index 7751a7c..0000000 --- a/fw/cntrllr/time.dat +++ /dev/null @@ -1 +0,0 @@ -0"! \ No newline at end of file diff --git a/fw/rtl/SummerCart64.sv b/fw/rtl/SummerCart64.sv index b4ee080..74fe7b0 100644 --- a/fw/rtl/SummerCart64.sv +++ b/fw/rtl/SummerCart64.sv @@ -5,7 +5,7 @@ module SummerCart64 ( output o_usb_cs, input i_usb_miso, inout [3:0] io_usb_miosi, - input i_usb_powered, + input i_usb_pwren, input i_uart_rxd, output o_uart_txd, @@ -44,29 +44,121 @@ module SummerCart64 ( output o_led ); - if_system system_if (.in_clk(i_clk)); - system system_inst (.system_if(system_if)); + logic [7:0] gpio_o; + logic [7:0] gpio_i; + logic [7:0] gpio_oe; - wire [7:0] gpio_o; - wire [7:0] gpio_i; - wire [7:0] gpio_oe; + always_comb begin + o_led = gpio_oe[0] ? gpio_o[0] : 1'bZ; + o_n64_irq = gpio_oe[1] ? gpio_o[1] : 1'bZ; + gpio_i = {4'b0000, i_n64_nmi, i_n64_reset, o_n64_irq, o_led}; + end - assign o_led = gpio_oe[0] ? gpio_o[0] : 1'bZ; - assign o_n64_irq = gpio_oe[1] ? gpio_o[1] : 1'bZ; - assign gpio_i = {4'b0000, i_n64_nmi, i_n64_reset, o_n64_irq, o_led}; + if_system sys ( + .in_clk(i_clk), + .n64_reset(i_n64_reset), + .n64_nmi(i_n64_nmi) + ); + + system system_inst ( + .sys(sys) + ); cpu_soc cpu_soc_inst ( - .system_if(system_if), + .sys(sys), + .gpio_o(gpio_o), .gpio_i(gpio_i), .gpio_oe(gpio_oe), + + .i2c_scl(io_rtc_scl), + .i2c_sda(io_rtc_sda), + .usb_clk(o_usb_clk), .usb_cs(o_usb_cs), .usb_miso(i_usb_miso), .usb_miosi(io_usb_miosi), - .usb_powered(i_usb_powered), - .i2c_scl(io_rtc_scl), - .i2c_sda(io_rtc_sda) + .usb_pwren(i_usb_pwren), + + .uart_rxd(i_uart_rxd), + .uart_txd(o_uart_txd), + .uart_cts(i_uart_cts), + .uart_rts(o_uart_rts) ); + logic n64_request; + logic n64_ack; + logic n64_write; + logic [31:0] n64_address; + logic [15:0] n64_wdata; + logic [15:0] n64_rdata; + + n64_pi n64_pi_inst ( + .sys(sys), + + .n64_pi_alel(i_n64_pi_alel), + .n64_pi_aleh(i_n64_pi_aleh), + .n64_pi_read(i_n64_pi_read), + .n64_pi_write(i_n64_pi_write), + .n64_pi_ad(io_n64_pi_ad), + + .request(n64_request), + .ack(n64_ack), + .write(n64_write), + .address(n64_address), + .wdata(n64_wdata), + .rdata(n64_rdata) + ); + + logic flash_request; + logic [31:0] flash_rdata; + logic flash_busy; + logic flash_ack; + + logic in_address; + logic dummy_ack; + + intel_flash intel_flash_inst ( + .clock(sys.clk), + .reset_n(~sys.reset), + .avmm_data_addr(n64_address[31:2]), + .avmm_data_read((n64_ack && in_address) || flash_request), + .avmm_data_readdata(flash_rdata), + .avmm_data_waitrequest(flash_busy), + .avmm_data_readdatavalid(flash_ack), + .avmm_data_burstcount(2'd1) + ); + + + always_ff @(posedge sys.clk) begin + dummy_ack <= 1'b0; + if (sys.reset) begin + flash_request <= 1'b0; + end else begin + if (!flash_busy) begin + flash_request <= 1'b0; + end + if (n64_request && in_address) begin + flash_request <= 1'b1; + end + + if (!in_address && n64_request) begin + dummy_ack <= 1'b1; + end + end + end + + always_comb begin + in_address = n64_address < 32'h10008000; + n64_rdata = n64_address[1] ? {flash_rdata[23:16], flash_rdata[31:24]} : {flash_rdata[7:0], flash_rdata[15:8]}; + if (!in_address) n64_rdata = 32'd0; + + n64_ack = 1'b0; + if (in_address) begin + n64_ack = flash_ack; + end else begin + n64_ack = dummy_ack; + end + end + endmodule diff --git a/fw/rtl/cpu/cpu_ram.sv b/fw/rtl/cpu/cpu_ram.sv index e49ce1f..36d2cce 100644 --- a/fw/rtl/cpu/cpu_ram.sv +++ b/fw/rtl/cpu/cpu_ram.sv @@ -1,10 +1,10 @@ module cpu_ram(if_cpu_bus bus); - wire bank; - reg [3:0][7:0] ram_1 [0:4095]; - reg [3:0][7:0] ram_2 [0:2047]; - reg [31:0] q_1, q_2; - wire [31:0] q; + logic bank; + logic [3:0][7:0] ram_1 [0:4095]; + // logic [3:0][7:0] ram_2 [0:2047]; + logic [31:0] q_1;//, q_2; + // logic [31:0] q; assign bank = bus.address[14]; @@ -12,7 +12,7 @@ module cpu_ram(if_cpu_bus bus); bus.rdata = 32'd0; if (bus.ack) begin bus.rdata = q_1; - if (bank) bus.rdata = q_2; + // if (bank) bus.rdata = q_2; end end @@ -32,13 +32,13 @@ module cpu_ram(if_cpu_bus bus); if (bus.wmask[3]) ram_1[bus.address[13:2]][3] <= bus.wdata[31:24]; end - q_2 <= ram_2[bus.address[12:2]]; - if (bus.request & bank) begin - if (bus.wmask[0]) ram_2[bus.address[12:2]][0] <= bus.wdata[7:0]; - if (bus.wmask[1]) ram_2[bus.address[12:2]][1] <= bus.wdata[15:8]; - if (bus.wmask[2]) ram_2[bus.address[12:2]][2] <= bus.wdata[23:16]; - if (bus.wmask[3]) ram_2[bus.address[12:2]][3] <= bus.wdata[31:24]; - end + // q_2 <= ram_2[bus.address[12:2]]; + // if (bus.request & bank) begin + // if (bus.wmask[0]) ram_2[bus.address[12:2]][0] <= bus.wdata[7:0]; + // if (bus.wmask[1]) ram_2[bus.address[12:2]][1] <= bus.wdata[15:8]; + // if (bus.wmask[2]) ram_2[bus.address[12:2]][2] <= bus.wdata[23:16]; + // if (bus.wmask[3]) ram_2[bus.address[12:2]][3] <= bus.wdata[31:24]; + // end end endmodule diff --git a/fw/rtl/cpu/cpu_soc.sv b/fw/rtl/cpu/cpu_soc.sv index 88ef2c0..d5cc2ab 100644 --- a/fw/rtl/cpu/cpu_soc.sv +++ b/fw/rtl/cpu/cpu_soc.sv @@ -1,18 +1,23 @@ module cpu_soc ( - if_system.sys system_if, + if_system.sys sys, input [7:0] gpio_i, output [7:0] gpio_o, output [7:0] gpio_oe, + inout i2c_scl, + inout i2c_sda, + output usb_clk, output usb_cs, input usb_miso, inout [3:0] usb_miosi, - input usb_powered, + input usb_pwren, - inout i2c_scl, - inout i2c_sda + input uart_rxd, + output uart_txd, + input uart_cts, + output uart_rts ); enum bit [3:0] { @@ -21,14 +26,15 @@ module cpu_soc ( GPIO, I2C, USB, + UART, __NUM_DEVICES } e_address_map; if_cpu_bus #( .NUM_DEVICES(__NUM_DEVICES) ) bus ( - .clk(system_if.clk), - .reset(system_if.reset) + .clk(sys.clk), + .reset(sys.reset) ); cpu_wrapper # ( @@ -59,13 +65,23 @@ module cpu_soc ( ); cpu_usb cpu_usb_inst ( - .system_if(system_if), + .sys(sys), .bus(bus.at[USB].device), .usb_clk(usb_clk), .usb_cs(usb_cs), .usb_miso(usb_miso), .usb_miosi(usb_miosi), - .usb_powered(usb_powered) + .usb_pwren(usb_pwren) + ); + + cpu_uart #( + .BAUD_RATE(1_000_000) + ) cpu_uart_inst ( + .bus(bus.at[UART].device), + .uart_rxd(uart_rxd), + .uart_txd(uart_txd), + .uart_cts(uart_cts), + .uart_rts(uart_rts) ); endmodule diff --git a/fw/rtl/cpu/cpu_uart.sv b/fw/rtl/cpu/cpu_uart.sv index 63684d4..ff28bb7 100644 --- a/fw/rtl/cpu/cpu_uart.sv +++ b/fw/rtl/cpu/cpu_uart.sv @@ -1,81 +1,89 @@ -// module cpu_uart ( -// if_system.sys system_if, -// if_cpu_bus_out cpu_bus_if, -// if_cpu_bus_in cpu_uart_if, +module cpu_uart # ( + parameter BAUD_RATE = 1_000_000 +) ( + if_cpu_bus bus, -// output ftdi_clk, -// output ftdi_si, -// input ftdi_so, -// input ftdi_cts -// ); + input uart_rxd, + output uart_txd, + input uart_cts, + output uart_rts +); -// wire request; -// wire [31:0] rdata; + localparam BAUD_GEN_VALUE = int'(100_000_000 / BAUD_RATE) - 1'd1; -// cpu_bus_glue #(.ADDRESS(4'hD)) cpu_bus_glue_uart_inst ( -// .*, -// .cpu_peripheral_if(cpu_uart_if), -// .request(request), -// .rdata(rdata) -// ); + typedef enum bit [1:0] { + S_TX_IDLE, + S_TX_DATA + } e_tx_state; -// reg rx_ready; -// wire tx_busy; -// reg [7:0] rx_data; -// reg [7:0] tx_data; + e_tx_state tx_state; + logic [7:0] tx_data; + logic tx_start; -// always_comb begin -// case (cpu_bus_if.address[3:2]) -// 0: rdata = {30'd0, ~tx_busy, ~rx_ready}; -// 1: rdata = {24'd0, rx_data}; -// 2: rdata = {24'd0, tx_data}; -// default: rdata = 32'd0; -// endcase -// end + always_comb begin + bus.rdata = 32'd0; + if (bus.ack) begin + case (bus.address[2:2]) + 0: bus.rdata = {30'd0, tx_state == S_TX_IDLE, 1'b0}; + default: bus.rdata = 32'd0; + endcase + end + end -// wire rx_valid; -// reg tx_valid; -// wire [7:0] f_rx_data; + always_ff @(posedge bus.clk) begin + bus.ack <= 1'b0; + tx_start <= 1'b0; -// always_ff @(posedge system_if.clk) begin -// tx_valid <= 1'b0; + if (bus.request) begin + bus.ack <= 1'b1; -// if (rx_valid) begin -// rx_ready <= 1'b0; -// rx_data <= f_rx_data; -// end + case (bus.address[2:2]) + 2'd1: if (bus.wmask[0]) begin + tx_data <= bus.wdata[7:0]; + tx_start <= 1'b1; + end + endcase + end + end -// if (system_if.reset) begin -// rx_ready <= 1'b1; -// end else if (request) begin -// if (cpu_bus_if.wstrb[0] && cpu_bus_if.address[3:2] == 2'd2 && !tx_busy) begin -// tx_valid <= 1'b1; -// tx_data <= cpu_bus_if.wdata[7:0]; -// end -// if (cpu_bus_if.address[3:2] == 2'd1) begin -// rx_ready <= 1'b1; -// end -// end -// end + logic [6:0] tx_baud_counter; + logic [3:0] tx_bit_counter; + logic [9:0] tx_shifter; -// usb_ftdi_fsi usb_ftdi_fsi_inst ( -// .i_clk(system_if.clk), -// .i_reset(system_if.reset), + always_ff @(posedge bus.clk) begin + tx_baud_counter <= tx_baud_counter + 1'd1; + uart_txd <= tx_shifter[0]; -// .o_ftdi_clk(ftdi_clk), -// .o_ftdi_si(ftdi_si), -// .i_ftdi_so(ftdi_so), -// .i_ftdi_cts(ftdi_cts), + if (bus.reset) begin + tx_state <= S_TX_IDLE; + tx_shifter <= 10'h3FF; + end else begin + case (tx_state) + S_TX_IDLE: begin + if (tx_start) begin + tx_state <= S_TX_DATA; + tx_baud_counter <= 7'd0; + tx_bit_counter <= 4'd0; + tx_shifter <= {1'b1, tx_data, 1'b0}; + end + end -// .i_rx_ready(rx_ready), -// .o_rx_valid(rx_valid), -// // .o_rx_channel(1'bX), -// .o_rx_data(f_rx_data), + S_TX_DATA: begin + if (tx_baud_counter == BAUD_GEN_VALUE) begin + tx_baud_counter <= 7'd0; + tx_bit_counter <= tx_bit_counter + 1'd1; + tx_shifter <= {1'b1, tx_shifter[9:1]}; + if (tx_bit_counter == 4'd9) begin + tx_state <= S_TX_IDLE; + end + end + end -// .o_tx_busy(tx_busy), -// .i_tx_valid(tx_valid), -// .i_tx_channel(1'b1), -// .i_tx_data(tx_data) -// ); + default: begin + tx_state <= S_TX_IDLE; + end + endcase + end + end -// endmodule +endmodule diff --git a/fw/rtl/cpu/cpu_usb.sv b/fw/rtl/cpu/cpu_usb.sv index 1d4fccf..9eeb0e3 100644 --- a/fw/rtl/cpu/cpu_usb.sv +++ b/fw/rtl/cpu/cpu_usb.sv @@ -1,23 +1,23 @@ module cpu_usb ( - if_system system_if, + if_system sys, if_cpu_bus bus, output usb_clk, output usb_cs, input usb_miso, inout [3:0] usb_miosi, - input usb_powered + input usb_pwren ); - reg rx_flush; - wire rx_empty; - reg rx_read; - wire [7:0] rx_rdata; + logic rx_flush; + logic rx_empty; + logic rx_read; + logic [7:0] rx_rdata; - reg tx_flush; - wire tx_full; - reg tx_write; - reg [7:0] tx_wdata; + logic tx_flush; + logic tx_full; + logic tx_write; + logic [7:0] tx_wdata; always_comb begin bus.rdata = 32'd0; @@ -61,13 +61,13 @@ module cpu_usb ( end usb_ft1248 usb_ft1248_inst ( - .system_if(system_if), + .sys(sys), .usb_clk(usb_clk), .usb_cs(usb_cs), .usb_miso(usb_miso), .usb_miosi(usb_miosi), - .usb_powered(usb_powered), + .usb_pwren(usb_pwren), .rx_flush(rx_flush), .rx_empty(rx_empty), diff --git a/fw/rtl/intel/flash/intel_flash.qsys b/fw/rtl/intel/flash/intel_flash.qsys index f9dad29..148b576 100644 --- a/fw/rtl/intel/flash/intel_flash.qsys +++ b/fw/rtl/intel/flash/intel_flash.qsys @@ -7,17 +7,17 @@ description="" tags="INTERNAL_COMPONENT=true" categories="System" /> - @@ -71,8 +71,8 @@ Read only,Read only,Hidden,Read only,Read only $${FILENAME}_onchip_flash_0 - btldr/btldr.hex - btldr/btldr.hex + C:/Dev/SummerCollection/sw/bootloader/what/build/SummerLoader64.hex + C:/Dev/SummerCollection/sw/bootloader/what/build/SummerLoader64.hex diff --git a/fw/rtl/memory/memory_sdram.sv b/fw/rtl/memory/memory_sdram.sv new file mode 100644 index 0000000..e69de29 diff --git a/fw/rtl/n64/n64_pi.sv b/fw/rtl/n64/n64_pi.sv new file mode 100644 index 0000000..0a85970 --- /dev/null +++ b/fw/rtl/n64/n64_pi.sv @@ -0,0 +1,165 @@ +module n64_pi ( + if_system.sys sys, + + input n64_pi_alel, + input n64_pi_aleh, + input n64_pi_read, + input n64_pi_write, + inout [15:0] n64_pi_ad, + + output request, + input ack, + output write, + output [31:0] address, + output [15:0] wdata, + input [15:0] rdata +); + + // Control signals input synchronization + + logic [2:0] n64_pi_alel_ff; + logic [2:0] n64_pi_aleh_ff; + logic [2:0] n64_pi_read_ff; + logic [2:0] n64_pi_write_ff; + + always_ff @(posedge sys.clk) begin + n64_pi_aleh_ff <= {n64_pi_aleh_ff[1:0], n64_pi_aleh}; + n64_pi_alel_ff <= {n64_pi_alel_ff[1:0], n64_pi_alel}; + n64_pi_read_ff <= {n64_pi_read_ff[1:0], n64_pi_read}; + n64_pi_write_ff <= {n64_pi_write_ff[1:0], n64_pi_write}; + end + + logic pi_reset; + logic pi_aleh; + logic pi_alel; + logic pi_read; + logic pi_read_delayed; + logic pi_write; + logic pi_write_delayed; + + always_comb begin + pi_reset = sys.n64_hard_reset; + pi_aleh = n64_pi_aleh_ff[2]; + pi_alel = n64_pi_alel_ff[2]; + pi_read = n64_pi_read_ff[1]; + pi_read_delayed = n64_pi_read_ff[2]; + pi_write = n64_pi_write_ff[1]; + pi_write_delayed = n64_pi_write_ff[2]; + end + + // PI bus state and event generator + + typedef enum bit [1:0] { + PI_MODE_IDLE = 2'b10, + PI_MODE_HIGH = 2'b11, + PI_MODE_LOW = 2'b01, + PI_MODE_VALID = 2'b00 + } e_pi_mode; + + e_pi_mode pi_mode; + e_pi_mode last_pi_mode; + logic last_read; + logic last_write; + + always_comb begin + pi_mode = e_pi_mode'({pi_aleh, pi_alel}); + end + + always_ff @(posedge sys.clk) begin + last_pi_mode <= pi_mode; + last_read <= pi_read; + last_write <= pi_write; + end + + logic aleh_op; + logic alel_op; + logic read_op; + logic write_op; + + always_comb begin + aleh_op = !pi_reset && last_pi_mode != PI_MODE_HIGH && pi_mode == PI_MODE_HIGH; + alel_op = !pi_reset && last_pi_mode == PI_MODE_HIGH && pi_mode == PI_MODE_LOW; + read_op = !pi_reset && pi_mode == PI_MODE_VALID && last_read && !pi_read; + write_op = !pi_reset && pi_mode == PI_MODE_VALID && last_write && !pi_write; + end + + // Input and output data sampling + + logic [15:0] n64_pi_ad_input; + logic [15:0] n64_pi_ad_output; + logic [15:0] n64_pi_ad_output_data; + logic [15:0] n64_pi_ad_output_data_buffer; + logic n64_pi_ad_output_enable; + logic n64_pi_ad_output_enable_data; + + always_comb begin + n64_pi_ad = n64_pi_ad_output_enable ? n64_pi_ad_output : 16'hZZZZ; + n64_pi_ad_output_enable_data = !pi_reset && pi_mode == PI_MODE_VALID && !pi_read_delayed; + end + + always_ff @(posedge sys.clk) begin + n64_pi_ad_input <= n64_pi_ad; + n64_pi_ad_output <= n64_pi_ad_output_data; + n64_pi_ad_output_enable <= n64_pi_ad_output_enable_data; + if (read_op) begin + n64_pi_ad_output_data <= n64_pi_ad_output_data_buffer; + end + end + + // Internal bus controller + + typedef enum bit [0:0] { + S_IDLE, + S_WAIT + } e_state; + + e_state state; + logic first_operation; + logic pending_operation; + logic pending_write; + + always_ff @(posedge sys.clk) begin + request <= 1'b0; + + if (sys.reset || sys.n64_hard_reset || sys.n64_soft_reset) begin + state <= S_IDLE; + first_operation <= 1'b0; + pending_operation <= 1'b0; + end else begin + case (state) + S_IDLE: begin + if (aleh_op) address[31:16] <= n64_pi_ad_input; + if (alel_op) address[15:0] <= {n64_pi_ad_input[15:1], 1'b0}; + if (alel_op || read_op || write_op || pending_operation) begin + state <= S_WAIT; + request <= 1'b1; + write <= write_op || (pending_operation && pending_write); + if (!alel_op && !(first_operation && write_op)) begin + address[31:1] <= address[31:1] + 1'd1; + end + wdata <= n64_pi_ad_input; + first_operation <= alel_op; + end + end + + S_WAIT: begin + if (ack) begin + state <= S_IDLE; + n64_pi_ad_output_data_buffer <= rdata; + end + if (read_op || write_op) begin + pending_operation <= 1'b1; + pending_write <= write_op; + end + end + + default: begin + state <= S_IDLE; + first_operation <= 1'b0; + pending_operation <= 1'b0; + end + endcase + end + end + +endmodule diff --git a/fw/rtl/system/system.sv b/fw/rtl/system/system.sv index 0b9121c..a7dc294 100644 --- a/fw/rtl/system/system.sv +++ b/fw/rtl/system/system.sv @@ -1,19 +1,31 @@ -interface if_system (input in_clk); +interface if_system ( + input in_clk, + input n64_reset, + input n64_nmi +); logic clk; logic sdram_clk; logic reset; + logic n64_soft_reset; + logic n64_hard_reset; - modport pll ( + modport internal ( input in_clk, + input n64_reset, + input n64_nmi, output clk, output sdram_clk, - output reset + output reset, + output n64_soft_reset, + output n64_hard_reset ); modport sys ( input clk, - input reset + input reset, + input n64_soft_reset, + input n64_hard_reset ); modport sdram ( @@ -23,23 +35,34 @@ interface if_system (input in_clk); endinterface -module system (if_system.pll system_if); +module system (if_system.internal sys); - wire locked; - wire external_reset; - - assign system_if.reset = ~locked | external_reset; + logic locked; + logic external_reset; + logic [1:0] n64_reset_ff; + logic [1:0] n64_nmi_ff; intel_pll intel_pll_inst ( - .inclk0(system_if.in_clk), - .c0(system_if.clk), - .c1(system_if.sdram_clk), + .inclk0(sys.in_clk), + .c0(sys.clk), + .c1(sys.sdram_clk), .locked(locked) ); - // intel_snp intel_snp_inst ( - // .source(external_reset), - // .source_clk(system_if.clk) - // ); + intel_snp intel_snp_inst ( + .source(external_reset), + .source_clk(sys.clk) + ); + + always_ff @(posedge sys.clk) begin + n64_reset_ff <= {n64_reset_ff[0], sys.n64_reset}; + n64_nmi_ff <= {n64_nmi_ff[0], sys.n64_nmi}; + end + + always_comb begin + sys.reset = ~locked | external_reset; + sys.n64_hard_reset <= ~n64_reset_ff[1]; + sys.n64_soft_reset <= ~n64_nmi_ff[1]; + end endmodule diff --git a/fw/rtl/usb/usb_ft1248.sv b/fw/rtl/usb/usb_ft1248.sv index e2c9acb..cd8d791 100644 --- a/fw/rtl/usb/usb_ft1248.sv +++ b/fw/rtl/usb/usb_ft1248.sv @@ -1,11 +1,11 @@ module usb_ft1248 ( - if_system.sys system_if, + if_system.sys sys, output usb_clk, output usb_cs, input usb_miso, inout [3:0] usb_miosi, - input usb_powered, + input usb_pwren, input rx_flush, output rx_empty, @@ -32,7 +32,7 @@ module usb_ft1248 ( wire [7:0] tx_rdata; fifo8 fifo_8_rx_inst ( - .clock(system_if.clk), + .clock(sys.clk), .sclr(rx_flush), .empty(rx_empty), @@ -47,7 +47,7 @@ module usb_ft1248 ( ); fifo8 fifo_8_tx_inst ( - .clock(system_if.clk), + .clock(sys.clk), .sclr(tx_flush), .empty(tx_empty), @@ -86,8 +86,8 @@ module usb_ft1248 ( reg [3:0] clock_divider; wire rising_edge = clock_divider[1]; - always_ff @(posedge system_if.clk) begin - if (system_if.reset || state == S_TRY_RX || state == S_TRY_TX) begin + always_ff @(posedge sys.clk) begin + if (sys.reset || state == S_TRY_RX || state == S_TRY_TX) begin clock_divider <= 4'b0001; end else begin clock_divider <= {clock_divider[2:0], clock_divider[3]}; @@ -120,7 +120,7 @@ module usb_ft1248 ( usb_miosi = miosi_output_enable ? miosi_output : 4'bZZZZ; end - always_ff @(posedge system_if.clk) begin + always_ff @(posedge sys.clk) begin clk_output <= clk_data; cs_output <= cs_data; miosi_input <= usb_miosi; @@ -133,11 +133,11 @@ module usb_ft1248 ( reg is_write; - always_ff @(posedge system_if.clk) begin + always_ff @(posedge sys.clk) begin rx_write <= 1'b0; tx_read <= 1'b0; - if (system_if.reset) begin + if (sys.reset) begin state <= S_TRY_RX; cs_data <= 1'b1; miosi_output_enable_data <= 1'b0; diff --git a/fw/stp.stp b/fw/stp.stp index a0cec5d..7f2b030 100644 --- a/fw/stp.stp +++ b/fw/stp.stp @@ -1,19 +1,680 @@ + - - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 'if_system:sys|if_system.n64_hard_reset' == low && 'if_system:sys|if_system.n64_soft_reset' == low && 'n64_pi:n64_pi_inst|ack' == rising edge + + + + + + + + + + + + + + 1 + 1 + + 'n64_pi:n64_pi_inst|ack' == high + + + + + + + + + + + + + + + + + 000000000000000000001000000000001000001110110000000000000001000000001000000000000001000000001001000000000000000000001010000000000000000000000000000000000000000000001000000010000000010000000100000000000001000000001000000010000010110000000000000000000000000000001010000010000000010000000100000000000000000000001010000010000000010000000100000000000001000000001010000010000010010000000000000000000000000000001000010010000000010000000100000000000000000000001000010010000000010000000100000000000001000000001000010010000011010000000000000000000000000000001010010010000111100001000000000000000000000000001010010010000111100001000000000000000001000000001010010010000100101000111000000000000000000000001000001010000100100001000010000000000000000000001000001010000100100001000010000000000001000000001000001010000000000000000000000000000000000000001010001010001110001001000010000000000000000000001010001010001110001001000010000000000001000000001010001010000000000011000000000000000000000000001000011010000101000000010010000000000000000000001000011010000101000000010010000000000001000000001000011010001000000011011100000000000000000000001010011010000000000000000000000000000000000000001010011010000000000000000000000000000001000000001010011010000000000000000000000000000000000000001000000110001100100011110111000000000000000000001000000110001100100011110111000000000001000000001000000110000111111001011111000000000000000000001010000110001110101100110111000000000000000000001010000110001110101100110111000000000001000000001010000110000000000000000000000000000000000000001000010110000110101010110111000000000000000000001000010110000110101010110111000000000001000000001000010110000000000010000000000000000000000000001010010110001110101010110111000000000000000000001010010110001110101010110111000000000001000000001010010110000000000001000000000000000000000000001000001110000110101110110111000000000000000000001000001110000110101110110111000000000001000000001000001110000000000011000000000000000000000000001010001110001110101110110111000000000000000000001010001110001110101110110111000000000001000000001010001110000000000000100000000000000000000000001000011110000111100001000000000000000000000000001000011110000111100001000000000000000001000000001000011110000100101000111000000000000000000000001010011110000100100001000010000000000000000000001010011110000100100001000010000000000001000000001010011110000000000000000000000000000000000000001000000001000111100101000000000000000000000000001000000001000111100101000000000000000001000000001000000001000000101001111111000000000000000000001010000001001111100101000000000000000000000000001010000001001111100101000000000000000001000000001010000001000000101000111111000000000000000000001000010001000111100011000000000000000000000000001000010001000111100011000000000000000001000000001000010001000100101000110000000000000000000000001010010001000100100011000110000000000000000000001010010001000100100011000110000000000001000000001010010001000000000000000000000000000000000000001000001001001101100001000000000000000000000000001000001001001101100001000000000000000001000000001000001001000000000000001000000000000000000000001010001001001110101001000010000000000000000000001010001001001110101001000010000000000001000000001010001001000000000010000000000000000000000000001000011001001100100000100000000000000000000000001000011001001100100000100000000000000001000000001000011001000111000000001011000000000000000000001010011001000000000000000000000000000000000000001010011001000000000000000000000000000001000000001010011001000000000000000000000000000000000000001000000101001000100000110001000000000000000000001000000101001000100000110001000000000001000000001000000101001111111111111111000000000000000000001010000101000101000000010001000000000000000000001010000101000101000000010001000000000001000000001010000101001111111011111111000000000000000000001000010101000000000000000000000000000000000000001000010101000000000000000000000000000001000000001000010101000000000000000000000000000000000000001010010101000110101000000010000000000000000000001010010101000110101000000010000000000001000000001010010101000000000001000000000000000000000000001000001101001101100001000000000000000000000000001000001101001101100001000000000000000001000000001000001101000000000010100000000000000000000000001010001101001110101001000010000000000000000000001010001101001110101001000010000000000001000000001010001101000000000011000000000000000000000000001000011101000110101000000010000000000000000000001000011101000110101000000010000000000001000000001000011101000000000000000000000000000000000000001010011101001100100000100000000000000000000000001010011101001100100000100000000000000001000000001010011101000000000010000000000000000000000000001000000011000000000000000000000000000000000000001000000011000000000000000000000000000001000000001000000011000000000000000000000000000000000000001010000011001000100000110001000000000000000000001010000011001000100000110001000000000001000000001010000011001111111111111111000000000000000000001000010011000101000000010001000000000000000000001000010011000101000000010001000000000001000000001000010011001111111011111111000000000000000000001010010011000000000000000000000000000000000000001010010011000000000000000000000000000001000000001010010011000000000000000000000000000000000000001000001011001101100001000000000000000000000000001000001011001101100001000000000000000001000000001000001011000000000111000000000000000000000000001010001011001110101001000010000000000000000000001010001011001110101001000010000000000001000000001010001011000000000000000000000000000000000000001000011011001100100000100000000000000000000000001000011011001100100000100000000000000001000000001000011011000000000000010000000000000000000000001010011011001000100000110001000000000000000000001010011011001000100000110001000000000001000000001010011011001111111111111111000000000000000000001000000111000101000000010001000000000000000000001000000111000101000000010001000000000001000000001000000111000111111111111111000000000000000000001010000111001101100001000000000000000000000000001010000111001101100001000000000000000001000000001010000111001000000111000010000000000000000000001000010111001110101001000110000000000000000000001000010111001110101001000110000000000001000000001000010111000000000000000000000000000000000000001010010111001111100001000000000000000000000000001010010111001111100001000000000000000001000000001010010111000011000001000000000000000000000000001000001111001101100001010010000000000000000000001000001111001101100001010010000000000001000000001000001111000010100001110000000000000000000000001010001111001110101001001010000000000000000000001010001111001110101001001010000000000001000000001010001111000000000001000000000000000000000000001000011111000110101000001010000000000000000000001000011111000110101000001010000000000001000000001000011111000000000010100000000000000000000000001010011111001111100001000000000000000000000000001010011111001111100001000000000000000001000000001010011111000000001000000000000000000000000000001000000000101110101001001010000000000000000000001000000000101110101001001010000000000001000000001000000000100000000010000000000000000000000000001010000000100000000000000000000000000000000000001010000000100000000000000000000000000001000000001010000000101010110010010000000000000000000000001000010000100000000000000000000000000000000000001000010000100000000000000000000000000001000000001000010000101001110010010000000000000000000000001010010000101111100111000000000000000000000000001010010000101111100111000000000000000001000000001010010000100000101000111111000000000000000000001000001000100000000000000000000000000000000000001000001000100000000000000000000000000001000000001000001000101000011010010000000000000000000000001010001000101111100001100000000000000000000000001010001000101111100001100000000000000001000000001010001000100000101000111111000000000000000000001000011000100111100110100000000000000000000000001000011000100111100110100000000000000001000000001000011000100000101000000000000000000000000000001010011000100000000000000000000000000000000000001010011000100000000000000000000000000001000000001010011000101011101010010000000000000000000000001000000100100111100110000000000000000000000000001000000100100111100110000000000000000001000000001000000100100000101000111111000000000000000000001010000100101111100110000000000000000000000000001010000100101111100110000000000000000001000000001010000100100000101000000000000000000000000000001000010100100000000000000000000000000000000000001000010100100000000000000000000000000001000000001000010100101001001010010000000000000000000000001010010100100111100010100000000000000000000000001010010100100111100010100000000000000001000000001010010100100000101000000000000000000000000000001000001100101100100011110111000000000000000000001000001100101100100011110111000000000001000000001000001100100111111001110111000000000000000000001010001100100000000000010111000000000000000000001010001100100000000000010111000000000001000000001010001100101001111010010000000000000000000000001000011100100111100000100000000000000000000000001000011100100111100000100000000000000001000000001000011100100100101000110000000000000000000000001010011100100110001000100001000000000000000000001010011100100110001000100001000000000001000000001010011100100000000010000000000000000000000000001000000010101111100000100000000000000000000000001000000010101111100000100000000000000001000000001000000010101000000000000010000000000000000000001010000010101100100000110001000000000000000000001010000010101100100000110001000000000001000000001010000010101000000000000010000000000000000000001000010010101101000000100001000000000000000000001000010010101101000000100001000000000001000000001000010010101000000010000000000000000000000000001010010010100000000000000000000000000000000000001010010010100000000000000000000000000001000000001010010010100000000000000000000000000000000000001000001010100100100000100000000000000000000000001000001010100100100000100000000000000001000000001000001010100000000000000001000000000000000000001010001010101101100000111010000000000000000000001010001010101101100000111010000000000001000000001010001010100000010000000000000000000000000000001000011010100001000000000000000000000000000000001000011010100001000000000000000000000001000000001000011010101000000100000000000000000000000000001010011010100000000000000000000000000000000000001010011010100000000000000000000000000001000000001010011010100000000000000000000000000000000000001000000110100100100000100000000000000000000000001000000110100100100000100000000000000001000000001000000110100100000000000000000000000000000000001010000110101101100000111010000000000000000000001010000110101101100000111010000000000001000000001010000110100000001000000000000000000000000000001000010110100110101111010001000000000000000000001000010110100110101111010001000000000001000000001000010110100000000010000000000000000000000000001010010110101100100010111110000000000000000000001010010110101100100010111110000000000001000000001010010110100000000011000000000000000000000000001000001110100110000000000010000000000000000000001000001110100110000000000010000000000001000000001000001110100000000111101110000000000000000000001010001110100000000000000000000000000000000000001010001110100000000000000000000000000001000000001010001110100000000000000000000000000000000000001000011110100001000000001000000000000000000000001000011110100001000000001000000000000001000000001000011110100000000001110000000000000000000000001010011110100000000000000000000000000000000000001010011110100000000000000000000000000001000000001010011110100000000000000000000000000000000000001000000001100110101100010111000000000000000000001000000001100110101100010111000000000001000000001000000001100000000000000000000000000000000000001010000001101100100001000000000000000000000000001010000001101100100001000000000000000001000000001010000001100000100000000000000000000000000000001000010001101110101001000110000000000000000000001000010001101110101001000110000000000001000000001000010001100000000000000000000000000000000000001010010001101110001101011110000000000000000000001010010001101110001101011110000000000001000000001010010001100000000000000000000000000000000000001000001001100111100001000000000000000000000000001000001001100111100001000000000000000001000000001000001001101001111111111100000000000000000000001010001001100000000001011010000000000000000000001010001001100000000001011010000000000001000000001010001001100011010010010000000000000000000000001000011001101110101101010111000000000000000000001000011001101110101101010111000000000001000000001000011001100000000010000000000000000000000000001010011001101000100011110111000000000000000000001010011001101000100011110111000000000001000000001010011001100000000001000000000000000000000000001000000101101100100001000000000000000000000000001000000101101100100001000000000000000001000000001000000101100001000000000000000000000000000000001010000101101110101001000110000000000000000000001010000101101110101001000110000000000001000000001010000101100000000000000000000000000000000000001000010101100111100001000000000000000000000000001000010101100111100001000000000000000001000000001000010101101001101001100000000000000000000000001010010101100101000001011010000000000000000000001010010101100101000001011010000000000001000000001010010101100000000011000000000000000000000000001000001101100000000000000000000000000000000000001000001101100000000000000000000000000001000000001000001101100000000000000000000000000000000000001010001101100111100001000000000000000000000000001010001101100111100001000000000000000001000000001010001101100010000000000000000000000000000000001000011101100000000001000011000000000000000000001000011101100000000001000011000000000001000000001000011101100000011000010000000000000000000000001010011101100000000000110011000000000000000000001010011101100000000000110011000000000001000000001010011101100010011000010000000000000000000000001000000011100000000000110011000000000000000000001000000011100000000000110011000000000001000000001000000011100010011000010000000000000000000000001010000011100111100001000000000000000000000000001010000011100111100001000000000000000001000000001010000011100000000000010000000000000000000000001000010011100000000001001101000000000000000000001000010011100000000001001101000000000001000000001000010011100001101000010000000000000000000000001010010011100000000001000101000000000000000000001010010011100000000001000101000000000001000000001010010011100000101000010000000000000000000000001000001011100000000100100000000000000000000000001000001011100000000100100000000000000001000000001000001011100001001000001000000000000000000000001010001011100000100100101001000000000000000000001010001011100000100100101001000000000001000000001010001011101000000000000000000000000000000000001000011011100001000000000000000000000000000000001000011011100001000000000000000000000001000000001000011011101000000100000000000000000000000000001010011011100000000000000000000000000000000000001010011011100000000000000000000000000001000000001010011011100000000000000000000000000000000000001000000111100111100001000000000000000000000000001000000111100111100001000000000000000001000000001000000111100000000000100000000000000000000000001010000111100000000001000101000000000000000000001010000111100000000001000101000000000001000000001010000111100000101000010000000000000000000000001000010111100100100001000000000000000000000000001000010111100100100001000000000000000001000000001000010111100000100000000000000000000000000000001010010111100110101001000110000000000000000000001010010111100110101001000110000000000001000000001010010111100000000000000000000000000000000000001000001111101110001001011110000000000000000000001000001111101110001001011110000000000001000000001000001111100000000010010000000000000000000000001010001111100110001101111110000000000000000000001010001111100110001101111110000000000001000000001010001111100000000000000000000000000000000000001000011111100100100001000000000000000000000000001000011111100100100001000000000000000001000000001000011111100001000000000000000000000000000000001010011111100110101001000110000000000000000000001010011111100110101001000110000000000001000000001010011111100000000000000000000000000000000000001000000000011001100001010010000000000000000000001000000000011001100001010010000000000001000000001000000000011111111111111111000000000000000000001010000000010100100001000000000000000000000000001010000000010100100001000000000000000001000000001010000000010100000000000010000000000000000000001000010000010101000001010010000000000000000000001000010000010101000001010010000000000001000000001000010000011000000001000000000000000000000000001010010000010000000000000000000000000000000000001010010000010000000000000000000000000001000000001010010000010000000000000000000000000000000000001000001000011111100101100000000000000000000000001000001000011111100101100000000000000001000000001000001000010000000000000010000000000000000000001010001000011000000101101011000000000000000000001010001000011000000101101011000000000001000000001010001000010001011010010000000000000000000000001000011000010101000000001011000000000000000000001000011000010101000000001011000000000001000000001000011000011000000010000000000000000000000000001010011000010000000000000000000000000000000000001010011000010000000000000000000000000001000000001010011000010000000000000000000000000000000000001000000100010111100001000000000000000000000000001000000100010111100001000000000000000001000000001000000100010001000011100000000000000000000000001010000100010101100001000010000000000000000000001010000100010101100001000010000000000001000000001010000100010010000010000001000000000000000000001000010100010110101001011110000000000000000000001000010100010110101001011110000000000001000000001000010100010000000001100000000000000000000000001010010100010001000000000000000000000000000000001010010100010001000000000000000000000001000000001010010100011000000100000000000000000000000000001000001100010111100001000000000000000000000000001000001100010111100001000000000000000001000000001000001100010010000011000000000000000000000000001010001100010101100001000010000000000000000000001010001100010101100001000010000000000001000000001010001100010001000010000001000000000000000000001000011100010110101001011110000000000000000000001000011100010110101001011110000000000001000000001000011100010000000001100000000000000000000000001010011100010111100001000000000000000000000000001010011100010111100001000000000000000001000000001010011100010010000000000000000000000000000000001000000010010000000001001110000000000000000000001000000010010000000001001110000000000001000000001000000010010001110000010000000000000000000000001010000010010000000000111110000000000000000000001010000010010000000000111110000000000001000000001010000010010011110000010000000000000000000000001000010010010000000000111110000000000000000000001000010010010000000000111110000000000001000000001000010010010011110000010000000000000000000000001010010010011100100011010110000000000000000000001010010010011100100011010110000000000001000000001010010010011000000000000000000000000000000000001000001010010110100001010110000000000000000000001000001010010110100001010110000000000001000000001000001010010000000001000000000000000000000000001010001010010101000000000010000000000000000000001010001010010101000000000010000000000001000000001010001010010111111010001111000000000000000000001000011010010000000000000000000000000000000000001000011010010000000000000000000000000001000000001000011010010000000000000000000000000000000000001010011010010111100001000000000000000000000000001010011010010111100001000000000000000001000000001010011010010100011000000000000000000000000000001000000110010110101001001010000000000000000000001000000110010110101001001010000000000001000000001000000110010000000011000000000000000000000000001010000110010111100001000000000000000000000000001010000110010111100001000000000000000001000000001010000110010000001000000000000000000000000000001000010110010110101001001010000000000000000000001000010110010110101001001010000000000001000000001000010110010000000010000000000000000000000000001010010110010000000000001111000000000000000000001010010110010000000000001111000000000001000000001010010110011010111010010000000000000000000000001000001110010000000000000000000000000000000000001000001110010000000000000000000000000001000000001000001110011011000010010000000000000000000000001010001110011110001001010111000000000000000000001010001110011110001001010111000000000001000000001010001110010000000010000000000000000000000000001000011110010111100001000000000000000000000000001000011110010111100001000000000000000001000000001000011110011001101001000000000000000000000000001010011110010101000001010010000000000000000000001010011110010101000001010010000000000001000000001010011110010000000110100000000000000000000000001000000001010000000000000000000000000000000000001000000001010000000000000000000000000001000000001000000001010000000000000000000000000000000000001010000001010110101001110001000000000000000000001010000001010110101001110001000000000001000000001010000001010000000010000000000000000000000000001000010001011100100010110011000000000000000000001000010001011100100010110011000000000001000000001000010001010000000011000000000000000000000000001010010001010110001010010111000000000000000000001010010001010110001010010111000000000001000000001010010001010000000000000000000000000000000000001000001001011000100011110111000000000000000000001000001001011000100011110111000000000001000000001000001001010000000001000000000000000000000000001010001001011100100010000000000000000000000000001010001001011100100010000000000000000001000000001010001001011000000000000000000000000000000000001000011001010110000000000010000000000000000000001000011001010110000000000010000000000001000000001000011001010000000000100101000000000000000000001010011001010000000000000000000000000000000000001010011001010000000000000000000000000001000000001010011001010000000000000000000000000000000000001000000101010110001001001101000000000000000000001000000101010110001001001101000000000001000000001000000101010000000000000000000000000000000000001010000101010111100001000000000000000000000000001010000101010111100001000000000000000001000000001010000101010000000001000000000000000000000000001000010101010000000110100010000000000000000000001000010101010000000110100010000000000001000000001000010101010000010000010000000000000000000000001010010101011110001001000010000000000000000000001010010101011110001001000010000000000001000000001010010101010000000000000000000000000000000000001000001101010110001001001101000000000000000000001000001101010110001001001101000000000001000000001000001101010000000000000000000000000000000000001010001101010111100001000000000000000000000000001010001101010111100001000000000000000001000000001010001101010000000001000000000000000000000000001000011101010000000110100010000000000000000000001000011101010000000110100010000000000001000000001000011101010000010000010000000000000000000000001010011101011110001001000010000000000000000000001010011101011110001001000010000000000001000000001010011101010000000000000000000000000000000000001000000011010111100001000000000000000000000000001000000011010111100001000000000000000001000000001000000011010100000000000000000000000000000000001010000011010000000001001110000000000000000000001010000011010000000001001110000000000001000000001010000011010001110000010000000000000000000000001000010011010000000000110011000000000000000000001000010011010000000000110011000000000001000000001000010011010010011000010000000000000000000000001010010011010111100001000000000000000000000000001010010011010111100001000000000000000001000000001010010011010000000000100000000000000000000000001000001011010000000001001101000000000000000000001000001011010000000001001101000000000001000000001000001011010001101000010000000000000000000000001010001011010001000000000000000000000000000000001010001011010001000000000000000000000001000000001010001011011000000000010000000000000000000000001000011011011110101110110001000000000000000000001000011011011110101110110001000000000001000000001000011011010000000010000000000000000000000000001010011011011100100010101100000000000000000000001010011011011100100010101100000000000001000000001010011011010000000011000000000000000000000000001000000111010110001010010111000000000000000000001000000111010110001010010111000000000001000000001000000111010000000000000000000000000000000000001010000111011000100011110111000000000000000000001010000111011000100011110111000000000001000000001010000111010000000001000000000000000000000000001000010111011100100010000000000000000000000000001000010111011100100010000000000000000001000000001000010111011000000000000000000000000000000000001010010111010110000000000010000000000000000000001010010111010110000000000010000000000001000000001010010111010000000000100101000000000000000000001000001111010000000000000000000000000000000000001000001111010000000000000000000000000001000000001000001111010000000000000000000000000000000000001010001111010110001001011100000000000000000000001010001111010110001001011100000000000001000000001010001111010000000000000000000000000000000000001000011111010111100001000000000000000000000000001000011111010111100001000000000000000001000000001000011111010000000001000000000000000000000000001010011111011000000110000010000000000000000000001010011111011000000110000010000000000001000000001010011111010000010000010000000000000000000000001000000000111110001001000010000000000000000000001000000000111110001001000010000000000001000000001000000000110000000000000000000000000000000000001010000000110111100001000000000000000000000000001010000000110111100001000000000000000001000000001010000000110000000000100000000000000000000000001000010000111000000110000010000000000000000000001000010000111000000110000010000000000001000000001000010000110000010000010000000000000000000000001010010000111110001001000010000000000000000000001010010000111110001001000010000000000001000000001010010000110000000000000000000000000000000000001000001000110111100001000000000000000000000000001000001000110111100001000000000000000001000000001000001000110000000001100000000000000000000000001010001000111000000110000010000000000000000000001010001000111000000110000010000000000001000000001010001000110000010000010000000000000000000000001000011000111110001001000010000000000000000000001000011000111110001001000010000000000001000000001000011000110000000000000000000000000000000000001010011000110110001001011100000000000000000000001010011000110110001001011100000000000001000000001010011000110000000000000000000000000000000000001000000100110111100001000000000000000000000000001000000100110111100001000000000000000001000000001000000100110000000001000000000000000000000000001010000100111000000110000010000000000000000000001010000100111000000110000010000000000001000000001010000100110000010000010000000000000000000000001000010100111110001001000010000000000000000000001000010100111110001001000010000000000001000000001000010100110000000000000000000000000000000000001010010100110111100001000000000000000000000000001010010100110111100001000000000000000001000000001010010100110000000000100000000000000000000000001000001100111000000110000010000000000000000000001000001100111000000110000010000000000001000000001000001100110000010000010000000000000000000000001010001100111110001001000010000000000000000000001010001100111110001001000010000000000001000000001010001100110000000000000000000000000000000000001000011100110111100001000000000000000000000000001000011100110111100001000000000000000001000000001000011100110000000001100000000000000000000000001010011100111000000110000010000000000000000000001010011100111000000110000010000000000001000000001010011100110000010000010000000000000000000000001000000010111110001001000010000000000000000000001000000010111110001001000010000000000001000000001000000010110000000000000000000000000000000000001010000010110111100001000000000000000000000000001010000010110111100001000000000000000001000000001010000010110010000000000000000000000000000000001000010010110000000001011101000000000000000000001000010010110000000001011101000000000001000000001000010010110011101000010000000000000000000000001010010010110000000000101100000000000000000000001010010010110000000000101100000000000001000000001010010010110001100000010000000000000000000000001000001010110000000000101100000000000000000000001000001010110000000000101100000000000001000000001000001010110001100000010000000000000000000000001010001010110111100001000000000000000000000000001010001010110111100001000000000000000001000000001010001010110000000000010000000000000000000000001000011010110000000001011100000000000000000000001000011010110000000001011100000000000001000000001000011010110011100000010000000000000000000000001010011010111100100100011000000000000000000000001010011010111100100100011000000000000001000000001010011010111000000000000000000000000000000000001000000110111000000011011000000000000000000000001000000110111000000011011000000000000001000000001000000110110000010101010000000000000000000000001010000110110101000000000010000000000000000000001010000110110101000000000010000000000001000000001010000110111111111100001111000000000000000000001000010110110000000000000000000000000000000000001000010110110000000000000000000000000001000000001000010110110000000000000000000000000000000000001010010110110111100101000000000000000000000000001010010110110111100101000000000000000001000000001010010110110100101000111000000000000000000000001000001110110000000100100000000000000000000000001000001110110000000100100000000000000001000000001000001110110101001000001100000000000000000000001010001110111111100001000000000000000000000000001010001110111111100001000000000000000001000000001010001110110000000110000000000000000000000000001000011110111101100001010010000000000000000000001000011110111101100001010010000000000001000000001000011110110101100010110001000000000000000000001010011110110000000100110010000000000000000000001010011110110000000100110010000000000001000000001010011110111010010010010000000000000000000000001000000001111110101001001010000000000000000000001000000001111110101001001010000000000001000000001000000001110000000000100000000000000000000000001010000001111110001001001010000000000000000000001010000001111110001001001010000000000001000000001010000001110000000000100000000000000000000000001000010001110111100001000000000000000000000000001000010001110111100001000000000000000001000000001000010001110000101000000000000000000000000000001010010001110101100001000010000000000000000000001010010001110101100001000010000000000001000000001010010001110000000000000011000000000000000000001000001001111111100001000000000000000000000000001000001001111111100001000000000000000001000000001000001001111110000111111111000000000000000000001010001001111101100001010010000000000000000000001010001001111101100001010010000000000001000000001010001001111111111111111111000000000000000000001000011001111000000001001101000000000000000000001000011001111000000001001101000000000001000000001000011001110001101010010000000000000000000000001010011001110110101110100010000000000000000000001010011001110110101110100010000000000001000000001010011001110000000001100000000000000000000000001000000101110000000000001111000000000000000000001000000101110000000000001111000000000001000000001000000101111010111010010000000000000000000000001010000101111100100011110111000000000000000000001010000101111100100011110111000000000001000000001010000101110000000001001000000000000000000000001000010101111110001100110111000000000000000000001000010101111110001100110111000000000001000000001000010101110000000000000000000000000000000000001010010101110110001010110111000000000000000000001010010101110110001010110111000000000001000000001010010101110000000010000000000000000000000000001000001101111110001010110111000000000000000000001000001101111110001010110111000000000001000000001000001101110000000001000000000000000000000000001010001101110110001110110111000000000000000000001010001101110110001110110111000000000001000000001010001101110000000011000000000000000000000000001000011101111110001110110111000000000000000000001000011101111110001110110111000000000001000000001000011101110000000000100000000000000000000000001010011101111100100011110111000000000000000000001010011101111100100011110111000000000001000000001010011101110000000001100000000000000000000000001000000011110111100001000000000000000000000000001000000011110111100001000000000000000001000000001000000011110000001000000000000000000000000000001010000011110100100001000010000000000000000000001010000011110100100001000010000000000001000000001010000011110000000000000000000000000000000000001000010011111100100001000010000000000000000000001000010011111100100001000010000000000001000000001000010011110000010000000000000000000000000000001010010011111100100001010010000000000000000000001010010011111100100001010010000000000001000000001010010011110111111000011111000000000000000000001000001011110000010000000100000000000000000000001000001011110000010000000100000000000001000000001000001011110000111000000000000000000000000000001010001011110000010000000100000000000000000000001010001011110000010000000100000000000001000000001010001011110010111000000000000000000000000000001000011011110111101001000010000000000000000000001000011011110111101001000010000000000001000000001000011011110000000000000000000000000000000000001010011011111000000001000010000000000000000000001010011011111000000001000010000000000001000000001010011011111010000101010000000000000000000000001000000111110101000000010000000000000000000000001000000111110101000000010000000000000001000000001000000111111111111011111111000000000000000000001010000111110100100001000010000000000000000000001010000111110100100001000010000000000001000000001010000111110000000000010000000000000000000000001000010111110111100001000000000000000000000000001000010111110111100001000000000000000001000000001000010111110000001000000000000000000000000000001010010111110100100001000010000000000000000000001010010111110100100001000010000000000001000000001010010111110000000000000000000000000000000000001000001111111100100001000010000000000000000000001000001111111100100001000010000000000001000000001000001111110000100000000000000000000000000000001010001111111100100001010010000000000000000000001010001111111100100001010010000000000001000000001010001111110111111000111111000000000000000000001000011111111111101001000010000000000000000000001000011111111111101001000010000000000001000000001000011111110000000000000000000000000000000000001010011111111000000001000010000000000000000000001010011111111000000001000010000000000001000000001010011111111010000101010000010000000000000000001000000000000101000000010000010000000000000000001000000000000101000000010000010000000001000000001000000000001111111011111111010000000000000000001010000000000100100001000010010000000000000000001010000000000100100001000010010000000001000000001010000000000000000000100000010000000000000000001000010000000001000000000000010000000000000000001000010000000001000000000000010000000001000000001000010000001000000100100000010000000000000000001010010000000000000000000000010000000000000000001010010000000000000000000000010000000001000000001010010000000000000000000000010000000000000000001000001000000111100001000000010000000000000000001000001000000111100001000000010000000001000000001000001000000000001000000000010000000000000000001010001000000100100001000010010000000000000000001010001000000100100001000010010000000001000000001010001000000000000000000000010000000000000000001000011000001100100001000010010000000000000000001000011000001100100001000010010000000001000000001000011000000000010000000000010000000000000000001010011000001100100001010010010000000000000000001010011000001100100001010010010000000001000000001010011000000111111000011111010000000000000000001000000100000000010000000100010000000000000000001000000100000000010000000100010000000001000000001000000100000000111000000000010000000000000000001010000100000000010000000100010000000000000000001010000100000000010000000100010000000001000000001010000100000010111000000000010000000000000000001000010100000111101001000010010000000000000000001000010100000111101001000010010000000001000000001000010100000000000000000000010000000000000000001010010100001000000001000010010000000000000000001010010100001000000001000010010000000001000000001010010100001010000101010000010000000000000000001000001100000101000000010000010000000000000000001000001100000101000000010000010000000001000000001000001100001111111011111111010000000000000000001010001100000100100001000010010000000000000000001010001100000100100001000010010000000001000000001010001100000000000000010000010000000000000000001000011100000111100001000000010000000000000000001000011100000111100001000000010000000001000000001000011100000000001000000000010000000000000000001010011100000100100001000010010000000000000000001010011100000100100001000010010000000001000000001010011100000000000000000000010000000000000000001000000010001100100001000010010000000000000000001000000010001100100001000010010000000001000000001000000010000000100000000000010000000000000000001010000010001100100001010010010000000000000000001010000010001100100001010010010000000001000000001010000010000111111000111111010000000000000000001000010010001111101000000010010000000000000000001000010010001111101000000010010000000001000000001000010010000000000000000000010000000000000000001010010010001000000001000010010000000000000000001010010010001000000001000010010000000001000000001010010010001010000101010000010000000000000000001000001010000101000000010000010000000000000000001000001010000101000000010000010000000001000000001000001010001111111011111111010000000000000000001010001010000100100001000010010000000000000000001010001010000100100001000010010000000001000000001010001010000000000000100000010000000000000000001000011010000111100101000000010000000000000000001000011010000111100101000000010000000001000000001000011010000100101000000000010000000000000000001010011010000100100101001010010000000000000000001010011010000100100101001010010000000001000000001010011010000000000000000000010000000000000000001000000110001111100101000000010000000000000000001000000110001111100101000000010000000001000000001000000110000111111000111111010000000000000000001010000110001111100001000000010000000000000000001010000110001111100001000000010000000001000000001010000110000000000000100000010000000000000000001000010110001000000101001010010000000000000000001000010110001000000101001010010000000001000000001000010110000001010010010000010000000000000000001010010110000111100001000000010000000000000000001010010110000111100001000000010000000001000000001010010110000100101000000000010000000000000000001000001110001100100001010010010000000000000000001000001110001100100001010010010000000001000000001000001110001111111111111111010000000000000000001010001110001111100101000000010000000000000000001010001110001111100101000000010000000001000000001010001110000100101000000000010000000000000000001000011110000100100001000010010000000000000000001000011110000100100001000010010000000001000000001000011110000100000000001100010000000000000000001010011110001100100101011010010000000000000000001010011110001100100101011010010000000001000000001010011110000100000010111011010000000000000000001000000001001000000001000010010000000000000000001000000001001000000001000010010000000001000000001000000001000000010010010000010000000000000000001010000001001000000001011010010000000000000000001010000001001000000001011010010000000001000000001010000001000011010010010000010000000000000000001000010001001111100001000000010000000000000000001000010001001111100001000000010000000001000000001000010001000000101000000000010000000000000000001010010001000000000101000010010000000000000000001010010001000000000101000010010000000001000000001010010001001000010010010000010000000000000000001000001001000000000101011010010000000000000000001000001001000000000101011010010000000001000000001000001001001011010010010000010000000000000000001010001001001100100001010010010000000000000000001010001001001100100001010010010000000001000000001010001001000000000000000000010000000000000000001000011001001110001011000010010000000000000000001000011001001110001011000010010000000001000000001000011001000000000000000000010000000000000000001010011001000100100001000010010000000000000000001010011001000100100001000010010000000001000000001010011001000000000010000000010000000000000000001000000101001000000101000010010000000000000000001000000101001000000101000010010000000001000000001000000101001010000101010000010000000000000000001010000101001100100001010010010000000000000000001010000101001100100001010010010000000001000000001010000101000000000010000000010000000000000000001000010101000101000000010000010000000000000000001000010101000101000000010000010000000001000000001000010101001111111101111111010000000000000000001010010101001110101011010010010000000000000000001010010101001110101011010010010000000001000000001010010101000111111011111111010000000000000000001000001101000111100011000000010000000000000000001000001101000111100011000000010000000001000000001000001101000000001000000000010000000000000000001010001101000100100011000110010000000000000000001010001101000100100011000110010000000001000000001010001101000000000000000000010000000000000000001000011101000000000000000110010000000000000000001000011101000000000000000110010000000001000000001000011101000000000001000000010000000000000000001010011101000000000000000000010000000000000000001010011101000000000000000000010000000001000000001010011101000000000000000000010000000000000000001000000011001111100101000000010000000000000000001000000011001111100101000000010000000001000000001000000011000001101000000000010000000000000000001010000011001110001001011010010000000000000000001010000011001110001001011010010000000001000000001010000011000000000001000000010000000000000000001000010011000111100101000000010000000000000000001000010011000111100101000000010000000001000000001000010011001111000111111111010000000000000000001010010011000101100101001010010000000000000000001010010011000101100101001010010000000001000000001010010011001111111111111111010000000000000000001000001011001111100000000000010000000000000000001000001011001111100000000000010000000001000000001000001011000100101000011000010000000000000000001010001011000000000101010010010000000000000000001010001011000000000101010010010000000001000000001010001011000010010010010000010000000000000000001000011011001110101001010000010000000000000000001000011011001110101001010000010000000001000000001000011011000000000000000000010000000000000000001010011011000111100001000000010000000000000000001010011011000111100001000000010000000001000000001010011011000100101000011000010000000000000000001000000111000110001001000010010000000000000000001000000111000110001001000010010000000001000000001000000111000000000000100000010000000000000000001010000111000001100001000010010000000000000000001010000111000001100001000010010000000001000000001010000111000000000100000000010000000000000000001000010111000101010000000010010000000000000000001000010111000101010000000010010000000001000000001000010111001111111011111111010000000000000000001010010111000111100001000000010000000000000000001010010111000111100001000000010000000001000000001010010111000100101000011000010000000000000000001000001111000100100001000000010000000000000000001000001111000100100001000000010000000001000000001000001111000001000000000000010000000000000000001010001111001000000101000010010000000000000000001010001111001000000101000010010000000001000000001010001111000000010000010000010000000000000000001000011111000000000101000010010000000000000000001000011111000000000101000010010000000001000000001000011111000000010010010000010000000000000000001010011111001111100000000000010000000000000000001010011111001111100000000000010000000001000000001010011111000100101000011000010000000000000000001000000000100110101001010000010000000000000000001000000000100110101001010000010000000001000000001000000000100000000010000000010000000000000000001010000000100111100101000000010000000000000000001010000000100111100101000000010000000001000000001010000000100000000000100000010000000000000000001000010000100100100101001010010000000000000000001000010000100100100101001010010000000001000000001000010000101111111111111111010000000000000000001010010000101111100000000000010000000000000000001010010000101111100000000000010000000001000000001010010000100100101000011000010000000000000000001000001000100110101101010000010000000000000000001000001000100110101101010000010000000001000000001000001000100000000011000000010000000000000000001010001000100000000000000000010000000000000000001010001000100000000000000000010000000001000000001010001000100000000000000000010000000000000000001000011000100000000000000000010000000000000000001000011000100000000000000000010000000001000000001000011000100000000000000000010000000000000000001010011000100000000000000000010000000000000000001010011000100000000000000000010000000001000000001010011000100000000000000000010000000000000000001000000100100000000000000000010000000000000000001000000100100000000000000000010000000001000000001000000100100000000000000000010000000000000000001010000100100000000000000000010000000000000000001010000100100000000000000000010000000001000000001010000100100000000000000000010000000000000000001000010100100000000000000000010000000000000000001000010100100000000000000000010000000001000000001000010100100000000000000000010000000000000000001010010100100000000000000000010000000000000000001010010100100000000000000000010000000001000000001010010100100000000000000000010000000000000000001000001100100000000000000000010000000000000000001000001100100000000000000000010000000001000000001000001100100000000000000000010000000000000000001010001100100000000000000000010000000000000000001010001100100000000000000000010000000001000000001010001100100000000000000000010000000000000000001000011100100000000000000000010000000000000000001000011100100000000000000000010000000001000000001000011100100000000000000000010000000000000000001010011100100000000000000000010000000000000000001010011100100000000000000000010000000001000000001010011100100000000000000000010000000000000000001000000010100000000000000000010000000000000000001000000010100000000000000000010000000001000000001000000010100000000000000000010000000000000000001010000010100000000000000000010000000000000000001010000010100000000000000000010000000001000000001010000010100000000000000000010000000000000000001000010010100000000000000000010000000000000000001000010010100000000000000000010000000001000000001000010010100000000000000000010000000000000000001010010010100000000000000000010000000000000000001010010010100000000000000000010000000001000000001010010010100000000000000000010000000000000000001000001010100000000000000000010000000000000000001000001010100000000000000000010000000001000000001000001010100000000000000000010000000000000000001010001010100000000000000000010000000000000000001010001010100000000000000000010000000001000000001010001010100000000000000000010000000000000000001000011010100000000000000000010000000000000000001000011010100000000000000000010000000001000000001000011010100000000000000000010000000000000000001010011010100000000000000000010000000000000000001010011010100000000000000000010000000001000000001010011010100000000000000000010000000000000000001000000110100000000000000000010000000000000000001000000110100000000000000000010000000001000000001000000110100000000000000000010000000000000000001010000110100000000000000000010000000000000000001010000110100000000000000000010000000001000000001010000110100000000000000000010000000000000000001000010110100000000000000000010000000000000000001000010110100000000000000000010000000001000000001000010110100000000000000000010000000000000000001010010110100000000000000000010000000000000000001010010110100000000000000000010000000001000000001010010110100000000000000000010000000000000000001000001110100000000000000000010000000000000000001000001110100000000000000000010000000001000000001000001110100000000000000000010000000000000000001010001110100000000000000000010000000000000000001010001110100000000000000000010000000001000000001010001110100000000000000000010000000000000000001000011110100000000000000000010000000000000000001000011110100000000000000000010000000001000000001000011110100000000000000000010000000000000000001010011110100000000000000000010000000000000000001010011110100000000000000000010000000001000000001010011110100000000000000000010000000000000000001000000001100000000000000000010000000000000000001000000001100000000000000000010000000001000000001000000001100000000000000000010000000000000000001010000001101111100101000000010000000000000000001010000001101111100101000000010000000001000000001010000001100100101000011000010000000000000000001000010001101110001101011010010000000000000000001000010001101110001101011010010000000001000000001000010001100000000000100000010000000000000000001010010001101001100101011010010000000000000000001010010001101001100101011010010000000001000000001010010001101000000000000000010000000000000000001000001001100101000000011010010000000000000000001000001001100101000000011010010000000001000000001000001001100111111000011111010000000000000000001010001001100000000000000000010000000000000000001010001001100000000000000000010000000001000000001010001001100000000000000000010000000000000000001000011001101111100101000000010000000000000000001000011001101111100101000000010000000001000000001000011001100001101000000000010000000000000000001010011001100110001010011010010000000000000000001010011001100110001010011010010000000001000000001010011001100000000001000000010000000000000000001000000101100000000000001101010000000000000000001000000101100000000000001101010000000001000000001000000101101010100010010000010000000000000000001010000101101111100000000000010000000000000000001010000101101111100000000000010000000001000000001010000101100111010001101010010000000000000000001000010101101101100000010000010000000000000000001000010101101101100000010000010000000001000000001000010101101010001010011011010000000000000000001010010101101000000000010100010000000000000000001010010101101000000000010100010000000001000000001010010101101000000001100000010000000000000000001000001101101100100011110111010000000000000000001000001101101100100011110111010000000001000000001000001101100111111000011111010000000000000000001010001101101110101111110111010000000000000000001010001101101110101111110111010000000001000000001010001101100000000011100000010000000000000000001000011101100110101000110111010000000000000000001000011101100110101000110111010000000001000000001000011101100000000010100000010000000000000000001010011101101111100111100000010000000000000000001010011101101111100111100000010000000001000000001010011101100000000000100000010000000000000000001000000011100000000000000000010000000000000000001000000011100000000000000000010000000001000000001000000011101011000010010000010000000000000000001010000011100000000000000000010000000000000000001010000011100000000000000000010000000001000000001010000011101000010010010000010000000000000000001000010011100000000000000100010000000000000000001000010011100000000000000100010000000001000000001000010011101010010010010000010000000000000000001010010011101100100011000000010000000000000000001010010011101100100011000000010000000001000000001010010011100000000000010000010000000000000000001000001011100000000000000000010000000000000000001000001011100000000000000000010000000001000000001000001011100001000100100000010000000000000000001010001011100100100100001000010000000000000000001010001011100100100100001000010000000001000000001010001011101000000000000000010000000000000000001000011011100000000000001000010000000000000000001000011011100000000000001000010000000001000000001000011011101011100010010000010000000000000000001010011011100000000000001000010000000000000000001010011011100000000000001000010000000001000000001010011011101001010010010000010000000000000000001000000111100000000000001000010000000000000000001000000111100000000000001000010000000001000000001000000111101011010010010000010000000000000000001010000111100000000000001000010000000000000000001010000111100000000000001000010000000001000000001010000111101000001010010000010000000000000000001000010111100000000000001000010000000000000000001000010111100000000000001000010000000001000000001000010111101001100010010000010000000000000000001010010111100000000000001000010000000000000000001010010111100000000000001000010000000001000000001010010111101000110010010000010000000000000000001000001111100110001100010010010000000000000000001000001111100110001100010010010000000001000000001000001111100000000000000000010000000000000000001010001111100000000100011100010000000000000000001010001111100000000100011100010000000001000000001010001111101011000000010000010000000000000000001000011111101000000110011000010000000000000000001000011111101000000110011000010000000001000000001000011111101010000101010000010000000000000000001010011111100001000000010000010000000000000000001010011111100001000000010000010000000001000000001010011111100000000100000000010000000000000000001000000000010000000000011000010000000000000000001000000000010000000000011000010000000001000000001000000000011010100010010000010000000000000000001010000000010100100101001010010000000000000000001010000000010100100101001010010000000001000000001010000000011000000000000000010000000000000000001000010000011001100100001000010000000000000000001000010000011001100100001000010000000001000000001000010000011000000111100000010000000000000000001010010000011000000100010110010000000000000000001010010000011000000100010110010000000001000000001010010000011011110100010000010000000000000000001000001000010000000100011110010000000000000000001000001000010000000100011110010000000001000000001000001000010000011110000000010000000000000000001010001000010000000100011000010000000000000000001010001000010000000100011000010000000001000000001010001000010001110010000000010000000000000000001000011000010000000001101110010000000000000000001000011000010000000001101110010000000001000000001000011000011000100010010000010000000000000000001010011000010000000100001100010000000000000000001010011000010000000100001100010000000001000000001010011000011010000101010000010000000000000000001000000100010000000000010100010000000000000000001000000100010000000000010100010000000001000000001000000100011011100010010000010000000000000000001010000100010000000100011010010000000000000000001010000100010000000100011010010000000001000000001010000100010011010110010000010000000000000000001000010100010001000000010000010000000000000000001000010100010001000000010000010000000001000000001000010100010000000010000000010000000000000000001010010100010000000010000001010000000000000000001010010100010000000010000001010000000001000000001010010100011000001000010000010000000000000000001000001100010000000100011100010000000000000000001000001100010000000100011100010000000001000000001000001100010010011110010000010000000000000000001010001100010001000000000000010000000000000000001010001100010001000000000000010000000001000000001010001100010000000100000000010000000000000000001000011100010000000110010011010000000000000000001000011100010000000110010011010000000001000000001000011100010001100110010000010000000000000000001010011100010000000010001100010000000000000000001010011100010000000010001100010000000001000000001010011100010001100110010000010000000000000000001000000010010100100001000010010000000000000000001000000010010100100001000010010000000001000000001000000010010000000010000000010000000000000000001010000010010000000000101000010000000000000000001010000010010000000000101000010000000001000000001010000010010011110110010000010000000000000000001000010010011100100001010010010000000000000000001000010010011100100001010010010000000001000000001000010010010000000010000000010000000000000000001010010010011101000111100010010000000000000000001010010010011101000111100010010000000001000000001010010010010111111001011111010000000000000000001000001010010000000011011110010000000000000000001000001010010000000011011110010000000001000000001000001010011000110000010000010000000000000000001010001010010000000101011100010000000000000000001010001010010000000101011100010000000001000000001010001010010001110110010000010000000000000000001000011010011000000101001110010000000000000000001000011010011000000101001110010000000001000000001000011010010011100110010000010000000000000000001010011010010000000110000001010000000000000000001010011010010000000110000001010000000001000000001010011010010000011110010000010000000000000000001000000110010000000011000011010000000000000000001000000110010000000011000011010000000001000000001000000110010000001110010000010000000000000000001010000110011111100101000000010000000000000000001010000110011111100101000000010000000001000000001010000110010001101000000000010000000000000000001000010110010110001001011010010000000000000000001000010110010110001001011010010000000001000000001000010110010000000000100000010000000000000000001010010110010101000001011100010000000000000000001010010110010101000001011100010000000001000000001010010110010000000110000000010000000000000000001000001110010000000000000000010000000000000000001000001110010000000000000000010000000001000000001000001110010000000000000000010000000000000000001010001110010110001001011010010000000000000000001010001110010110001001011010010000000001000000001010001110010000000010100000010000000000000000001000011110010101000001000001010000000000000000001000011110010101000001000001010000000001000000001000011110011000000100000000010000000000000000001010011110010000000000000000010000000000000000001010011110010000000000000000010000000001000000001010011110010000000000000000010000000000000000001000000001011100000000100000010000000000000000001000000001011100000000100000010000000001000000001000000001011000000100000000010000000000000000001010000001010000000000000000010000000000000000001010000001010000000000000000010000000001000000001010000001010000000000000000010000000000000000001000010001011100000000100000010000000000000000001000010001011100000000100000010000000001000000001000010001011111111111111111010000000000000000001010010001010000000000000000010000000000000000001010010001010000000000000000010000000001000000001010010001010000000000000000010000000000000000001000001001011111100001000000010000000000000000001000001001011111100001000000010000000001000000001000001001010100101001000000010000000000000000001010001001011110001001010010010000000000000000001010001001011110001001010010010000000001000000001010001001010000000000000000010000000000000000001000011001010110001000110111010000000000000000001000011001010110001000110111010000000001000000001000011001010000000010100000010000000000000000001010011001011110001111110111010000000000000000001010011001011110001111110111010000000001000000001010011001010000000011100000010000000000000000001000000101010001000000010010010000000000000000001000000101010001000000010010010000000001000000001000000101010000000110000000010000000000000000001010000101011100100011110111010000000000000000001010000101011100100011110111010000000001000000001010000101010000000000010000010000000000000000001000010101010100100101000000010000000000000000001000010101010100100101000000010000000001000000001000010101011000000000001000010000000000000000001010010101011111100000000000010000000000000000001010010101011111100000000000010000000001000000001010010101010100101010000000010000000000000000001000001101010110101101010000010000000000000000001000001101010110101101010000010000000001000000001000001101010000000000100000010000000000000000001010001101011111100000000000010000000000000000001010001101011111100000000000010000000001000000001010001101010100101001000000010000000000000000001000011101010110101000010000010000000000000000001000011101010110101000010000010000000001000000001000011101010000000000000000010000000000000000001010011101011111100101000000010000000000000000001010011101011111100101000000010000000001000000001010011101010000000101010100010000000000000000001000000011011101100101011010010000000000000000001000000011011101100101011010010000000001000000001000000011010010101111010101010000000000000000001010000011011111100000000000010000000000000000001010000011011111100000000000010000000001000000001010000011010100101010000000010000000000000000001000010011011110101101010000010000000000000000001000010011011110101101010000010000000001000000001000010011010000000000100000010000000000000000001010010011011111100000000000010000000000000000001010010011011111100000000000010000000001000000001010010011010100101000110000010000000000000000001000001011010100100001000000010000000000000000001000001011010100100001000000010000000001000000001000001011011100000010101010010000000000000000001010001011010110101001010000010000000000000000001010001011010110101001010000010000000001000000001010001011010000000011000000010000000000000000001000011011011111100000000000010000000000000000001000011011011111100000000000010000000001000000001000011011010100101000000100010000000000000000001010011011010110101000010000010000000000000000001010011011010110101000010000010000000001000000001010011011010000000001100000010000000000000000001000000111011111100000000000010000000000000000001000000111011111100000000000010000000001000000001000000111010100101000101000010000000000000000001010000111010110101000010000010000000000000000001010000111010110101000010000010000000001000000001010000111010000000011000000010000000000000000001000010111011111100000000000010000000000000000001000010111011111100000000000010000000001000000001000010111010100101000110000010000000000000000001010010111011100100001000000010000000000000000001010010111011100100001000000010000000001000000001010010111010010000000000000010000000000000000001000001111011110101001010000010000000000000000001000001111011110101001010000010000000001000000001000001111010000000000000000010000000000000000001010001111011100100001000000010000000000000000001010001111011100100001000000010000000001000000001010001111010000000100000000010000000000000000001000011111011111100000000000010000000000000000001000011111011111100000000000010000000001000000001000011111010100101000011000010000000000000000001010011111010111100001000000010000000000000000001010011111010111100001000000010000000001000000001010011111010000101000000000010000000000000000001000000000110101100001000010010000000000000000001000000000110101100001000010010000000001000000001000000000110000000000000011010000000000000000001010000000111110101001010000010000000000000000001010000000111110101001010000010000000001000000001010000000110000000000100000010000000000000000001000010000111110101110100010010000000000000000001000010000111110101110100010010000000001000000001000010000110000000010100000010000000000000000001010010000111110101010100010010000000000000000001010010000111110101010100010010000000001000000001010010000110000000011000000010000000000000000001000001000111110101100100010010000000000000000001000001000111110101100100010010000000001000000001000001000110000000010000000010000000000000000001010001000110001000000011001010000000000000000001010001000110001000000011001010000000001000000001010001000110000000010000000010000000000000000001000011000110110101010100010010000000000000000001000011000110110101010100010010000000001000000001000011000110000000000000000010000000000000000001010011000111111100001000000010000000000000000001010011000111111100001000000010000000001000000001010011000110100101000000001010000000000000000001000000100110001000000000000010000000000000000001000000100110001000000000000010000000001000000001000000100111000000100000000010000000000000000001010000100111100100001010010010000000000000000001010000100111100100001010010010000000001000000001010000100110000000000000000010000000000000000001000010100111111100001000000010000000000000000001000010100111111100001000000010000000001000000001000010100110001101000000000010000000000000000001010010100111100100001010010010000000000000000001010010100111100100001010010010000000001000000001010010100110000000000000000010000000000000000001000001100111110101001000010010000000000000000001000001100111110101001000010010000000001000000001000001100110000000001000000010000000000000000001010001100110111100001000000010000000000000000001010001100110111100001000000010000000001000000001010001100110100101000000000010000000000000000001000011100110100100001000010010000000000000000001000011100110100100001000010010000000001000000001000011100110000000000000000010000000000000000001010011100111000100001000010010000000000000000001010011100111000100001000010010000000001000000001010011100110001000000000000010000000000000000001000000010110100100001000010010000000000000000001000000010110100100001000010010000000001000000001000000010110000000010000000010000000000000000001010000010111101000001000010010000000000000000001010000010111101000001000010010000000001000000001010000010110111111111111111010000000000000000001000010010110110101000000010010000000000000000001000010010110110101000000010010000000001000000001000010010110111111011111111010000000000000000001010010010110111100001000000010000000000000000001010010010110111100001000000010000000001000000001010010010110100101000000000010000000000000000001000001010110100100001000010010000000000000000001000001010110100100001000010010000000001000000001000001010110001000000000000010000000000000000001010001010111000100001000010010000000000000000001010001010111000100001000010010000000001000000001010001010110001000000000000010000000000000000001000011010110100100001000010010000000000000000001000011010110100100001000010010000000001000000001000011010110000000010000000010000000000000000001010011010111101000001000010010000000000000000001010011010111101000001000010010000000001000000001010011010110111111111111111010000000000000000001000000110110110101000000010010000000000000000001000000110110110101000000010010000000001000000001000000110110111111011111111010000000000000000001010000110111111100101000000010000000000000000001010000110111111100101000000010000000001000000001010000110110001101000000000010000000000000000001000010110111110001001011010010000000000000000001000010110111110001001011010010000000001000000001000010110110000000001000000010000000000000000001010010110110000000000010010010000000000000000001010010110110000000000010010010000000001000000001010010110110000000001000000010000000000000000001000001110110000000000000000010000000000000000001000001110110000000000000000010000000001000000001000001110110000000000000000010000000000000000001010001110110000000000000000010000000000000000001010001110110000000000000000010000000001000000001010001110110000000000000000010000000000000000001000011110111100100011110111010000000000000000001000011110111100100011110111010000000001000000001000011110110111111000011011010000000000000000001010011110110110101000110111010000000000000000001010011110110110101000110111010000000001000000001010011110110000000000001000010000000000000000001000000001111110101000110111010000000000000000001000000001111110101000110111010000000001000000001000000001110000000010001000010000000000000000001010000001110000000000000000010000000000000000001010000001110000000000000000010000000001000000001010000001111010001010010000010000000000000000001000010001110000000000000000010000000000000000001000010001110000000000000000010000000001000000001000010001111000001010010000010000000000000000001010010001110110101100010111010000000000000000001010010001110110101100010111010000000001000000001010010001110000000000000000010000000000000000001000001001111110101100010111010000000000000000001000001001111110101100010111010000000001000000001000001001110000000010000000010000000000000000001010001001110110101010010111010000000000000000001010001001110110101010010111010000000001000000001010001001110000000001000000010000000000000000001000011001111110101010010111010000000000000000001000011001111110101010010111010000000001000000001000011001110000000011000000010000000000000000001010011001110110101110010111010000000000000000001010011001110110101110010111010000000001000000001010011001110000000000100000010000000000000000001000000101111110101110010111010000000000000000001000000101111110101110010111010000000001000000001000000101110000000010100000010000000000000000001010000101110110101001010111010000000000000000001010000101110110101001010111010000000001000000001010000101110000000001100000010000000000000000001000010101111110101001010111010000000000000000001000010101111110101001010111010000000001000000001000010101110000000011100000010000000000000000001010010101110110101101010111010000000000000000001010010101110110101101010111010000000001000000001010010101110000000000010000010000000000000000001000001101111110101101010111010000000000000000001000001101111110101101010111010000000001000000001000001101110000000010010000010000000000000000001010001101110110101011010111010000000000000000001010001101110110101011010111010000000001000000001010001101110000000001010000010000000000000000001000011101111110101011010111010000000000000000001000011101111110101011010111010000000001000000001000011101110000000011010000010000000000000000001010011101110110101111010111010000000000000000001010011101110110101111010111010000000001000000001010011101110000000000110000010000000000000000001000000011111110101111010111010000000000000000001000000011111110101111010111010000000001000000001000000011110000000010110000010000000000000000001010000011110110101001110111010000000000000000001010000011110110101001110111010000000001000000001010000011110000000001110000010000000000000000001000010011111110101001110111010000000000000000001000010011111110101001110111010000000001000000001000010011110000000011110000010000000000000000001010010011110110101100110111010000000000000000001010010011110110101100110111010000000001000000001010010011110000000001001000010000000000000000001000001011111110101100110111010000000000000000001000001011111110101100110111010000000001000000001000001011110000000011001000010000000000000000001010001011110110101010110111010000000000000000001010001011110110101010110111010000000001000000001010001011110000000000101000010000000000000000001000011011111110101010110111010000000000000000001000011011111110101010110111010000000001000000001000011011110000000010101000010000000000000000001010011011110110101110110111010000000000000000001010011011110110101110110111010000000001000000001010011011110000000001101000010000000000000000001000000111111110101110110111010000000000000000001000000111111110101110110111010000000001000000001000000111110000000011101000010000000000000000001010000111110110101111110111010000000000000000001010000111110110101111110111010000000001000000001010000111110000000000011000010000000000000000001000010111111110101111110111010000000000000000001000010111111110101111110111010000000001000000001000010111110000000010011000010000000000000000001010010111110110000000000010010000000000000000001010010111110110000000000010010000000001000000001010010111110000000000010001010000000000000000001000001111110000000000000000010000000000000000001000001111110000000000000000010000000001000000001000001111110000000000000000010000000000000000001010001111110100100000100001010000000000000000001010001111110100100000100001010000000001000000001010001111111000000000000000010000000000000000001000011111111010100001000001010000000000000000001000011111111010100001000001010000000001000000001000011111110000000010000000010000000000000000001010011111110101000000010010010000000000000000001010011111110101000000010010010000000001000000001010011111111111111101111111001000000000000000001000000000000000000100010001001000000000000000001000000000000000000100010001001000000001000000001000000000001010001000010000001000000000000000001010000000001000000000100000001000000000000000001010000000001000000000100000001000000001000000001010000000000000100100000100001000000000000000001000010000000110000000000010001000000000000000001000010000000110000000000010001000000001000000001000010000000000000000100101001000000000000000001010010000001100100010000000001000000000000000001010010000001100100010000000001000000001000000001010010000001000000000000000001000000000000000001000001000001110001111110111001000000000000000001000001000001110001111110111001000000001000000001000001000000000000010011000001000000000000000001010001000001000000000100000001000000000000000001010001000001000000000100000001000000001000000001010001000000001000100000100001000000000000000001000011000001110001000110111001000000000000000001000011000001110001000110111001000000001000000001000011000000000000010001000001000000000000000001010011000001110001100010111001000000000000000001010011000001110001100010111001000000001000000001010011000000000000010000000001000000000000000001000000100000110001010010111001000000000000000001000000100000110001010010111001000000001000000001000000100000000000001000000001000000000000000001010000100001110001010010111001000000000000000001010000100001110001010010111001000000001000000001010000100000000000011000000001000000000000000001000010100000110001110010111001000000000000000001000010100000110001110010111001000000001000000001000010100000000000000100000001000000000000000001010010100001110001110010111001000000000000000001010010100001110001110010111001000000001000000001010010100000000000010100000001000000000000000001000001100000110001001010111001000000000000000001000001100000110001001010111001000000001000000001000001100000000000001100000001000000000000000001010001100001110001001010111001000000000000000001010001100001110001001010111001000000001000000001010001100000000000011100000001000000000000000001000011100000110001101010111001000000000000000001000011100000110001101010111001000000001000000001000011100000000000000010000001000000000000000001010011100001110001101010111001000000000000000001010011100001110001101010111001000000001000000001010011100000000000010010000001000000000000000001000000010000110001011010111001000000000000000001000000010000110001011010111001000000001000000001000000010000000000001010000001000000000000000001010000010001110001011010111001000000000000000001010000010001110001011010111001000000001000000001010000010000000000011010000001000000000000000001000010010000110001111010111001000000000000000001000010010000110001111010111001000000001000000001000010010000000000000110000001000000000000000001010010010001110001111010111001000000000000000001010010010001110001111010111001000000001000000001010010010000000000010110000001000000000000000001000001010000110001001110111001000000000000000001000001010000110001001110111001000000001000000001000001010000000000001110000001000000000000000001010001010001110001001110111001000000000000000001010001010001110001001110111001000000001000000001010001010000000000011110000001000000000000000001000011010000110001000110111001000000000000000001000011010000110001000110111001000000001000000001000011010000000000000001000001000000000000000001010011010000110001100110111001000000000000000001010011010000110001100110111001000000001000000001010011010000000000001001000001000000000000000001000000110001110001100110111001000000000000000001000000110001110001100110111001000000001000000001000000110000000000011001000001000000000000000001010000110000110001010110111001000000000000000001010000110000110001010110111001000000001000000001010000110000000000000101000001000000000000000001000010110001110001010110111001000000000000000001000010110001110001010110111001000000001000000001000010110000000000010101000001000000000000000001010010110000110001110110111001000000000000000001010010110000110001110110111001000000001000000001010010110000000000001101000001000000000000000001000001110001110001110110111001000000000000000001000001110001110001110110111001000000001000000001000001110000000000011101000001000000000000000001010001110000110001111110111001000000000000000001010001110000110001111110111001000000001000000001010001110000000000000011000001000000000000000001000011110000000000000011111001000000000000000001000011110000000000000011111001000000001000000001000011110000000000001000000001000000000000000001010011110001100100011110111001000000000000000001010011110001100100011110111001000000001000000001010011110000000000000010100001000000000000000001000000001001100100011110111001000000000000000001000000001001100100011110111001000000001000000001000000001000111111000011111001000000000000000001010000001001110101111110111001000000000000000001010000001001110101111110111001000000001000000001010000001000000000011100000001000000000000000001000010001000000000000000000001000000000000000001000010001000000000000000000001000000001000000001000010001001010010010010000001000000000000000001010010001000000000000000000001000000000000000001010010001000000000000000000001000000001000000001010010001001011010010010000001000000000000000001000001001000000000000000000001000000000000000001000001001000000000000000000001000000001000000001000001001001000110010010000001000000000000000001010001001000010100101100110001000000000000000001010001001000010100101100110001000000001000000001010001001000000000000001000001000000000000000001000011001000001010000001011001000000000000000001000011001000001010000001011001000000001000000001000011001000000000001100000001000000000000000001010011001000000000000000000001000000000000000001010011001000000000000000000001000000001000000001010011001001001000010010000001000000000000000001000000101000110000000000010001000000000000000001000000101000110000000000010001000000001000000001000000101001000000100001001001000000000000000001010000101000000000000000110001000000000000000001010000101000000000000000110001000000001000000001010000101001000100010010000001000000000000000001000010101000011010000001000001000000000000000001000010101000011010000001000001000000001000000001000010101000000000001000000001000000000000000001010010101000010100101110010001000000000000000001010010101000010100101110010001000000001000000001010010101000000000000101000001000000000000000001000001101001000000001001000001000000000000000001000001101001000000001001000001000000001000000001000001101001001011100010000001000000000000000001010001101000000000011001011001000000000000000001010001101000000000011001011001000000001000000001010001101001000000001100000001000000000000000001000011101000000000000001000001000000000000000001000011101000000000000001000001000000001000000001000011101001010010010010000001000000000000000001010011101000000000000000000001000000000000000001010011101000000000000000000001000000001000000001010011101000001011100100000001000000000000000001000000011000000000101111010001000000000000000001000000011000000000101111010001000000001000000001000000011001011010000010000001000000000000000001010000011000000000000000000001000000000000000001010000011000000000000000000001000000001000000001010000011000000000000000000001000000000000000001000010011000010100101110010001000000000000000001000010011000010100101110010001000000001000000001000010011000000000000101000001000000000000000001010010011000101000000001011001000000000000000001010010011000101000000001011001000000001000000001010010011001111111000111111001000000000000000001000001011000100100011000110001000000000000000001000001011000100100011000110001000000001000000001000001011001000000000000000001000000000000000001010001011001000000101000000001000000000000000001010001011001000000101000000001000000001000000001010001011000000100000000100001000000000000000001000011011001000000101000100001000000000000000001000011011001000000101000100001000000001000000001000011011001000100100010000001000000000000000001010011011000000000010000000001000000000000000001010011011000000000010000000001000000001000000001010011011000000100000000100001000000000000000001000000111001000000101000100001000000000000000001000000111001000000101000100001000000001000000001000000111001000100100010000001000000000000000001010000111000000000010000000001000000000000000001010000111000000000010000000001000000001000000001010000111000000100000001000001000000000000000001000010111000110000000000010001000000000000000001000010111000110000000000010001000000001000000001000010111000000000000011001001000000000000000001010010111000100100010000100001000000000000000001010010111000100100010000100001000000001000000001010010111000111111000100100001000000000000000001000001111000001000000000000001000000000000000001000001111000001000000000000001000000001000000001000001111001000000100000000001000000000000000001010001111001110001111110111001000000000000000001010001111001110001111110111001000000001000000001010001111000000000011100000001000000000000000001000011111000000000000000000001000000000000000001000011111000000000000000000001000000001000000001000011111001001000010010000001000000000000000001010011111001110001111110111001000000000000000001010011111001110001111110111001000000001000000001010011111000000000011100000001000000000000000001000000000101100100011110111001000000000000000001000000000101100100011110111001000000001000000001000000000100000000000010000001000000000000000001010000000100000000000011111001000000000000000001010000000100000000000011111001000000001000000001010000000100000000001000000001000000000000000001000010000100000000000000000001000000000000000001000010000100000000000000000001000000001000000001000010000100000000000000000001000000000000000001010010000101100100011110111001000000000000000001010010000101100100011110111001000000001000000001010010000100111111001101111001000000000000000001000001000101110101111110111001000000000000000001000001000101110101111110111001000000001000000001000001000100000000011100000001000000000000000001010001000100000000000000000001000000000000000001010001000100000000000000000001000000001000000001010001000101001000010010000001000000000000000001000011000100110000000000010001000000000000000001000011000100110000000000010001000000001000000001000011000100000000000100101001000000000000000001010011000101100100010000000001000000000000000001010011000101100100010000000001000000001000000001010011000100000000100000000001000000000000000001000000100100000000000000000001000000000000000001000000100100000000000000000001000000001000000001000000100101001111010010000001000000000000000001010000100100100100101100000001000000000000000001010000100100100100101100000001000000001000000001010000100101111111111111111001000000000000000001000010100100110101101100101001000000000000000001000010100100110101101100101001000000001000000001000010100100000000010000000001000000000000000001010010100101110001100000101001000000000000000001010010100101110001100000101001000000001000000001010010100100000000010000000001000000000000000001000001100100110101101100101001000000000000000001000001100100110101101100101001000000001000000001000001100100000000000000000001000000000000000001010001100100110101101100101001000000000000000001010001100100110101101100101001000000001000000001010001100100000000000000000001000000000000000001000011100100000000000000000001000000000000000001000011100100000000000000000001000000001000000001000011100101000111010010000001000000000000000001010011100101000000100000000001000000000000000001010011100101000000100000000001000000001000000001010011100100111000100000000001000000000000000001000000010100001100101111000001000000000000000001000000010100001100101111000001000000001000000001000000010101000000000000000001000000000000000001010000010100001010000001011001000000000000000001010000010100001010000001011001000000001000000001010000010101000000100000000001000000000000000001000010010100100100011100111001000000000000000001000010010100100100011100111001000000001000000001000010010101000000000000000001000000000000000001010010010100100100100001000001000000000000000001010010010100100100100001000001000000001000000001010010010101000000000000000001000000000000000001000001010100100100011100111001000000000000000001000001010100100100011100111001000000001000000001000001010101000000000000000001000000000000000001010001010100010100101100111001000000000000000001010001010100010100101100111001000000001000000001010001010100000000001000000001000000000000000001000011010100101000000001011001000000000000000001000011010100101000000001011001000000001000000001000011010101111111001111111001000000000000000001010011010101000000100000000001000000000000000001010011010101000000100000000001000000001000000001010011010100011000100001000001000000000000000001000000110100100100111101111001000000000000000001000000110100100100111101111001000000001000000001000000110101000000000000000001000000000000000001010000110100010100101101111001000000000000000001010000110100010100101101111001000000001000000001010000110100000000101000000001000000000000000001000010110100101010000001011001000000000000000001000010110100101010000001011001000000001000000001000010110101111111111011111001000000000000000001010010110100100100101100000001000000000000000001010010110100100100101100000001000000001000000001010010110101111111111111111001000000000000000001000001110101110001111110111001000000000000000001000001110101110001111110111001000000001000000001000001110100000000011100000001000000000000000001010001110101100100011110111001000000000000000001010001110101100100011110111001000000001000000001010001110100000000001010000001000000000000000001000011110100000000000011111001000000000000000001000011110100000000000011111001000000001000000001000011110100000000001000000001000000000000000001010011110100000000000000000001000000000000000001010011110100000000000000000001000000001000000001010011110100000000000000000001000000000000000001000000001101100100011110111001000000000000000001000000001101100100011110111001000000001000000001000000001100111111001101111001000000000000000001010000001101110101111110111001000000000000000001010000001101110101111110111001000000001000000001010000001100000000011100000001000000000000000001000010001100110101010010111001000000000000000001000010001100110101010010111001000000001000000001000010001100000000000010000001000000000000000001010010001100000101000010111001000000000000000001010010001100000101000010111001000000001000000001010010001101000000110010000001000000000000000001000001001100000000000000000001000000000000000001000001001100000000000000000 + T111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 + + + @@ -25,8 +686,8 @@ - - + + diff --git a/sw/bootloader/.gitignore b/sw/bootloader/.gitignore index 796b96d..e53d106 100644 --- a/sw/bootloader/.gitignore +++ b/sw/bootloader/.gitignore @@ -1 +1,2 @@ /build +/what \ No newline at end of file diff --git a/sw/bootloader/Makefile b/sw/bootloader/Makefile index 52e5383..698432b 100644 --- a/sw/bootloader/Makefile +++ b/sw/bootloader/Makefile @@ -16,7 +16,7 @@ HEADER_NAME = header PROG_NAME = SummerLoader64 -ROM_SIZE = 1k +ROM_SIZE = 32k SOURCE_DIR = src BUILD_DIR = build @@ -31,7 +31,7 @@ VPATH = $(SRC_DIRS) COMMONFLAGS = -march=vr4300 -mtune=vr4300 ASFLAGS = $(COMMONFLAGS) -CFLAGS = $(COMMONFLAGS) -std=gnu11 -Os -Wall -I$(ROOTDIR)/mips64-elf/include $(INC_DIRS) +CFLAGS = $(COMMONFLAGS) -std=gnu11 -Os -Wall -I$(ROOTDIR)/mips64-elf/include $(INC_DIRS) -ffunction-sections -fdata-sections -Wl,--gc-sections LINK_FLAGS = -L$(ROOTDIR)/mips64-elf/lib -ldragon -lc -lm -ldragonsys -Tn64.ld -L./libsc64/lib -lsc64_libdragon N64_FLAGS = -l $(ROM_SIZE) -h $(HEADER_PATH)/$(HEADER_NAME) -o $(BUILD_DIR)/$(PROG_NAME).z64 N64_FLAGS_PADDED = -l 1028k -h $(HEADER_PATH)/$(HEADER_NAME) -o $(BUILD_DIR)/$(PROG_NAME)_padded.z64 diff --git a/sw/bootloader/build.sh b/sw/bootloader/build.sh index 34cd58e..b9de05c 100755 --- a/sw/bootloader/build.sh +++ b/sw/bootloader/build.sh @@ -7,4 +7,4 @@ build_in_docker() { $1 /bin/bash -c "cd /src && make clean && make -f $2 all" } -build_in_docker "anacierdem/libdragon:latest" "Makefile" +build_in_docker "anacierdem/libdragon:6.0.2" "Makefile" diff --git a/sw/bootloader/src/main.c b/sw/bootloader/src/main.c index b5e3956..07916dc 100644 --- a/sw/bootloader/src/main.c +++ b/sw/bootloader/src/main.c @@ -29,128 +29,129 @@ static menu_load_error_t convert_error(sc64_sd_fs_error_t sd_fs_error) { int main(void) { - OS_BOOT_CONFIG->tv_type = TV_NTSC; + while (1); + // OS_BOOT_CONFIG->tv_type = TV_NTSC; - if (sc64_get_version() != SC64_CART_VERSION_A) { - loader_display_error_and_halt(E_MENU_ERROR_NOT_SC64, ""); - } + // if (sc64_get_version() != SC64_CART_VERSION_A) { + // loader_display_error_and_halt(E_MENU_ERROR_NOT_SC64, ""); + // } - sc64_enable_rom_switch(); + // sc64_enable_rom_switch(); - uint32_t boot_mode = sc64_get_boot_mode(); + // uint32_t boot_mode = sc64_get_boot_mode(); - bool skip_menu = (boot_mode & SC64_CART_BOOT_SKIP_MENU); - bool cic_seed_override = (boot_mode & SC64_CART_BOOT_CIC_SEED_OVERRIDE); - bool tv_type_override = (boot_mode & SC64_CART_BOOT_TV_TYPE_OVERRIDE); - bool ddipl_override = (boot_mode & SC64_CART_BOOT_DDIPL_OVERRIDE); - bool rom_loaded = (boot_mode & SC64_CART_BOOT_ROM_LOADED); - tv_type_t tv_type = ((boot_mode & SC64_CART_BOOT_TV_TYPE_MASK) >> SC64_CART_BOOT_TV_TYPE_BIT); - uint16_t cic_seed = ((boot_mode & SC64_CART_BOOT_CIC_SEED_MASK) >> SC64_CART_BOOT_CIC_SEED_BIT); + // bool skip_menu = (boot_mode & SC64_CART_BOOT_SKIP_MENU); + // bool cic_seed_override = (boot_mode & SC64_CART_BOOT_CIC_SEED_OVERRIDE); + // bool tv_type_override = (boot_mode & SC64_CART_BOOT_TV_TYPE_OVERRIDE); + // bool ddipl_override = (boot_mode & SC64_CART_BOOT_DDIPL_OVERRIDE); + // bool rom_loaded = (boot_mode & SC64_CART_BOOT_ROM_LOADED); + // tv_type_t tv_type = ((boot_mode & SC64_CART_BOOT_TV_TYPE_MASK) >> SC64_CART_BOOT_TV_TYPE_BIT); + // uint16_t cic_seed = ((boot_mode & SC64_CART_BOOT_CIC_SEED_MASK) >> SC64_CART_BOOT_CIC_SEED_BIT); - if (!skip_menu) { - char rom_path[256] = DEFAULT_MENU_FILE_PATH; - char save_path[256] = "\0"; - sc64_sd_fs_error_t sd_fs_error; - sc64_sd_fs_config_t config = { - .rom = rom_path, - .rom_reload = false, - .save = save_path, - .save_type = 0, - .save_writeback = false, - .cic_seed = 0xFFFF, - .tv_type = -1, - }; + // if (!skip_menu) { + // char rom_path[256] = DEFAULT_MENU_FILE_PATH; + // char save_path[256] = "\0"; + // sc64_sd_fs_error_t sd_fs_error; + // sc64_sd_fs_config_t config = { + // .rom = rom_path, + // .rom_reload = false, + // .save = save_path, + // .save_type = 0, + // .save_writeback = false, + // .cic_seed = 0xFFFF, + // .tv_type = -1, + // }; - sd_fs_error = sc64_sd_fs_init(); - if (sd_fs_error != SC64_SD_FS_OK) { - loader_display_error_and_halt(convert_error(sd_fs_error), "sc64_sd_fs_init"); - } + // sd_fs_error = sc64_sd_fs_init(); + // if (sd_fs_error != SC64_SD_FS_OK) { + // loader_display_error_and_halt(convert_error(sd_fs_error), "sc64_sd_fs_init"); + // } - sd_fs_error = sc64_sd_fs_load_config(CONFIG_FILE_PATH, &config); - if ((sd_fs_error != SC64_SD_FS_OK) && (sd_fs_error != SC64_SD_FS_NO_FILE)) { - loader_display_error_and_halt(convert_error(sd_fs_error), "sc64_sd_fs_load_config"); - } + // sd_fs_error = sc64_sd_fs_load_config(CONFIG_FILE_PATH, &config); + // if ((sd_fs_error != SC64_SD_FS_OK) && (sd_fs_error != SC64_SD_FS_NO_FILE)) { + // loader_display_error_and_halt(convert_error(sd_fs_error), "sc64_sd_fs_load_config"); + // } - if (config.cic_seed != 0xFFFF) { - cic_seed_override = true; - cic_seed = config.cic_seed; - } + // if (config.cic_seed != 0xFFFF) { + // cic_seed_override = true; + // cic_seed = config.cic_seed; + // } - if (config.tv_type != -1) { - tv_type_override = true; - tv_type = config.tv_type; - } + // if (config.tv_type != -1) { + // tv_type_override = true; + // tv_type = config.tv_type; + // } - if (!rom_loaded || config.rom_reload) { - loader_display_logo(); - } + // if (!rom_loaded || config.rom_reload) { + // loader_display_logo(); + // } - if (config.save_type > 0) { - sc64_disable_eeprom(); - sc64_disable_sram(); - sc64_disable_flashram(); + // if (config.save_type > 0) { + // sc64_disable_eeprom(); + // sc64_disable_sram(); + // sc64_disable_flashram(); - switch (config.save_type) { - case 1: sc64_enable_eeprom(false); break; - case 2: sc64_enable_eeprom(true); break; - case 3: - case 4: sc64_enable_sram(); break; - case 5: - case 6: sc64_enable_flashram(); break; - } + // switch (config.save_type) { + // case 1: sc64_enable_eeprom(false); break; + // case 2: sc64_enable_eeprom(true); break; + // case 3: + // case 4: sc64_enable_sram(); break; + // case 5: + // case 6: sc64_enable_flashram(); break; + // } - if (config.save_type >= 3 || config.save_type <= 5) { - sc64_set_save_address(SC64_SDRAM_SIZE - (128 * 1024)); - } else if (config.save_type == 6) { - sc64_set_save_address(0x01618000); - } + // if (config.save_type >= 3 || config.save_type <= 5) { + // sc64_set_save_address(SC64_SDRAM_SIZE - (128 * 1024)); + // } else if (config.save_type == 6) { + // sc64_set_save_address(0x01618000); + // } - if (rom_loaded && (config.save[0] != '\0') && config.save_writeback) { - sd_fs_error = sc64_sd_fs_store_save(config.save); - if (sd_fs_error != SC64_SD_FS_OK) { - loader_display_error_and_halt(convert_error(sd_fs_error), "sc64_sd_fs_store_save"); - } - } - } + // if (rom_loaded && (config.save[0] != '\0') && config.save_writeback) { + // sd_fs_error = sc64_sd_fs_store_save(config.save); + // if (sd_fs_error != SC64_SD_FS_OK) { + // loader_display_error_and_halt(convert_error(sd_fs_error), "sc64_sd_fs_store_save"); + // } + // } + // } - if (!rom_loaded || config.rom_reload) { - sd_fs_error = sc64_sd_fs_load_rom(config.rom); - if (sd_fs_error != SC64_SD_FS_OK) { - loader_display_error_and_halt(convert_error(sd_fs_error), "sc64_sd_fs_load_rom"); - } + // if (!rom_loaded || config.rom_reload) { + // sd_fs_error = sc64_sd_fs_load_rom(config.rom); + // if (sd_fs_error != SC64_SD_FS_OK) { + // loader_display_error_and_halt(convert_error(sd_fs_error), "sc64_sd_fs_load_rom"); + // } - sc64_set_boot_mode(boot_mode | SC64_CART_BOOT_ROM_LOADED); - } + // sc64_set_boot_mode(boot_mode | SC64_CART_BOOT_ROM_LOADED); + // } - if ((config.save_type > 0) && (config.save[0] != '\0') && !rom_loaded) { - sd_fs_error = sc64_sd_fs_load_save(config.save); - if (sd_fs_error != SC64_SD_FS_OK) { - loader_display_error_and_halt(convert_error(sd_fs_error), "sc64_sd_fs_load_save"); - } - } + // if ((config.save_type > 0) && (config.save[0] != '\0') && !rom_loaded) { + // sd_fs_error = sc64_sd_fs_load_save(config.save); + // if (sd_fs_error != SC64_SD_FS_OK) { + // loader_display_error_and_halt(convert_error(sd_fs_error), "sc64_sd_fs_load_save"); + // } + // } - sc64_sd_fs_deinit(); + // sc64_sd_fs_deinit(); - if (!rom_loaded || config.rom_reload) { - loader_cleanup(); - } - } + // if (!rom_loaded || config.rom_reload) { + // loader_cleanup(); + // } + // } - if (ddipl_override) { - sc64_enable_ddipl(); - } else { - sc64_disable_ddipl(); - } + // if (ddipl_override) { + // sc64_enable_ddipl(); + // } else { + // sc64_disable_ddipl(); + // } - cart_header_t *cart_header = boot_load_cart_header(ddipl_override); + // cart_header_t *cart_header = boot_load_cart_header(ddipl_override); - if (!cic_seed_override) { - cic_seed = boot_get_cic_seed(cart_header); - } + // if (!cic_seed_override) { + // cic_seed = boot_get_cic_seed(cart_header); + // } - if (!tv_type_override) { - tv_type = boot_get_tv_type(cart_header); - } + // if (!tv_type_override) { + // tv_type = boot_get_tv_type(cart_header); + // } - boot(cart_header, cic_seed, tv_type, ddipl_override); + // boot(cart_header, cic_seed, tv_type, ddipl_override); } diff --git a/sw/libsc64/build.sh b/sw/libsc64/build.sh index 9cfe432..2bff121 100755 --- a/sw/libsc64/build.sh +++ b/sw/libsc64/build.sh @@ -6,6 +6,6 @@ build_in_docker() { $1 /bin/bash -c "cd /src && make -f $2 all" } -build_in_docker "anacierdem/libdragon:latest" "Makefile.libdragon" +build_in_docker "anacierdem/libdragon:6.0.2" "Makefile.libdragon" build_in_docker "polprzewodnikowy/n64sdkmod:latest" "Makefile.libultra"