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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [VHDL/] [o8_lfsr32.vhd] - Blame information for rev 244

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 214 jshamlet
-- Copyright (c)2018, 2020 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_register
25
-- Description:  Provides a byte of pseudo-random data on every read
26
--
27
-- Register Map:
28
-- Offset  Bitfield Description                        Read/Write
29
--   0x00  AAAAAAAA Data output                          (RW)
30
--
31
-- Revision History
32
-- Author          Date     Change
33
------------------ -------- ---------------------------------------------------
34
-- Seth Henry      04/25/18 Design Start
35
-- Seth Henry      04/10/20 Code cleanup and comments
36 224 jshamlet
-- Seth Henry      04/16/20 Modified to use Open8 bus record
37 214 jshamlet
 
38
library ieee;
39
  use ieee.std_logic_1164.all;
40
  use ieee.std_logic_misc.all;
41
 
42
library work;
43
  use work.open8_pkg.all;
44
 
45
entity o8_lfsr32 is
46
generic(
47 217 jshamlet
  Init_Seed                  : std_logic_vector(31 downto 0) := x"CAFEBABE";
48
  Address                    : ADDRESS_TYPE
49 214 jshamlet
);
50
port(
51 223 jshamlet
  Open8_Bus                  : in OPEN8_BUS_TYPE;
52 217 jshamlet
  Rd_Data                    : out DATA_TYPE
53 214 jshamlet
);
54
end entity;
55
 
56
architecture behave of o8_lfsr32 is
57
 
58 224 jshamlet
  alias Clock                is Open8_Bus.Clock;
59
  alias Reset                is Open8_Bus.Reset;
60
 
61 217 jshamlet
  constant User_Addr         : std_logic_vector(15 downto 1)
62
                               := Address(15 downto 1);
63 223 jshamlet
  alias  Comp_Addr           is Open8_Bus.Address(15 downto 1);
64 244 jshamlet
  signal Addr_Match          : std_logic := '0';
65
  alias  Reg_Sel_d           is Open8_Bus.Address(0);
66 217 jshamlet
  signal Reg_Sel_q           : std_logic := '0';
67 244 jshamlet
  signal Rd_En_d             : std_logic := '0';
68
  signal Rd_En_q             : std_logic := '0';
69 214 jshamlet
 
70 217 jshamlet
  signal d0                  : std_logic := '0';
71
  signal lfsr                : std_logic_vector(31 downto 0) := x"00000000";
72
  signal lfsr_q              : std_logic_vector(31 downto 0) := x"00000000";
73 214 jshamlet
 
74
begin
75
 
76 244 jshamlet
  Addr_Match                 <= '1' when Comp_Addr = User_Addr else '0';
77
  Rd_En_d                    <= Addr_Match and Open8_Bus.Rd_En;
78
 
79 217 jshamlet
  d0                         <= lfsr(31) xnor lfsr(21) xnor lfsr(1) xnor lfsr(0);
80 214 jshamlet
 
81
  lfsr_proc: process( Clock, Reset )
82
  begin
83
    if( Reset = Reset_Level )then
84 217 jshamlet
      Reg_Sel_q              <= '0';
85 244 jshamlet
      Rd_En_q                <= '0';
86 217 jshamlet
      Rd_Data                <= x"00";
87
      lfsr                   <= Init_Seed;
88
      lfsr_q                 <= x"00000000";
89 214 jshamlet
    elsif( rising_edge(Clock) )then
90 244 jshamlet
      Reg_Sel_q              <= Reg_Sel_d;
91
 
92
      Rd_En_q                <= Rd_En_d;
93
      Rd_Data                <= OPEN8_NULLBUS;
94
      if( Rd_En_q = '1' )then
95 217 jshamlet
        Rd_Data              <= lfsr_q(31 downto 24);
96
        lfsr_q               <= lfsr_q(23 downto 0) & x"00";
97 214 jshamlet
        if( Reg_Sel_q = '1' )then
98 217 jshamlet
          Rd_Data            <= lfsr_q(31) & "0000000";
99
          lfsr_q             <= lfsr_q(30 downto 0) & '0';
100 214 jshamlet
        end if;
101
      end if;
102
 
103
      if( or_reduce(lfsr_q) = '0' )then
104 217 jshamlet
        lfsr_q               <= lfsr;
105
        lfsr                 <= lfsr(30 downto 0) & d0;
106 214 jshamlet
      end if;
107
    end if;
108
  end process;
109
 
110
end architecture;

powered by: WebSVN 2.1.0

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