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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [VHDL/] [o8_romtape_8k.vhd] - Blame information for rev 327

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 324 jshamlet
-- Copyright (c)2023 Jeremy Seth Henry
2
-- All rights reserved.
3
--
4
-- Redistribution and use in source and binary forms, with or without
5
-- modification, are permitted provided that the following conditions are met:
6
--     * Redistributions of source code must retain the above copyright
7
--       notice, this list of conditions and the following disclaimer.
8
--     * Redistributions in binary form must reproduce the above copyright
9
--       notice, this list of conditions and the following disclaimer in the
10
--       documentation and/or other materials provided with the distribution,
11
--       where applicable (as part of a user interface, debugging port, etc.)
12
--
13
-- THIS SOFTWARE IS PROVIDED BY JEREMY SETH HENRY ``AS IS'' AND ANY
14
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
-- DISCLAIMED. IN NO EVENT SHALL JEREMY SETH HENRY BE LIABLE FOR ANY
17
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
--
24
-- VHDL Units :  o8_romtape_8k
25
-- Description:  Provides serial FIFO-like access to an 8k ROM with settable
26
--            :   start address and increment. Automatically increments on
27
--            :   read.
28
--            :  This allows for bulk data to be accessed without using up
29
--            :   large amounts of address space, such as text strings or
30
--            :   configuration parameters.
31
--
32
--            :  Note 1: The ROM Position register tracks the internal
33
--            :   address, and will change once the ROM is accessed.
34
--
35
--            :  Note 2: The ROM Address Auto-Increment value is a signed
36
--            :   offset. This implies that the auto-increment varies from
37
--            :   -128 to 127.
38
--            :   A value of 0x00 will disable the auto-increment function.
39
 
40
-- WP Register Map:
41
-- Offset  Bitfield Description                        Read/Write
42
--   0x00  AAAAAAAA ROM Data                             (RO)
43
--   0x01  AAAAAAAA ROM Address Auto-Increment           (RW)
44
--   0x02  AAAAAAAA ROM Position (lower)                 (RW)
45
--   0x03  ---AAAAA ROM Position (upper)                 (RW)
46
--
47
-- Revision History
48
-- Author          Date     Change
49
------------------ -------- ---------------------------------------------------
50
-- Seth Henry      07/18/23 Initial Design
51
 
52
library ieee;
53
use ieee.std_logic_1164.all;
54
use ieee.std_logic_signed.all;
55
use ieee.std_logic_arith.all;
56
 
57
library work;
58
  use work.open8_pkg.all;
59
 
60
entity o8_romtape_8k is
61
generic(
62
  Address                    : ADDRESS_TYPE
63
);
64
port(
65
  Open8_Bus                  : in  OPEN8_BUS_TYPE;
66
  Write_Qual                 : in  std_logic := '1';
67
  Rd_Data                    : out DATA_TYPE
68
);
69
end entity;
70
 
71
architecture behave of o8_romtape_8k is
72
 
73
  alias Clock                is Open8_Bus.Clock;
74
  alias Reset                is Open8_Bus.Reset;
75
 
76
  constant User_Addr         : std_logic_vector(15 downto 2)
77
                               := Address(15 downto 2);
78
  alias  Comp_Addr           is Open8_Bus.Address(15 downto 2);
79
  signal Addr_Match          : std_logic;
80
 
81
  alias  Reg_Addr            is Open8_Bus.Address(1 downto 0);
82
  signal Reg_Sel             : std_logic_vector(1 downto 0);
83
 
84
  signal Wr_En               : std_logic := '0';
85
  signal Wr_Data             : DATA_TYPE := OPEN8_NULLBUS;
86
  signal Rd_En               : std_logic := '0';
87
 
88
  signal Address_Ptr         : signed(12 downto 0);
89
  alias  Address_Ptr_L       is Address_Ptr(7 downto 0);
90
  alias  Address_Ptr_H       is Address_Ptr(12 downto 8);
91
 
92
  signal Address_Incr        : signed(12 downto 0);
93
  alias  Address_Incr_L      is Address_Incr(7 downto 0);
94
  alias  Address_Incr_H      is Address_Incr(12 downto 8);
95
 
96
  constant DEFLT_INCR        : signed(12 downto 0) :=
97
                                 conv_signed(1,13);
98
 
99
  signal ROM_Ptr             : std_logic_vector(12 downto 0);
100
  signal ROM_Data            : std_logic_vector(7 downto 0);
101
 
102
begin
103
 
104
  -- Due to reads altering the state of the entity, all access should be
105
  --  qualified by Write_Qual
106
  Addr_Match                 <= Write_Qual when Comp_Addr = User_Addr else '0';
107
 
108
  Reg_proc: process( Reset, Clock )
109
  begin
110
    if( Reset = Reset_Level )then
111
 
112
      Address_Ptr            <= (others => '0');
113
      Address_Incr           <= DEFLT_INCR;
114
 
115
      Reg_Sel                <= (others => '0');
116
      Wr_En                  <= '0';
117
      Wr_Data                <= OPEN8_NULLBUS;
118
      Rd_En                  <= '0';
119
 
120
      Rd_Data                <= OPEN8_NULLBUS;
121
 
122
    elsif( rising_edge(Clock) )then
123
      Reg_Sel                <= Reg_Addr;
124
 
125
      Wr_En                  <= Addr_Match and Open8_Bus.Wr_En;
126
      Wr_Data                <= Open8_Bus.Wr_Data;
127
      if( Wr_en = '1' )then
128
        case( Reg_Sel )is
129
          when "01" =>
130
            Address_Incr_L   <= signed(Wr_Data);
131
            Address_Incr_H   <= (others => Wr_Data(7));
132
          when "10" =>
133
            Address_Ptr_L    <= signed(Wr_Data);
134
          when "11" =>
135
            Address_Ptr_H    <= signed(Wr_Data(4 downto 0));
136
          when others =>
137
            null;
138
        end case;
139
      end if;
140
 
141
      Rd_En                  <= Addr_Match and Open8_Bus.Rd_En;
142
 
143
      Rd_Data                <= OPEN8_NULLBUS;
144
      if( Rd_En = '1' )then
145
        case( Reg_Sel )is
146
          when "00" =>
147
            Rd_Data          <= ROM_Data;
148
            Address_Ptr      <= Address_Ptr + Address_Incr;
149
          when "01" =>
150
            Rd_Data          <= std_logic_vector(Address_Incr_L);
151
          when "10" =>
152
            Rd_Data          <= ROM_Ptr(7 downto 0);
153
          when "11" =>
154
            Rd_Data          <= "000" & ROM_Ptr(12 downto 8);
155
          when others =>
156
            null;
157
        end case;
158
      end if;
159
 
160
    end if;
161
  end process;
162
 
163
  ROM_Ptr                    <= std_logic_vector(Address_Ptr);
164
 
165
  U_ROM : entity work.rom_8k_core
166
  port map(
167
    address                  => ROM_Ptr,
168
    clock                    => Clock,
169
    q                        => ROM_Data
170
  );
171
 
172
end architecture;

powered by: WebSVN 2.1.0

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