-
Notifications
You must be signed in to change notification settings - Fork 0
又更新了,但不知道更了什么 #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
又更新了,但不知道更了什么 #13
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| DFXRuntime Profile Report: | ||
| Total Application(DFX) Runtime : CPU : 0:2:18 WALL : 0:0:0 0.00 % | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,9 +23,9 @@ parameter DIGIT_SPACING = 4; // 数字间距 | |||||||||||||||||||||||||||||||||||||||||||||||||
| parameter SCORE_DISPLAY_X = 488; // 分数数字显示起始X坐标(居中对齐) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| parameter SCORE_DISPLAY_Y = 130; // 分数数字显示起始Y坐标(在"得分"下方) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| logic [3:0] cell_x; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| logic [3:0] cell_x; // 当前像素对应的网格单元X坐标 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| assign cell_x = (curr_pix_x - GRID_START_X) / BLOCK_SIZE; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| logic [4:0] cell_y; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| logic [4:0] cell_y; // 当前像素对应的网格单元Y坐标 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| assign cell_y = curr_pix_y / BLOCK_SIZE; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| logic [3:0] cell_color; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -65,88 +65,133 @@ always_comb begin | |||||||||||||||||||||||||||||||||||||||||||||||||
| // 默认值 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| pixel_color = 12'h6cf; // 背景色 #6cf 8(:D | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // 游戏网格渲染 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (curr_pix_x >= GRID_START_X && curr_pix_x < GRID_START_X + GRID_WIDTH && curr_pix_y >= 0 && curr_pix_y < GRID_HEIGHT) begin // 在游戏网格内 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cell_color = game_grid_array[cell_y][cell_x]; // 取出对应单元格 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // 检查当前行是否正在消除 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| is_clearing_row = clearing_rows[cell_y]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // 基础颜色(未加特效) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| case (cell_color) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4'h0: base_color = 12'hFFF; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4'h1: base_color = 12'hF00; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4'h2: base_color = 12'h0F0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4'h3: base_color = 12'h00F; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4'h4: base_color = 12'hFF0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4'h5: base_color = 12'h0FF; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4'h6: base_color = 12'hF0F; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4'h7: base_color = 12'h888; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| default: base_color = 12'hFFF; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4'h0: base_color = 12'hFFF; // 空白为白色 #FFF | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4'h1: base_color = 12'hF00; // 红色 #F00 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4'h2: base_color = 12'h0F0; // 绿色 #0F0 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4'h3: base_color = 12'h00F; // 蓝色 #00F | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4'h4: base_color = 12'hFF0; // 黄色 #FF0 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4'h5: base_color = 12'h0FF; // 青色 #0FF | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4'h6: base_color = 12'hF0F; // 品红 #F0F | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4'h7: base_color = 12'h888; // 灰色 #888 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| default: base_color = 12'hFFF; // 默认白色 #FFF | ||||||||||||||||||||||||||||||||||||||||||||||||||
| endcase | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // 显示方块颜色(不管是否在消行) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| pixel_color = base_color; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if (is_clearing_row && cell_color != 4'h0) begin | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // 动画阶段量化,约1秒 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| phase = clear_animation_counter[25:21]; // 0..31 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| crack_t = (phase >> 2) + 5'd1; // 裂纹厚度随时间加深 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| disp = phase[4:1]; // 碎片位移像素 0~15 | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // 碎片飞出 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| dir = {cell_x[0]^cell_y[1], cell_x[1]^cell_y[0]}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| randbit = cell_x[2]^cell_y[2]^cell_x[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| sx = block_x_offset; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| sy = block_y_offset; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| sx_s = sx; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| sy_s = sy; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| case (dir) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2'b00: sx_s = (sx > disp) ? (sx - disp) : 6'd63; // 右 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2'b01: sx_s = sx + disp; // 左 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2'b10: sy_s = sy + disp; // 上 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| default: sy_s = (sy > disp) ? (sy - disp) : 6'd63; // 下 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| endcase | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| in_bounds = (sx_s < BLOCK_SIZE) && (sy_s < BLOCK_SIZE); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // 碎片形状与稀疏门控(随时间更稀疏) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| pattern = (sx_s[2] ^ sy_s[1] ^ randbit) | (sx_s[1] & ~sy_s[2]); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| dist_bucket = (dir[0]) ? sx_s[4:3] : sy_s[4:3]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| gate = (dist_bucket >= phase[4:3]); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if (in_bounds && pattern && gate) begin | ||||||||||||||||||||||||||||||||||||||||||||||||||
| pixel_color = base_color; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| end else begin | ||||||||||||||||||||||||||||||||||||||||||||||||||
| pixel_color = 12'hFFF; // 飞出后留白 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // 裂纹加深:十字 + 对角线,厚度随时间增长 | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // 在消除行上添加裂纹效果(非碎片部分显示背景色) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (clear_line && is_clearing_row && cell_color != 4'h0) begin | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // counter / 781250 (25_000_000 / 32 = 781250) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| phase = (clear_animation_counter / 781250) & 5'h1F; // 确保在0-31范围 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| disp = (phase * 24) >> 5; // 碎片最大位移1个方块24像素,随phase线性增长 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| crack_t = (phase >> 2) + 5'd1; // 裂纹厚度随时间加深 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| mid5 = (BLOCK_SIZE/2); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| d1 = (block_x_offset >= block_y_offset) ? (block_x_offset - block_y_offset) : (block_y_offset - block_x_offset); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| d1 = (block_x_offset >= block_y_offset) ? (block_x_offset - block_y_offset) : (block_y_offset - block_x_offset); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| sum_xy = block_x_offset + block_y_offset; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| d2 = (sum_xy >= (BLOCK_SIZE-1)) ? (sum_xy - (BLOCK_SIZE-1)) : ((BLOCK_SIZE-1) - sum_xy); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ax = (block_x_offset >= mid5) ? (block_x_offset - mid5) : (mid5 - block_x_offset); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ay = (block_y_offset >= mid5) ? (block_y_offset - mid5) : (mid5 - block_y_offset); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| d2 = (sum_xy >= (BLOCK_SIZE-1)) ? (sum_xy - (BLOCK_SIZE-1)) : ((BLOCK_SIZE-1) - sum_xy); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ax = (block_x_offset >= mid5) ? (block_x_offset - mid5) : (mid5 - block_x_offset); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ay = (block_y_offset >= mid5) ? (block_y_offset - mid5) : (mid5 - block_y_offset); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if ((d1 <= crack_t) || (d2 <= crack_t) || (ax <= (crack_t>>1)) || (ay <= (crack_t>>1))) begin | ||||||||||||||||||||||||||||||||||||||||||||||||||
| pixel_color = 12'hFFF; // 裂纹为亮白 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| pixel_color = 12'hFFF; // 裂纹为白 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // 碎片飞溅动画 - 在所有区域检查(包括游戏区外) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (clear_line) begin | ||||||||||||||||||||||||||||||||||||||||||||||||||
| logic [4:0] anim_phase; // 动画阶段 0-31 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| logic [5:0] anim_disp; // 碎片位移 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| logic fragment_drawn; // 是否已绘制碎片 | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+111
to
+113
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // 动画阶段量化(32步) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // 计数器范围: 0 ~ 25_000_000 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // 归一化到 0~31: (counter * 32) / 25_000_000 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // 简化: counter / 781250 (25_000_000 / 32 = 781250) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| anim_phase = (clear_animation_counter / 781250) & 5'h1F; // 确保在0-31范围 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| anim_disp = (anim_phase * 48) >> 5; // 碎片最大位移2个方块48像素,随anim_phase线性增长 | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| fragment_drawn = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // 遍历所有可能的源方块位置(游戏网格内) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| for (int src_y = 0; src_y < 20; src_y++) begin | ||||||||||||||||||||||||||||||||||||||||||||||||||
| for (int src_x = 0; src_x < 10; src_x++) begin | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!fragment_drawn && clearing_rows[src_y]) begin | ||||||||||||||||||||||||||||||||||||||||||||||||||
| logic [3:0] src_color; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| logic [1:0] src_dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| logic src_randbit; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| logic signed [10:0] pixel_offset_x, pixel_offset_y; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| logic [5:0] local_x, local_y; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| logic signed [10:0] src_screen_x, src_screen_y; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| logic signed [10:0] fragment_screen_x, fragment_screen_y; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+124
to
+134
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // 遍历所有可能的源方块位置(游戏网格内) | |
| for (int src_y = 0; src_y < 20; src_y++) begin | |
| for (int src_x = 0; src_x < 10; src_x++) begin | |
| if (!fragment_drawn && clearing_rows[src_y]) begin | |
| logic [3:0] src_color; | |
| logic [1:0] src_dir; | |
| logic src_randbit; | |
| logic signed [10:0] pixel_offset_x, pixel_offset_y; | |
| logic [5:0] local_x, local_y; | |
| logic signed [10:0] src_screen_x, src_screen_y; | |
| logic signed [10:0] fragment_screen_x, fragment_screen_y; | |
| // Declare temporary variables once at the top of the always_comb block to avoid excessive combinational logic | |
| logic [3:0] src_color; | |
| logic [1:0] src_dir; | |
| logic src_randbit; | |
| logic signed [10:0] pixel_offset_x, pixel_offset_y; | |
| logic [5:0] local_x, local_y; | |
| logic signed [10:0] src_screen_x, src_screen_y; | |
| logic signed [10:0] fragment_screen_x, fragment_screen_y; | |
| // 遍历所有可能的源方块位置(游戏网格内) | |
| for (int src_y = 0; src_y < 20; src_y++) begin | |
| for (int src_x = 0; src_x < 10; src_x++) begin | |
| if (!fragment_drawn && clearing_rows[src_y]) begin |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This nested loop structure iterates up to 200 times (20 rows × 10 columns) for every pixel being rendered, which is extremely inefficient. For a 640×480 display, this means up to 61.44 million loop iterations per frame. This will likely cause severe synthesis issues and timing violations.
Consider refactoring to:
- Pre-calculate fragment positions in a sequential clocked process
- Store active fragments in a small array (one entry per clearing row)
- Check only the relevant fragments for the current pixel instead of iterating through all grid positions
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider removing these excessive blank lines (20+ empty lines). While whitespace can improve readability, this many consecutive blank lines doesn't add value and increases file size unnecessarily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be a Xilinx DFX (Dynamic Function eXchange) runtime report file, which is typically an auto-generated output file. Build artifacts and tool-generated reports should generally not be tracked in version control.
Consider adding
dfx_runtime.txtor*.txt(if appropriate) to the.gitignorefile to prevent committing build outputs.