diff --git a/lib/corelib.s b/lib/corelib.s index 6970971..57f35a8 100644 --- a/lib/corelib.s +++ b/lib/corelib.s @@ -588,19 +588,13 @@ DIVU_END: ; wait approx. 1 millisecond ; -; the ROM at address 4 -; contains the cpu clock freq in KHz - .EQU CLK_KHZ_ADDR 4 +; 83.333 MHz Clock, three instructions a 4 cycles +; 83333 / 12 = 6944.4166 +; works only if executed without wait states (i.e. +; from BRAM/SRAM) WAIT1MSEC: - LOADC CLK_KHZ_ADDR - LOADI - ; divide by 16 - SHR - SHR - SHR - SHR + LOADCP 6944 WAIT1LOOP: - INC 0 ; NOP to make the loop 16 cycles long DEC 1 DUP CBRANCH.NZ WAIT1LOOP diff --git a/lib/rommon.s b/lib/rommon.s index 4828008..a967e4b 100644 --- a/lib/rommon.s +++ b/lib/rommon.s @@ -7,16 +7,8 @@ .EQU UART_REG 2048 .EQU MON_ADDR 64512 - .EQU CLK_KHZ 76923 - BRANCH 2 ; the very first instruction is not ; executed correctly - BRANCH MON_START ; branch over constant - -CLK_KHZ_ADDR: - .WORD CLK_KHZ ; to calibrate the delay loop - -MON_START: LOADCP 65020 ; initialise FP and RP registers STOREREG FP LOADCP 65024 @@ -790,17 +782,13 @@ COPY_BLK1: ; wait approx. 1 millisecond ; +; 83.333 MHz Clock, three instructions a 4 cycles +; 83333 / 12 = 6944.4166 +; works only if executed without wait states (i.e. +; from BRAM/SRAM) WAIT1MSEC: - ; get clock freq in khz - LOADC CLK_KHZ_ADDR - LOADI - ; divide by 16 - SHR - SHR - SHR - SHR + LOADCP 6944 WAIT1LOOP: - INC 0 ; NOP to make loop 16 cycles long DEC 1 DUP CBRANCH.NZ WAIT1LOOP diff --git a/tridoracpu/tridoracpu.srcs/Arty-A7-35-Master.xdc b/tridoracpu/tridoracpu.srcs/Arty-A7-35-Master.xdc index 7c62767..c618478 100644 --- a/tridoracpu/tridoracpu.srcs/Arty-A7-35-Master.xdc +++ b/tridoracpu/tridoracpu.srcs/Arty-A7-35-Master.xdc @@ -216,5 +216,3 @@ set_property -dict {PACKAGE_PIN C2 IOSTANDARD LVCMOS33} [get_ports rst] #set_property -dict { PACKAGE_PIN A15 IOSTANDARD LVCMOS33 } [get_ports { isns0v95_p }]; #IO_L8P_T1_AD10P_15 Sch=ad_p[10] set_property BITSTREAM.GENERAL.COMPRESS True [current_design] - -set_max_delay -from [get_pins vgafb0/display_timings_inst/o_vblank_reg/C] -to [get_pins vgafb0/vblank_xfer_reg/D] 3.000 diff --git a/tridoracpu/tridoracpu.srcs/cpuclk.v b/tridoracpu/tridoracpu.srcs/cpuclk.v index a214cc4..613d85e 100644 --- a/tridoracpu/tridoracpu.srcs/cpuclk.v +++ b/tridoracpu/tridoracpu.srcs/cpuclk.v @@ -17,9 +17,7 @@ module cpu_clkgen( .CLKFBOUT_PHASE(0.0), // Phase offset in degrees of CLKFB (-360.000-360.000). .CLKIN1_PERIOD(10.0), // Input clock period in ns to ps resolution (i.e. 33.333 is 30 MHz). // CLKOUT0_DIVIDE - CLKOUT6_DIVIDE: Divide amount for each CLKOUT (1-128) - // CPU Clock: 12.0 = 83.33MHz CPU Clock, 333.33MHz Memory Clock - // 13.0 = 76.92MHz CPU Clock, 307.69MHz Memory Clock - .CLKOUT0_DIVIDE_F(13.0), // Divide amount for CLKOUT0 (1.000-128.000). + .CLKOUT0_DIVIDE_F(12.0), // Divide amount for CLKOUT0 (1.000-128.000). .CLKOUT1_DIVIDE(5), .CLKOUT2_DIVIDE(40), // 40 = 25MHz pixel clock (should be 25.175MHz per spec) for 640x480 //.CLKOUT2_DIVIDE(25), // 25 = 40MHz pixel clock for 800x600 diff --git a/tridoracpu/tridoracpu.srcs/mig_dram_0/mig_a.prj b/tridoracpu/tridoracpu.srcs/mig_dram_0/mig_a.prj index 58ff963..b263a25 100644 --- a/tridoracpu/tridoracpu.srcs/mig_dram_0/mig_a.prj +++ b/tridoracpu/tridoracpu.srcs/mig_dram_0/mig_a.prj @@ -39,12 +39,12 @@ DDR3_SDRAM/Components/MT41K128M16XX-15E - 3300 + 3000 1.8V 4:1 - 75.757 + 83.333 0 - 606 + 666 1.000 1 1 diff --git a/tridoracpu/tridoracpu.srcs/mig_dram_0/mig_b.prj b/tridoracpu/tridoracpu.srcs/mig_dram_0/mig_b.prj index 99d2e0c..b263a25 100644 --- a/tridoracpu/tridoracpu.srcs/mig_dram_0/mig_b.prj +++ b/tridoracpu/tridoracpu.srcs/mig_dram_0/mig_b.prj @@ -39,12 +39,12 @@ DDR3_SDRAM/Components/MT41K128M16XX-15E - 3250 + 3000 1.8V 4:1 - 76.923 + 83.333 0 - 615 + 666 1.000 1 1 diff --git a/tridoracpu/tridoracpu.srcs/top.v b/tridoracpu/tridoracpu.srcs/top.v index 2af2d10..e79d611 100644 --- a/tridoracpu/tridoracpu.srcs/top.v +++ b/tridoracpu/tridoracpu.srcs/top.v @@ -3,8 +3,7 @@ // or as clk_1hz for debugging `define clock cpuclk -//`define clkfreq 83333333 -`define clkfreq 76923076 +`define clkfreq 83333333 //`define clock clk //`define clkfreq 100000000 //`define clock clk_1hz diff --git a/tridoracpu/tridoracpu.srcs/vgafb.v b/tridoracpu/tridoracpu.srcs/vgafb.v index 37c1376..4e8d668 100644 --- a/tridoracpu/tridoracpu.srcs/vgafb.v +++ b/tridoracpu/tridoracpu.srcs/vgafb.v @@ -62,11 +62,10 @@ module display_timings #( // o_scanline: high for one tick at the start of each visible scanline assign o_scanline = (o_sy >= VA_STA) && (o_sy <= VA_END) && (o_sx == H_STA); - // set vblank at end of frame, clear at start always @(posedge i_pix_clk) begin - if(o_sy == VA_END) o_vblank <= 1; - else if (o_sy == -1) o_vblank <= 0; + if(o_frame) o_vblank <= 1; + else if (o_de) o_vblank <= 0; end always @ (posedge i_pix_clk) @@ -176,7 +175,6 @@ module vgafb #(VMEM_ADDR_WIDTH = 15, VMEM_DATA_WIDTH = 32) ( wire scanline; // scanline start wire vblank; // vertical blank reg vblank_buf; // vertical blank in cpu clock domain - reg vblank_xfer; // vertical blank clock domain crossing display_timings #( // 640x480 800x600 1280x720 1920x1080 `ifdef RES_1024_768 @@ -235,7 +233,7 @@ module vgafb #(VMEM_ADDR_WIDTH = 15, VMEM_DATA_WIDTH = 32) ( always @(posedge pix_clk) frame_d <= frame; - always @(posedge cpu_clk) { vblank_buf, vblank_xfer } <= { vblank_xfer, vblank }; + always @(posedge cpu_clk) vblank_buf <= vblank; always @(posedge cpu_clk) begin diff --git a/tridoracpu/tridoracpu.xpr b/tridoracpu/tridoracpu.xpr index 721335b..a4c6545 100644 --- a/tridoracpu/tridoracpu.xpr +++ b/tridoracpu/tridoracpu.xpr @@ -1,10 +1,9 @@ - - - - + + + - + - + @@ -255,6 +233,18 @@ + + + + + + + + + + @@ -308,18 +298,6 @@ - - - - - - - - - - @@ -339,8 +317,8 @@ - - + + @@ -350,17 +328,17 @@ - + - + - + - + @@ -386,9 +364,9 @@ - + - + @@ -399,7 +377,7 @@ - +