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

Subversion Repositories usb11

[/] [usb11/] [trunk/] [rtl/] [systemc/] [rom_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 <stdio.h>
2
 
3
#include "systemc.h"
4
#include "usb_rom.h"
5
 
6
SC_MODULE(test) {
7
        sc_in<bool> clk;
8
        sc_out<sc_uint<8> > adr;
9
        sc_in<sc_uint<8> > dout;
10
 
11
        int i;
12
 
13
        void update(void) {
14
                i = 0;
15
                for (i = 0; i < 256; i++) {
16
                        adr.write(i);
17
                        wait(clk.posedge_event());
18
                        wait(clk.negedge_event());
19
                        fprintf(stdout, "ROM[%x]: %x\n", i, dout.read().to_uint());
20
                }
21
                wait();
22
                wait();
23
                sc_stop();
24
        }
25
 
26
        SC_CTOR(test) {
27
                SC_THREAD(update);
28
                sensitive_pos(clk);
29
        }
30
};
31
 
32
int sc_main(int argc, char *argv[]) {
33
 
34
        sc_set_time_resolution(1.0, SC_NS);
35
 
36
        sc_clock clk("clock", 10.0, SC_NS);
37
        sc_signal<sc_uint<8> > adr, dout;
38
 
39
        usb_rom i_rom("ROM");
40
        test i_test("TEST");
41
 
42
        i_rom.clk(clk);
43
        i_rom.adr(adr);
44
        i_rom.dout(dout);
45
 
46
        i_test.clk(clk);
47
        i_test.adr(adr);
48
        i_test.dout(dout);
49
 
50
        sc_trace_file *log = sc_create_vcd_trace_file("ROM_TEST");
51
        sc_trace(log, clk, "Clock");
52
        sc_trace(log, adr, "Address");
53
        sc_trace(log, dout, "ROM_Data");
54
 
55
        //sc_start(1000, SC_NS);
56
        sc_start();
57
 
58
        sc_close_vcd_trace_file(log);
59
 
60
        return 0;
61
}
62
 

powered by: WebSVN 2.1.0

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