OSDN Git Service

- DE1 board initial commit
authorastoria-d <astoria-d@mail.goo.ne.jp>
Sun, 1 Sep 2013 01:45:07 +0000 (10:45 +0900)
committerastoria-d <astoria-d@mail.goo.ne.jp>
Sun, 1 Sep 2013 01:45:07 +0000 (10:45 +0900)
- vga and cpu/ppu clock unified. vga = ppu x 2 multipled. clock driver updted.

de1_nes/.gitignore [new file with mode: 0644]
de1_nes/clock/clock_divider.vhd [new file with mode: 0644]
de1_nes/cpu/cpu_registers.vhd [new file with mode: 0644]
de1_nes/de1_nes.dpf [new file with mode: 0644]
de1_nes/de1_nes.pin [new file with mode: 0644]
de1_nes/de1_nes.qpf [new file with mode: 0644]
de1_nes/de1_nes.qsf [new file with mode: 0644]
de1_nes/de1_nes.qws [new file with mode: 0644]
de1_nes/de1_nes.vhd [new file with mode: 0644]
de1_nes/de1_nes.vwf [new file with mode: 0644]
de1_nes/ppu/ppu_registers.vhd [new file with mode: 0644]

diff --git a/de1_nes/.gitignore b/de1_nes/.gitignore
new file mode 100644 (file)
index 0000000..1055d93
--- /dev/null
@@ -0,0 +1,6 @@
+*.done\r
+*.summary\r
+*.rpt\r
+*.pof\r
+*.sof\r
+db/*
\ No newline at end of file
diff --git a/de1_nes/clock/clock_divider.vhd b/de1_nes/clock/clock_divider.vhd
new file mode 100644 (file)
index 0000000..83d8562
--- /dev/null
@@ -0,0 +1,71 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.std_logic_unsigned.all;
+
+entity clock_divider is 
+    port (  base_clk    : in std_logic;
+            reset_n     : in std_logic;
+            cpu_clk     : out std_logic;
+            ppu_clk     : out std_logic;\r
+            vga_clk     : out std_logic\r
+        );
+end clock_divider;
+
+architecture rtl of clock_divider is
+
+signal loop2 : std_logic_vector (0 downto 0);\r
+signal loop6 : std_logic_vector (2 downto 0);
+signal cpu_cnt_rst_n   : std_logic;\r
+signal cpu_clk_new             : std_logic;\r
+signal cpu_clk_old             : std_logic;\r
+signal cpu_we_n                        : std_logic;\r
+\r
+component counter_register \r
+    generic (\r
+        dsize       : integer := 8;\r
+        inc         : integer := 1\r
+    );\r
+    port (  clk         : in std_logic;\r
+            rst_n       : in std_logic;\r
+            ce_n        : in std_logic;\r
+            we_n        : in std_logic;\r
+            d           : in std_logic_vector(dsize - 1 downto 0);\r
+            q           : out std_logic_vector(dsize - 1 downto 0)\r
+    );\r
+end component;\r
+\r
+component d_flip_flop_bit\r
+    port (  \r
+            clk     : in std_logic;\r
+            res_n   : in std_logic;\r
+            set_n   : in std_logic;\r
+            we_n    : in std_logic;\r
+            d       : in std_logic;\r
+            q       : out std_logic\r
+        );\r
+end component;\r
+\r
+begin
+       ---base clock 25 MHz = VGA clock.\r
+       cpu_clk_old <= not cpu_clk_new;\r
+       cpu_clk <= cpu_clk_new;\r
+    ppu_clk <= not loop2(0);\r
+       vga_clk <= base_clk;\r
+\r
+       cpu_cnt_rst_n <= '0' when reset_n = '0' else\r
+                                        '0' when loop6 = "110" else\r
+                                        '1';
+       cpu_we_n <= '0' when loop6 = "101" else\r
+                                '1';\r
+\r
+    ppu_clk_cnt : counter_register generic map (1) port map \r
+        (base_clk, reset_n, '0', '1', (others=>'0'), loop2);\r
+\r
+       cpu_clk_cnt : counter_register generic map (3) port map \r
+        (base_clk, cpu_cnt_rst_n, '0', '1', (others=>'0'), loop6);\r
+\r
+    cpu_clk_cnt2 : d_flip_flop_bit port map \r
+        (base_clk, reset_n, '1', cpu_we_n, cpu_clk_old, cpu_clk_new);\r
+\r
+end rtl;
+
diff --git a/de1_nes/cpu/cpu_registers.vhd b/de1_nes/cpu/cpu_registers.vhd
new file mode 100644 (file)
index 0000000..7021c0a
--- /dev/null
@@ -0,0 +1,492 @@
+
+----------------------------------------
+--- d-flipflop with set/reset
+----------------------------------------
+
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity d_flip_flop is 
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            clk     : in std_logic;
+            res_n   : in std_logic;
+            set_n   : in std_logic;
+            we_n    : in std_logic;
+            d       : in std_logic_vector (dsize - 1 downto 0);
+            q       : out std_logic_vector (dsize - 1 downto 0)
+        );
+end d_flip_flop;
+
+architecture rtl of d_flip_flop is
+begin
+
+    process (clk, res_n, set_n, d)
+    begin
+        if (res_n = '0') then
+            q <= (others => '0');
+        elsif (set_n = '0') then
+            q <= d;
+        elsif (clk'event and clk = '1') then
+            if (we_n = '0') then
+                q <= d;
+            end if;
+        end if;
+    end process;
+end rtl;
+
+
+--------- 1 bit d-flipflop.
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity d_flip_flop_bit is 
+    port (  
+            clk     : in std_logic;
+            res_n   : in std_logic;
+            set_n   : in std_logic;
+            we_n    : in std_logic;
+            d       : in std_logic;
+            q       : out std_logic
+        );
+end d_flip_flop_bit;
+
+architecture rtl of d_flip_flop_bit is
+begin
+
+    process (clk, res_n, set_n, d)
+    begin
+        if (res_n = '0') then
+            q <= '0';
+        elsif (set_n = '0') then
+            q <= d;
+        elsif (clk'event and clk = '1') then
+            if (we_n = '0') then
+                q <= d;
+            end if;
+        end if;
+    end process;
+end rtl;
+
+----------------------------------------
+--- data latch declaration
+----------------------------------------
+
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity latch is 
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            clk     : in std_logic;
+            d       : in std_logic_vector (dsize - 1 downto 0);
+            q       : out std_logic_vector (dsize - 1 downto 0)
+        );
+end latch;
+
+architecture rtl of latch is
+begin
+
+    process (clk, d)
+    begin
+        if ( clk = '1') then
+            --latch only when clock is high
+            q <= d;
+        end if;
+    end process;
+end rtl;
+
+----------------------------------------
+--- tri-state buffer
+----------------------------------------
+
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity tri_state_buffer is 
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            oe_n    : in std_logic;
+            d       : in std_logic_vector (dsize - 1 downto 0);
+            q       : out std_logic_vector (dsize - 1 downto 0)
+        );
+end tri_state_buffer;
+
+architecture rtl of tri_state_buffer is
+begin
+    q <= d when oe_n = '0' else
+        (others => 'Z');
+end rtl;
+
+
+----------------------------------------
+--- dual port d flip flop w/ tri-state buffer
+----------------------------------------
+
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity dual_dff is 
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            clk             : in std_logic;
+            res_n           : in std_logic;
+            set_n           : in std_logic;
+            gate_cmd        : in std_logic_vector (3 downto 0);
+            front_port      : inout std_logic_vector (dsize - 1 downto 0);
+            back_in_port    : in std_logic_vector (dsize - 1 downto 0);
+            back_out_port   : out std_logic_vector (dsize - 1 downto 0)
+        );
+end dual_dff;
+
+architecture rtl of dual_dff is
+
+component d_flip_flop
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            clk     : in std_logic;
+            res_n   : in std_logic;
+            set_n   : in std_logic;
+            we_n    : in std_logic;
+            d       : in std_logic_vector (dsize - 1 downto 0);
+            q       : out std_logic_vector (dsize - 1 downto 0)
+        );
+end component;
+
+component tri_state_buffer
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            oe_n    : in std_logic;
+            d       : in std_logic_vector (dsize - 1 downto 0);
+            q       : out std_logic_vector (dsize - 1 downto 0)
+        );
+end component;
+
+signal we_n : std_logic;
+signal q : std_logic_vector (dsize - 1 downto 0);
+signal d : std_logic_vector (dsize - 1 downto 0);
+
+begin
+    ----------gate_cmd format 
+    ------3 : front port oe_n
+    ------2 : front port we_n
+    ------1 : back port oe_n
+    ------0 : back port we_n
+    we_n <= (gate_cmd(2) and gate_cmd(0));
+
+    d <= front_port when gate_cmd(2) = '0' else
+         back_in_port when gate_cmd(0) = '0' else
+         (others => 'Z');
+
+    dff_inst : d_flip_flop generic map (dsize) 
+                    port map(clk, res_n, set_n, we_n, d, q);
+
+    front_tsb : tri_state_buffer generic map (dsize) 
+                    port map(gate_cmd(3), q, front_port);
+
+    back_tsb : tri_state_buffer generic map (dsize) 
+                    port map(gate_cmd(1), q, back_out_port);
+end rtl;
+
+
+----------------------------------------
+--- data bus buffer
+----------------------------------------
+
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity data_bus_buffer is 
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            clk         : in std_logic;
+            r_nw        : in std_logic;
+            int_oe_n    : in std_logic;
+            int_dbus : inout std_logic_vector (dsize - 1 downto 0);
+            ext_dbus : inout std_logic_vector (dsize - 1 downto 0)
+        );
+end data_bus_buffer;
+
+architecture rtl of data_bus_buffer is
+component latch
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            clk     : in std_logic;
+            d       : in std_logic_vector (dsize - 1 downto 0);
+            q       : out std_logic_vector (dsize - 1 downto 0)
+        );
+end component;
+
+component tri_state_buffer
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            oe_n    : in std_logic;
+            d       : in std_logic_vector (dsize - 1 downto 0);
+            q       : out std_logic_vector (dsize - 1 downto 0)
+        );
+end component;
+
+signal rd_clk : std_logic;
+signal wr_clk : std_logic;
+signal read_buf : std_logic_vector (dsize - 1 downto 0);
+signal write_buf : std_logic_vector (dsize - 1 downto 0);
+begin
+    rd_clk <= r_nw and clk;
+    wr_clk <= (not r_nw) and clk;
+
+    --read from i/o to cpu
+    latch_r : latch generic map (dsize) 
+                    port map(rd_clk, ext_dbus, read_buf);
+    read_tsb : tri_state_buffer generic map (dsize) 
+                    port map(int_oe_n, read_buf, int_dbus);
+    --write from cpu to io
+    latch_w : latch generic map (dsize) 
+                    port map(wr_clk, int_dbus, write_buf);
+    write_tsb : tri_state_buffer generic map (dsize) 
+                    port map(r_nw, write_buf, ext_dbus);
+end rtl;
+
+------------------------------------------
+----- input data latch register
+------------------------------------------
+
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity input_data_latch is 
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            clk         : in std_logic;
+            oe_n        : in std_logic;
+            we_n        : in std_logic;
+            int_dbus    : in std_logic_vector (dsize - 1 downto 0);
+            alu_bus     : out std_logic_vector (dsize - 1 downto 0)
+        );
+end input_data_latch;
+
+architecture rtl of input_data_latch is
+
+component latch
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            clk     : in std_logic;
+            d       : in std_logic_vector (dsize - 1 downto 0);
+            q       : out std_logic_vector (dsize - 1 downto 0)
+        );
+end component;
+
+component tri_state_buffer
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            oe_n    : in std_logic;
+            d       : in std_logic_vector (dsize - 1 downto 0);
+            q       : out std_logic_vector (dsize - 1 downto 0)
+        );
+end component;
+
+signal latch_clk : std_logic;
+signal latch_buf : std_logic_vector (dsize - 1 downto 0);
+
+begin
+    latch_clk <= (not we_n) and clk;
+    latch_inst : latch generic map (dsize) 
+                    port map(latch_clk, int_dbus, latch_buf);
+    iput_data_tsb : tri_state_buffer generic map (dsize) 
+                    port map(oe_n, latch_buf, alu_bus);
+
+end rtl;
+
+----------------------------------------
+--- status register component
+----------------------------------------
+
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity processor_status is 
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            clk         : in std_logic;
+            res_n       : in std_logic;
+            dec_oe_n    : in std_logic;
+            bus_oe_n    : in std_logic;
+            set_flg_n   : in std_logic;
+            flg_val     : in std_logic;
+            load_bus_all_n      : in std_logic;
+            load_bus_nz_n       : in std_logic;
+            set_from_alu_n      : in std_logic;
+            alu_n       : in std_logic;
+            alu_v       : in std_logic;
+            alu_z       : in std_logic;
+            alu_c       : in std_logic;
+            stat_c      : out std_logic;
+            dec_val     : inout std_logic_vector (dsize - 1 downto 0);
+            int_dbus    : inout std_logic_vector (dsize - 1 downto 0)
+        );
+end processor_status;
+
+architecture rtl of processor_status is
+
+component d_flip_flop
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            clk     : in std_logic;
+            res_n   : in std_logic;
+            set_n   : in std_logic;
+            we_n    : in std_logic;
+            d       : in std_logic_vector (dsize - 1 downto 0);
+            q       : out std_logic_vector (dsize - 1 downto 0)
+        );
+end component;
+
+component tri_state_buffer
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            oe_n    : in std_logic;
+            d       : in std_logic_vector (dsize - 1 downto 0);
+            q       : out std_logic_vector (dsize - 1 downto 0)
+        );
+end component;
+
+signal we_n : std_logic;
+signal d : std_logic_vector (dsize - 1 downto 0);
+signal status_val : std_logic_vector (dsize - 1 downto 0);
+
+begin
+    dec_tsb : tri_state_buffer generic map (dsize) 
+                    port map(dec_oe_n, status_val, dec_val);
+    dbus_tsb : tri_state_buffer generic map (dsize) 
+                    port map(bus_oe_n, status_val, int_dbus);
+
+    we_n <= set_flg_n and load_bus_all_n and 
+                load_bus_nz_n and set_from_alu_n;
+
+    dff_inst : d_flip_flop generic map (dsize) 
+                    port map(clk, '1', res_n, we_n, d, status_val);
+
+    --carry status for adc/sbc.
+    stat_c <= status_val(0);
+
+    main_p : process (clk, res_n, we_n, dec_val, int_dbus, 
+                            alu_n, alu_v, alu_z, alu_c)
+    variable tmp : std_logic_vector (dsize - 1 downto 0);
+    begin
+--        SR Flags (bit 7 to bit 0):
+--
+--        N   ....    Negative
+--        V   ....    Overflow
+--        -   ....    ignored
+--        B   ....    Break
+--        D   ....    Decimal (use BCD for arithmetics)
+--        I   ....    Interrupt (IRQ disable)
+--        Z   ....    Zero
+--        C   ....    Carry
+    
+      ---only interrupt flag is set on reset.
+        if (res_n = '0') then
+            d <= "00000100";
+        else
+            d <= (others => 'Z');
+        end if;
+
+        ---from flag set/clear instructions
+        if (set_flg_n = '0') then
+            if flg_val = '1' then
+                tmp := (dec_val and "11111111");
+            else
+                tmp := "00000000";
+            end if;
+            d <= tmp or (status_val and not dec_val);
+
+        ---status flag set from the data on the internal data bus.
+        ---interpret the input data by the dec_val input.
+        ---load/pop/rti/t[asxy]
+        elsif (load_bus_all_n = '0') then
+            ---set the data bus data as they are.
+            d <= int_dbus;
+        elsif (load_bus_nz_n = '0') then
+            tmp := status_val;
+            d (6 downto 2) <= tmp (6 downto 2);
+            d (0) <= tmp (0);
+
+            ---other case: n/z data must be interpreted.
+            --n bit.
+            if int_dbus(7) = '1' then
+                d (7) <= '1';
+            else
+                d (7) <= '0';
+            end if;
+            --z bit.
+            ---nor outputs 1 when all inputs are 0.
+            if  (int_dbus(7) or int_dbus(6) or 
+                    int_dbus(5) or int_dbus(4) or int_dbus(3) or 
+                    int_dbus(2) or int_dbus(1) or int_dbus(0)) = '0' then
+                d (1) <= '1';
+            else
+                d (1) <= '0';
+            end if;
+
+        ---status set from alu
+        elsif (set_from_alu_n = '0') then
+            tmp := status_val;
+            d (5 downto 2) <= tmp (5 downto 2);
+
+            --n bit.
+            if (dec_val(7) = '1') then
+                d (7) <= alu_n;
+            else
+                d (7) <= tmp (7);
+            end if;
+            --v bit.
+            if (dec_val(6) = '1') then
+                d (6) <= alu_v;
+            else
+                d (6) <= tmp (6);
+            end if;
+            --z bit.
+            if (dec_val(1) = '1') then
+                d (1) <= alu_z;
+            else
+                d (1) <= tmp (1);
+            end if;
+            --c bit.
+            if (dec_val(0) = '1') then
+                d (0) <= alu_c;
+            else
+                d (0) <= tmp (0);
+            end if;
+        end if; --if (set_flg_n = '0') then
+    end process;
+end rtl;
+
+
diff --git a/de1_nes/de1_nes.dpf b/de1_nes/de1_nes.dpf
new file mode 100644 (file)
index 0000000..f0b3ecc
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+\r
+<pin_planner>\r
+       <pin_info>\r
+       </pin_info>\r
+       <buses>\r
+       </buses>\r
+       <group_file_association>\r
+       </group_file_association>\r
+       <pin_planner_file_specifies>\r
+       </pin_planner_file_specifies>\r
+</pin_planner>\r
diff --git a/de1_nes/de1_nes.pin b/de1_nes/de1_nes.pin
new file mode 100644 (file)
index 0000000..bb13649
--- /dev/null
@@ -0,0 +1,559 @@
+ -- Copyright (C) 1991-2007 Altera Corporation\r
+ -- Your use of Altera Corporation's design tools, logic functions \r
+ -- and other software and tools, and its AMPP partner logic \r
+ -- functions, and any output files from any of the foregoing \r
+ -- (including device programming or simulation files), and any \r
+ -- associated documentation or information are expressly subject \r
+ -- to the terms and conditions of the Altera Program License \r
+ -- Subscription Agreement, Altera MegaCore Function License \r
+ -- Agreement, or other applicable license agreement, including, \r
+ -- without limitation, that your use is for the sole purpose of \r
+ -- programming logic devices manufactured by Altera and sold by \r
+ -- Altera or its authorized distributors.  Please refer to the \r
+ -- applicable agreement for further details.\r
+ -- \r
+ -- This is a Quartus II output file. It is for reporting purposes only, and is\r
+ -- not intended for use as a Quartus II input file. This file cannot be used\r
+ -- to make Quartus II pin assignments - for instructions on how to make pin\r
+ -- assignments, please see Quartus II help.\r
+ ---------------------------------------------------------------------------------\r
+\r
+\r
+\r
+ ---------------------------------------------------------------------------------\r
+ -- NC            : No Connect. This pin has no internal connection to the device.\r
+ -- DNU           : Do Not Use. This pin MUST NOT be connected.\r
+ -- VCCPGM        : Dedicated power pin for configuration, which MUST be connected to 1.8V, 2.5V or 3.0V depending on the needs of the configuration device.\r
+ -- VCCINT        : Dedicated power pin, which MUST be connected to VCC  (1.2V).\r
+ -- VCCIO         : Dedicated power pin, which MUST be connected to VCC\r
+ --                 of its bank.\r
+ --                                    Bank 1:         3.3V\r
+ --                                    Bank 2:         3.3V\r
+ --                                    Bank 3:         3.3V\r
+ --                                    Bank 4:         3.3V\r
+ --                                    Bank 5:         3.3V\r
+ --                                    Bank 6:         3.3V\r
+ --                                    Bank 7:         3.3V\r
+ --                                    Bank 8:         3.3V\r
+ -- GND           : Dedicated ground pin. Dedicated GND pins MUST be connected to GND.\r
+ --                                    It can also be used to report unused dedicated pins. The connection\r
+ --                                    on the board for unused dedicated pins depends on whether this will\r
+ --                                    be used in a future design. One example is device migration. When\r
+ --                                    using device migration, refer to the device pin-tables. If it is a\r
+ --                                    GND pin in the pin table or if it will not be used in a future design\r
+ --                                    for another purpose the it MUST be connected to GND. If it is an unused\r
+ --                                    dedicated pin, then it can be connected to a valid signal on the board\r
+ --                                    (low, high, or toggling) if that signal is required for a different\r
+ --                                    revision of the design.\r
+ -- GND+          : Unused input pin. It can also be used to report unused dual-purpose pins.\r
+ --                                    This pin should be connected to GND. It may also be connected  to a\r
+ --                                    valid signal  on the board  (low, high, or toggling)  if that signal\r
+ --                                    is required for a different revision of the design.\r
+ -- GND*          : Unused  I/O  pin.   For transceiver I/O banks (Bank 13, 14, 15, 16 and 17),\r
+ --                connect each pin marked GND* either individually through a 10 kohm resistor\r
+ --                to GND or tie all pins together and connect through a single 10 kohm resistor\r
+ --                to GND.\r
+ --                For non-transceiver I/O banks, connect each pin marked GND* directly to GND\r
+ --                or leave it unconnected.\r
+ -- RESERVED      : Unused I/O pin, which MUST be left unconnected.\r
+ -- RESERVED_INPUT    : Pin is tri-stated and should be connected to the board.\r
+ -- RESERVED_INPUT_WITH_WEAK_PULLUP    : Pin is tri-stated with internal weak pull-up resistor.\r
+ -- RESERVED_INPUT_WITH_BUS_HOLD       : Pin is tri-stated with bus-hold circuitry.\r
+ -- RESERVED_OUTPUT_DRIVEN_HIGH        : Pin is output driven high.\r
+ ---------------------------------------------------------------------------------\r
+\r
+\r
+\r
+ ---------------------------------------------------------------------------------\r
+ -- Pin directions (input, output or bidir) are based on device operating in user mode.\r
+ ---------------------------------------------------------------------------------\r
+\r
+Quartus II Version 7.2 Build 151 09/26/2007 SJ Web Edition\r
+CHIP  "de1_nes"  ASSIGNED TO AN: EP2C20F484C7\r
+\r
+Pin Name/Usage               : Location  : Dir.   : I/O Standard      : Voltage : I/O Bank  : User Assignment\r
+-------------------------------------------------------------------------------------------------------------\r
+GND                          : A1        : gnd    :                   :         :           :                \r
+VCCIO3                       : A2        : power  :                   : 3.3V    : 3         :                \r
+GND*                         : A3        :        :                   :         : 3         :                \r
+GND*                         : A4        :        :                   :         : 3         :                \r
+GND*                         : A5        :        :                   :         : 3         :                \r
+GND*                         : A6        :        :                   :         : 3         :                \r
+GND*                         : A7        :        :                   :         : 3         :                \r
+GND*                         : A8        :        :                   :         : 3         :                \r
+GND*                         : A9        :        :                   :         : 3         :                \r
+GND*                         : A10       :        :                   :         : 3         :                \r
+GND*                         : A11       :        :                   :         : 3         :                \r
+GND+                         : A12       :        :                   :         : 4         :                \r
+GND*                         : A13       :        :                   :         : 4         :                \r
+GND*                         : A14       :        :                   :         : 4         :                \r
+GND*                         : A15       :        :                   :         : 4         :                \r
+GND*                         : A16       :        :                   :         : 4         :                \r
+GND*                         : A17       :        :                   :         : 4         :                \r
+GND*                         : A18       :        :                   :         : 4         :                \r
+GND*                         : A19       :        :                   :         : 4         :                \r
+GND*                         : A20       :        :                   :         : 4         :                \r
+VCCIO4                       : A21       : power  :                   : 3.3V    : 4         :                \r
+GND                          : A22       : gnd    :                   :         :           :                \r
+VCCIO1                       : AA1       : power  :                   : 3.3V    : 1         :                \r
+GND                          : AA2       : gnd    :                   :         :           :                \r
+GND*                         : AA3       :        :                   :         : 8         :                \r
+GND*                         : AA4       :        :                   :         : 8         :                \r
+GND*                         : AA5       :        :                   :         : 8         :                \r
+GND*                         : AA6       :        :                   :         : 8         :                \r
+GND*                         : AA7       :        :                   :         : 8         :                \r
+GND*                         : AA8       :        :                   :         : 8         :                \r
+dbg_pin0                     : AA9       : output : 3.3-V LVTTL       :         : 8         : N              \r
+GND*                         : AA10      :        :                   :         : 8         :                \r
+GND*                         : AA11      :        :                   :         : 8         :                \r
+GND*                         : AA12      :        :                   :         : 7         :                \r
+GND*                         : AA13      :        :                   :         : 7         :                \r
+GND*                         : AA14      :        :                   :         : 7         :                \r
+GND*                         : AA15      :        :                   :         : 7         :                \r
+GND*                         : AA16      :        :                   :         : 7         :                \r
+GND*                         : AA17      :        :                   :         : 7         :                \r
+GND*                         : AA18      :        :                   :         : 7         :                \r
+GND*                         : AA19      :        :                   :         : 7         :                \r
+GND*                         : AA20      :        :                   :         : 7         :                \r
+GND                          : AA21      : gnd    :                   :         :           :                \r
+VCCIO6                       : AA22      : power  :                   : 3.3V    : 6         :                \r
+GND                          : AB1       : gnd    :                   :         :           :                \r
+VCCIO8                       : AB2       : power  :                   : 3.3V    : 8         :                \r
+GND*                         : AB3       :        :                   :         : 8         :                \r
+GND*                         : AB4       :        :                   :         : 8         :                \r
+GND*                         : AB5       :        :                   :         : 8         :                \r
+GND*                         : AB6       :        :                   :         : 8         :                \r
+GND*                         : AB7       :        :                   :         : 8         :                \r
+GND*                         : AB8       :        :                   :         : 8         :                \r
+GND*                         : AB9       :        :                   :         : 8         :                \r
+GND*                         : AB10      :        :                   :         : 8         :                \r
+GND*                         : AB11      :        :                   :         : 8         :                \r
+GND*                         : AB12      :        :                   :         : 7         :                \r
+GND*                         : AB13      :        :                   :         : 7         :                \r
+GND*                         : AB14      :        :                   :         : 7         :                \r
+GND*                         : AB15      :        :                   :         : 7         :                \r
+GND*                         : AB16      :        :                   :         : 7         :                \r
+GND*                         : AB17      :        :                   :         : 7         :                \r
+GND*                         : AB18      :        :                   :         : 7         :                \r
+GND*                         : AB19      :        :                   :         : 7         :                \r
+GND*                         : AB20      :        :                   :         : 7         :                \r
+VCCIO7                       : AB21      : power  :                   : 3.3V    : 7         :                \r
+GND                          : AB22      : gnd    :                   :         :           :                \r
+VCCIO2                       : B1        : power  :                   : 3.3V    : 2         :                \r
+GND                          : B2        : gnd    :                   :         :           :                \r
+GND*                         : B3        :        :                   :         : 3         :                \r
+GND*                         : B4        :        :                   :         : 3         :                \r
+GND*                         : B5        :        :                   :         : 3         :                \r
+GND*                         : B6        :        :                   :         : 3         :                \r
+GND*                         : B7        :        :                   :         : 3         :                \r
+GND*                         : B8        :        :                   :         : 3         :                \r
+GND*                         : B9        :        :                   :         : 3         :                \r
+GND*                         : B10       :        :                   :         : 3         :                \r
+dbg_pin2                     : B11       : output : 3.3-V LVTTL       :         : 3         : N              \r
+GND+                         : B12       :        :                   :         : 4         :                \r
+GND*                         : B13       :        :                   :         : 4         :                \r
+GND*                         : B14       :        :                   :         : 4         :                \r
+GND*                         : B15       :        :                   :         : 4         :                \r
+dbg_pin4                     : B16       : output : 3.3-V LVTTL       :         : 4         : N              \r
+GND*                         : B17       :        :                   :         : 4         :                \r
+GND*                         : B18       :        :                   :         : 4         :                \r
+GND*                         : B19       :        :                   :         : 4         :                \r
+GND*                         : B20       :        :                   :         : 4         :                \r
+GND                          : B21       : gnd    :                   :         :           :                \r
+VCCIO5                       : B22       : power  :                   : 3.3V    : 5         :                \r
+GND*                         : C1        :        :                   :         : 2         :                \r
+GND*                         : C2        :        :                   :         : 2         :                \r
+~nCSO~ / RESERVED_INPUT_WITH_WEAK_PULLUP : C3        : input  : 3.3-V LVTTL       :         : 2         : N              \r
+~ASDO~ / RESERVED_INPUT_WITH_WEAK_PULLUP : C4        : input  : 3.3-V LVTTL       :         : 2         : N              \r
+GND                          : C5        : gnd    :                   :         :           :                \r
+VCCIO3                       : C6        : power  :                   : 3.3V    : 3         :                \r
+GND*                         : C7        :        :                   :         : 3         :                \r
+GND                          : C8        : gnd    :                   :         :           :                \r
+GND*                         : C9        :        :                   :         : 3         :                \r
+GND*                         : C10       :        :                   :         : 3         :                \r
+VCCIO3                       : C11       : power  :                   : 3.3V    : 3         :                \r
+VCCIO4                       : C12       : power  :                   : 3.3V    : 4         :                \r
+GND*                         : C13       :        :                   :         : 4         :                \r
+GND*                         : C14       :        :                   :         : 4         :                \r
+GND                          : C15       : gnd    :                   :         :           :                \r
+GND*                         : C16       :        :                   :         : 4         :                \r
+GND*                         : C17       :        :                   :         : 4         :                \r
+GND*                         : C18       :        :                   :         : 4         :                \r
+GND*                         : C19       :        :                   :         : 5         :                \r
+GND*                         : C20       :        :                   :         : 5         :                \r
+GND*                         : C21       :        :                   :         : 5         :                \r
+GND*                         : C22       :        :                   :         : 5         :                \r
+GND*                         : D1        :        :                   :         : 2         :                \r
+GND*                         : D2        :        :                   :         : 2         :                \r
+GND*                         : D3        :        :                   :         : 2         :                \r
+GND*                         : D4        :        :                   :         : 2         :                \r
+GND*                         : D5        :        :                   :         : 2         :                \r
+GND*                         : D6        :        :                   :         : 2         :                \r
+GND*                         : D7        :        :                   :         : 3         :                \r
+GND*                         : D8        :        :                   :         : 3         :                \r
+GND*                         : D9        :        :                   :         : 3         :                \r
+GND                          : D10       : gnd    :                   :         :           :                \r
+GND*                         : D11       :        :                   :         : 3         :                \r
+base_clk                     : D12       : input  : 3.3-V LVTTL       :         : 3         : Y              \r
+GND                          : D13       : gnd    :                   :         :           :                \r
+GND*                         : D14       :        :                   :         : 4         :                \r
+GND*                         : D15       :        :                   :         : 4         :                \r
+GND*                         : D16       :        :                   :         : 4         :                \r
+VCCIO4                       : D17       : power  :                   : 3.3V    : 4         :                \r
+GND                          : D18       : gnd    :                   :         :           :                \r
+GND*                         : D19       :        :                   :         : 5         :                \r
+GND*                         : D20       :        :                   :         : 5         :                \r
+GND*                         : D21       :        :                   :         : 5         :                \r
+GND*                         : D22       :        :                   :         : 5         :                \r
+GND*                         : E1        :        :                   :         : 2         :                \r
+GND*                         : E2        :        :                   :         : 2         :                \r
+GND*                         : E3        :        :                   :         : 2         :                \r
+GND*                         : E4        :        :                   :         : 2         :                \r
+VCCD_PLL3                    : E5        : power  :                   : 1.2V    :           :                \r
+VCCA_PLL3                    : E6        : power  :                   : 1.2V    :           :                \r
+GND*                         : E7        :        :                   :         : 3         :                \r
+GND*                         : E8        :        :                   :         : 3         :                \r
+GND*                         : E9        :        :                   :         : 3         :                \r
+VCCIO3                       : E10       : power  :                   : 3.3V    : 3         :                \r
+GND*                         : E11       :        :                   :         : 3         :                \r
+GND+                         : E12       :        :                   :         : 3         :                \r
+VCCIO4                       : E13       : power  :                   : 3.3V    : 4         :                \r
+GND*                         : E14       :        :                   :         : 4         :                \r
+GND*                         : E15       :        :                   :         : 4         :                \r
+GNDA_PLL2                    : E16       : gnd    :                   :         :           :                \r
+GND_PLL2                     : E17       : gnd    :                   :         :           :                \r
+dbg_pin3                     : E18       : output : 3.3-V LVTTL       :         : 5         : N              \r
+GND*                         : E19       :        :                   :         : 5         :                \r
+GND*                         : E20       :        :                   :         : 5         :                \r
+GND*                         : E21       :        :                   :         : 5         :                \r
+GND*                         : E22       :        :                   :         : 5         :                \r
+GND*                         : F1        :        :                   :         : 2         :                \r
+GND*                         : F2        :        :                   :         : 2         :                \r
+GND*                         : F3        :        :                   :         : 2         :                \r
+GND*                         : F4        :        :                   :         : 2         :                \r
+GND_PLL3                     : F5        : gnd    :                   :         :           :                \r
+GND_PLL3                     : F6        : gnd    :                   :         :           :                \r
+GNDA_PLL3                    : F7        : gnd    :                   :         :           :                \r
+GND*                         : F8        :        :                   :         : 3         :                \r
+dbg_pin7                     : F9        : output : 3.3-V LVTTL       :         : 3         : N              \r
+dbg_pin1                     : F10       : output : 3.3-V LVTTL       :         : 3         : N              \r
+GND*                         : F11       :        :                   :         : 3         :                \r
+dbg_pin6                     : F12       : output : 3.3-V LVTTL       :         : 4         : N              \r
+GND*                         : F13       :        :                   :         : 4         :                \r
+GND*                         : F14       :        :                   :         : 4         :                \r
+GND*                         : F15       :        :                   :         : 4         :                \r
+VCCA_PLL2                    : F16       : power  :                   : 1.2V    :           :                \r
+VCCD_PLL2                    : F17       : power  :                   : 1.2V    :           :                \r
+GND_PLL2                     : F18       : gnd    :                   :         :           :                \r
+GND                          : F19       : gnd    :                   :         :           :                \r
+GND*                         : F20       :        :                   :         : 5         :                \r
+GND*                         : F21       :        :                   :         : 5         :                \r
+GND*                         : F22       :        :                   :         : 5         :                \r
+NC                           : G1        :        :                   :         :           :                \r
+NC                           : G2        :        :                   :         :           :                \r
+GND*                         : G3        :        :                   :         : 2         :                \r
+GND                          : G4        : gnd    :                   :         :           :                \r
+GND*                         : G5        :        :                   :         : 2         :                \r
+GND*                         : G6        :        :                   :         : 2         :                \r
+GND*                         : G7        :        :                   :         : 3         :                \r
+GND*                         : G8        :        :                   :         : 3         :                \r
+VCCIO3                       : G9        : power  :                   : 3.3V    : 3         :                \r
+GND                          : G10       : gnd    :                   :         :           :                \r
+GND*                         : G11       :        :                   :         : 3         :                \r
+GND*                         : G12       :        :                   :         : 4         :                \r
+GND                          : G13       : gnd    :                   :         :           :                \r
+VCCIO4                       : G14       : power  :                   : 3.3V    : 4         :                \r
+GND*                         : G15       :        :                   :         : 4         :                \r
+dbg_pin5                     : G16       : output : 3.3-V LVTTL       :         : 4         : N              \r
+GND*                         : G17       :        :                   :         : 5         :                \r
+GND*                         : G18       :        :                   :         : 5         :                \r
+VCCIO5                       : G19       : power  :                   : 3.3V    : 5         :                \r
+GND*                         : G20       :        :                   :         : 5         :                \r
+GND*                         : G21       :        :                   :         : 5         :                \r
+GND*                         : G22       :        :                   :         : 5         :                \r
+GND*                         : H1        :        :                   :         : 2         :                \r
+GND*                         : H2        :        :                   :         : 2         :                \r
+GND*                         : H3        :        :                   :         : 2         :                \r
+GND*                         : H4        :        :                   :         : 2         :                \r
+GND*                         : H5        :        :                   :         : 2         :                \r
+GND*                         : H6        :        :                   :         : 2         :                \r
+GND*                         : H7        :        :                   :         : 3         :                \r
+GND*                         : H8        :        :                   :         : 3         :                \r
+GND*                         : H9        :        :                   :         : 3         :                \r
+GND*                         : H10       :        :                   :         : 3         :                \r
+GND*                         : H11       :        :                   :         : 3         :                \r
+GND*                         : H12       :        :                   :         : 4         :                \r
+GND*                         : H13       :        :                   :         : 4         :                \r
+GND*                         : H14       :        :                   :         : 4         :                \r
+GND*                         : H15       :        :                   :         : 4         :                \r
+GND*                         : H16       :        :                   :         : 5         :                \r
+GND*                         : H17       :        :                   :         : 5         :                \r
+GND*                         : H18       :        :                   :         : 5         :                \r
+GND*                         : H19       :        :                   :         : 5         :                \r
+GND                          : H20       : gnd    :                   :         :           :                \r
+NC                           : H21       :        :                   :         :           :                \r
+NC                           : H22       :        :                   :         :           :                \r
+GND*                         : J1        :        :                   :         : 2         :                \r
+GND*                         : J2        :        :                   :         : 2         :                \r
+NC                           : J3        :        :                   :         :           :                \r
+GND*                         : J4        :        :                   :         : 2         :                \r
+NC                           : J5        :        :                   :         :           :                \r
+NC                           : J6        :        :                   :         :           :                \r
+VCCIO2                       : J7        : power  :                   : 3.3V    : 2         :                \r
+NC                           : J8        :        :                   :         :           :                \r
+NC                           : J9        :        :                   :         :           :                \r
+VCCINT                       : J10       : power  :                   : 1.2V    :           :                \r
+VCCINT                       : J11       : power  :                   : 1.2V    :           :                \r
+VCCINT                       : J12       : power  :                   : 1.2V    :           :                \r
+VCCINT                       : J13       : power  :                   : 1.2V    :           :                \r
+GND*                         : J14       :        :                   :         : 4         :                \r
+GND*                         : J15       :        :                   :         : 5         :                \r
+VCCIO5                       : J16       : power  :                   : 3.3V    : 5         :                \r
+GND*                         : J17       :        :                   :         : 5         :                \r
+GND*                         : J18       :        :                   :         : 5         :                \r
+GND*                         : J19       :        :                   :         : 5         :                \r
+GND*                         : J20       :        :                   :         : 5         :                \r
+GND*                         : J21       :        :                   :         : 5         :                \r
+GND*                         : J22       :        :                   :         : 5         :                \r
+nCE                          : K1        :        :                   :         : 2         :                \r
+TCK                          : K2        : input  :                   :         : 2         :                \r
+GND                          : K3        : gnd    :                   :         :           :                \r
+DATA0                        : K4        : input  :                   :         : 2         :                \r
+TDI                          : K5        : input  :                   :         : 2         :                \r
+TMS                          : K6        : input  :                   :         : 2         :                \r
+GND                          : K7        : gnd    :                   :         :           :                \r
+NC                           : K8        :        :                   :         :           :                \r
+VCCINT                       : K9        : power  :                   : 1.2V    :           :                \r
+GND                          : K10       : gnd    :                   :         :           :                \r
+GND                          : K11       : gnd    :                   :         :           :                \r
+GND                          : K12       : gnd    :                   :         :           :                \r
+GND                          : K13       : gnd    :                   :         :           :                \r
+VCCINT                       : K14       : power  :                   : 1.2V    :           :                \r
+NC                           : K15       :        :                   :         :           :                \r
+GND                          : K16       : gnd    :                   :         :           :                \r
+NC                           : K17       :        :                   :         :           :                \r
+NC                           : K18       :        :                   :         :           :                \r
+GND                          : K19       : gnd    :                   :         :           :                \r
+GND*                         : K20       :        :                   :         : 5         :                \r
+GND*                         : K21       :        :                   :         : 5         :                \r
+GND*                         : K22       :        :                   :         : 5         :                \r
+GND+                         : L1        :        :                   :         : 2         :                \r
+GND+                         : L2        :        :                   :         : 2         :                \r
+VCCIO2                       : L3        : power  :                   : 3.3V    : 2         :                \r
+nCONFIG                      : L4        :        :                   :         : 2         :                \r
+TDO                          : L5        : output :                   :         : 2         :                \r
+DCLK                         : L6        :        :                   :         : 2         :                \r
+NC                           : L7        :        :                   :         :           :                \r
+GND*                         : L8        :        :                   :         : 2         :                \r
+VCCINT                       : L9        : power  :                   : 1.2V    :           :                \r
+GND                          : L10       : gnd    :                   :         :           :                \r
+GND                          : L11       : gnd    :                   :         :           :                \r
+GND                          : L12       : gnd    :                   :         :           :                \r
+GND                          : L13       : gnd    :                   :         :           :                \r
+VCCINT                       : L14       : power  :                   : 1.2V    :           :                \r
+NC                           : L15       :        :                   :         :           :                \r
+NC                           : L16       :        :                   :         :           :                \r
+NC                           : L17       :        :                   :         :           :                \r
+GND*                         : L18       :        :                   :         : 5         :                \r
+GND*                         : L19       :        :                   :         : 5         :                \r
+VCCIO5                       : L20       : power  :                   : 3.3V    : 5         :                \r
+GND+                         : L21       :        :                   :         : 5         :                \r
+GND+                         : L22       :        :                   :         : 5         :                \r
+GND+                         : M1        :        :                   :         : 1         :                \r
+GND+                         : M2        :        :                   :         : 1         :                \r
+VCCIO1                       : M3        : power  :                   : 3.3V    : 1         :                \r
+GND                          : M4        : gnd    :                   :         :           :                \r
+GND*                         : M5        :        :                   :         : 1         :                \r
+GND*                         : M6        :        :                   :         : 1         :                \r
+NC                           : M7        :        :                   :         :           :                \r
+NC                           : M8        :        :                   :         :           :                \r
+VCCINT                       : M9        : power  :                   : 1.2V    :           :                \r
+GND                          : M10       : gnd    :                   :         :           :                \r
+GND                          : M11       : gnd    :                   :         :           :                \r
+GND                          : M12       : gnd    :                   :         :           :                \r
+GND                          : M13       : gnd    :                   :         :           :                \r
+VCCINT                       : M14       : power  :                   : 1.2V    :           :                \r
+NC                           : M15       :        :                   :         :           :                \r
+NC                           : M16       :        :                   :         :           :                \r
+MSEL0                        : M17       :        :                   :         : 6         :                \r
+GND*                         : M18       :        :                   :         : 6         :                \r
+GND*                         : M19       :        :                   :         : 6         :                \r
+VCCIO6                       : M20       : power  :                   : 3.3V    : 6         :                \r
+GND+                         : M21       :        :                   :         : 6         :                \r
+GND+                         : M22       :        :                   :         : 6         :                \r
+GND*                         : N1        :        :                   :         : 1         :                \r
+GND*                         : N2        :        :                   :         : 1         :                \r
+GND*                         : N3        :        :                   :         : 1         :                \r
+GND*                         : N4        :        :                   :         : 1         :                \r
+NC                           : N5        :        :                   :         :           :                \r
+GND*                         : N6        :        :                   :         : 1         :                \r
+GND                          : N7        : gnd    :                   :         :           :                \r
+NC                           : N8        :        :                   :         :           :                \r
+VCCINT                       : N9        : power  :                   : 1.2V    :           :                \r
+GND                          : N10       : gnd    :                   :         :           :                \r
+GND                          : N11       : gnd    :                   :         :           :                \r
+GND                          : N12       : gnd    :                   :         :           :                \r
+GND                          : N13       : gnd    :                   :         :           :                \r
+VCCINT                       : N14       : power  :                   : 1.2V    :           :                \r
+GND*                         : N15       :        :                   :         : 6         :                \r
+GND                          : N16       : gnd    :                   :         :           :                \r
+MSEL1                        : N17       :        :                   :         : 6         :                \r
+CONF_DONE                    : N18       :        :                   :         : 6         :                \r
+GND                          : N19       : gnd    :                   :         :           :                \r
+nSTATUS                      : N20       :        :                   :         : 6         :                \r
+GND*                         : N21       :        :                   :         : 6         :                \r
+GND*                         : N22       :        :                   :         : 6         :                \r
+GND*                         : P1        :        :                   :         : 1         :                \r
+GND*                         : P2        :        :                   :         : 1         :                \r
+GND*                         : P3        :        :                   :         : 1         :                \r
+NC                           : P4        :        :                   :         :           :                \r
+GND*                         : P5        :        :                   :         : 1         :                \r
+GND*                         : P6        :        :                   :         : 1         :                \r
+VCCIO1                       : P7        : power  :                   : 3.3V    : 1         :                \r
+GND*                         : P8        :        :                   :         : 8         :                \r
+GND*                         : P9        :        :                   :         : 8         :                \r
+VCCINT                       : P10       : power  :                   : 1.2V    :           :                \r
+VCCINT                       : P11       : power  :                   : 1.2V    :           :                \r
+VCCINT                       : P12       : power  :                   : 1.2V    :           :                \r
+VCCINT                       : P13       : power  :                   : 1.2V    :           :                \r
+NC                           : P14       :        :                   :         :           :                \r
+GND*                         : P15       :        :                   :         : 6         :                \r
+VCCIO6                       : P16       : power  :                   : 3.3V    : 6         :                \r
+GND*                         : P17       :        :                   :         : 6         :                \r
+GND*                         : P18       :        :                   :         : 6         :                \r
+NC                           : P19       :        :                   :         :           :                \r
+NC                           : P20       :        :                   :         :           :                \r
+NC                           : P21       :        :                   :         :           :                \r
+NC                           : P22       :        :                   :         :           :                \r
+GND*                         : R1        :        :                   :         : 1         :                \r
+GND*                         : R2        :        :                   :         : 1         :                \r
+GND                          : R3        : gnd    :                   :         :           :                \r
+NC                           : R4        :        :                   :         :           :                \r
+GND*                         : R5        :        :                   :         : 1         :                \r
+GND*                         : R6        :        :                   :         : 1         :                \r
+GND*                         : R7        :        :                   :         : 1         :                \r
+GND*                         : R8        :        :                   :         : 1         :                \r
+GND*                         : R9        :        :                   :         : 8         :                \r
+GND*                         : R10       :        :                   :         : 8         :                \r
+GND*                         : R11       :        :                   :         : 8         :                \r
+GND*                         : R12       :        :                   :         : 7         :                \r
+GND*                         : R13       :        :                   :         : 7         :                \r
+GND*                         : R14       :        :                   :         : 7         :                \r
+GND*                         : R15       :        :                   :         : 7         :                \r
+GND*                         : R16       :        :                   :         : 7         :                \r
+GND*                         : R17       :        :                   :         : 6         :                \r
+GND*                         : R18       :        :                   :         : 6         :                \r
+GND*                         : R19       :        :                   :         : 6         :                \r
+GND*                         : R20       :        :                   :         : 6         :                \r
+GND*                         : R21       :        :                   :         : 6         :                \r
+rst_n                        : R22       : input  : 3.3-V LVTTL       :         : 6         : Y              \r
+GND*                         : T1        :        :                   :         : 1         :                \r
+GND*                         : T2        :        :                   :         : 1         :                \r
+GND*                         : T3        :        :                   :         : 1         :                \r
+VCCIO1                       : T4        : power  :                   : 3.3V    : 1         :                \r
+GND*                         : T5        :        :                   :         : 1         :                \r
+GND*                         : T6        :        :                   :         : 1         :                \r
+GND*                         : T7        :        :                   :         : 8         :                \r
+GND*                         : T8        :        :                   :         : 8         :                \r
+VCCIO8                       : T9        : power  :                   : 3.3V    : 8         :                \r
+GND                          : T10       : gnd    :                   :         :           :                \r
+GND*                         : T11       :        :                   :         : 8         :                \r
+GND*                         : T12       :        :                   :         : 7         :                \r
+GND                          : T13       : gnd    :                   :         :           :                \r
+VCCIO7                       : T14       : power  :                   : 3.3V    : 7         :                \r
+GND*                         : T15       :        :                   :         : 7         :                \r
+GND*                         : T16       :        :                   :         : 7         :                \r
+GND_PLL4                     : T17       : gnd    :                   :         :           :                \r
+GND*                         : T18       :        :                   :         : 6         :                \r
+VCCIO6                       : T19       : power  :                   : 3.3V    : 6         :                \r
+GND                          : T20       : gnd    :                   :         :           :                \r
+GND*                         : T21       :        :                   :         : 6         :                \r
+GND*                         : T22       :        :                   :         : 6         :                \r
+GND*                         : U1        :        :                   :         : 1         :                \r
+GND*                         : U2        :        :                   :         : 1         :                \r
+GND*                         : U3        :        :                   :         : 1         :                \r
+GND*                         : U4        :        :                   :         : 1         :                \r
+GND_PLL1                     : U5        : gnd    :                   :         :           :                \r
+VCCD_PLL1                    : U6        : power  :                   : 1.2V    :           :                \r
+VCCA_PLL1                    : U7        : power  :                   : 1.2V    :           :                \r
+GND*                         : U8        :        :                   :         : 8         :                \r
+GND*                         : U9        :        :                   :         : 8         :                \r
+GND*                         : U10       :        :                   :         : 8         :                \r
+GND+                         : U11       :        :                   :         : 8         :                \r
+GND+                         : U12       :        :                   :         : 8         :                \r
+GND*                         : U13       :        :                   :         : 7         :                \r
+GND*                         : U14       :        :                   :         : 7         :                \r
+GND*                         : U15       :        :                   :         : 7         :                \r
+VCCA_PLL4                    : U16       : power  :                   : 1.2V    :           :                \r
+VCCD_PLL4                    : U17       : power  :                   : 1.2V    :           :                \r
+GND*                         : U18       :        :                   :         : 6         :                \r
+GND*                         : U19       :        :                   :         : 6         :                \r
+GND*                         : U20       :        :                   :         : 6         :                \r
+GND*                         : U21       :        :                   :         : 6         :                \r
+GND*                         : U22       :        :                   :         : 6         :                \r
+GND*                         : V1        :        :                   :         : 1         :                \r
+GND*                         : V2        :        :                   :         : 1         :                \r
+GND                          : V3        : gnd    :                   :         :           :                \r
+GND*                         : V4        :        :                   :         : 1         :                \r
+GND_PLL1                     : V5        : gnd    :                   :         :           :                \r
+GND                          : V6        : gnd    :                   :         :           :                \r
+GNDA_PLL1                    : V7        : gnd    :                   :         :           :                \r
+GND*                         : V8        :        :                   :         : 8         :                \r
+GND*                         : V9        :        :                   :         : 8         :                \r
+VCCIO8                       : V10       : power  :                   : 3.3V    : 8         :                \r
+GND*                         : V11       :        :                   :         : 8         :                \r
+GND+                         : V12       :        :                   :         : 7         :                \r
+VCCIO7                       : V13       : power  :                   : 3.3V    : 7         :                \r
+GND*                         : V14       :        :                   :         : 7         :                \r
+GND*                         : V15       :        :                   :         : 7         :                \r
+GNDA_PLL4                    : V16       : gnd    :                   :         :           :                \r
+GND                          : V17       : gnd    :                   :         :           :                \r
+GND_PLL4                     : V18       : gnd    :                   :         :           :                \r
+GND*                         : V19       :        :                   :         : 6         :                \r
+GND*                         : V20       :        :                   :         : 6         :                \r
+GND*                         : V21       :        :                   :         : 6         :                \r
+GND*                         : V22       :        :                   :         : 6         :                \r
+GND*                         : W1        :        :                   :         : 1         :                \r
+GND*                         : W2        :        :                   :         : 1         :                \r
+GND*                         : W3        :        :                   :         : 1         :                \r
+GND*                         : W4        :        :                   :         : 1         :                \r
+GND*                         : W5        :        :                   :         : 1         :                \r
+VCCIO8                       : W6        : power  :                   : 3.3V    : 8         :                \r
+GND*                         : W7        :        :                   :         : 8         :                \r
+GND*                         : W8        :        :                   :         : 8         :                \r
+GND*                         : W9        :        :                   :         : 8         :                \r
+GND                          : W10       : gnd    :                   :         :           :                \r
+GND*                         : W11       :        :                   :         : 8         :                \r
+GND+                         : W12       :        :                   :         : 7         :                \r
+GND                          : W13       : gnd    :                   :         :           :                \r
+GND*                         : W14       :        :                   :         : 7         :                \r
+GND*                         : W15       :        :                   :         : 7         :                \r
+GND*                         : W16       :        :                   :         : 7         :                \r
+VCCIO7                       : W17       : power  :                   : 3.3V    : 7         :                \r
+NC                           : W18       :        :                   :         :           :                \r
+GND                          : W19       : gnd    :                   :         :           :                \r
+~LVDS91p/nCEO~               : W20       : output : 3.3-V LVTTL       :         : 6         : N              \r
+GND*                         : W21       :        :                   :         : 6         :                \r
+GND*                         : W22       :        :                   :         : 6         :                \r
+GND*                         : Y1        :        :                   :         : 1         :                \r
+GND*                         : Y2        :        :                   :         : 1         :                \r
+GND*                         : Y3        :        :                   :         : 1         :                \r
+GND*                         : Y4        :        :                   :         : 1         :                \r
+GND*                         : Y5        :        :                   :         : 8         :                \r
+GND*                         : Y6        :        :                   :         : 8         :                \r
+GND*                         : Y7        :        :                   :         : 8         :                \r
+GND                          : Y8        : gnd    :                   :         :           :                \r
+GND*                         : Y9        :        :                   :         : 8         :                \r
+GND*                         : Y10       :        :                   :         : 8         :                \r
+VCCIO8                       : Y11       : power  :                   : 3.3V    : 8         :                \r
+VCCIO7                       : Y12       : power  :                   : 3.3V    : 7         :                \r
+GND*                         : Y13       :        :                   :         : 7         :                \r
+GND*                         : Y14       :        :                   :         : 7         :                \r
+GND                          : Y15       : gnd    :                   :         :           :                \r
+GND*                         : Y16       :        :                   :         : 7         :                \r
+GND*                         : Y17       :        :                   :         : 7         :                \r
+GND*                         : Y18       :        :                   :         : 6         :                \r
+GND*                         : Y19       :        :                   :         : 6         :                \r
+GND*                         : Y20       :        :                   :         : 6         :                \r
+GND*                         : Y21       :        :                   :         : 6         :                \r
+GND*                         : Y22       :        :                   :         : 6         :                \r
diff --git a/de1_nes/de1_nes.qpf b/de1_nes/de1_nes.qpf
new file mode 100644 (file)
index 0000000..99408ce
--- /dev/null
@@ -0,0 +1,23 @@
+# Copyright (C) 1991-2007 Altera Corporation\r
+# Your use of Altera Corporation's design tools, logic functions \r
+# and other software and tools, and its AMPP partner logic \r
+# functions, and any output files from any of the foregoing \r
+# (including device programming or simulation files), and any \r
+# associated documentation or information are expressly subject \r
+# to the terms and conditions of the Altera Program License \r
+# Subscription Agreement, Altera MegaCore Function License \r
+# Agreement, or other applicable license agreement, including, \r
+# without limitation, that your use is for the sole purpose of \r
+# programming logic devices manufactured by Altera and sold by \r
+# Altera or its authorized distributors.  Please refer to the \r
+# applicable agreement for further details.\r
+\r
+\r
+\r
+QUARTUS_VERSION = "7.2"\r
+DATE = "10:06:40  September 01, 2013"\r
+\r
+\r
+# Revisions\r
+\r
+PROJECT_REVISION = "de1_nes"\r
diff --git a/de1_nes/de1_nes.qsf b/de1_nes/de1_nes.qsf
new file mode 100644 (file)
index 0000000..0908aff
--- /dev/null
@@ -0,0 +1,48 @@
+# Copyright (C) 1991-2007 Altera Corporation\r
+# Your use of Altera Corporation's design tools, logic functions \r
+# and other software and tools, and its AMPP partner logic \r
+# functions, and any output files from any of the foregoing \r
+# (including device programming or simulation files), and any \r
+# associated documentation or information are expressly subject \r
+# to the terms and conditions of the Altera Program License \r
+# Subscription Agreement, Altera MegaCore Function License \r
+# Agreement, or other applicable license agreement, including, \r
+# without limitation, that your use is for the sole purpose of \r
+# programming logic devices manufactured by Altera and sold by \r
+# Altera or its authorized distributors.  Please refer to the \r
+# applicable agreement for further details.\r
+\r
+\r
+# The default values for assignments are stored in the file\r
+#              de1_nes_assignment_defaults.qdf\r
+# If this file doesn't exist, and for assignments not listed, see file\r
+#              assignment_defaults.qdf\r
+\r
+# Altera recommends that you do not modify this file. This\r
+# file is updated automatically by the Quartus II software\r
+# and any changes you make may be lost or overwritten.\r
+\r
+\r
+set_global_assignment -name FAMILY "Cyclone II"\r
+set_global_assignment -name DEVICE EP2C20F484C7\r
+set_global_assignment -name TOP_LEVEL_ENTITY de1_nes\r
+set_global_assignment -name ORIGINAL_QUARTUS_VERSION 7.2\r
+set_global_assignment -name PROJECT_CREATION_TIME_DATE "10:06:40  SEPTEMBER 01, 2013"\r
+set_global_assignment -name LAST_QUARTUS_VERSION 7.2\r
+set_global_assignment -name USE_GENERATED_PHYSICAL_CONSTRAINTS OFF -section_id eda_palace\r
+set_global_assignment -name DEVICE_FILTER_PACKAGE FBGA\r
+set_global_assignment -name DEVICE_FILTER_PIN_COUNT 484\r
+set_global_assignment -name DEVICE_FILTER_SPEED_GRADE 7\r
+set_instance_assignment -name PARTITION_HIERARCHY no_file_for_top_partition -to | -section_id Top\r
+set_global_assignment -name PARTITION_NETLIST_TYPE SOURCE -section_id Top\r
+set_global_assignment -name PARTITION_COLOR 2147039 -section_id Top\r
+set_global_assignment -name LL_ROOT_REGION ON -section_id "Root Region"\r
+set_global_assignment -name LL_MEMBER_STATE LOCKED -section_id "Root Region"\r
+set_location_assignment PIN_D12 -to base_clk\r
+set_location_assignment PIN_R22 -to rst_n\r
+set_global_assignment -name VHDL_FILE ppu/ppu_registers.vhd\r
+set_global_assignment -name VHDL_FILE cpu/cpu_registers.vhd\r
+set_global_assignment -name VHDL_FILE clock/clock_divider.vhd\r
+set_global_assignment -name VHDL_FILE de1_nes.vhd\r
+set_global_assignment -name VECTOR_WAVEFORM_FILE de1_nes.vwf\r
+set_global_assignment -name INCREMENTAL_VECTOR_INPUT_SOURCE de1_nes.vwf
\ No newline at end of file
diff --git a/de1_nes/de1_nes.qws b/de1_nes/de1_nes.qws
new file mode 100644 (file)
index 0000000..ea3644e
--- /dev/null
@@ -0,0 +1,22 @@
+[ProjectWorkspace]\r
+ptn_Child1=Frames\r
+[ProjectWorkspace.Frames]\r
+ptn_Child1=ChildFrames\r
+[ProjectWorkspace.Frames.ChildFrames]\r
+ptn_Child1=Document-0\r
+ptn_Child2=Document-1\r
+ptn_Child3=Document-2\r
+ptn_Child4=Document-3\r
+ptn_Child5=Document-4\r
+[ProjectWorkspace.Frames.ChildFrames.Document-0]\r
+ptn_Child1=ViewFrame-0\r
+[ProjectWorkspace.Frames.ChildFrames.Document-0.ViewFrame-0]\r
+DocPathName=de1_nes.vwf\r
+DocumentCLSID={4a9ed22a-e60b-11d1-a0bd-0020affa43f2}\r
+IsChildFrameDetached=False\r
+IsActiveChildFrame=False\r
+ptn_Child1=StateMap\r
+[ProjectWorkspace.Frames.ChildFrames.Document-0.ViewFrame-0.StateMap]\r
+AFC_SIM_AP_NAME=de1_nes\r
+AFC_PROJ_DB_PATH=D:/daisuke/nes/repo/motonesfpga/de1_nes/db/de1_nes.quartus_db\r
+AFC_IN_REPORT=False\r
diff --git a/de1_nes/de1_nes.vhd b/de1_nes/de1_nes.vhd
new file mode 100644 (file)
index 0000000..f8fd347
--- /dev/null
@@ -0,0 +1,154 @@
+library ieee;\r
+use ieee.std_logic_1164.all;\r
+use ieee.std_logic_unsigned.conv_integer;\r
+\r
+--  \r
+--   MOTO NES FPGA On GHDL Simulation Environment Virtual Cuicuit Board\r
+--   All of the components are assembled and instanciated on this board.\r
+--  \r
+\r
+entity de1_nes is \r
+    port (  \r
+               base_clk        : in std_logic;\r
+               rst_n           : in std_logic;\r
+               dbg_pin0        : out std_logic;\r
+               dbg_pin1        : out std_logic;\r
+               dbg_pin2        : out std_logic;\r
+               dbg_pin3        : out std_logic;\r
+               dbg_pin4        : out std_logic;\r
+               dbg_pin5        : out std_logic;\r
+               dbg_pin6        : out std_logic;\r
+               dbg_pin7        : out std_logic\r
+         );\r
+end de1_nes;\r
+\r
+architecture rtl of de1_nes is\r
+    component mos6502\r
+        generic (   dsize : integer := 8;\r
+                    asize : integer :=16\r
+                );\r
+        port (  input_clk   : in std_logic; --phi0 input pin.\r
+                rdy         : in std_logic;\r
+                rst_n       : in std_logic;\r
+                irq_n       : in std_logic;\r
+                nmi_n       : in std_logic;\r
+                dbe         : in std_logic;\r
+                r_nw        : out std_logic;\r
+                phi1        : out std_logic;\r
+                phi2        : out std_logic;\r
+                addr        : out std_logic_vector ( asize - 1 downto 0);\r
+                d_io        : inout std_logic_vector ( dsize - 1 downto 0)\r
+        );\r
+    end component;\r
+\r
+    component clock_divider\r
+        port (  base_clk    : in std_logic;\r
+                reset_n     : in std_logic;\r
+                cpu_clk     : out std_logic;\r
+                               ppu_clk     : out std_logic;\r
+                               vga_clk     : out std_logic\r
+            );\r
+    end component;\r
+\r
+    component address_decoder\r
+    generic (abus_size : integer := 16; dbus_size : integer := 8);\r
+        port (  phi2        : in std_logic;\r
+                R_nW        : in std_logic; \r
+                addr       : in std_logic_vector (abus_size - 1 downto 0);\r
+                d_io       : inout std_logic_vector (dbus_size - 1 downto 0);\r
+                ppu_ce_n    : out std_logic\r
+    );\r
+    end component;\r
+\r
+    component ppu\r
+    port (  clk         : in std_logic;\r
+            ce_n        : in std_logic;\r
+            rst_n       : in std_logic;\r
+            r_nw        : in std_logic;\r
+            cpu_addr    : in std_logic_vector (2 downto 0);\r
+            cpu_d       : inout std_logic_vector (7 downto 0);\r
+            vblank_n    : out std_logic;\r
+            rd_n        : out std_logic;\r
+            wr_n        : out std_logic;\r
+            ale         : out std_logic;\r
+            vram_ad     : inout std_logic_vector (7 downto 0);\r
+            vram_a      : out std_logic_vector (13 downto 8);\r
+            vga_clk     : in std_logic;\r
+            h_sync_n    : out std_logic;\r
+            v_sync_n    : out std_logic;\r
+            r           : out std_logic_vector(3 downto 0);\r
+            g           : out std_logic_vector(3 downto 0);\r
+            b           : out std_logic_vector(3 downto 0)\r
+    );\r
+    end component;\r
+\r
+    component v_address_decoder\r
+    generic (abus_size : integer := 14; dbus_size : integer := 8);\r
+        port (  clk         : in std_logic; \r
+                rd_n        : in std_logic;\r
+                wr_n        : in std_logic;\r
+                ale         : in std_logic;\r
+                vram_ad     : inout std_logic_vector (7 downto 0);\r
+                vram_a      : in std_logic_vector (13 downto 8)\r
+            );\r
+    end component;\r
+\r
+    constant data_size : integer := 8;\r
+    constant addr_size : integer := 16;\r
+    constant size14    : integer := 14;\r
+\r
+    signal cpu_clk  : std_logic;\r
+    signal ppu_clk  : std_logic;\r
+\r
+    signal rdy, irq_n, nmi_n, dbe, r_nw : std_logic;\r
+    signal phi1, phi2 : std_logic;\r
+    signal addr : std_logic_vector( addr_size - 1 downto 0);\r
+    signal d_io : std_logic_vector( data_size - 1 downto 0);\r
+\r
+    signal ppu_ce_n : std_logic;\r
+    signal rd_n     : std_logic;\r
+    signal wr_n     : std_logic;\r
+    signal ale      : std_logic;\r
+    signal vram_ad  : std_logic_vector (7 downto 0);\r
+    signal vram_a   : std_logic_vector (13 downto 8);\r
+\r
+    signal vga_clk     : std_logic;\r
+    signal h_sync_n    : std_logic;\r
+    signal v_sync_n    : std_logic;\r
+    signal r           : std_logic_vector(3 downto 0);\r
+    signal g           : std_logic_vector(3 downto 0);\r
+    signal b           : std_logic_vector(3 downto 0);\r
+\r
+begin\r
+\r
+    irq_n <= '0';\r
+    rdy <= '1';\r
+\r
+    --ppu/cpu clock generator\r
+    clock_inst : clock_divider port map \r
+        (base_clk, rst_n, cpu_clk, ppu_clk, vga_clk);\r
+\r
+--    --mos 6502 cpu instance\r
+--    cpu_inst : mos6502 generic map (data_size, addr_size) \r
+--        port map (cpu_clk, rdy, rst_n, irq_n, nmi_n, dbe, r_nw, \r
+--                phi1, phi2, addr, d_io);\r
+\r
+--    addr_dec_inst : address_decoder generic map (addr_size, data_size) \r
+--        port map (phi2, r_nw, addr, d_io, ppu_ce_n);\r
+\r
+    --nes ppu instance\r
+--    ppu_inst : ppu \r
+--        port map (ppu_clk, ppu_ce_n, rst_n, r_nw, addr(2 downto 0), d_io, \r
+--                nmi_n, rd_n, wr_n, ale, vram_ad, vram_a,\r
+--                vga_clk, h_sync_n, v_sync_n, r, g, b);\r
+\r
+--    ppu_addr_decoder : v_address_decoder generic map (size14, data_size) \r
+--        port map (ppu_clk, rd_n, wr_n, ale, vram_ad, vram_a);\r
+\r
+-----debug-----\r
+       dbg_pin0 <= cpu_clk;\r
+       dbg_pin1 <= ppu_clk;\r
+       dbg_pin2 <= vga_clk;\r
+\r
+end rtl;\r
+\r
diff --git a/de1_nes/de1_nes.vwf b/de1_nes/de1_nes.vwf
new file mode 100644 (file)
index 0000000..469bc77
--- /dev/null
@@ -0,0 +1,186 @@
+/*\r
+WARNING: Do NOT edit the input and output ports in this file in a text\r
+editor if you plan to continue editing the block that represents it in\r
+the Block Editor! File corruption is VERY likely to occur.\r
+*/\r
+\r
+/*\r
+Copyright (C) 1991-2007 Altera Corporation\r
+Your use of Altera Corporation's design tools, logic functions \r
+and other software and tools, and its AMPP partner logic \r
+functions, and any output files from any of the foregoing \r
+(including device programming or simulation files), and any \r
+associated documentation or information are expressly subject \r
+to the terms and conditions of the Altera Program License \r
+Subscription Agreement, Altera MegaCore Function License \r
+Agreement, or other applicable license agreement, including, \r
+without limitation, that your use is for the sole purpose of \r
+programming logic devices manufactured by Altera and sold by \r
+Altera or its authorized distributors.  Please refer to the \r
+applicable agreement for further details.\r
+*/\r
+\r
+HEADER\r
+{\r
+       VERSION = 1;\r
+       TIME_UNIT = ns;\r
+       DATA_OFFSET = 0.0;\r
+       DATA_DURATION = 10000000.0;\r
+       SIMULATION_TIME = 0.0;\r
+       GRID_PHASE = 0.0;\r
+       GRID_PERIOD = 10.0;\r
+       GRID_DUTY_CYCLE = 50;\r
+}\r
+\r
+SIGNAL("base_clk")\r
+{\r
+       VALUE_TYPE = NINE_LEVEL_BIT;\r
+       SIGNAL_TYPE = SINGLE_BIT;\r
+       WIDTH = 1;\r
+       LSB_INDEX = -1;\r
+       DIRECTION = INPUT;\r
+       PARENT = "";\r
+}\r
+\r
+SIGNAL("rst_n")\r
+{\r
+       VALUE_TYPE = NINE_LEVEL_BIT;\r
+       SIGNAL_TYPE = SINGLE_BIT;\r
+       WIDTH = 1;\r
+       LSB_INDEX = -1;\r
+       DIRECTION = INPUT;\r
+       PARENT = "";\r
+}\r
+\r
+SIGNAL("dbg_pin0")\r
+{\r
+       VALUE_TYPE = NINE_LEVEL_BIT;\r
+       SIGNAL_TYPE = SINGLE_BIT;\r
+       WIDTH = 1;\r
+       LSB_INDEX = -1;\r
+       DIRECTION = OUTPUT;\r
+       PARENT = "";\r
+}\r
+\r
+SIGNAL("dbg_pin1")\r
+{\r
+       VALUE_TYPE = NINE_LEVEL_BIT;\r
+       SIGNAL_TYPE = SINGLE_BIT;\r
+       WIDTH = 1;\r
+       LSB_INDEX = -1;\r
+       DIRECTION = OUTPUT;\r
+       PARENT = "";\r
+}\r
+\r
+SIGNAL("dbg_pin2")\r
+{\r
+       VALUE_TYPE = NINE_LEVEL_BIT;\r
+       SIGNAL_TYPE = SINGLE_BIT;\r
+       WIDTH = 1;\r
+       LSB_INDEX = -1;\r
+       DIRECTION = OUTPUT;\r
+       PARENT = "";\r
+}\r
+\r
+TRANSITION_LIST("base_clk")\r
+{\r
+       NODE\r
+       {\r
+               REPEAT = 1;\r
+               NODE\r
+               {\r
+                       REPEAT = 125000;\r
+                       LEVEL 0 FOR 40.0;\r
+                       LEVEL 1 FOR 40.0;\r
+               }\r
+       }\r
+}\r
+\r
+TRANSITION_LIST("rst_n")\r
+{\r
+       NODE\r
+       {\r
+               REPEAT = 1;\r
+               LEVEL 0 FOR 400.0;\r
+               LEVEL 1 FOR 9999600.0;\r
+       }\r
+}\r
+\r
+TRANSITION_LIST("dbg_pin0")\r
+{\r
+       NODE\r
+       {\r
+               REPEAT = 1;\r
+               LEVEL X FOR 10000000.0;\r
+       }\r
+}\r
+\r
+TRANSITION_LIST("dbg_pin1")\r
+{\r
+       NODE\r
+       {\r
+               REPEAT = 1;\r
+               LEVEL X FOR 10000000.0;\r
+       }\r
+}\r
+\r
+TRANSITION_LIST("dbg_pin2")\r
+{\r
+       NODE\r
+       {\r
+               REPEAT = 1;\r
+               LEVEL X FOR 10000000.0;\r
+       }\r
+}\r
+\r
+DISPLAY_LINE\r
+{\r
+       CHANNEL = "base_clk";\r
+       EXPAND_STATUS = COLLAPSED;\r
+       RADIX = ASCII;\r
+       TREE_INDEX = 0;\r
+       TREE_LEVEL = 0;\r
+}\r
+\r
+DISPLAY_LINE\r
+{\r
+       CHANNEL = "rst_n";\r
+       EXPAND_STATUS = COLLAPSED;\r
+       RADIX = ASCII;\r
+       TREE_INDEX = 1;\r
+       TREE_LEVEL = 0;\r
+}\r
+\r
+DISPLAY_LINE\r
+{\r
+       CHANNEL = "dbg_pin0";\r
+       EXPAND_STATUS = COLLAPSED;\r
+       RADIX = ASCII;\r
+       TREE_INDEX = 2;\r
+       TREE_LEVEL = 0;\r
+}\r
+\r
+DISPLAY_LINE\r
+{\r
+       CHANNEL = "dbg_pin1";\r
+       EXPAND_STATUS = COLLAPSED;\r
+       RADIX = ASCII;\r
+       TREE_INDEX = 3;\r
+       TREE_LEVEL = 0;\r
+}\r
+\r
+DISPLAY_LINE\r
+{\r
+       CHANNEL = "dbg_pin2";\r
+       EXPAND_STATUS = COLLAPSED;\r
+       RADIX = ASCII;\r
+       TREE_INDEX = 4;\r
+       TREE_LEVEL = 0;\r
+}\r
+\r
+TIME_BAR\r
+{\r
+       TIME = 29850;\r
+       MASTER = TRUE;\r
+}\r
+;\r
diff --git a/de1_nes/ppu/ppu_registers.vhd b/de1_nes/ppu/ppu_registers.vhd
new file mode 100644 (file)
index 0000000..bca7ea2
--- /dev/null
@@ -0,0 +1,170 @@
+--------------------------------
+----------shift registers -----
+--------------------------------
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity shift_register is 
+    generic (
+        dsize : integer := 8;
+        shift : integer := 1
+    );
+    port (  clk         : in std_logic;
+            rst_n       : in std_logic;
+            ce_n        : in std_logic;
+            we_n        : in std_logic;
+            d           : in std_logic_vector(dsize - 1 downto 0);
+            q           : out std_logic_vector(dsize - 1 downto 0)
+    );
+end shift_register;
+
+architecture rtl of shift_register is
+
+component d_flip_flop
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            clk     : in std_logic;
+            res_n   : in std_logic;
+            set_n   : in std_logic;
+            we_n    : in std_logic;
+            d       : in std_logic_vector (dsize - 1 downto 0);
+            q       : out std_logic_vector (dsize - 1 downto 0)
+        );
+end component;
+
+signal dff_we_n : std_logic;
+signal q_out : std_logic_vector(dsize - 1 downto 0);
+signal df_in : std_logic_vector(dsize - 1 downto 0);
+
+begin
+
+    q <= q_out;
+    dff_we_n <= ce_n and we_n;
+    dff_inst : d_flip_flop generic map (dsize)
+            port map (clk, rst_n, '1', dff_we_n, df_in, q_out);
+
+    clk_p : process (clk, we_n, ce_n, d) 
+    begin
+        if (we_n = '0') then
+            df_in <= d;
+        elsif (ce_n = '0') then
+            df_in (dsize - 1 downto dsize - shift) <= (others => '0');
+            df_in (dsize - shift - 1  downto 0) <= 
+                q_out(dsize - 1 downto shift);
+        end if;
+    end process;
+
+end rtl;
+
+-------------------------------
+------ count up registers -----
+-------------------------------
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity counter_register is 
+    
+    generic (
+        dsize       : integer := 8;
+        inc         : integer := 1
+    );
+    port (  clk         : in std_logic;
+            rst_n       : in std_logic;
+            ce_n        : in std_logic;
+            we_n        : in std_logic;
+            d           : in std_logic_vector(dsize - 1 downto 0);
+            q           : out std_logic_vector(dsize - 1 downto 0)
+    );
+end counter_register;
+
+architecture rtl of counter_register is
+
+component d_flip_flop
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            clk     : in std_logic;
+            res_n   : in std_logic;
+            set_n   : in std_logic;
+            we_n    : in std_logic;
+            d       : in std_logic_vector (dsize - 1 downto 0);
+            q       : out std_logic_vector (dsize - 1 downto 0)
+        );
+end component;
+
+use ieee.std_logic_unsigned.all;
+
+signal dff_we_n : std_logic;
+signal d_in : std_logic_vector(dsize - 1 downto 0);
+signal q_out : std_logic_vector(dsize - 1 downto 0);
+
+begin
+    q <= q_out;
+    dff_we_n <= ce_n and we_n;
+    counter_reg_inst : d_flip_flop generic map (dsize)
+            port map (clk, rst_n, '1', dff_we_n, d_in, q_out);
+        
+    clk_p : process (clk, we_n, ce_n, d)
+    begin
+        if (we_n = '0') then
+            d_in <= d;
+        elsif (ce_n = '0') then
+            d_in <= q_out + inc;
+        end if;
+    end process;
+
+end rtl;
+
+-------------------------------
+-- LS373 transparent D-latch---
+-------------------------------
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity ls373 is 
+    generic (
+        dsize : integer := 8
+    );
+    port (  c         : in std_logic;
+            oc_n      : in std_logic;
+            d         : in std_logic_vector(dsize - 1 downto 0);
+            q         : out std_logic_vector(dsize - 1 downto 0)
+    );
+end ls373;
+
+architecture rtl of ls373 is
+
+component latch
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            clk     : in std_logic;
+            d       : in std_logic_vector (dsize - 1 downto 0);
+            q       : out std_logic_vector (dsize - 1 downto 0)
+        );
+end component;
+
+component tri_state_buffer
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            oe_n    : in std_logic;
+            d       : in std_logic_vector (dsize - 1 downto 0);
+            q       : out std_logic_vector (dsize - 1 downto 0)
+        );
+end component;
+
+signal q_out       : std_logic_vector (dsize - 1 downto 0);
+
+begin
+    ls373_inst : latch generic map (dsize)
+            port map (c, d, q_out);
+    tsb_inst : tri_state_buffer generic map (dsize)
+            port map (oc_n, q_out, q);
+end rtl;
+