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

Subversion Repositories bluespec-80211atransmitter

[/] [bluespec-80211atransmitter/] [trunk/] [Controller.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
import FIFO::*;
27
import DataTypes::*;
28
import Interfaces::*;
29
import LibraryFunctions::*;
30
 
31
function Header#(24) makeHeader(Rate rate, Bit#(12) length);
32
   function Bit#(4) translate_rate(Rate r);
33
      case (r)
34
        R1:      return 4'b1101;
35
        R2:      return 4'b1111;
36
        R4:      return 4'b0101;
37
        default: return ?;
38
      endcase
39
   endfunction
40
 
41
   function Bit#(12) translate_length (Bit#(12) x) = reverseBits(x);
42
 
43
   Bit#(1) parity = getParity({translate_rate(rate),length});
44
 
45
   return({translate_rate(rate),1'b0,translate_length(length),parity,6'b0});
46
 
47
endfunction
48
 
49
 
50
(* synthesize *)
51
module mkController(Controller#(24,24,24));
52
  FIFO#(RateData#(24)) toS  <- mkFIFO();
53
  FIFO#(Header#(24))   toC  <- mkFIFO();
54
 
55
  Reg#(Bool)     active <- mkReg(False);
56
  Reg#(Bit#(12)) length <- mkRegU;
57
  Reg#(Rate)       rate <- mkRegU;
58
 
59
  method Action getFromMAC(TXMAC2ControllerInfo x) if (!active);
60
     active <= True;
61
     length <= x.length();
62
     rate   <= x.rate();
63
     toC.enq( makeHeader(x.rate, x.length));
64
  endmethod
65
 
66
  method Action getDataFromMAC(Data#(24) x) if (active);
67
     toS.enq(RateData{
68
               rate: rate,
69
               data: x.data
70
              });
71
     rate   <= RNone;
72
     length <= length - 3;
73
     if (length <= 3 )
74
        active <= False;
75
  endmethod
76
 
77
  method ActionValue#(Header#(24)) getHeader();
78
     toC.deq();
79
     return(toC.first);
80
  endmethod
81
 
82
  method ActionValue#(RateData#(24)) getData();
83
     toS.deq();
84
     return(toS.first);
85
  endmethod
86
 
87
endmodule

powered by: WebSVN 2.1.0

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