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

Subversion Repositories cryptosorter

[/] [cryptosorter/] [trunk/] [memocodeDesignContest2008/] [ctrl/] [mkTester.bsv] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 kfleming
/*
2
Copyright (c) 2008 MIT
3
 
4
Permission is hereby granted, free of charge, to any person
5
obtaining a copy of this software and associated documentation
6
files (the "Software"), to deal in the Software without
7
restriction, including without limitation the rights to use,
8
copy, modify, merge, publish, distribute, sublicense, and/or sell
9
copies of the Software, and to permit persons to whom the
10
Software is furnished to do so, subject to the following
11
conditions:
12
 
13
The above copyright notice and this permission notice shall be
14
included in all copies or substantial portions of the Software.
15
 
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
OTHER DEALINGS IN THE SOFTWARE.
24
 
25
Author: Myron King
26
*/
27
import Memocode08Types ::*;
28
import ExternalMemory  ::*;
29
import PLBMasterDummy  ::*;
30
import Interfaces      ::*;
31
import StmtFSM         ::*;
32
import GetPut          ::*;
33
import Vector          ::*;
34
import FIFO            ::*;
35
import Four2OneMerger  ::*;
36
 
37
typedef Bit#(TLog#(RecordsPerMemRequest)) RpmrBits;
38
 
39
module mkEMTB (Empty);
40
 
41
   let recwid        = fromInteger(valueOf(RecordWidth));
42
   let rpmr          = fromInteger(valueOf(RecordsPerMemRequest));
43
   RpmrBits rpmr_msk = 0;
44
 
45
   PLBMaster dummy       <- mkPLBMasterDummy();
46
   ExternalMemory extMem <- mkExternalMemory(dummy);
47
   Reg#(Bit#(32)) count  <- mkReg(0);
48
   Reg#(int) state       <- mkReg(0);
49
   Reg#(Bool) need_req   <- mkReg(True);
50
 
51
   rule get_mem((state==0)&&!need_req);
52
      RpmrBits tr = truncate(count+1);
53
      if(truncate(count+1)==rpmr_msk)
54
         need_req <= True;
55
      let a <- extMem.read[0].read();
56
      $display(a);
57
      count <= count+1;
58
      if(count+1==8192)
59
         state<=1;
60
   endrule
61
 
62
   rule req_mem((state==0)&&need_req);
63
      extMem.read[0].readReq(count*recwid/8);
64
      need_req <= False;
65
   endrule
66
 
67
   rule fin(state==1);
68
      $finish();
69
   endrule
70
 
71
endmodule
72
 
73
 
74
module mk421TB (Empty);
75
 
76
   Four2One merger <- mkFour2One();
77
   Reg#(Bool) started <- mkReg(False);
78
 
79
 
80
   Stmt feeder =
81
   (seq
82
       merger.in[0].put(0);
83
       merger.in[1].put(0);
84
       merger.in[2].put(0);
85
       merger.in[3].put(0);
86
 
87
       merger.in[0].put(1);
88
       merger.in[1].put(2);
89
       merger.in[2].put(3);
90
       merger.in[3].put(4);
91
 
92
 
93
       merger.in[0].put(4);
94
       merger.in[1].put(3);
95
       merger.in[2].put(2);
96
       merger.in[3].put(1);
97
 
98
       merger.in[0].put(4);
99
       merger.in[1].put(3);
100
       merger.in[2].put(1);
101
       merger.in[3].put(2);
102
 
103
    endseq);
104
 
105
   FSM ffsm <- mkFSM(feeder);
106
 
107
   rule start (!started);
108
      $display("start merge");
109
      ffsm.start();
110
      started <= True;
111
   endrule
112
 
113
 
114
   rule get_stuff (True);
115
      let a <- merger.out.get();
116
      $display(a);
117
   endrule
118
 
119
endmodule

powered by: WebSVN 2.1.0

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