-- Practical Test Application for the Potato Processor
|
-- The Potato Processor - A simple processor for FPGAs
|
-- (c) Kristian Klomsten Skordal 2015 <kristian.skordal@wafflemail.net>
|
-- (c) Kristian Klomsten Skordal 2015 <kristian.skordal@wafflemail.net>
|
-- Report bugs and issues on <https://github.com/skordal/potato-test/issues>
|
-- Report bugs and issues on <http://opencores.org/project,potato,bugtracker>
|
|
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
|
|
entity imem_wrapper is
|
entity imem_wrapper is
|
port(
|
port(
|
clk : in std_logic;
|
clk : in std_logic;
|
reset : in std_logic;
|
reset : in std_logic;
|
|
|
-- Wishbone interface:
|
-- Wishbone interface:
|
wb_adr_in : in std_logic_vector(12 downto 0);
|
wb_adr_in : in std_logic_vector(12 downto 0);
|
wb_dat_out : out std_logic_vector(31 downto 0);
|
wb_dat_out : out std_logic_vector(31 downto 0);
|
wb_cyc_in : in std_logic;
|
wb_cyc_in : in std_logic;
|
wb_stb_in : in std_logic;
|
wb_stb_in : in std_logic;
|
wb_ack_out : out std_logic
|
wb_ack_out : out std_logic
|
);
|
);
|
end entity imem_wrapper;
|
end entity imem_wrapper;
|
|
|
architecture behaviour of imem_wrapper is
|
architecture behaviour of imem_wrapper is
|
|
|
type wb_state is (IDLE, READ_ACK);
|
type wb_state is (IDLE, READ_ACK);
|
signal state : wb_state := IDLE;
|
signal state : wb_state := IDLE;
|
|
|
signal address : std_logic_vector(10 downto 0);
|
signal address : std_logic_vector(10 downto 0);
|
signal data : std_logic_vector(31 downto 0);
|
signal data : std_logic_vector(31 downto 0);
|
|
|
signal ack : std_logic := '0';
|
signal ack : std_logic := '0';
|
|
|
begin
|
begin
|
|
|
imem: entity work.instruction_rom
|
imem: entity work.instruction_rom
|
port map(
|
port map(
|
clka => clk,
|
clka => clk,
|
addra => address,
|
addra => address,
|
douta => wb_dat_out
|
douta => wb_dat_out
|
);
|
);
|
|
|
wb_ack_out <= ack and wb_cyc_in and wb_stb_in;
|
wb_ack_out <= ack and wb_cyc_in and wb_stb_in;
|
|
|
wishbone: process(clk)
|
wishbone: process(clk)
|
begin
|
begin
|
if rising_edge(clk) then
|
if rising_edge(clk) then
|
if reset = '1' then
|
if reset = '1' then
|
ack <= '0';
|
ack <= '0';
|
state <= IDLE;
|
state <= IDLE;
|
else
|
else
|
case state is
|
case state is
|
when IDLE =>
|
when IDLE =>
|
if wb_cyc_in = '1' and wb_stb_in = '1' then
|
if wb_cyc_in = '1' and wb_stb_in = '1' then
|
address <= wb_adr_in(12 downto 2);
|
address <= wb_adr_in(12 downto 2);
|
state <= READ_ACK;
|
state <= READ_ACK;
|
end if;
|
end if;
|
when READ_ACK =>
|
when READ_ACK =>
|
if ack = '0' then
|
if ack = '0' then
|
ack <= '1';
|
ack <= '1';
|
elsif wb_stb_in = '0' then
|
elsif wb_stb_in = '0' then
|
ack <= '0';
|
ack <= '0';
|
state <= IDLE;
|
state <= IDLE;
|
end if;
|
end if;
|
end case;
|
end case;
|
end if;
|
end if;
|
end if;
|
end if;
|
end process wishbone;
|
end process wishbone;
|
|
|
end architecture behaviour;
|
end architecture behaviour;
|
|
|