2 use ieee.std_logic_1164.all;
3 use ieee.std_logic_unsigned.all;
6 port ( ppu_clk : in std_logic;
8 pos_x : buffer std_logic_vector (8 downto 0);
9 pos_y : buffer std_logic_vector (8 downto 0);
10 nes_r : buffer std_logic_vector (3 downto 0);
11 nes_g : buffer std_logic_vector (3 downto 0);
12 nes_b : buffer std_logic_vector (3 downto 0)
17 architecture rtl of dummy_ppu is
19 component counter_register
24 port ( clk : in std_logic;
28 d : in std_logic_vector(dsize - 1 downto 0);
29 q : out std_logic_vector(dsize - 1 downto 0)
33 signal x_res_n, y_res_n, y_en_n : std_logic;
34 signal cnt_clk : std_logic;
35 signal frame_en_n : std_logic;
38 signal frame_cnt : std_logic_vector(7 downto 0);
42 cnt_clk <= not ppu_clk;
43 x_inst : counter_register generic map (9, 1)
44 port map (cnt_clk , x_res_n, '0', '1', (others => '0'), pos_x);
45 y_inst : counter_register generic map (9, 1)
46 port map (cnt_clk , y_res_n, y_en_n, '1', (others => '0'), pos_y);
48 frame_cnt_inst : counter_register generic map (8, 1)
49 port map (cnt_clk , rst_n, frame_en_n, '1', (others => '0'), frame_cnt);
52 p_write : process (rst_n, ppu_clk)
58 nes_r <= (others => '0');
59 nes_g <= (others => '0');
60 nes_b <= (others => '0');
61 elsif (rising_edge(ppu_clk)) then
63 if (pos_x = "101010100") then
67 if (pos_y = "100000101") then
90 use ieee.std_logic_1164.all;
91 use ieee.std_logic_unsigned.conv_integer;
92 use ieee.std_logic_arith.conv_std_logic_vector;
93 use work.motonesfpga_common.all;
96 port ( ppu_clk : in std_logic;
97 vga_clk : in std_logic;
99 pos_x : in std_logic_vector (8 downto 0);
100 pos_y : in std_logic_vector (8 downto 0);
101 nes_r : in std_logic_vector (3 downto 0);
102 nes_g : in std_logic_vector (3 downto 0);
103 nes_b : in std_logic_vector (3 downto 0);
104 h_sync_n : out std_logic;
105 v_sync_n : out std_logic;
106 r : out std_logic_vector(3 downto 0);
107 g : out std_logic_vector(3 downto 0);
108 b : out std_logic_vector(3 downto 0)
112 architecture rtl of vga_ctl is
114 component counter_register
116 dsize : integer := 8;
119 port ( clk : in std_logic;
120 rst_n : in std_logic;
123 d : in std_logic_vector(dsize - 1 downto 0);
124 q : out std_logic_vector(dsize - 1 downto 0)
128 constant VGA_W : integer := 640;
129 constant VGA_H : integer := 480;
130 constant VGA_W_MAX : integer := 800;
131 constant VGA_H_MAX : integer := 525;
132 constant H_SP : integer := 95;
133 constant H_BP : integer := 48;
134 constant H_FP : integer := 15;
136 constant V_SP : integer := 2;
137 constant V_BP : integer := 33;
138 constant V_FP : integer := 10;
140 signal vga_x : std_logic_vector (9 downto 0);
141 signal vga_y : std_logic_vector (9 downto 0);
142 signal x_res_n, y_res_n, y_en_n : std_logic;
143 signal cnt_clk : std_logic;
147 cnt_clk <= not vga_clk;
148 x_inst : counter_register generic map (10, 1)
149 port map (cnt_clk , x_res_n, '0', '1', (others => '0'), vga_x);
150 y_inst : counter_register generic map (10, 1)
151 port map (cnt_clk , y_res_n, y_en_n, '1', (others => '0'), vga_y);
153 p_vga : process (rst_n, vga_clk)
155 if (rst_n = '0') then
163 elsif (rising_edge(vga_clk)) then
165 if (vga_x = "1100011111") then
169 if (vga_y = "1000001100") then
180 --sync signal assert.
181 if (vga_x >= conv_std_logic_vector((VGA_W + H_FP) , 10) and
182 vga_x < conv_std_logic_vector((VGA_W + H_FP + H_SP) , 10)) then
188 if (vga_y >= conv_std_logic_vector((VGA_H + V_FP) , 10) and
189 vga_y < conv_std_logic_vector((VGA_H + V_FP + V_SP) , 10)) then
196 if (vga_y <=conv_std_logic_vector((VGA_H) , 10)) then
197 if (vga_x < conv_std_logic_vector((VGA_W) , 10)) then
220 --constant VGA_W : integer := 256;
221 --constant VGA_H : integer := 240;
222 --constant VGA_W_MAX : integer := 341;
223 --constant VGA_H_MAX : integer := 262;
225 --constant H_SP : integer := (95 / 2);
226 --constant H_FP : integer := (15 / 2);
228 --constant V_SP : integer := (2 / 2);
229 --constant V_FP : integer := (10 / 2);
233 -- p_vga : process (rst_n, vga_clk)
235 -- if (rst_n = '0') then
238 -- r<=(others => '0');
239 -- g<=(others => '0');
240 -- b<=(others => '0');
241 -- elsif (rising_edge(vga_clk)) then
243 -- --sync signal assert.
244 -- if (pos_x >= conv_std_logic_vector(VGA_W + H_FP , 9) and
245 -- pos_x < conv_std_logic_vector(VGA_W + H_FP + H_SP, 9)) then
251 -- if (pos_y >= conv_std_logic_vector(VGA_H + V_FP, 9) and
252 -- pos_y < conv_std_logic_vector(VGA_H + V_FP + V_SP, 9)) then
258 -- if (pos_y <=conv_std_logic_vector(VGA_H, 9)) then
259 -- if (pos_x < conv_std_logic_vector(VGA_W, 9)) then
260 -- r<=(others => '1');
261 -- g<=(others => '1');
262 -- b<=(others => '1');
264 -- r<=(others => '0');
265 -- g<=(others => '0');
266 -- b<=(others => '0');
269 -- r<=(others => '0');
270 -- g<=(others => '0');
271 -- b<=(others => '0');