[from now] Mon Nov 26 12:40:25 JST 2012

diff --git a/2nd/display/display_buffer.v b/2nd/display/display_buffer.v
index 6c8795d..36c0cc7 100644
--- a/2nd/display/display_buffer.v
+++ b/2nd/display/display_buffer.v
@@ -1,18 +1,20 @@
 module display_buffer (input clk,
-                           input            write_enable,
-                           input [11:0]     address,
-                           input [6:0]      write_data,
-                           output reg [6:0] read_data);
-   parameter MEM_SIZE=2400;
+                       input             write_enable,
+                       input [13:0]      address,
+                       input [23:0]      write_data,
+                       output reg [23:0] read_data);
+   parameter MEM_SIZE=16384;

-   reg [6:0] RAM[MEM_SIZE-1:0];
+   reg [23:0] RAM[MEM_SIZE-1:0];
+   reg [13:0] write_counter;

    initial
-     $readmemb ("initial_text.dat", RAM);
+      write_counter <= 14'b0;

    always @ (posedge clk) begin
       if (write_enable == 1) begin
-         RAM[address] <= write_data;
+         RAM[write_counter] <= write_data;
+         write_counter <= write_counter + 1;
       end
       else begin
          read_data <= RAM[address];
[from now] Mon Nov 26 13:08:50 JST 2012

diff --git a/2nd/display/display_instruction_dispatcher.v b/2nd/display/display_instruction_dispatcher.v
index 0188824..03e7a11 100644
--- a/2nd/display/display_instruction_dispatcher.v
+++ b/2nd/display/display_instruction_dispatcher.v
@@ -6,8 +6,7 @@ module display_instruction_dispatcher(input clk,
                                       input [31:0]      rt,

                                       output reg        buffer_write_enable,
-                                      output reg [11:0] position,
-                                      output reg [6:0]  char_code);
+                                      output reg [23:0] color_code);

    parameter DISPLAY = 6'b001000;

@@ -18,13 +17,11 @@ module display_instruction_dispatcher(input clk,
    always @ (posedge(clk)) begin
       if (op == DISPLAY) begin
          buffer_write_enable <= 1'b1;
-         position <= rs[11:0];
-         char_code <= rt[6:0];
+         color_code <= rt[23:0];

       end else begin
          buffer_write_enable <= 1'b0;
-         position <= 11'b0;
-         char_code <= 7'b0;
+         color_code <= 24'b0;

       end
    end
[from now] Mon Nov 26 13:11:56 JST 2012

diff --git a/2nd/mimic.v b/2nd/mimic.v
index 60fa0db..e4b8baf 100644
--- a/2nd/mimic.v
+++ b/2nd/mimic.v
@@ -16,8 +16,7 @@ module mimic(input clk,
              output        rx_fifo_pop,

              output        display_buffer_write_enable,
-             output [11:0] display_position,
-             output [6:0]  display_char_code,
+             output [23:0] display_color_code,

              input [7:0]   key_status,
              input [7:0]   keycode);
@@ -172,7 +171,7 @@ module mimic(input clk,

    display_instruction_dispatcher display_inst
      (.clk(clk), .inst(inst_reg_read), .rs(rs_data), .rt(rt_data),
-      .buffer_write_enable(display_buffer_write_enable), .position(display_position), .char_code(display_char_code));
+      .buffer_write_enable(display_buffer_write_enable), .color_code(display_color_code));

    branch_condition_checker branch_condition_checker_inst
       (.op(inst_reg_read[31:26]), .rs(rs_data), .rt(rt_data), .go_branch(branch_taken));
diff --git a/2nd/top.vhd b/2nd/top.vhd
index b3f3b5e..08f6db1 100644
--- a/2nd/top.vhd
+++ b/2nd/top.vhd
@@ -59,8 +59,7 @@ architecture top of top is
       rx_fifo_pop      : out STD_LOGIC;

       display_buffer_write_enable : out STD_LOGIC;
-      display_position : out std_logic_vector(11 downto 0);
-      display_char_code : out std_logic_vector(6 downto 0);
+      display_color_code: out std_logic_vector(6 downto 0);

 			key_status : in std_logic_vector(7 downto 0);
 			keycode    : in std_logic_vector(7 downto 0));
@@ -125,8 +124,7 @@ architecture top of top is
       reset : in STD_LOGIC;

 			buffer_write_enable : in STD_LOGIC;
-      position            : in std_logic_vector(11 downto 0);
-      char_code           : in std_logic_vector(6 downto 0);
+      color_code          : in std_logic_vector(23 downto 0);

       r_data, g_data, b_data : out std_logic_vector(7 downto 0);
       vs_data, hs_data : out STD_LOGIC);
@@ -154,8 +152,7 @@ architecture top of top is

   -- display
   signal display_buffer_write_enable : STD_LOGIC;
-  signal display_position            : std_logic_vector(11 downto 0);
-  signal display_char_code           : std_logic_vector(6 downto 0);
+  signal display_color_code          : std_logic_vector(23 downto 0);

 	-- keyboard
 	signal key_status : std_logic_vector(7 downto 0);
@@ -191,8 +188,7 @@ begin  -- test
     rx_fifo_pop      => rx_pop,

     display_buffer_write_enable => display_buffer_write_enable,
-    display_position            => display_position,
-    display_char_code           => display_char_code,
+    display_color_code          => display_color_code,

 		key_status => key_status,
 		keycode    => keycode);
@@ -214,7 +210,7 @@ begin  -- test

 	-- workaround for not-stable VGA signal
 	tx_send_enable <= '1'               when core_tx_send_enable = '1' else display_buffer_write_enable;
-	tx_send_data   <= core_tx_send_data when core_tx_send_enable = '1' else "0"&display_char_code;
+	tx_send_data   <= core_tx_send_data when core_tx_send_enable = '1' else display_color_code(7 downto 0);

 	Inst_dcm100: dcm100 PORT MAP(
 		CLKIN_IN       => CLK,
@@ -230,8 +226,7 @@ begin  -- test
     reset   => not xrst,

     buffer_write_enable => display_buffer_write_enable,
-    position            => display_position,
-    char_code           => display_char_code,
+    color_code          => display_color_code,

     r_data  => r_data,
     g_data  => g_data,
[from now] Mon Nov 26 13:21:38 JST 2012

diff --git a/2nd/display/display.v b/2nd/display/display.v
index 9b2d704..d391f4d 100644
--- a/2nd/display/display.v
+++ b/2nd/display/display.v
@@ -3,8 +3,7 @@ module display(input clk,
                input        reset,

                input        buffer_write_enable,
-               input [11:0] position,
-               input [6:0]  char_code,
+               input [23:0] color_code,

                output [7:0] r_data,g_data,b_data,
                output       vs_data, hs_data);
@@ -34,10 +33,10 @@ module display(input clk,
    wire [7:0] red, green, blue;
    wire [8:0] row;
    wire [9:0] column;
-   text_drawer text_drawer_inst
+   image_drawer image_drawer_inst
       (.clk(clk), .reset(reset),
        .red(red), .green(green), .blue(blue), .row(row), .column(column),
-       .buffer_write_enable(buffer_write_enable), .position(position), .char_code(char_code));
+       .buffer_write_enable(buffer_write_enable), .color_code(color_code));

    vga vga_inst
       (.clk(clk25),
diff --git a/2nd/top.vhd b/2nd/top.vhd
index 08f6db1..54ca931 100644
--- a/2nd/top.vhd
+++ b/2nd/top.vhd
@@ -59,7 +59,7 @@ architecture top of top is
       rx_fifo_pop      : out STD_LOGIC;

       display_buffer_write_enable : out STD_LOGIC;
-      display_color_code: out std_logic_vector(6 downto 0);
+      display_color_code: out std_logic_vector(23 downto 0);

 			key_status : in std_logic_vector(7 downto 0);
 			keycode    : in std_logic_vector(7 downto 0));
TO SYNTHESIZE
[from now] Mon Nov 26 15:03:38 JST 2012

diff --git a/2nd/display/display_buffer.v b/2nd/display/display_buffer.v
index 36c0cc7..3830679 100644
--- a/2nd/display/display_buffer.v
+++ b/2nd/display/display_buffer.v
@@ -1,11 +1,11 @@
 module display_buffer (input clk,
                        input             write_enable,
                        input [13:0]      address,
-                       input [23:0]      write_data,
-                       output reg [23:0] read_data);
+                       input [11:0]      write_data,
+                       output reg [11:0] read_data);
    parameter MEM_SIZE=16384;

-   reg [23:0] RAM[MEM_SIZE-1:0];
+   reg [11:0] RAM[MEM_SIZE-1:0];
    reg [13:0] write_counter;

    initial
diff --git a/2nd/display/image_drawer.v b/2nd/display/image_drawer.v
new file mode 100644
index 0000000..b4b319d
--- /dev/null
+++ b/2nd/display/image_drawer.v
@@ -0,0 +1,38 @@
+module image_drawer(input clk,
+                   input        reset,
+
+                   output [7:0] red,green,blue,
+                   input [8:0]  row,
+                   input [9:0]  column,
+
+                   input        buffer_write_enable,
+                   input [23:0] color_code);
+
+   wire [6:0] x;
+   wire [6:0] y;
+   assign x = column[9:1] - 121;
+   assign y = row[8:1] - 61;
+
+   wire [13:0] display_address;
+   assign display_address = {y, 7'b0} + x;
+
+   wire [11:0] compressed;
+
+   assign compressed = {color_code[23:20], color_code[15:12], color_code[7:4]};
+
+   wire [11:0] rgb;
+   display_buffer display_buffer_inst
+     (.clk(clk),
+      .write_enable(buffer_write_enable),
+      .address(display_address),
+      .write_data(compressed),
+      .read_data(rgb));
+
+   wire display_in_range;
+   assign display_in_range = column >= 242 && column < 498 && row >= 112 && row < 368;
+
+   assign red   = display_in_range == 1'b1 ? {rgb[11:8], 4'b0} : 8'b0;
+   assign green = display_in_range == 1'b1 ? {rgb[ 7:4], 4'b0} : 8'b0;
+   assign blue  = display_in_range == 1'b1 ? {rgb[ 3:0], 4'b0} : 8'b0;
+
+endmodule
new display instruction