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

Subversion Repositories potato

[/] [potato/] [trunk/] [example/] [imem_wrapper.vhd] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 skordal
-- The Potato Processor - A simple processor for FPGAs
2 7 skordal
-- (c) Kristian Klomsten Skordal 2015 <kristian.skordal@wafflemail.net>
3 12 skordal
-- Report bugs and issues on <http://opencores.org/project,potato,bugtracker>
4 7 skordal
 
5
library ieee;
6
use ieee.std_logic_1164.all;
7
 
8
entity imem_wrapper is
9
        port(
10
                clk   : in std_logic;
11
                reset : in std_logic;
12
 
13
                -- Wishbone interface:
14
                wb_adr_in  : in  std_logic_vector(12 downto 0);
15
                wb_dat_out : out std_logic_vector(31 downto 0);
16
                wb_cyc_in  : in  std_logic;
17
                wb_stb_in  : in  std_logic;
18
                wb_ack_out : out std_logic
19
        );
20
end entity imem_wrapper;
21
 
22
architecture behaviour of imem_wrapper is
23
 
24
        type wb_state is (IDLE, READ_ACK);
25
        signal state : wb_state := IDLE;
26
 
27
        signal address : std_logic_vector(10 downto 0);
28
        signal data : std_logic_vector(31 downto 0);
29
 
30
        signal ack : std_logic := '0';
31
 
32
begin
33
 
34
        imem: entity work.instruction_rom
35
                port map(
36
                        clka => clk,
37
                        addra => address,
38
                        douta => wb_dat_out
39
                );
40
 
41
        wb_ack_out <= ack and wb_cyc_in and wb_stb_in;
42
 
43
        wishbone: process(clk)
44
        begin
45
                if rising_edge(clk) then
46
                        if reset = '1' then
47
                                ack <= '0';
48
                                state <= IDLE;
49
                        else
50
                                case state is
51
                                        when IDLE =>
52
                                                if wb_cyc_in = '1' and wb_stb_in = '1' then
53
                                                        address <= wb_adr_in(12 downto 2);
54
                                                        state <= READ_ACK;
55
                                                end if;
56
                                        when READ_ACK =>
57
                                                if ack = '0' then
58
                                                        ack <= '1';
59
                                                elsif wb_stb_in = '0' then
60
                                                        ack <= '0';
61
                                                        state <= IDLE;
62
                                                end if;
63
                                end case;
64
                        end if;
65
                end if;
66
        end process wishbone;
67
 
68
end architecture behaviour;

powered by: WebSVN 2.1.0

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