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

Subversion Repositories bluespec-h264

[/] [bluespec-h264/] [trunk/] [src_fpga/] [mkTestBench.bsv] - Blame information for rev 100

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 jamey.hick
 
2 83 jamey.hick
// The MIT License
3
 
4
// Copyright (c) 2006-2007 Massachusetts Institute of Technology
5
 
6
// Permission is hereby granted, free of charge, to any person obtaining a copy
7
// of this software and associated documentation files (the "Software"), to deal
8
// in the Software without restriction, including without limitation the rights
9
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
// copies of the Software, and to permit persons to whom the Software is
11
// furnished to do so, subject to the following conditions:
12
 
13
// The above copyright notice and this permission notice shall be included in
14
// all copies or substantial portions of the Software.
15
 
16
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
// THE SOFTWARE.
23
 
24
 
25 3 jamey.hick
//**********************************************************************
26
// Top level test-bench.  Mimics BRAM interface.
27
//----------------------------------------------------------------------
28
//
29
//
30
 
31
package mkTestBench;
32
 
33
import RegFile::*;
34
import IFPGAInterface::*;
35
import IEDKBRAM::*;
36
import mkTH::*;
37
import ISRAMWires::*;
38
import SRAMEmulator::*;
39
 
40
`define INPUT_SIZE 5298616
41
 
42
interface DoubleSRAM;
43
  interface ISRAMWires sram_controller1;
44
  interface ISRAMWires sram_controller2;
45
endinterface
46
 
47
 
48
module mkTestBench();
49
 
50
  IFPGAInterface h264 <- mkth();
51
 
52
  ISRAMEmulator sram1 <- mkSRAMEmulator(h264.sram_controller);
53
  ISRAMEmulator sram2 <- mkSRAMEmulator(h264.sram_controller2);
54
 
55
  RegFile#(Bit#(32), Bit#(8)) rfile <- mkRegFileLoad("./ww2.8.hex", 0, `INPUT_SIZE-1);
56
  Reg#(Bit#(32))  data_remaining <- mkReg(`INPUT_SIZE);
57
  Reg#(Bit#(32))  base_offset   <- mkReg(0);
58
  Reg#(Bit#(32))  index <- mkReg(0);
59
 
60
  rule read (h264.bram_controller.wen_output() == 0);
61
    index <= h264.bram_controller.addr_output();
62
    if(((index & ~3) == 32'hffc) || ((index & ~3) == 32'h1ffc))
63
      begin
64
        if(base_offset < `INPUT_SIZE)
65
         begin
66
          Bit#(16) data_slice = (data_remaining > 1024) ? 1024 : truncate(data_remaining);
67
          h264.bram_controller.data_input(zeroExtend({data_slice,8'hff}));
68
         end
69
        else
70
         begin
71
          h264.bram_controller.data_input(0);
72
         end
73
      end
74
    else
75
      begin
76
       h264.bram_controller.data_input({rfile.sub(base_offset + (index  & (~32'h1003))+0), rfile.sub(base_offset + (index  & (~32'h1003)) + 1), rfile.sub(base_offset + (index  & (~32'h1003)) + 2), rfile.sub(base_offset + (index  & (~32'h1003)) + 3)});
77
      end
78
  endrule
79
 
80
  rule write (h264.bram_controller.wen_output() != 0);
81
    h264.bram_controller.data_input(0);
82
    base_offset <= base_offset + 1024;
83
    data_remaining <= data_remaining - 1024;
84
  endrule
85
 
86
  //interface ISRAMWires sram_controller1 =  h264.sram_controller;
87
  //interface ISRAMWires sram_controller2 =  h264.sram_controller2;
88
 
89
endmodule
90
 
91
endpackage

powered by: WebSVN 2.1.0

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