@@ -74,6 +74,7 @@ package vga_pkg is
74
74
vga_we_ram: in std_ulogic ; -- Write enable RAM
75
75
vga_din: in std_ulogic_vector (15 downto 0 );
76
76
vga_addr: in std_ulogic_vector (12 downto 0 );
77
+ base: in std_ulogic_vector (12 downto 0 );
77
78
78
79
-- VGA control registers
79
80
i_font_sel: in std_ulogic_vector (0 downto 0 );
@@ -472,6 +473,8 @@ architecture rtl of vt100 is
472
473
signal saved_attr_n, saved_attr_c: unsigned (attr_default'range ) := (others => '0' );
473
474
474
475
signal reverse_video_c, reverse_video_n: boolean := false ;
476
+ signal base_n, base_c: unsigned (addr'range ) := (others => '0' );
477
+ signal addr_sel: unsigned (addr'range ) := (others => '0' );
475
478
begin
476
479
accumulator_0: work.vga_pkg.atoi
477
480
generic map (g => g, N => number)
@@ -487,25 +490,25 @@ begin
487
490
n_o => n_o);
488
491
489
492
address : block
490
- signal addr_int: unsigned (addr'range ) := (others => '0' );
491
493
signal mul: unsigned (15 downto 0 ) := (others => '0' );
494
+ signal addr_int: unsigned (addr'range ) := (others => '0' );
492
495
begin
493
496
mul <= to_unsigned (to_integer (y_c) * width , mul'length );
494
497
addr_int <= mul(addr_int'range ) + ("000000" & x_c);
495
- -- addr_int <= mul( addr_int'range) + ("000000" & x_c) + unsigned(base_c) ;
496
- addr <= std_ulogic_vector (addr_int) when state_c /= ERASING else std_ulogic_vector (count_c );
498
+ addr_sel <= addr_int when state_c /= ERASING else count_c ;
499
+ addr <= std_ulogic_vector (addr_sel + base_c );
497
500
end block ;
498
501
499
502
x_minus_one <= x_c - 1 ;
500
503
x_plus_one <= x_c + 1 ;
501
- x_underflow <= x_minus_one >= (width - 1 );
502
504
x_overflow <= x_c > (width - 1 );
505
+ x_underflow <= x_minus_one >= (width - 1 );
503
506
x_minus_one_limited <= (others => '0' ) when x_underflow else x_minus_one;
504
507
x_plus_one_limited <= to_unsigned (width - 1 , x_c'length ) when x_overflow else x_plus_one;
505
508
506
509
y_plus_one <= y_c + 1 ;
507
510
y_minus_one <= y_c - 1 ;
508
- y_overflow <= y_c >= (height - 1 );
511
+ y_overflow <= y_c >= (height - 1 ); -- NB. > for 1 more row, slightly off edge of screen
509
512
y_underflow <= y_minus_one > (height - 1 );
510
513
y_minus_one_limited <= (others => '0' ) when y_underflow else y_minus_one;
511
514
y_plus_one_limited <= to_unsigned (height - 1 , y_c'length ) when y_overflow else y_plus_one;
@@ -542,6 +545,7 @@ begin
542
545
vga_we_ram => data_we,
543
546
vga_din => vga_din,
544
547
vga_addr => addr,
548
+ base => std_ulogic_vector (base_c),
545
549
i_font_sel => font_sel_c,
546
550
i_vga_control_we => vga_ctr_we,
547
551
i_vga_control => vga_ctr,
@@ -601,6 +605,7 @@ begin
601
605
saved_y_c <= saved_y_n;
602
606
saved_attr_c <= saved_attr_n;
603
607
reverse_video_c <= reverse_video_n;
608
+ base_c <= base_n;
604
609
605
610
if state_c = RESET then
606
611
n1_n <= (others => '0' );
@@ -619,6 +624,7 @@ begin
619
624
ctl_n <= ctl_default;
620
625
conceal_n <= false ;
621
626
reverse_video_n <= false ;
627
+ base_n <= (others => '0' );
622
628
elsif state_c = ACCEPT then
623
629
if we = '1' then
624
630
c_n <= unsigned (char);
@@ -665,6 +671,7 @@ begin
665
671
count_n <= (others => '0' );
666
672
limit_n <= "1000000000" ;
667
673
state_n <= ERASING;
674
+ base_n <= (others => '0' );
668
675
when lsqb =>
669
676
state_n <= NUMBER1;
670
677
akk_init <= '1' ;
@@ -722,6 +729,7 @@ begin
722
729
when x"4a" => -- CSI n 'J'
723
730
x_n <= (others => '0' );
724
731
y_n <= (others => '0' );
732
+ base_n <= (others => '0' );
725
733
cursor_we <= '1' ;
726
734
state_n <= ERASING;
727
735
c_n <= blank;
@@ -732,6 +740,8 @@ begin
732
740
akk_init <= '1' ;
733
741
when x"6d" => -- CSI n 'm' : SGR
734
742
state_n <= ATTRIB;
743
+
744
+ -- TODO: Fixing scrolling, or remove
735
745
when x"53" => -- CSI n 'S' : scroll up
736
746
ctl_n(4 ) <= '0' ;
737
747
state_n <= WRITE ;
@@ -796,11 +806,13 @@ begin
796
806
y_n <= y_plus_one;
797
807
elsif y_overflow then
798
808
x_n <= (others => '0' );
799
- y_n <= ( others => '0' ) ;
809
+ y_n <= y_minus_one ;
800
810
state_n <= ERASING;
801
811
c_n <= blank;
802
- count_n <= (others => '0' );
803
- limit_n <= "1000000000" ;
812
+ count_n <= unsigned (addr_sel);
813
+ limit_value := unsigned (addr_sel) + width ;
814
+ limit_n <= limit_value(limit_n'high + 3 downto limit_n'low + 3 );
815
+ base_n <= base_c + width ;
804
816
else
805
817
state_n <= WRITE ;
806
818
end if ;
@@ -904,6 +916,7 @@ entity vga_top is
904
916
vga_we_ram: in std_ulogic ; -- Write enable RAM
905
917
vga_din: in std_ulogic_vector (15 downto 0 );
906
918
vga_addr: in std_ulogic_vector (12 downto 0 );
919
+ base: in std_ulogic_vector (12 downto 0 );
907
920
908
921
-- VGA control registers
909
922
i_font_sel: in std_ulogic_vector (0 downto 0 );
@@ -990,7 +1003,7 @@ begin
990
1003
991
1004
o_vga => o_vga);
992
1005
993
- text_addr_full <= control_c.ctl( 4 ) & text_addr;
1006
+ text_addr_full <= std_ulogic_vector ( unsigned (base) + unsigned ( text_addr)) ;
994
1007
995
1008
u_text_memory : entity work .dual_ port_block_ram -- holds at least 80x40 characters
996
1009
generic map (g => g,
0 commit comments