Skip to content

Commit

Permalink
Cutting down on input features and reverting on forbidden territory
Browse files Browse the repository at this point in the history
  • Loading branch information
SagarDevAchar authored Sep 3, 2024
1 parent 122c429 commit 82a8b55
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 49 deletions.
4 changes: 2 additions & 2 deletions info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ project:
# The pinout of your project. Leave unused pins blank. DO NOT delete or add any pins.
pinout:
# Inputs
ui[0]: ""
ui[1]: ""
ui[0]: "Stop / Run Animation"
ui[1]: "Play / Pause Audio"
ui[2]: ""
ui[3]: ""
ui[4]: ""
Expand Down
2 changes: 1 addition & 1 deletion src/audio_engine.v
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module audio_engine(
counter <= 18'd0;
else
if (~silence)
counter <= counter + 1;
counter <= counter + 1'd1;
end

assign synth_clk = counter[10];
Expand Down
4 changes: 2 additions & 2 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"//": "Reduce wasted space",
"TOP_MARGIN_MULT": 1,
"BOTTOM_MARGIN_MULT": 1,
"LEFT_MARGIN_MULT": 1,
"RIGHT_MARGIN_MULT": 1,
"LEFT_MARGIN_MULT": 6,
"RIGHT_MARGIN_MULT": 6,

"//": "Absolute die size",
"FP_SIZING": "absolute",
Expand Down
51 changes: 21 additions & 30 deletions src/graphics_engine.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,26 @@ module graphics_engine(

input wire [6:0] video_modes
);

wire [5:0] sine_off_y, sine_bg_off_y;

wire [5:0] overlay_rgb, sine_rgb, sine_bg_rgb, sine_rgb_dither, sine_bg_rgb_dither;
wire overlay_active, overlay_text_active, sine_active, sine_bg_active;

wire mode_toggle_animation = video_modes[6];
wire mode_toggle_daynight = video_modes[5];
wire mode_toggle_text_style = video_modes[4]; // TODO: Implement this
wire mode_toggle_text_style = video_modes[4];
wire mode_toggle_overlay = video_modes[3];
wire mode_toggle_big_sine = video_modes[2];
wire mode_toggle_little_sine = video_modes[1];
wire mode_negative = video_modes[0];

wire [5:0] bg_rgb = {6{mode_toggle_daynight}};
// wire [5:0] fg_rgb = ~bg_rgb;

wire [5:0] sine_off_y, sine_bg_off_y;

wire [5:0] overlay_rgb, sine_rgb, sine_bg_rgb, sine_rgb_dither, sine_bg_rgb_dither;
wire overlay_active, overlay_text_active, sine_active, sine_bg_active;

reg [9:0] ctr;
wire [9:0] anim_x, anim_2x;

reg en_v_sync;
always @(posedge clk, negedge rst_n) begin
if (~rst_n )begin
if (~rst_n)begin
ctr <= 10'd0;
en_v_sync <= 1'b1;
end else begin
Expand Down Expand Up @@ -63,38 +60,32 @@ module graphics_engine(
sine_layer sine_layer1 (
.sine_rgb(sine_rgb),
.x(anim_x[8:3]),
.y(sine_off_y[4:0]),

.daynight(mode_toggle_daynight)
.y(sine_off_y[4:0])
);

sine_layer sine_layer2 (
.sine_rgb(sine_bg_rgb),
.x(anim_2x[7:2]),
.y(sine_bg_off_y[4:0]),

.daynight(mode_toggle_daynight)
.y(sine_bg_off_y[4:0])
);

assign overlay_rgb = overlay_active ? (
(mode_toggle_daynight ^ &ctr[7:5]) ? (
{ctr[7], overlay_text_active, ctr[6], overlay_text_active, ctr[5], overlay_text_active}
) : {overlay_text_active, ctr[7], overlay_text_active, ctr[6], overlay_text_active, ctr[5]}
) : bg_rgb;
assign overlay_rgb = overlay_active ? {
{overlay_text_active, ctr[7], overlay_text_active, ctr[6], overlay_text_active, ctr[5]}
} : 6'b00_00_00;

assign sine_rgb_dither = mode_toggle_daynight ? sine_rgb | {6{(x[0] & y[0])}} : sine_rgb & {6{(x[0] | y[0])}};
assign sine_bg_rgb_dither = mode_toggle_daynight ? sine_bg_rgb | {6{(x[0] | y[0])}} : sine_bg_rgb & {6{(x[0] & y[0])}};
assign sine_rgb_dither = sine_rgb & {6{(x[0] | y[0])}};
assign sine_bg_rgb_dither = sine_bg_rgb & {6{(x[0] & y[0])}};

assign sine_active = (mode_toggle_daynight ? ~&sine_rgb_dither : |sine_rgb_dither) & ~mode_toggle_big_sine;
assign sine_bg_active = (mode_toggle_daynight ? ~&sine_bg_rgb_dither : |sine_bg_rgb_dither) & ~mode_toggle_little_sine;
assign sine_active = |sine_rgb_dither & ~mode_toggle_big_sine;
assign sine_bg_active = |sine_bg_rgb_dither & ~mode_toggle_little_sine;

assign {r, g, b} = (frame_active ? (
assign {r, g, b} = frame_active ? (
(overlay_active & ~mode_toggle_overlay) ? overlay_rgb : (
sine_active ? sine_rgb_dither : (
sine_bg_active ? sine_bg_rgb_dither : bg_rgb
sine_bg_active ? sine_bg_rgb_dither : 6'b00_00_00
)
)
) ^ {6{mode_negative}} : 6'b00_00_00);
) ^ {6{mode_negative}} : 6'b00_00_00;

wire _unused = &{sine_off_y[5], sine_bg_off_y[5], anim_x[9], anim_x[2:0], anim_2x[9:8], anim_2x[1:0], mode_toggle_text_style};
endmodule
wire _unused = &{sine_off_y[5], sine_bg_off_y[5], anim_x[9], anim_x[2:0], anim_2x[9:8], anim_2x[1:0], mode_toggle_text_style, mode_toggle_daynight};
endmodule
23 changes: 9 additions & 14 deletions src/sine_layer.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
module sine_layer (
output reg [5:0] sine_rgb,
input wire [5:0] x,
input wire [4:0] y,

input wire daynight
input wire [4:0] y
);

localparam [15:0] qsine_line00 = 16'b1100000000000000;
Expand All @@ -19,9 +17,6 @@ module sine_layer (
localparam [15:0] qsine_line08 = 16'b0000000000000100;
localparam [15:0] qsine_line09 = 16'b0000000000000010;
localparam [15:0] qsine_line10 = 16'b0000000000000001;

wire [5:0] bg_rgb = {6{daynight}};
wire [5:0] fg_rgb = ~bg_rgb;

function [3:0] sub_floor(input [3:0] a, b);
sub_floor = (a < b) ? 4'd0 : (a - b);
Expand All @@ -44,10 +39,10 @@ module sine_layer (
begin
if (inverted) begin
if (qsine_off_x[4])
qsine_colour = bg_rgb;
qsine_colour = 6'b00_00_00;
else begin
if (qsine_off_x[3])
qsine_colour = bg_rgb;
qsine_colour = 6'b00_00_00;
else begin
if (line[qsine_flip_x[3:0] + 4'd1])
qsine_colour = 6'b11_00_00;
Expand All @@ -64,13 +59,13 @@ module sine_layer (
else if (line[qsine_flip_x[3:0] + 4'd7])
qsine_colour = 6'b10_00_11;
else
qsine_colour = bg_rgb;
qsine_colour = 6'b00_00_00;
end
end
end else begin
if (qsine_off_x[4]) begin
if (line[qsine_flip_x[3:0]])
qsine_colour = fg_rgb;
qsine_colour = 6'b11_11_11;
else if (line[add_ceil(qsine_flip_x[3:0], 4'd1)])
qsine_colour = 6'b11_00_00;
else if (line[add_ceil(qsine_flip_x[3:0], 4'd2)])
Expand All @@ -86,10 +81,10 @@ module sine_layer (
else if (line[add_ceil(qsine_flip_x[3:0], 4'd7)])
qsine_colour = 6'b10_00_11;
else
qsine_colour = bg_rgb;
qsine_colour = 6'b00_00_00;
end else begin
if (line[qsine_off_x[3:0]])
qsine_colour = fg_rgb;
qsine_colour = 6'b11_11_11;
else if (line[sub_floor(qsine_off_x[3:0], 4'd1)])
qsine_colour = 6'b11_00_00;
else if (line[sub_floor(qsine_off_x[3:0], 4'd2)])
Expand All @@ -105,7 +100,7 @@ module sine_layer (
else if (line[sub_floor(qsine_off_x[3:0], 4'd7)])
qsine_colour = 6'b10_00_11;
else
qsine_colour = bg_rgb;
qsine_colour = 6'b00_00_00;
end
end
end
Expand Down Expand Up @@ -141,7 +136,7 @@ module sine_layer (
5'h10: sine_rgb = qsine_colour(qsine_line05, 1'd1);
5'h11: sine_rgb = qsine_colour(qsine_line04, 1'd1);
5'h12: sine_rgb = qsine_colour(qsine_line03, 1'd1);
default: sine_rgb = bg_rgb;
default: sine_rgb = 6'b00_00_00;
endcase
end

Expand Down

0 comments on commit 82a8b55

Please sign in to comment.