-
Notifications
You must be signed in to change notification settings - Fork 0
/
trace_pixgen.vhd
162 lines (146 loc) · 6.78 KB
/
trace_pixgen.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
----------------------------------------------------------------------------------
-- Author: Osowski Marcin
-- Create Date: 20:16:43 05/22/2011
----------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.types.all;
entity trace_pixgen is
port (
nrst : in std_logic;
clk108 : in std_logic;
segment : in integer range 0 to 15;
segment_change : in std_logic;
subsegment : in integer range 0 to 3;
subsegment_change : in std_logic;
line : in integer range 0 to 15;
line_change : in std_logic;
column : in integer range 0 to 1279;
column_change : in std_logic;
page_change : in std_logic;
active_pixgen_source : in PIXGEN_SOURCE_T;
currently_read_screen_segment : in natural range 0 to 13;
currently_read_screen_column : in natural range 0 to 1279;
time_resolution : in integer range 0 to 15;
is_reading_active : in std_logic;
doutb : in std_logic_vector (8 downto 0);
addrb : out std_logic_vector (12 downto 0);
vout : out std_logic_vector (7 downto 0)
);
end trace_pixgen;
architecture behavioral of trace_pixgen is
signal position_div_3 : integer range 0 to 5973;
signal position_mod_3 : integer range 0 to 2;
signal delayed_active_pixgen_source : PIXGEN_SOURCE_T;
signal delayed_subsegment : integer range 0 to 3;
signal delayed_position_mod_3 : integer range 0 to 2;
signal delayed_line : integer range 0 to 15;
signal position_div_3_on_beginning_segment : integer range 0 to 5973;
signal position_mod_3_on_beginning_segment : integer range 0 to 2;
signal currently_inside_reading_zone : std_logic;
begin
-- Computing current position
process (nrst, clk108, position_mod_3, position_div_3) is
variable incremented_position_div_3 : integer range 0 to 5973;
variable incremented_position_mod_3 : integer range 0 to 2;
begin
if position_mod_3 = 2 then
incremented_position_div_3 := position_div_3 + 1;
incremented_position_mod_3 := 0;
else
incremented_position_div_3 := position_div_3;
incremented_position_mod_3 := position_mod_3 + 1;
end if;
if nrst = '0' then
position_div_3 <= 0;
position_mod_3 <= 0;
currently_inside_reading_zone <= '0';
elsif rising_edge (clk108) then
if currently_read_screen_segment = 0 and currently_read_screen_column = 0 then
currently_inside_reading_zone <= '0';
else
if time_resolution >= 10 or is_reading_active = '0' then
if segment = currently_read_screen_segment and
column - currently_read_screen_column < 6 and
column - currently_read_screen_column >= 0 then
currently_inside_reading_zone <= '1';
else
currently_inside_reading_zone <= '0';
end if;
elsif time_resolution >= 7 then
if segment = currently_read_screen_segment then
currently_inside_reading_zone <= '1';
else
currently_inside_reading_zone <= '0';
end if;
else
currently_inside_reading_zone <= '0';
end if;
end if;
if active_pixgen_source = TRACE_PIXGEN_T then
if page_change = '1' then
position_div_3 <= 0;
position_mod_3 <= 0;
position_div_3_on_beginning_segment <= 0;
position_mod_3_on_beginning_segment <= 0;
elsif segment_change = '1' then
position_div_3 <= incremented_position_div_3;
position_mod_3 <= incremented_position_mod_3;
position_div_3_on_beginning_segment <= incremented_position_div_3;
position_mod_3_on_beginning_segment <= incremented_position_mod_3;
elsif line_change = '1' then
position_div_3 <= position_div_3_on_beginning_segment;
position_mod_3 <= position_mod_3_on_beginning_segment;
else
position_div_3 <= incremented_position_div_3;
position_mod_3 <= incremented_position_mod_3;
end if;
end if;
end if;
end process;
addrb <= std_logic_vector (to_unsigned (position_div_3, 13));
delayed_active_pixgen_source <= active_pixgen_source when rising_edge (clk108);
delayed_subsegment <= subsegment when rising_edge (clk108);
delayed_position_mod_3 <= position_mod_3 when rising_edge (clk108);
delayed_line <= line when rising_edge (clk108);
process (nrst, delayed_active_pixgen_source, delayed_subsegment, delayed_position_mod_3, delayed_line, currently_inside_reading_zone) is
begin
if nrst = '0' or delayed_active_pixgen_source /= TRACE_PIXGEN_T then
vout <= "00000000";
else
if currently_inside_reading_zone = '1' then
vout <= "10010010";
elsif delayed_subsegment = 0 then
-- red
if delayed_line = 15 then
vout <= "11100000";
elsif doutb (3 * delayed_position_mod_3) = '1' then
vout <= "11100000";
else
vout <= "00000000";
end if;
elsif delayed_subsegment = 1 then
-- green
if delayed_line = 15 then
vout <= "00011100";
elsif doutb (3 * delayed_position_mod_3 + 1) = '1' then
vout <= "00011100";
else
vout <= "00000000";
end if;
elsif delayed_subsegment = 2 then
-- blue
if delayed_line = 15 then
vout <= "00000011";
elsif doutb (3 * delayed_position_mod_3 + 2) = '1' then
vout <= "00000011";
else
vout <= "00000000";
end if;
else
vout <= "00000000";
end if;
end if;
end process;
end behavioral;