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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [mp3/] [bench/] [models/] [codec_model.v] - Blame information for rev 1773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 266 lampret
///////////////////////////////////////////////////////////////////
2
// Codec model for EK4520
3
//
4
// The model simulated only mode that is found in Xess board which
5
// is defined by:
6
// CMODE = 0
7
// DIF0  = 0
8
// DIF1  = 1
9
// This mode represent MCLK = 256fs
10
//      20 bit in/out MSB justified, SCLK = 64fs
11
//
12
// Functionality:
13
// -    The model takes the input channel and dumps the samples to 
14
//      an output file.
15
// -    The model creates activity on the input channel according to
16
//      an input file. (not yet implemented)
17
 
18
`include "timescale.v"
19
 
20
module codec_model (
21
        mclk, lrclk, sclk, sdin, sdout
22
        );
23
 
24
input   mclk;
25
input   lrclk;
26
input   sclk;
27
input   sdin;
28
output  sdout;
29
 
30
reg [19:0]       left_data;
31
reg [19:0]       right_data;
32
integer         left_count, right_count;
33
 
34
// The file descriptors
35
integer         left_file, right_file;
36
 
37
        assign sdout = 1'b0;
38
 
39
// Opening the files for output data
40
initial
41
   begin
42
        left_file = $fopen("../out/left.dat");
43
        right_file = $fopen("../out/right.dat");
44
   end // of opening files
45
 
46
always @(negedge lrclk)
47
   begin
48
        left_count = 19;
49
        right_count = 19;
50
        $fdisplay(left_file, left_data);
51
        $fdisplay(right_file, right_data);
52
   end
53
 
54
always @(negedge sclk)
55
   begin
56
      if ((left_count > 0) &  (lrclk == 1'b0)) begin
57
        left_data[left_count] <= sdin;
58
        left_count <= left_count - 1;
59
      end
60
      if ((right_count > 0) & (lrclk == 1'b1)) begin
61
        right_data[right_count] <= sdin;
62
        right_count <= right_count - 1;
63
      end
64
   end
65
 
66
endmodule

powered by: WebSVN 2.1.0

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