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

Subversion Repositories usb11

[/] [usb11/] [trunk/] [rtl/] [systemc/] [fifo_test.cpp] - Blame information for rev 15

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

Line No. Rev Author Line
1 2 alfoltran
#include "systemc.h"
2
#include "usb_fifo64x8.h"
3
 
4
SC_MODULE(test) {
5
        sc_in<bool> clk;
6
        sc_out<bool> rst, clr;
7
        sc_out<sc_uint<8> > din;
8
        sc_in<sc_uint<8> > dout;
9
        sc_out<bool> we, re;
10
        sc_in<bool> empty, full;
11
 
12
        int i;
13
 
14
        void update(void) {
15
                i = 0;
16
                rst.write(false);
17
                clr.write(false);
18
                we.write(false);
19
                re.write(false);
20
                wait();
21
                rst.write(true);
22
                wait(clk.posedge_event());
23
                we.write(true);
24
                while (!full.read()) {
25
                        din.write(i++);
26
                        wait(clk.posedge_event());
27
                        wait(clk.negedge_event());
28
                        cout << "WR: " << din.read() << endl;
29
                }
30
                we.write(false);
31
                wait(clk.posedge_event());
32
                re.write(true);
33
                while (!empty.read()) {
34
                        wait(clk.posedge_event());
35
                        wait(clk.negedge_event());
36
                        cout << "RD: " << dout.read() << endl;
37
                }
38
                re.write(false);
39
                wait();
40
                wait();
41
                sc_stop();
42
        }
43
 
44
        SC_CTOR(test) {
45
                SC_THREAD(update);
46
                sensitive_pos(clk);
47
        }
48
};
49
 
50
int sc_main(int argc, char *argv[]) {
51
 
52
        sc_set_time_resolution(1.0, SC_NS);
53
 
54
        sc_clock clk("clock", 10.0, SC_NS);
55
        sc_signal<sc_uint<8> > din, dout;
56
        sc_signal<bool> rst, clr, we, re, empty, full;
57
 
58
        usb_fifo64x8 i_fifo("FIFO");
59
        test i_test("TEST");
60
 
61
        i_fifo.clk(clk);
62
        i_fifo.rst(rst);
63
        i_fifo.clr(clr);
64
        i_fifo.we(we);
65
        i_fifo.din(din);
66
        i_fifo.re(re);
67
        i_fifo.dout(dout);
68
        i_fifo.empty(empty);
69
        i_fifo.full(full);
70
 
71
        i_test.clk(clk);
72
        i_test.rst(rst);
73
        i_test.clr(clr);
74
        i_test.din(din);
75
        i_test.dout(dout);
76
        i_test.we(we);
77
        i_test.re(re);
78
        i_test.empty(empty);
79
        i_test.full(full);
80
 
81
        sc_trace_file *log = sc_create_vcd_trace_file("FIFO_TEST");
82
        sc_trace(log, clk, "Clock");
83
        sc_trace(log, din, "DataIn");
84
        sc_trace(log, dout, "DataOut");
85
        sc_trace(log, empty, "Empty");
86
        sc_trace(log, full, "Full");
87
 
88
        //sc_start(1000, SC_NS);
89
        sc_start();
90
 
91
        sc_close_vcd_trace_file(log);
92
 
93
        return 0;
94
}
95
 

powered by: WebSVN 2.1.0

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