OSDN Git Service

address latch integration ok
[motonesfpga/motonesfpga.git] / de1_nes / ppu / ppu_registers.vhd
1 --------------------------------
2 ----------shift registers -----
3 --------------------------------
4 library ieee;
5 use ieee.std_logic_1164.all;
6
7 entity shift_register is 
8     generic (
9         dsize : integer := 8;
10         shift : integer := 1
11     );
12     port (  clk         : in std_logic;
13             rst_n       : in std_logic;
14             ce_n        : in std_logic;
15             we_n        : in std_logic;
16             d           : in std_logic_vector(dsize - 1 downto 0);
17             q           : out std_logic_vector(dsize - 1 downto 0)
18     );
19 end shift_register;
20
21 architecture rtl of shift_register is
22
23 component d_flip_flop
24     generic (
25             dsize : integer := 8
26             );
27     port (  
28             clk     : in std_logic;
29             res_n   : in std_logic;
30             set_n   : in std_logic;
31             we_n    : in std_logic;
32             d       : in std_logic_vector (dsize - 1 downto 0);
33             q       : out std_logic_vector (dsize - 1 downto 0)
34         );
35 end component;
36
37 signal dff_we_n : std_logic;
38 signal q_out : std_logic_vector(dsize - 1 downto 0);
39 signal df_in : std_logic_vector(dsize - 1 downto 0);
40
41 begin
42
43     q <= q_out;
44     dff_we_n <= ce_n and we_n;
45     dff_inst : d_flip_flop generic map (dsize)
46             port map (clk, rst_n, '1', dff_we_n, df_in, q_out);
47
48     clk_p : process (clk, we_n, ce_n, d) 
49     begin
50         if (we_n = '0') then
51             df_in <= d;
52         elsif (ce_n = '0') then
53             df_in (dsize - 1 downto dsize - shift) <= (others => '0');
54             df_in (dsize - shift - 1  downto 0) <= 
55                 q_out(dsize - 1 downto shift);
56         end if;
57     end process;
58
59 end rtl;
60
61 -------------------------------
62 -- LS373 transparent D-latch---
63 -------------------------------
64 library ieee;
65 use ieee.std_logic_1164.all;
66
67 entity ls373 is 
68     generic (
69         dsize : integer := 8
70     );
71     port (  c         : in std_logic;
72             we_n      : in std_logic;\r
73             oc_n      : in std_logic;\r
74             d         : in std_logic_vector(dsize - 1 downto 0);
75             q         : out std_logic_vector(dsize - 1 downto 0)
76     );
77 end ls373;
78
79 architecture rtl of ls373 is
80
81 component d_flip_flop\r
82     generic (\r
83             dsize : integer := 8\r
84             );\r
85     port (  \r
86             clk     : in std_logic;\r
87             res_n   : in std_logic;\r
88             set_n   : in std_logic;\r
89             we_n    : in std_logic;\r
90             d       : in std_logic_vector (dsize - 1 downto 0);\r
91             q       : out std_logic_vector (dsize - 1 downto 0)\r
92         );\r
93 end component;\r
94
95 component tri_state_buffer
96     generic (
97             dsize : integer := 8
98             );
99     port (  
100             oe_n    : in std_logic;
101             d       : in std_logic_vector (dsize - 1 downto 0);
102             q       : out std_logic_vector (dsize - 1 downto 0)
103         );
104 end component;
105
106 signal q_out       : std_logic_vector (dsize - 1 downto 0);
107
108 begin
109     out_reg_inst : d_flip_flop generic map (dsize)\r
110             port map (c, '1', '1', we_n, d, q_out);\r
111     tsb_inst : tri_state_buffer generic map (dsize)
112             port map (oc_n, q_out, q);
113 end rtl;
114