data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v
 line:85: before: "&&"
1: b"%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:85: Define or directive not defined: '`v_visible_offset'\nassign current_y = (vertical_counter >= `v_visible_offset && vertical_counter < `v_visible_offset_end) ? vertical_counter - `v_visible_offset : 11'b0;\n                                        ^~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:85: syntax error, unexpected &&, expecting TYPE-IDENTIFIER\nassign current_y = (vertical_counter >= `v_visible_offset && vertical_counter < `v_visible_offset_end) ? vertical_counter - `v_visible_offset : 11'b0;\n                                                          ^~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:85: Define or directive not defined: '`v_visible_offset_end'\nassign current_y = (vertical_counter >= `v_visible_offset && vertical_counter < `v_visible_offset_end) ? vertical_counter - `v_visible_offset : 11'b0;\n                                                                                ^~~~~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:85: Define or directive not defined: '`v_visible_offset'\nassign current_y = (vertical_counter >= `v_visible_offset && vertical_counter < `v_visible_offset_end) ? vertical_counter - `v_visible_offset : 11'b0;\n                                                                                                                            ^~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:86: Define or directive not defined: '`h_visible_offset'\nassign current_x = (horizontal_counter >= `h_visible_offset + `h_center_offset + 2'd2 && horizontal_counter < `h_visible_offset_end + `h_center_offset - 2'd3) ?\n                                          ^~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:86: Define or directive not defined: '`h_center_offset'\nassign current_x = (horizontal_counter >= `h_visible_offset + `h_center_offset + 2'd2 && horizontal_counter < `h_visible_offset_end + `h_center_offset - 2'd3) ?\n                                                              ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:86: Define or directive not defined: '`h_visible_offset_end'\nassign current_x = (horizontal_counter >= `h_visible_offset + `h_center_offset + 2'd2 && horizontal_counter < `h_visible_offset_end + `h_center_offset - 2'd3) ?\n                                                                                                              ^~~~~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:86: Define or directive not defined: '`h_center_offset'\nassign current_x = (horizontal_counter >= `h_visible_offset + `h_center_offset + 2'd2 && horizontal_counter < `h_visible_offset_end + `h_center_offset - 2'd3) ?\n                                                                                                                                      ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:87: Define or directive not defined: '`h_visible_offset'\n                                       horizontal_counter - (`h_visible_offset + `h_center_offset) : 11'b0;\n                                                             ^~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:87: Define or directive not defined: '`h_center_offset'\n                                       horizontal_counter - (`h_visible_offset + `h_center_offset) : 11'b0;\n                                                                                 ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:87: syntax error, unexpected ')', expecting TYPE-IDENTIFIER\n                                       horizontal_counter - (`h_visible_offset + `h_center_offset) : 11'b0;\n                                                                                                 ^\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:89: Define or directive not defined: '`h_visible_offset'\nassign visible_x = (horizontal_counter >= `h_visible_offset && horizontal_counter < `h_line_timing) ? horizontal_counter - `h_visible_offset : 11'b0;\n                                          ^~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:89: syntax error, unexpected &&, expecting TYPE-IDENTIFIER\nassign visible_x = (horizontal_counter >= `h_visible_offset && horizontal_counter < `h_line_timing) ? horizontal_counter - `h_visible_offset : 11'b0;\n                                                            ^~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:89: Define or directive not defined: '`h_line_timing'\nassign visible_x = (horizontal_counter >= `h_visible_offset && horizontal_counter < `h_line_timing) ? horizontal_counter - `h_visible_offset : 11'b0;\n                                                                                    ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:89: Define or directive not defined: '`h_visible_offset'\nassign visible_x = (horizontal_counter >= `h_visible_offset && horizontal_counter < `h_line_timing) ? horizontal_counter - `h_visible_offset : 11'b0;\n                                                                                                                           ^~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:143: Define or directive not defined: '`lowercase'\n   if (char == `lowercase)                                      \n               ^~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:143: syntax error, unexpected ')', expecting TYPE-IDENTIFIER\n   if (char == `lowercase)                                      \n                         ^\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:146: Define or directive not defined: '`uppercase'\n   else if (char == `uppercase)\n                    ^~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:156: Define or directive not defined: '`carriage_return'\n      if (char == `carriage_return || char_x == 6'b111111)      \n                  ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:156: syntax error, unexpected ||, expecting TYPE-IDENTIFIER\n      if (char == `carriage_return || char_x == 6'b111111)      \n                                   ^~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:162: syntax error, unexpected end\n   end\n   ^~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:186: Define or directive not defined: '`h_visible_offset'\n   is_dashed_line <= (horizontal_counter == (`h_visible_offset + `h_center_offset - 1'b1) || horizontal_counter == (`h_visible_offset_end + `h_center_offset - 1'b1)) && current_y[1:0] == 0;\n                                             ^~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:186: Define or directive not defined: '`h_center_offset'\n   is_dashed_line <= (horizontal_counter == (`h_visible_offset + `h_center_offset - 1'b1) || horizontal_counter == (`h_visible_offset_end + `h_center_offset - 1'b1)) && current_y[1:0] == 0;\n                                                                 ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:186: Define or directive not defined: '`h_visible_offset_end'\n   is_dashed_line <= (horizontal_counter == (`h_visible_offset + `h_center_offset - 1'b1) || horizontal_counter == (`h_visible_offset_end + `h_center_offset - 1'b1)) && current_y[1:0] == 0;\n                                                                                                                    ^~~~~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:186: Define or directive not defined: '`h_center_offset'\n   is_dashed_line <= (horizontal_counter == (`h_visible_offset + `h_center_offset - 1'b1) || horizontal_counter == (`h_visible_offset_end + `h_center_offset - 1'b1)) && current_y[1:0] == 0;\n                                                                                                                                            ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:187: syntax error, unexpected end\nend\n^~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:220: syntax error, unexpected end\nend\n^~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:225: Define or directive not defined: '`h_visible_offset'\n   if (horizontal_counter >= `h_visible_offset + `h_center_offset - 8'd36 && horizontal_counter < `h_visible_offset_end + `h_center_offset + 8'd36)\n                             ^~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:225: Define or directive not defined: '`h_center_offset'\n   if (horizontal_counter >= `h_visible_offset + `h_center_offset - 8'd36 && horizontal_counter < `h_visible_offset_end + `h_center_offset + 8'd36)\n                                                 ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:225: Define or directive not defined: '`h_visible_offset_end'\n   if (horizontal_counter >= `h_visible_offset + `h_center_offset - 8'd36 && horizontal_counter < `h_visible_offset_end + `h_center_offset + 8'd36)\n                                                                                                  ^~~~~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/161706166/src/pdp1_vga_typewriter.v:225: Define or directive not defined: '`h_center_offset'\n   if (horizontal_counter >= `h_visible_offset + `h_center_offset - 8'd36 && horizontal_counter < `h_visible_offset_end + `h_center_offset + 8'd36)\n                                                                                                                          ^~~~~~~~~~~~~~~~\n%Error: Cannot continue\n"
module pdp1_vga_typewriter (
   input clk,

   input [10:0] horizontal_counter,
   input [10:0] vertical_counter,

   output wire [7:0] red_out,
   output wire [7:0] green_out,
   output wire [7:0] blue_out,

   input [6:0] char_in_kbd,
   input [6:0] char_in_pdp,

   input have_typewriter_data,
   input have_keyboard_data
);




wire [11:0] charset_address;
wire [15:0] character_line_data;

wire [9:0] current_y, current_x;
wire [10:0] visible_x;

wire [7:0] fiodec_charcode;
wire [10:0] fb_rdaddress;




reg  [15:0] character_line_latch;

reg  [10:0] fb_wraddress;
reg  [7:0] fb_wdata;
reg  [0:0] fb_strobe_in;

reg [7:0] pixel_out, bg_out;
reg [6:0] char_in;

reg [5:0] char_x;
reg [4:0] char_y;

reg current_case = 1'b0;

reg prev_typewriter_strobe_in,
    prev_prev_typewriter_strobe_in,
    prev_keyboard_strobe_in,
    prev_prev_keyboard_strobe_in;

reg pdp_strobe_in,
    kbd_strobe_in;

reg inside_visible_area;

reg is_cursor_over_hole,
    is_dashed_line;






assign fb_rdaddress = { current_y[9:5] + char_y + 1'b1, current_x[9:4] };
assign charset_address = { fiodec_charcode[6:0], current_y[4:0] };




assign red_out   = inside_visible_area && ~is_cursor_over_hole && ~is_dashed_line ? pixel_out & bg_out : 8'b0;
assign green_out = inside_visible_area && ~is_cursor_over_hole && ~is_dashed_line ? pixel_out : 8'b0;
assign blue_out  = inside_visible_area && ~is_cursor_over_hole && ~is_dashed_line ? pixel_out & bg_out : 8'b0;




assign current_y = (vertical_counter >= `v_visible_offset && vertical_counter < `v_visible_offset_end) ? vertical_counter - `v_visible_offset : 11'b0;
assign current_x = (horizontal_counter >= `h_visible_offset + `h_center_offset + 2'd2 && horizontal_counter < `h_visible_offset_end + `h_center_offset - 2'd3) ?
                                       horizontal_counter - (`h_visible_offset + `h_center_offset) : 11'b0;

assign visible_x = (horizontal_counter >= `h_visible_offset && horizontal_counter < `h_line_timing) ? horizontal_counter - `h_visible_offset : 11'b0;




pdp1_terminal_charset charset_rom (
   .address(charset_address),
   .clock(clk),
   .q(character_line_data));

pdp1_terminal_fb terminal_framebuf (
   .clock(clk),
   .data({1'b00, char_in}),
   .rdaddress(fb_rdaddress),
   .wraddress(fb_wraddress),
   .wren(1'b1),
   .q(fiodec_charcode)
);






function [0:0] is_circle_8;
   input [4:0] coord_x;
   input [4:0] coord_y;
begin

   if (coord_x < 5'd16) coord_x = ~coord_x;
   if (coord_y > 5'd16) coord_y = ~coord_y;

   case (coord_y)
      5'd16:  is_circle_8 = coord_x < 5'd23;
      5'd15:  is_circle_8 = coord_x < 5'd23;
      5'd14:  is_circle_8 = coord_x < 5'd23;
      5'd13:  is_circle_8 = coord_x < 5'd23;
      5'd12:  is_circle_8 = coord_x < 5'd23;
      5'd11:  is_circle_8 = coord_x < 5'd22;
      5'd10:  is_circle_8 = coord_x < 5'd22;
      5'd9:   is_circle_8 = coord_x < 5'd21;
      5'd8:   is_circle_8 = coord_x < 5'd19;
      default: is_circle_8 = 1'b0;
   endcase
end

endfunction




task receive_char;
  input [6:0] char;
begin
   if (char == `lowercase)
      current_case <= 1'b0;

   else if (char == `uppercase)
      current_case <= 1'b1;

   else
   begin
      char_x <= char_x + 1'b1;
      fb_wraddress <= { char_y, char_x };
      char_in <= {current_case, char[5:0]};

      if (char == `carriage_return || char_x == 6'b111111)
      begin
         char_x <= 6'b1;
         char_y <= char_y + 1'b1;
      end

   end
end
endtask




always @(posedge clk) begin


   prev_prev_typewriter_strobe_in <= prev_typewriter_strobe_in;
   prev_typewriter_strobe_in <= have_typewriter_data;

   prev_keyboard_strobe_in <= have_keyboard_data;
   prev_prev_keyboard_strobe_in <= prev_keyboard_strobe_in;

   pdp_strobe_in <= ~prev_prev_typewriter_strobe_in && prev_typewriter_strobe_in;
   kbd_strobe_in <= ~prev_prev_keyboard_strobe_in && prev_keyboard_strobe_in;


   is_cursor_over_hole <= (visible_x[10:5] == 6'd3 || visible_x[10:5] == 6'd36) && is_circle_8(visible_x[4:0], vertical_counter[4:0]);


   is_dashed_line <= (horizontal_counter == (`h_visible_offset + `h_center_offset - 1'b1) || horizontal_counter == (`h_visible_offset_end + `h_center_offset - 1'b1)) && current_y[1:0] == 0;
end




always @(posedge clk) begin
   reg [5:0] dummy_erase;


   if (current_x[3:0] == 4'b0000)
      character_line_latch <= character_line_data;


   pixel_out <= character_line_latch[~current_x[3:0]] ? 8'h0 : 8'hff;

   if ((current_y[5] ^ char_y[0]) && current_y[1] && current_x)
      bg_out <= (current_y[5:0] == 6'h3f || current_y[5:0] == 6'h23) ? 8'h0 : 8'h80;
   else
      bg_out <= 8'hff;

   if (pdp_strobe_in)
      receive_char(char_in_pdp);

   else if (kbd_strobe_in)
      receive_char(char_in_kbd);


   else
   begin
      dummy_erase <= dummy_erase + 1'b1;
      fb_wraddress <= { char_y + 1'b1, dummy_erase };
      char_in <= 6'b0;
   end
end



always @(posedge clk) begin
   if (horizontal_counter >= `h_visible_offset + `h_center_offset - 8'd36 && horizontal_counter < `h_visible_offset_end + `h_center_offset + 8'd36)
      inside_visible_area <= 1'b1;
   else
      inside_visible_area <= 1'b0;

end


endmodule
module pdp1_vga_typewriter (
   input clk,

   input [10:0] horizontal_counter,
   input [10:0] vertical_counter,

   output wire [7:0] red_out,
   output wire [7:0] green_out,
   output wire [7:0] blue_out,

   input [6:0] char_in_kbd,
   input [6:0] char_in_pdp,

   input have_typewriter_data,
   input have_keyboard_data
);





wire [11:0] charset_address;
wire [15:0] character_line_data;

wire [9:0] current_y, current_x;
wire [10:0] visible_x;

wire [7:0] fiodec_charcode;
wire [10:0] fb_rdaddress;




reg  [15:0] character_line_latch;

reg  [10:0] fb_wraddress;
reg  [7:0] fb_wdata;
reg  [0:0] fb_strobe_in;

reg [7:0] pixel_out, bg_out;
reg [6:0] char_in;

reg [5:0] char_x;
reg [4:0] char_y;

reg current_case = 1'b0;

reg prev_typewriter_strobe_in,
    prev_prev_typewriter_strobe_in,
    prev_keyboard_strobe_in,
    prev_prev_keyboard_strobe_in;

reg pdp_strobe_in,
    kbd_strobe_in;

reg inside_visible_area;

reg is_cursor_over_hole,
    is_dashed_line;






assign fb_rdaddress = { current_y[9:5] + char_y + 1'b1, current_x[9:4] };
assign charset_address = { fiodec_charcode[6:0], current_y[4:0] };




assign red_out   = inside_visible_area && ~is_cursor_over_hole && ~is_dashed_line ? pixel_out & bg_out : 8'b0;
assign green_out = inside_visible_area && ~is_cursor_over_hole && ~is_dashed_line ? pixel_out : 8'b0;
assign blue_out  = inside_visible_area && ~is_cursor_over_hole && ~is_dashed_line ? pixel_out & bg_out : 8'b0;




assign current_y = (vertical_counter >= `v_visible_offset && vertical_counter < `v_visible_offset_end) ? vertical_counter - `v_visible_offset : 11'b0;
assign current_x = (horizontal_counter >= `h_visible_offset + `h_center_offset + 2'd2 && horizontal_counter < `h_visible_offset_end + `h_center_offset - 2'd3) ?
                                       horizontal_counter - (`h_visible_offset + `h_center_offset) : 11'b0;

assign visible_x = (horizontal_counter >= `h_visible_offset && horizontal_counter < `h_line_timing) ? horizontal_counter - `h_visible_offset : 11'b0;




pdp1_terminal_charset charset_rom (
   .address(charset_address),
   .clock(clk),
   .q(character_line_data));

pdp1_terminal_fb terminal_framebuf (
   .clock(clk),
   .data({1'b00, char_in}),
   .rdaddress(fb_rdaddress),
   .wraddress(fb_wraddress),
   .wren(1'b1),
   .q(fiodec_charcode)
);






function [0:0] is_circle_8;
   input [4:0] coord_x;
   input [4:0] coord_y;
begin

   if (coord_x < 5'd16) coord_x = ~coord_x;
   if (coord_y > 5'd16) coord_y = ~coord_y;

   case (coord_y)
      5'd16:  is_circle_8 = coord_x < 5'd23;
      5'd15:  is_circle_8 = coord_x < 5'd23;
      5'd14:  is_circle_8 = coord_x < 5'd23;
      5'd13:  is_circle_8 = coord_x < 5'd23;
      5'd12:  is_circle_8 = coord_x < 5'd23;
      5'd11:  is_circle_8 = coord_x < 5'd22;
      5'd10:  is_circle_8 = coord_x < 5'd22;
      5'd9:   is_circle_8 = coord_x < 5'd21;
      5'd8:   is_circle_8 = coord_x < 5'd19;
      default: is_circle_8 = 1'b0;
   endcase
end

endfunction




task receive_char;
  input [6:0] char;
begin
   if (char == `lowercase)
      current_case <= 1'b0;

   else if (char == `uppercase)
      current_case <= 1'b1;

   else
   begin
      char_x <= char_x + 1'b1;
      fb_wraddress <= { char_y, char_x };
      char_in <= {current_case, char[5:0]};

      if (char == `carriage_return || char_x == 6'b111111)
      begin
         char_x <= 6'b1;
         char_y <= char_y + 1'b1;
      end

   end
end
endtask




always @(posedge clk) begin


   prev_prev_typewriter_strobe_in <= prev_typewriter_strobe_in;
   prev_typewriter_strobe_in <= have_typewriter_data;

   prev_keyboard_strobe_in <= have_keyboard_data;
   prev_prev_keyboard_strobe_in <= prev_keyboard_strobe_in;

   pdp_strobe_in <= ~prev_prev_typewriter_strobe_in && prev_typewriter_strobe_in;
   kbd_strobe_in <= ~prev_prev_keyboard_strobe_in && prev_keyboard_strobe_in;


   is_cursor_over_hole <= (visible_x[10:5] == 6'd3 || visible_x[10:5] == 6'd36) && is_circle_8(visible_x[4:0], vertical_counter[4:0]);


   is_dashed_line <= (horizontal_counter == (`h_visible_offset + `h_center_offset - 1'b1) || horizontal_counter == (`h_visible_offset_end + `h_center_offset - 1'b1)) && current_y[1:0] == 0;
end




always @(posedge clk) begin
   reg [5:0] dummy_erase;


   if (current_x[3:0] == 4'b0000)
      character_line_latch <= character_line_data;


   pixel_out <= character_line_latch[~current_x[3:0]] ? 8'h0 : 8'hff;

   if ((current_y[5] ^ char_y[0]) && current_y[1] && current_x)
      bg_out <= (current_y[5:0] == 6'h3f || current_y[5:0] == 6'h23) ? 8'h0 : 8'h80;
   else
      bg_out <= 8'hff;

   if (pdp_strobe_in)
      receive_char(char_in_pdp);

   else if (kbd_strobe_in)
      receive_char(char_in_kbd);


   else
   begin
      dummy_erase <= dummy_erase + 1'b1;
      fb_wraddress <= { char_y + 1'b1, dummy_erase };
      char_in <= 6'b0;
   end
end



always @(posedge clk) begin
   if (horizontal_counter >= `h_visible_offset + `h_center_offset - 8'd36 && horizontal_counter < `h_visible_offset_end + `h_center_offset + 8'd36)
      inside_visible_area <= 1'b1;
   else
      inside_visible_area <= 1'b0;

end


endmodule