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

Subversion Repositories axi4_tlm_bfm

[/] [axi4_tlm_bfm/] [trunk/] [rtl/] [quartus-synthesis/] [prbs-31.vhdl] - Blame information for rev 20

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

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

powered by: WebSVN 2.1.0

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