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

Subversion Repositories cryptosorter

[/] [cryptosorter/] [trunk/] [memocodeDesignContest2008/] [xup/] [PLBMaster/] [PLBMasterDummy.bsv] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 kfleming
import RegFile         ::*;
2
import Interfaces      ::*;
3
import Types           ::*;
4
import Memocode08Types ::*;
5
import Parameters      ::*;
6
import FIFO            ::*;
7
import GetPut          ::*;
8
import Connectable     ::*;
9
import Memocode08Types ::*;
10
 
11
`define DummyDebug False
12
 
13
module mkPLBMasterDummy(PLBMaster);
14
 
15
   Reg#(Bit#(5)) stall   <- mkReg(~0);
16
   Reg#(Bit#(2)) jitter1  <- mkReg(0);
17
   Reg#(Bit#(1)) jitter2  <- mkReg(1);
18
   BlockAddr bank_mask = (fromInteger(valueOf(MemBankSelector))>>2);
19
 
20
   RegFile#(Bit#(18), Record)         mem_hi <- mkRegFileFull();
21
   RegFile#(Bit#(18), Record)         mem_lo <- mkRegFileFullLoad("unsorted.hex");
22
   Reg#(BlockAddr)           plbMasterCount <- mkReg(0);
23
 
24
   FIFO#(PLBMasterCommand) stall_fifo       <- mkFIFO();
25
   FIFO#(PLBMasterCommand) plbMasterCommand <- mkFIFO();
26
 
27
 
28
   function Tuple2#(Bool,BlockAddr) m(PLBMasterCommand a);
29
      if (a matches tagged LoadPage .addr)
30
         return tuple2(True,addr);
31
      else
32
         return tuple2(False,?);
33
   endfunction
34
 
35
   rule toggle (True);
36
      jitter1 <= jitter1-1;
37
      jitter2 <= jitter2-1;
38
   endrule
39
 
40
   rule decr_stall (stall != 0);
41
      stall <= stall-1;
42
   endrule
43
 
44
   rule xfer (stall==0);
45
      plbMasterCommand.enq(stall_fifo.first());
46
      stall_fifo.deq();
47
      stall <= maxBound;
48
   endrule
49
 
50
   interface Put wordInput;
51
   method Action put(Record wordInput) if(plbMasterCommand.first matches (tagged StorePage .addr) &&& (jitter1==0));
52
      let mem = ((addr&bank_mask)!=0) ? mem_hi : mem_lo;
53
      let idx = (addr>>2) + plbMasterCount;
54
      mem.upd(truncate(pack(idx)), wordInput);
55
      if(`DummyDebug) $display("plbMaster put %d", plbMasterCount);
56
      if(plbMasterCount + 1 == fromInteger(valueOf(RecordsPerMemRequest)))
57
         begin
58
            plbMasterCommand.deq;
59
            plbMasterCount <= 0;
60
         end
61
      else
62
         begin
63
            plbMasterCount <= plbMasterCount + 1;
64
         end
65
 
66
      if(`DummyDebug) $display("%m call put with addr %x mask %x",addr, addr&bank_mask);
67
   endmethod
68
   endinterface
69
 
70
 
71
   // using this function m is ugly, but I can't get the damn match syntax to parse
72
   // correctly inthe rule predicate... FUCK!
73
   interface Get wordOutput;
74
   method ActionValue#(Record) get() if(plbMasterCommand.first matches (tagged LoadPage .addr) &&& (jitter2==0));
75
      let mem = ((addr&bank_mask)!=0) ? mem_hi : mem_lo;
76
      let idx = (addr>>2) + plbMasterCount;
77
      let rv  = mem.sub(truncate(pack(idx)));
78
      if(`DummyDebug) $display("plbMaster get %d", plbMasterCount);
79
      if(`DummyDebug) $display("%m call get with addr %x mask %x",addr, addr&bank_mask);
80
      if(plbMasterCount + 1 == fromInteger(valueOf(RecordsPerMemRequest)))
81
         begin
82
            plbMasterCommand.deq;
83
            plbMasterCount <= 0;
84
         end
85
      else
86
         begin
87
            plbMasterCount <= plbMasterCount + 1;
88
         end
89
      return rv;
90
   endmethod
91
   endinterface
92
 
93
   interface Put plbMasterCommandInput;
94
      method Action put(PLBMasterCommand command);
95
         if(command matches tagged LoadPage .addr)
96
            begin
97
               if(`DummyDebug) $display("plbMasterCommand load %h", addr);
98
            end
99
         else if(command matches tagged StorePage .addr)
100
            begin
101
               if(`DummyDebug) $display("plbMasterCommand store %h", addr);
102
            end
103
         else
104
            $error();
105
         stall_fifo.enq(command);
106
   endmethod
107
   endinterface
108
 
109
   interface plbMasterWires = ?;
110
endmodule

powered by: WebSVN 2.1.0

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