2 use ieee.std_logic_1164.all;
3 use ieee.std_logic_unsigned.conv_integer;
6 -- MOTO NES FPGA On GHDL Simulation Environment Virtual Cuicuit Board
7 -- All of the components are assembled and instanciated on this board.
11 port ( reset_n : in std_logic
15 architecture rtl of motones_sim is
17 generic ( dsize : integer := 8;
20 port ( input_clk : in std_logic; --phi0 input pin.
29 addr : out std_logic_vector ( asize - 1 downto 0);
30 d_in : in std_logic_vector ( dsize - 1 downto 0);
31 d_out : out std_logic_vector ( dsize - 1 downto 0)
35 component clock_divider
36 port ( base_clk : in std_logic;
37 reset_n : in std_logic;
38 cpu_clk : out std_logic;
39 ppu_clk : out std_logic
43 ---clock frequency = 21,477,270 (21 MHz)
44 constant base_clock_time : time := 46 ns;
46 signal base_clk : std_logic;
47 signal cpu_clk, ppu_clk : std_logic;
49 constant data_size : integer := 8;
50 constant addr_size : integer := 16;
52 signal rdy, irq_n, nmi_n, dbe, r_nw : std_logic;
53 signal phi1, phi2 : std_logic;
54 signal addr : std_logic_vector( addr_size - 1 downto 0);
55 signal d_in : std_logic_vector( data_size - 1 downto 0);
56 signal d_out : std_logic_vector( data_size - 1 downto 0);
60 clock_inst : clock_divider port map
61 (base_clk, reset_n, cpu_clk, ppu_clk);
63 cpu_inst : mos6502 generic map (data_size, addr_size)
64 port map (cpu_clk, rdy, reset_n, irq_n, nmi_n, dbe, r_nw,
65 phi1, phi2, addr, d_in, d_out);
67 --- generate base clock.
71 wait for base_clock_time / 2;
73 wait for base_clock_time / 2;