commit:95a8fb0345eff95dcbef8349dec7c249da5af287
author:Chip
committer:Chip
date:Fri Aug 30 17:59:09 2024 -0500
parents:1ba64a3d917d481ebd1b12ce0850d10682f52a16
Final, working version (for now)
diff --git a/src/config.json b/src/config.json
line changes: +1/-1
index 8a7560e..e903958
--- a/src/config.json
+++ b/src/config.json
@@ -13,7 +13,7 @@
 
   "//": "PL_TARGET_DENSITY - You can increase this if Global Placement fails with error GPL-0302.",
   "//": "Users have reported that values up to 0.8 worked well for them.",
-  "PL_TARGET_DENSITY": 0.65,
+  "PL_TARGET_DENSITY": 0.67,
 
   "//": "CLOCK_PERIOD - Increase this in case you are getting setup time violations.",
   "//": "The value is in nanoseconds, so 20ns == 50MHz.",

diff --git a/src/project.v b/src/project.v
line changes: +26/-6
index 5270da1..d9bb799
--- a/src/project.v
+++ b/src/project.v
@@ -93,6 +93,7 @@ module tt_um_bytex64_munch (
   // Misc signals
   wire [5:0] lfsr;
   wire [1:0] stage;
+  wire [3:0] stage_timer;
 
   // State
   reg [6:0] counter;        // general 7-bit counter
@@ -169,23 +170,40 @@ module tt_um_bytex64_munch (
     .selector(pattern_clock[3:2]),
     .hpos(hpos),
     .vpos(vpos),
+    .stage(stage),
+    .stage_timer(stage_timer),
     .pixel(text_pixel)
   );
 
   stage_sequencer stage_seq_inst(
     .seq_clk(!pattern_clock[3]),
     .rst_n(rst_n),
-    .stage(stage)
+    .stage(stage),
+    .stage_timer(stage_timer)
   );
 
-  wire [2:0] munch_color = {1'b0, stage}; //stage == 0 ? 0 : (stage == 1 ? 2 : lfsr[2:0]);
+  reg [2:0] background_color;
+
+  wire [2:0] munch_color = stage == 0 ? 0 : (stage != 3 ? 2 : ~background_color);
+  wire [5:0] text_color = stage == 1 && pattern_clock[3:2] != 2'b10 ? palette[0] :
+    (stage == 3 && pattern_clock[3:2] == 2'b10 ? palette[5] & {3{bright[5]}} :
+      palette[7]);
 
   assign layer[0] = palette[munch_color] & {3{bright[munch_level]}};
   // color bars
   //assign layer[0] = palette[vpos[6:4]] & {3{bright[hpos[6:4]]}};
-  assign layer[1] = text_pixel ? palette[7] : 0;
+  assign layer[1] = text_pixel ? text_color : 0;
+
+  assign pixel_color = layer[1] != 0 ? layer[1] :
+    (layer[0] != 0 ? layer[0] : palette[background_color]);
 
-  assign pixel_color = layer[1] != 0 ? layer[1] : layer[0];
+  always @(negedge pattern_clock[1], negedge rst_n) begin
+    if (!rst_n)
+      background_color <= 0;
+    else
+      if (stage == 3)
+        background_color <= lfsr[2:0];
+  end
 
   always @(posedge vsync, negedge rst_n) begin
     if (!rst_n)
@@ -226,7 +244,8 @@ endmodule
 module stage_sequencer(
   input wire seq_clk,
   input wire rst_n,
-  output wire [1:0] stage
+  output wire [1:0] stage,
+  output wire [3:0] stage_timer
 );
   reg [3:0] timer;
   reg [1:0] stage_seq;
@@ -234,7 +253,7 @@ module stage_sequencer(
   wire [3:0] stage_timings [3:0];
 
   assign stage_timings[0] = 3;
-  assign stage_timings[1] = 7;
+  assign stage_timings[1] = 3;
   assign stage_timings[2] = 7;
   assign stage_timings[3] = 0;
 
@@ -256,5 +275,6 @@ module stage_sequencer(
   end
 
   assign stage = stage_seq;
+  assign stage_timer = timer;
 
 endmodule

diff --git a/src/video.v b/src/video.v
line changes: +19/-4
index 2f5da2d..ef3edbd
--- a/src/video.v
+++ b/src/video.v
@@ -31,7 +31,7 @@ module chargen(
   input wire [9:0] vpos,
   output wire pixel
 );
-  wire [9:0] charmap [11:0];
+  wire [9:0] charmap [14:0];
   wire [9:0] segments;
 
   /* digits 0-9
@@ -57,7 +57,10 @@ module chargen(
   assign charmap[8]  = 10'b0101110011;  // R
   assign charmap[9]  = 10'b0001101101;  // S
   assign charmap[10] = 10'b1000000001;  // T
-  assign charmap[11] = 10'b1000011111;  // V (U)
+  assign charmap[11] = 10'b0100100110;  // V
+  assign charmap[12] = 10'b1000001111;  // D
+  assign charmap[13] = 10'b0010110000;  // Y
+  assign charmap[14] = 10'b0000111111;  // O
 
   assign segments = charmap[character];
 
@@ -87,6 +90,9 @@ parameter C_R  = 4'd8;
 parameter C_S  = 4'd9;
 parameter C_T  = 4'd10;
 parameter C_V  = 4'd11;
+parameter C_D  = 4'd12;
+parameter C_Y  = 4'd13;
+parameter C_O  = 4'd14;
 
 module text(
   input wire [9:0] x,
@@ -121,20 +127,29 @@ module text_sequencer(
   input wire [1:0] selector,
   input wire [9:0] hpos,
   input wire [9:0] vpos,
+  input wire [1:0] stage,
+  input wire [3:0] stage_timer,
   output wire pixel
 );
 
-  wire [23:0] words [3:0];
+  wire [23:0] words [6:0];
+  wire [2:0] word_select;
 
   assign words[0] = {C_sp, C_sp, C_sp, C_T, C_A, C_E};
   assign words[1] = {C_sp, C_P, C_E, C_E, C_L, C_S};
   assign words[2] = {C_sp, C_sp, C_K, C_C, C_A, C_H};
   assign words[3] = {C_T, C_A, C_E, C_P, C_E, C_R};
+  assign words[4] = {C_sp, C_Y, C_D, C_A, C_E, C_R};
+  assign words[5] = {C_sp, C_sp, C_sp, C_sp, C_K, C_O};
+  assign words[6] = {C_sp, C_sp, C_E, C_V, C_A, C_R};
+
+  assign word_select = (stage > 0 ? {stage == 3 && selector == 2'd2, selector} :
+    (stage_timer != 0 ? 3'd4 : 3'd5));
 
   text text_gen(
     .x(10'd100),
     .y(10'd280),
-    .str(words[selector]),
+    .str(words[word_select]),
     .hpos(hpos),
     .vpos(vpos),
     .pixel(pixel)