OpenCores
URL https://opencores.org/ocsvn/lxp32/lxp32/trunk

Subversion Repositories lxp32

[/] [lxp32/] [trunk/] [rtl/] [lxp32_dbus.vhd] - Diff between revs 2 and 6

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 2 Rev 6
Line 52... Line 52...
signal byte_mode: std_logic;
signal byte_mode: std_logic;
signal sel: std_logic_vector(3 downto 0);
signal sel: std_logic_vector(3 downto 0);
signal sig: std_logic;
signal sig: std_logic;
signal rmw_mode: std_logic;
signal rmw_mode: std_logic;
 
 
 
signal dbus_rdata: std_logic_vector(31 downto 0);
signal selected_byte: std_logic_vector(7 downto 0);
signal selected_byte: std_logic_vector(7 downto 0);
 
 
begin
begin
 
 
process (clk_i) is
process (clk_i) is
begin
begin
        if rising_edge(clk_i) then
        if rising_edge(clk_i) then
                if rst_i='1' then
                if rst_i='1' then
                        we_out<='0';
                        we_out<='0';
                        strobe<='0';
                        strobe<='0';
 
                        sig<='-';
 
                        byte_mode<='-';
 
                        sel<=(others=>'-');
 
                        we<='-';
 
                        rmw_mode<='-';
 
                        dbus_adr_o<=(others=>'-');
 
                        dbus_dat_o<=(others=>'-');
                else
                else
                        we_out<='0';
                        we_out<='0';
                        if strobe='0' then
                        if strobe='0' then
                                if valid_i='1' and cmd_dbus_i='1' then
                                if valid_i='1' and cmd_dbus_i='1' then
                                        strobe<='1';
                                        strobe<='1';
                                        sig<=cmd_signed_i;
                                        sig<=cmd_signed_i;
 
 
                                        dbus_adr_o<=addr_i(31 downto 2);
                                        dbus_adr_o<=addr_i(31 downto 2);
                                        dbus_dat_o<=wdata_i;
 
 
 
                                        if cmd_dbus_byte_i='0' then
                                        if cmd_dbus_byte_i='0' then
                                                byte_mode<='0';
                                                byte_mode<='0';
 
                                                dbus_dat_o<=wdata_i;
                                                sel<="1111";
                                                sel<="1111";
 
 
                                                -- synthesis translate_off
                                                -- synthesis translate_off
                                                assert addr_i(1 downto 0)="00"
                                                assert addr_i(1 downto 0)="00"
                                                        report "Misaligned word-granular access on data bus"
                                                        report "Misaligned word-granular access on data bus"
                                                        severity warning;
                                                        severity warning;
                                                -- synthesis translate_on
                                                -- synthesis translate_on
                                        else
                                        else
                                                byte_mode<='1';
                                                byte_mode<='1';
 
                                                dbus_dat_o<=wdata_i(7 downto 0)&wdata_i(7 downto 0)&
 
                                                        wdata_i(7 downto 0)&wdata_i(7 downto 0);
 
 
                                                case addr_i(1 downto 0) is
                                                case addr_i(1 downto 0) is
                                                when "00" => sel<="0001"; dbus_dat_o(7 downto 0)<=wdata_i(7 downto 0);
                                                when "00" => sel<="0001";
                                                when "01" => sel<="0010"; dbus_dat_o(15 downto 8)<=wdata_i(7 downto 0);
                                                when "01" => sel<="0010";
                                                when "10" => sel<="0100"; dbus_dat_o(23 downto 16)<=wdata_i(7 downto 0);
                                                when "10" => sel<="0100";
                                                when "11" => sel<="1000"; dbus_dat_o(31 downto 24)<=wdata_i(7 downto 0);
                                                when "11" => sel<="1000";
                                                when others =>
                                                when others =>
                                                end case;
                                                end case;
                                        end if;
                                        end if;
 
 
                                        if not RMW then
                                        if not RMW then
Line 134... Line 145...
 
 
sel_rmw_gen: if RMW generate
sel_rmw_gen: if RMW generate
        dbus_sel_o<=(others=>'1');
        dbus_sel_o<=(others=>'1');
end generate;
end generate;
 
 
selected_byte_gen: for i in selected_byte'range generate
 
        selected_byte(i)<=(dbus_dat_i(i) and sel(0)) or
 
                (dbus_dat_i(i+8) and sel(1)) or
 
                (dbus_dat_i(i+16) and sel(2)) or
 
                (dbus_dat_i(i+24) and sel(3));
 
end generate;
 
 
 
process (clk_i) is
process (clk_i) is
begin
begin
        if rising_edge(clk_i) then
        if rising_edge(clk_i) then
                if byte_mode='0' then
                dbus_rdata<=dbus_dat_i;
                        rdata_o<=dbus_dat_i;
 
                else
 
                        rdata_o(7 downto 0)<=selected_byte;
 
                        for i in rdata_o'high downto 8 loop
 
                                rdata_o(i)<=selected_byte(selected_byte'high) and sig;
 
                        end loop;
 
                end if;
 
        end if;
        end if;
end process;
end process;
 
 
 
selected_byte_gen: for i in selected_byte'range generate
 
        selected_byte(i)<=(dbus_rdata(i) and sel(0)) or
 
                (dbus_rdata(i+8) and sel(1)) or
 
                (dbus_rdata(i+16) and sel(2)) or
 
                (dbus_rdata(i+24) and sel(3));
 
end generate;
 
 
 
rdata_o<=dbus_rdata when byte_mode='0' else
 
        X"000000"&selected_byte when selected_byte(selected_byte'high)='0' or sig='0' else
 
        X"FFFFFF"&selected_byte;
 
 
we_o<=we_out;
we_o<=we_out;
busy_o<=strobe or we_out;
busy_o<=strobe or we_out;
 
 
end architecture;
end architecture;
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.