OpenCores
URL https://opencores.org/ocsvn/bluespec-80211atransmitter/bluespec-80211atransmitter/trunk

Subversion Repositories bluespec-80211atransmitter

[/] [bluespec-80211atransmitter/] [trunk/] [Scrambler.bsv] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ndave
// The MIT License
2
//
3
// Copyright (c) 2006 Nirav Dave (ndave@csail.mit.edu)
4
//
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
//
12
// The above copyright notice and this permission notice shall be included in
13
// all copies or substantial portions of the Software.
14
//
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
// THE SOFTWARE.
22
 
23
 
24
 
25
 
26
// *************************************************************************
27
//  Scrambler.bsv
28
// *************************************************************************
29
import DataTypes::*;
30
import Interfaces::*;
31
 
32
import LibraryFunctions::*;
33
import FIFO::*;
34
 
35
 
36
interface Scrambler#(type n);
37
   //inputs
38
   method Action fromControl(RateData#(n) x);
39
 
40
   //outputs
41
   method ActionValue#(RateData#(n))  toEncoder();
42
endinterface
43
 
44
(* synthesize *)
45
module mkScrambler_48(Scrambler#(24));
46
   let _s <- mkScrambler();
47
   return (_s);
48
endmodule
49
 
50
module mkScrambler(Scrambler#(n));
51
 
52
  Reg#(Bit#(7))       seqR <- mkRegU;
53
  FIFO#(RateData#(n)) outQ <- mkFIFO();
54
 
55
  method Action fromControl(RateData#(n) x);
56
     Bit#(7) headSeq = case (x.rate)
57
                          R1   : return 7'b1001011;
58
                          R2   : return 7'b1001011;
59
                          R4   : return 7'b1001011;
60
                          RNone: return seqR;
61
                       endcase;
62
 
63
     Bit#(7) scram_seq = headSeq;
64
 
65
     Bit#(1) newS;
66
     Bit#(n) inData  = x.data;
67
     Bit#(n) outData = 0;
68
 
69
     for(Integer i = 0; i < valueOf(n); i = i + 1)
70
        begin
71
           newS = scram_seq[0] ^ scram_seq[3];
72
           outData[i] = newS ^ inData[i];
73
           scram_seq = {newS,scram_seq[6:1]};
74
        end
75
 
76
     outQ.enq(RateData{
77
        rate: x.rate,
78
        data: outData
79
        });
80
 
81
   endmethod
82
 
83
   method ActionValue#(RateData#(n)) toEncoder();
84
      outQ.deq();
85
      return(outQ.first());
86
   endmethod
87
 
88
endmodule

powered by: WebSVN 2.1.0

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