@[email protected] asked
module my_code #(
parameter int WIDTH = 640,
parameter int HEIGHT = 480,
parameter int CONSOLE_COLUMNS = WIDTH / 8,
parameter int CONSOLE_ROWS = HEIGHT / 8
)(
input logic clk,
input logic rst,
input int px,
input int py,
input logic hsync,
input logic vsync,
input int col,
input int row,
output int char,
output logic [23:0] foreground_color,
output logic [23:0] background_color
);
logic [31:0] frame_counter = '0;
logic old_vsync = '0;
logic [7:0] wave_offset;
logic [7:0] pattern_select;
logic [7:0] hue_shift;
// Create animated wave pattern for background
assign wave_offset = frame_counter[7:0] + col;
// Cycle through different pattern types
assign pattern_select = frame_counter[10:8];
// Hue rotation effect
assign hue_shift = frame_counter[15:8];
always_comb begin
logic [7:0] red, green, blue;
logic [7:0] char_value;
logic [7:0] pattern_output;
// Create cute animated pattern based on row and column
case(pattern_select)
3'b000: pattern_output = (row + col) ^ wave_offset; // Diagonal stripes
3'b001: pattern_output = row * col + frame_counter[7:0]; // Grid pattern
3'b010: pattern_output = ((row ^ col) << 1) + hue_shift; // XOR pattern
default: pattern_output = (row + frame_counter[7:0]) ^ col; // Animated checkerboard
endcase
// RGB color cycling with pattern
red = pattern_output + hue_shift;
green = pattern_output + (hue_shift >> 1);
blue = pattern_output - hue_shift;
background_color = {red, green, blue};
// Character selection creates a cute animation
char_value = ((row * 13 + col * 7) + frame_counter[9:0]) % 256;
// Display cute characters: stars, diamonds, hearts, etc.
if (char_value < 64)
char = 42; // '*' - star
else if (char_value < 128)
char = 43; // '+' - plus
else if (char_value < 192)
char = 46; // '.' - dot
else
char = 35; // '#' - hash
// Foreground color inverts based on background brightness
if ((red + green + blue) > 12'h600)
foreground_color = 24'h000000; // Black text on bright background
else
foreground_color = 24'hFFFFFF; // White text on dark background
end
always_ff @(posedge clk) begin
if (rst) begin
frame_counter <= '0;
old_vsync <= '0;
end else begin
// Increment frame counter on vsync falling edge
if (vsync == 1'b0 && old_vsync == 1'b1) begin
frame_counter <= frame_counter + 1;
end
old_vsync <= vsync;
end
end
endmodule
Sucess!
UtilizationCellUsedAvailableUsage
DCCA2563.6%
EHXPLLL1250%
MULT18X18D32810.7%
TRELLIS_COMB1107242884.6%
TRELLIS_FF152242880.6%
TRELLIS_IO101975.1%
TimingClockAchievedConstraint
$glbnet$clkp40.55 MHz25 MHz
$glbnet$clkt307.69 MHz250 MHz
Code
module my_code #(
parameter int WIDTH = 640,
parameter int HEIGHT = 480,
parameter int CONSOLE_COLUMNS = WIDTH / 8,
parameter int CONSOLE_ROWS = HEIGHT / 8
)(
input logic clk,
input logic rst,
input int px,
input int py,
input logic hsync,
input logic vsync,
input int col,
input int row,
output int char,
output logic [23:0] foreground_color,
output logic [23:0] background_color
);
logic [31:0] frame_counter = '0;
logic old_vsync = '0;
logic [7:0] wave_offset;
logic [7:0] pattern_select;
logic [7:0] hue_shift;
// Create animated wave pattern for background
assign wave_offset = frame_counter[7:0] + col;
// Cycle through different pattern types
assign pattern_select = frame_counter[10:8];
// Hue rotation effect
assign hue_shift = frame_counter[15:8];
always_comb begin
logic [7:0] red, green, blue;
logic [7:0] char_value;
logic [7:0] pattern_output;
// Create cute animated pattern based on row and column
case(pattern_select)
3'b000: pattern_output = (row + col) ^ wave_offset; // Diagonal stripes
3'b001: pattern_output = row * col + frame_counter[7:0]; // Grid pattern
3'b010: pattern_output = ((row ^ col) << 1) + hue_shift; // XOR pattern
default: pattern_output = (row + frame_counter[7:0]) ^ col; // Animated checkerboard
endcase
// RGB color cycling with pattern
red = pattern_output + hue_shift;
green = pattern_output + (hue_shift >> 1);
blue = pattern_output - hue_shift;
background_color = {red, green, blue};
// Character selection creates a cute animation
char_value = ((row * 13 + col * 7) + frame_counter[9:0]) % 256;
// Display cute characters: stars, diamonds, hearts, etc.
if (char_value < 64)
char = 42; // '*' - star
else if (char_value < 128)
char = 43; // '+' - plus
else if (char_value < 192)
char = 46; // '.' - dot
else
char = 35; // '#' - hash
// Foreground color inverts based on background brightness
if ((red + green + blue) > 12'h600)
foreground_color = 24'h000000; // Black text on bright background
else
foreground_color = 24'hFFFFFF; // White text on dark background
end
always_ff @(posedge clk) begin
if (rst) begin
frame_counter <= '0;
old_vsync <= '0;
end else begin
// Increment frame counter on vsync falling edge
if (vsync == 1'b0 && old_vsync == 1'b1) begin
frame_counter <= frame_counter + 1;
end
old_vsync <= vsync;
end
end
endmodule
#FPGA #Icepi-Zero #HDL #SystemVerilog