Skip to content

Commit

Permalink
Change vertical_scheudler to use global clk for clocking
Browse files Browse the repository at this point in the history
  • Loading branch information
FavoritoHJS committed Aug 27, 2024
1 parent f8e0d8a commit 3bbb83e
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions src/project.v
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,24 @@ module tt_um_favoritohjs_scroller (
);
/*Module parameters are broken, so i have to do this and hope it gets optimized away.*/
vertical_scheudler vscheudler1 (
.hsync(hsync),
.clk(clk),
.rst_n(rst_n),
.hsync(hsync),
.vsync(vsync),
.scanline(vcount),
.xpos(hcount),
.ypos(vcount),
.START_HEIGHT(10'd116),
.LOOP_LENGTH(5'd16),
.val(cutoff1),
.border(vborder1));

vertical_scheudler vscheudler2 (
.hsync(hsync),
.clk(clk),
.rst_n(rst_n),
.hsync(hsync),
.vsync(vsync),
.scanline(vcount),
.xpos(hcount),
.ypos(vcount),
.START_HEIGHT(10'd184),
.LOOP_LENGTH(5'd8),
.val(cutoff2),
Expand Down Expand Up @@ -214,10 +218,12 @@ endmodule

/*Module parameters are broken, so i have to do this and hope it gets optimized away.*/
module vertical_scheudler(
input wire hsync,
input wire clk,
input wire rst_n,
input wire hsync,
input wire vsync,
input wire [9:0] scanline,
input wire [9:0] xpos,
input wire [9:0] ypos,
input wire [4:0] LOOP_LENGTH,
input wire [9:0] START_HEIGHT,
output wire [4:0] val,
Expand All @@ -229,28 +235,30 @@ module vertical_scheudler(
reg borderreg;
assign val = blockval;
assign border = borderreg;
always @(posedge hsync) begin
always @(posedge clk) begin
if (~rst_n || ~vsync) begin
started <= 1'b0;
blockline <= (LOOP_LENGTH - 1);
blockval <= 5'b0;
borderreg <= 1'b0;
end else begin
if (scanline == START_HEIGHT) begin
if (ypos == START_HEIGHT) begin
started <= 1'b1;
end
if (started) begin
if (blockline == 0) begin
blockline <= (LOOP_LENGTH - 1);
if (blockval != 16) begin
blockval <= blockval + 1;
if (xpos == 10'd656) begin
if (blockline == 0) begin
blockline <= (LOOP_LENGTH - 1);
if (blockval != 16) begin
blockval <= blockval + 1;
end
end else begin
blockline <= blockline - 1;
end
end else begin
blockline <= blockline - 1;
if (blockline == LOOP_LENGTH - 1) borderreg <= 0;
if (blockline == 1) borderreg <= 1;
if (blockline == 0) borderreg <= 1;
end
if (blockline == LOOP_LENGTH - 1) borderreg <= 0;
if (blockline == 1) borderreg <= 1;
if (blockline == 0) borderreg <= 1;
end
end
end
Expand Down

0 comments on commit 3bbb83e

Please sign in to comment.