From 661bbb0ced4754e5d202b4039c8930c9ad45fe55 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Fri, 9 Feb 2018 10:59:52 -0600 Subject: [PATCH] fixed hsync generator to use assign --- presets/verilog/ball_paddle.v | 8 +++----- presets/verilog/hvsync_generator.v | 20 ++++++++------------ src/worker/workermain.js | 6 ++++-- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/presets/verilog/ball_paddle.v b/presets/verilog/ball_paddle.v index 9b3f40c2..cee24975 100644 --- a/presets/verilog/ball_paddle.v +++ b/presets/verilog/ball_paddle.v @@ -83,10 +83,8 @@ module ball_paddle_top(clk, reset, hpaddle, hsync, vsync, rgb); reg [6:0] brick_index; wire brick_gfx = lr_border || (brick_present && vpos[2:0] != 0 && hpos[3:1] != 4); - wire visible_clk = clk & display_on; - // scan bricks: compute brick_index and brick_present flag - always @(posedge visible_clk) + always @(posedge clk) // see if we are scanning brick area if (vpos[8:6] == 1 && !lr_border) begin @@ -121,7 +119,7 @@ module ball_paddle_top(clk, reset, hpaddle, hsync, vsync, rgb); /* verilator lint_on MULTIDRIVEN */ // compute ball collisions with paddle and playfield - always @(posedge visible_clk) + always @(posedge clk) if (ball_pixel_collide) begin // did we collide w/ paddle? if (paddle_gfx) begin @@ -135,7 +133,7 @@ module ball_paddle_top(clk, reset, hpaddle, hsync, vsync, rgb); end // compute ball collisions with brick and increment score - always @(posedge visible_clk) + always @(posedge clk) if (ball_pixel_collide && brick_present) begin brick_array[brick_index] <= 0; incscore <= 1; // increment score diff --git a/presets/verilog/hvsync_generator.v b/presets/verilog/hvsync_generator.v index feb74c68..7693bb14 100644 --- a/presets/verilog/hvsync_generator.v +++ b/presets/verilog/hvsync_generator.v @@ -31,32 +31,28 @@ module hvsync_generator(clk, reset, hsync, vsync, display_on, hpos, vpos); wire hmaxxed = (hpos == H_MAX) || reset; wire vmaxxed = (vpos == V_MAX) || reset; - // increment horizontal position counter + // horizontal position counter always @(posedge clk) begin + hsync <= (hpos>=H_SYNC_START && hpos<=H_SYNC_END); if(hmaxxed) hpos <= 0; else hpos <= hpos + 1; end - // increment vertical position counter + // vertical position counter always @(posedge clk) begin + vsync <= (vpos>=V_SYNC_START && vpos<=V_SYNC_END); if(hmaxxed) - if (!vmaxxed) - vpos <= vpos + 1; - else + if (vmaxxed) vpos <= 0; + else + vpos <= vpos + 1; end - // compute hsync + vsync + display_on signals - always @(posedge clk) - begin - hsync <= (hpos>=H_SYNC_START && hpos<=H_SYNC_END); - vsync <= (vpos>=V_SYNC_START && vpos<=V_SYNC_END); - display_on <= (hpos