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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [VHDL/] [o8_register.vhd] - Blame information for rev 317

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

Line No. Rev Author Line
1 194 jshamlet
-- Copyright (c)2006, 2016, 2019, 2020 Jeremy Seth Henry
2 180 jshamlet
-- 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 194 jshamlet
-- (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 180 jshamlet
--
24
-- VHDL Units :  o8_register
25 213 jshamlet
-- Description:  Provides a single addressible 8-bit output register
26 180 jshamlet
--
27
-- Register Map:
28
-- Offset  Bitfield Description                        Read/Write
29
--   0x00  AAAAAAAA Registered Outputs                    (RW)
30
--
31
-- Revision History
32
-- Author          Date     Change
33
------------------ -------- ---------------------------------------------------
34
-- Seth Henry      12/20/19 Design Start
35 224 jshamlet
-- Seth Henry      04/16/20 Modified to use Open8 bus record
36 244 jshamlet
-- Seth Henry      05/18/20 Added write qualification input
37 180 jshamlet
 
38
library ieee;
39
  use ieee.std_logic_1164.all;
40
  use ieee.std_logic_unsigned.all;
41
  use ieee.std_logic_arith.all;
42 191 jshamlet
  use ieee.std_logic_misc.all;
43 180 jshamlet
 
44
library work;
45
  use work.open8_pkg.all;
46
 
47
entity o8_register is
48
generic(
49 217 jshamlet
  Default_Value              : DATA_TYPE := x"00";
50
  Address                    : ADDRESS_TYPE
51 180 jshamlet
);
52
port(
53 223 jshamlet
  Open8_Bus                  : in  OPEN8_BUS_TYPE;
54 244 jshamlet
  Write_Qual                 : in  std_logic := '1';
55 217 jshamlet
  Rd_Data                    : out DATA_TYPE;
56 180 jshamlet
  --
57 217 jshamlet
  Register_Out               : out DATA_TYPE
58 180 jshamlet
);
59
end entity;
60
 
61
architecture behave of o8_register is
62
 
63 224 jshamlet
  alias Clock                is Open8_Bus.Clock;
64
  alias Reset                is Open8_Bus.Reset;
65
 
66 217 jshamlet
  constant User_Addr         : std_logic_vector(15 downto 0)
67
                               := Address(15 downto 0);
68 223 jshamlet
  alias  Comp_Addr           is Open8_Bus.Address(15 downto 0);
69 217 jshamlet
  signal Addr_Match          : std_logic;
70 180 jshamlet
 
71 244 jshamlet
  signal Wr_En_d             : std_logic := '0';
72
  signal Wr_En_q             : std_logic := '0';
73
  alias  Wr_Data_d           is Open8_Bus.Wr_Data;
74
  signal Wr_Data_q           : DATA_TYPE := x"00";
75
  signal Rd_En_d             : std_logic := '0';
76
  signal Rd_En_q             : std_logic := '0';
77
 
78
  signal Reg_Out             : DATA_TYPE := x"00";
79
 
80 180 jshamlet
begin
81
 
82 217 jshamlet
  Addr_Match                 <= '1' when Comp_Addr = User_Addr else '0';
83 244 jshamlet
  Wr_En_d                    <= Addr_Match and Open8_Bus.Wr_En;
84
  Rd_En_d                    <= Addr_Match and Open8_Bus.Rd_En;
85 180 jshamlet
 
86
  io_reg: process( Clock, Reset )
87
  begin
88
    if( Reset = Reset_Level )then
89 244 jshamlet
      Wr_En_q                <= '0';
90 221 jshamlet
      Wr_Data_q              <= x"00";
91 217 jshamlet
      Reg_Out                <= Default_Value;
92 244 jshamlet
      Rd_En_q                <= '0';
93 217 jshamlet
      Rd_Data                <= OPEN8_NULLBUS;
94 180 jshamlet
    elsif( rising_edge( Clock ) )then
95 244 jshamlet
      Wr_En_q                <= Wr_En_d;
96
      Wr_Data_q              <= Wr_Data_d;
97
      if( Wr_En_q = '1' and Write_Qual = '1' )then
98 217 jshamlet
        Reg_Out              <= Wr_Data_q;
99 180 jshamlet
      end if;
100
 
101 217 jshamlet
      Rd_Data                <= OPEN8_NULLBUS;
102 244 jshamlet
      Rd_En_q                <= Rd_En_d;
103
      if( Rd_En_q = '1' )then
104 217 jshamlet
        Rd_Data              <= Reg_Out;
105 180 jshamlet
      end if;
106
    end if;
107
  end process;
108
 
109 217 jshamlet
  Register_Out               <= Reg_Out;
110 180 jshamlet
 
111
end architecture;

powered by: WebSVN 2.1.0

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