This commit was manufactured by cvs2svn to create tag 'MIPS_R12'.

git-svn-id: http://moon:8086/svn/vhdl/tags/MIPS_R12@934 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
2011-07-24 08:18:46 +00:00
parent faa81b57e9
commit aef784643a
396 changed files with 4562 additions and 83217 deletions
+74 -63
View File
@@ -3,10 +3,6 @@ USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.NUMERIC_STD.ALL;
ENTITY gpio_wb IS
Generic
(
f_sysclk : real := 100.0
);
Port
(
CLK_I : in STD_LOGIC;
@@ -23,45 +19,46 @@ ENTITY gpio_wb IS
DAT_O : out unsigned(31 downto 0);
INT_TIM_O : out STD_LOGIC;
sys_gpi_0 : in unsigned(31 downto 0);
sys_gpo_0 : out unsigned(31 downto 0)
sys_gpo0 : out unsigned(31 downto 0);
sys_gpo1 : out unsigned(31 downto 0);
sys_gpi0 : in unsigned(31 downto 0);
sys_gpi1 : in unsigned(31 downto 0)
);
END gpio_wb;
ARCHITECTURE behavior OF gpio_wb IS
constant num_timers : natural := 2;
constant ncycles_usec : natural := natural(f_sysclk);
constant num_timers : natural := 2;
signal gpio_0_dout_reg : unsigned(31 downto 0);
signal gpio_0_dir_reg : unsigned(31 downto 0);
signal gpio_0_din_reg : unsigned(31 downto 0);
signal gpo0_reg : unsigned(31 downto 0);
signal gpo1_reg : unsigned(31 downto 0);
signal gpi0_reg : unsigned(31 downto 0);
signal gpi1_reg : unsigned(31 downto 0);
-- Signals to form an timer generating an interrupt every microsecond
subtype tick_usec_t is natural range 0 to ncycles_usec-1;
signal tick_usec : tick_usec_t := 0;
signal cnt_usec : unsigned(31 downto 0);
signal cnt_sec : unsigned(31 downto 0);
signal cnt_usec_preset : unsigned(31 downto 0);
signal cnt_sec_preset : unsigned(31 downto 0);
signal cnt_usec_en : std_logic;
signal cnt_usec_we : std_logic;
signal cnt_sec_en : std_logic;
signal cnt_sec_we : std_logic;
subtype tick_usec_t is natural range 0 to 99;
signal tick_usec : tick_usec_t;
signal cnt_usec : unsigned(31 downto 0);
signal cnt_sec : unsigned(31 downto 0);
signal cnt_usec_preset : unsigned(31 downto 0);
signal cnt_sec_preset : unsigned(31 downto 0);
signal cnt_usec_en : std_logic;
signal cnt_usec_we : std_logic;
signal cnt_sec_en : std_logic;
signal cnt_sec_we : std_logic;
type timer_array_t is array (0 to num_timers-1) of unsigned(31 downto 0);
signal timer_cnt : timer_array_t;
signal timer_cmp : timer_array_t;
signal timer_en : unsigned(0 to num_timers-1);
signal timer_inten : unsigned(0 to num_timers-1);
signal timer_irq : unsigned(0 to num_timers-1);
signal timer_ovl : unsigned(0 to num_timers-1);
signal timer_irq_ack : unsigned(0 to num_timers-1);
signal timer_cnt_we : unsigned(0 to num_timers-1);
signal timer_cmp_we : unsigned(0 to num_timers-1);
signal timer_cnt : timer_array_t;
signal timer_cmp : timer_array_t;
signal timer_en : unsigned(0 to num_timers-1);
signal timer_inten : unsigned(0 to num_timers-1);
signal timer_irq : unsigned(0 to num_timers-1);
signal timer_ovl : unsigned(0 to num_timers-1);
signal timer_irq_ack : unsigned(0 to num_timers-1);
signal timer_cnt_we : unsigned(0 to num_timers-1);
signal timer_cmp_we : unsigned(0 to num_timers-1);
signal reg_data_wr : unsigned(31 downto 0);
signal reg_data_wr : unsigned(31 downto 0);
begin
@@ -79,33 +76,25 @@ tim_irq:
end process;
------------------------------------------------------------------
gpio_0_out:
process(gpio_0_dir_reg, gpio_0_dout_reg)
begin
for i in 0 to 31 loop
sys_gpo_0(i) <= 'Z';
if gpio_0_dir_reg(i) = '1' then
sys_gpo_0(i) <= gpio_0_dout_reg(i);
end if;
end loop;
end process;
------------------------------------------------------------------
gpio_0_in:
led_out:
process(CLK_I)
begin
if rising_edge(CLK_I) then
for i in 0 to 31 loop
if gpio_0_dir_reg(i) = '1' then
gpio_0_din_reg(i) <= gpio_0_dout_reg(i);
else
gpio_0_din_reg(i) <= sys_gpi_0(i);
end if;
end loop;
sys_gpo0 <= gpo0_reg;
sys_gpo1 <= gpo1_reg;
end if;
end process;
------------------------------------------------------------------
btn_ps2_in:
process(CLK_I)
begin
if rising_edge(CLK_I) then
gpi0_reg <= sys_gpi0;
gpi1_reg <= sys_gpi1;
end if;
end process;
------------------------------------------------------------------
registers_write:
process(CLK_I)
@@ -117,19 +106,41 @@ registers_write:
timer_cmp_we <= (others => '0');
timer_irq_ack <= (others => '0');
if RST_I = '1' then
gpio_0_dout_reg <= (others => '0');
gpio_0_dir_reg <= (others => '0');
timer_en <= (others => '0');
timer_inten <= (others => '0');
gpo0_reg <= (others => '0');
gpo1_reg <= (others => '0');
timer_en <= (others => '0');
timer_inten <= (others => '0');
elsif (STB_I and CYC_I and WE_I) = '1' then
reg_data_wr <= DAT_I;
case ADDR_I(6 downto 2) is
when "00000" =>
gpio_0_dout_reg <= DAT_I;
if SEL_I(0) = '1' then
gpo0_reg(7 downto 0) <= DAT_I(7 downto 0);
end if;
if SEL_I(1) = '1' then
gpo0_reg(15 downto 8) <= DAT_I(15 downto 8);
end if;
if SEL_I(2) = '1' then
gpo0_reg(23 downto 16) <= DAT_I(23 downto 16);
end if;
if SEL_I(3) = '1' then
gpo0_reg(31 downto 24) <= DAT_I(31 downto 24);
end if;
when "00001" =>
gpio_0_dir_reg <= DAT_I;
if SEL_I(0) = '1' then
gpo1_reg(7 downto 0) <= DAT_I(7 downto 0);
end if;
if SEL_I(1) = '1' then
gpo1_reg(15 downto 8) <= DAT_I(15 downto 8);
end if;
if SEL_I(2) = '1' then
gpo1_reg(23 downto 16) <= DAT_I(23 downto 16);
end if;
if SEL_I(3) = '1' then
gpo1_reg(31 downto 24) <= DAT_I(31 downto 24);
end if;
when "00010" =>
cnt_usec_we <= '1';
@@ -176,10 +187,10 @@ registers_read:
case ADDR_I(6 downto 2) is
when "00000" =>
DAT_O <= gpio_0_din_reg;
DAT_O <= gpi0_reg;
when "00001" =>
DAT_O <= gpio_0_dir_reg;
DAT_O <= gpi1_reg;
when "00010" =>
DAT_O <= cnt_usec;
@@ -240,7 +251,7 @@ cnt_usec_clock:
if cnt_usec_we = '1' then
cnt_usec <= reg_data_wr;
elsif cnt_usec_en = '1' then
if to_01(cnt_usec) >= to_unsigned(1E6 - 1, 32) then
if cnt_usec >= to_unsigned(1E6 - 1, 32) then
cnt_usec <= (others => '0');
cnt_sec_en <= '1';
else
@@ -277,7 +288,7 @@ proc_int_timer:
elsif timer_cnt_we(i) = '1' then
timer_cnt(i) <= reg_data_wr;
elsif timer_en(i) = '1' then
if to_01(timer_cnt(i)) >= timer_cmp(i) then
if timer_cnt(i) >= timer_cmp(i) then
timer_cnt(i) <= (others => '0');
if timer_inten(i) = '1' then
if timer_irq(i) = '1' then