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

Subversion Repositories axi4_tlm_bfm

[/] [axi4_tlm_bfm/] [trunk/] [tester/] [stimuli/] [prbs-15.vhdl] - Blame information for rev 24

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 daniel.kho
/*
2
        This file is part of the Galois Linear Feedback Shift Register
3
        (galois_lfsr) project:
4
                http://www.opencores.org/project,galois_lfsr
5
 
6
        Description
7
        Synthesisable use case for Galois LFSR.
8
        This example is a CRC generator that uses a Galois LFSR.
9
 
10
        ToDo:
11
 
12
        Author(s):
13
        - Daniel C.K. Kho, daniel.kho@opencores.org | daniel.kho@tauhop.com
14
 
15
        Copyright (C) 2012-2013 Authors and OPENCORES.ORG
16
 
17
        This source file may be used and distributed without
18
        restriction provided that this copyright statement is not
19
        removed from the file and that any derivative work contains
20
        the original copyright notice and the associated disclaimer.
21
 
22
        This source file is free software; you can redistribute it
23
        and/or modify it under the terms of the GNU Lesser General
24
        Public License as published by the Free Software Foundation;
25
        either version 2.1 of the License, or (at your option) any
26
        later version.
27
 
28
        This source is distributed in the hope that it will be
29
        useful, but WITHOUT ANY WARRANTY; without even the implied
30
        warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
31
        PURPOSE. See the GNU Lesser General Public License for more
32
        details.
33
 
34
        You should have received a copy of the GNU Lesser General
35
        Public License along with this source; if not, download it
36
        from http://www.opencores.org/lgpl.shtml.
37
*/
38
library ieee; use ieee.std_logic_1164.all, ieee.numeric_std.all; use ieee.math_real.all;
39
/* Enable for synthesis; comment out for simulation.
40
        For this design, we just need boolean_vector. This is already included in Questa/ModelSim,
41
        but Quartus doesn't yet support this.
42
*/
43
library tauhop; use tauhop.types.all;
44
 
45
entity prbs15 is
46
        generic(
47
                parallelLoad:boolean:=false;
48
                tapVector:boolean_vector:=(
49
                        /* Example polynomial from Wikipedia:
50
                                http://en.wikipedia.org/wiki/Computation_of_cyclic_redundancy_checks
51
                        */
52
                        --0|1|2|8=>true, 7 downto 3=>false
53
                        0|1|15=>true, 14 downto 2=>false
54
                )
55
        );
56
        port(
57
                /* Comment-out for simulation. */
58
                clk,reset:in std_ulogic;
59
                seed:in unsigned(tapVector'high downto 0):=16x"ace1";            --9x"57";
60
                prbs:out unsigned(15 downto 0):=(others=>'0')
61
        );
62
end entity prbs15;
63
 
64
architecture rtl of prbs15 is
65
        signal n,c:natural;
66
 
67
        /* Tester signals. */
68
        signal d:std_ulogic;
69
        /* synthesis translate_off */
70
--      signal clk,reset:std_ulogic:='0';
71
        /* synthesis translate_on */
72
 
73
        signal loadEn:std_ulogic;               -- clock gating.
74
--      signal loadEn,computeClk:std_ulogic;            -- clock gating.
75
        signal loaded:boolean;
76
--      signal computed,i_computed:boolean;
77
 
78
begin
79
--      loadEn<=clk when reset='0' and not i_computed else '0';
80
        loadEn<=clk when reset='0' else '0';
81
 
82
        /* Galois LFSR instance. */
83
        i_lfsr: entity work.lfsr(rtl)
84
                generic map(taps=>tapVector)
85
                /*generic map(taps => (
86
                        0|1|2|8=>true,
87
                        7 downto 3=>false
88
                ))*/
89
                port map(nReset=>not reset, clk=>loadEn,
90
                        load=>parallelLoad,
91
                        seed=>seed,
92
                        d=>d,
93
                        q=>prbs(prbs'range)
94
        );
95
 
96
        /* Load message into LFSR. */
97
        process(reset,loadEn) is begin
98
                if reset then loaded<=false; n<=seed'length-1; d<='0';
99
--              if reset then loaded<=false; n<=seed'length-1;
100
                elsif rising_edge(loadEn) then
101
                        d<='0';
102
 
103
                        /* for parallel mode, LFSR automatically loads the seed in parallel. */
104
                        if parallelLoad then d<='0'; loaded<=true;
105
--                      if parallelLoad then loaded<=true;
106
                        else
107
                                if not loaded then d<=seed(n); end if;
108
 
109
                                if n>0 then n<=n-1;
110
                                else loaded<=true;
111
                                end if;
112
                        end if;
113
                end if;
114
        end process;
115
 
116
--      d<=seed(n) when rising_edge(loadEn);
117
end architecture rtl;

powered by: WebSVN 2.1.0

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