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-31.vhdl] - Blame information for rev 37

Go to most recent revision | 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, tauhop.axiTransactor.all;
44
 
45
entity prbs31 is
46
        generic(
47
                isParallelLoad: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|3|31=>true, 1|2|30 downto 4=>false
54
                )
55
        );
56
        port(
57
                /* Comment-out for simulation. */
58
                clk,reset:in std_ulogic;
59
                en:in boolean;
60
--              seed:in unsigned(tapVector'high downto 0);
61
--              prbs:out unsigned(31 downto 0):=(others=>'0')
62
                seed:in i_transactor.t_msg;
63
                prbs:out i_transactor.t_msg
64
        );
65
end entity prbs31;
66
 
67
architecture rtl of prbs31 is
68
        signal n,c:natural;
69
 
70
        /* Tester signals. */
71
        signal d:std_ulogic;
72
        /* synthesis translate_off */
73
--      signal clk,reset:std_ulogic:='0';
74
        /* synthesis translate_on */
75
 
76
        signal loadEn:std_ulogic;               -- clock gating.
77
        signal load:boolean;
78
--      signal loadEn,computeClk:std_ulogic;            -- clock gating.
79
        signal loaded,i_loaded:boolean;
80
--      signal computed,i_computed:boolean;
81
 
82
begin
83
--      loadEn<=clk when reset='0' and not i_computed else '0';
84
        loadEn<=clk when reset='0' and en else '0';
85
 
86
        /* Galois LFSR instance. */
87
        i_lfsr: entity tauhop.lfsr(rtl)
88
                generic map(taps=>tapVector)
89
                /*generic map(taps => (
90
                        0|1|2|8=>true,
91
                        7 downto 3=>false
92
                ))*/
93
                port map(nReset=>not reset, clk=>loadEn,
94
--                      load=>isParallelLoad,
95
                        load=>load,
96
                        seed=>seed,
97
                        d=>d,
98
                        q=>prbs(prbs'range)
99
        );
100
 
101
        /* Load message into LFSR. */
102
        process(reset,loadEn) is begin
103
                if reset then loaded<=false; n<=seed'length-1; d<='0';
104
--              if reset then loaded<=false; n<=seed'length-1;
105
                elsif rising_edge(loadEn) then
106
                        d<='0';
107
 
108
                        /* for parallel mode, LFSR automatically loads the seed in parallel. */
109
                        if isParallelLoad then loaded<=true;
110
                        else
111
                                if not loaded then d<=seed(n); end if;
112
 
113
                                if n>0 then n<=n-1;
114
                                else loaded<=true;
115
                                end if;
116
                        end if;
117
                end if;
118
        end process;
119
 
120
        load<=(loaded xor i_loaded) and isParallelLoad and reset='0';
121
 
122
        /* Register pipelines. */
123
    process(clk) is begin
124
        if rising_edge(clk) then
125
            i_loaded<=loaded;
126
        end if;
127
    end process;
128
end architecture rtl;

powered by: WebSVN 2.1.0

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