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

Subversion Repositories cic

[/] [cic/] [trunk/] [header/] [comb.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ahmed.shah
SC_MODULE(comb)
2
{
3
        /// Design entity
4
        sc_in<bool>     CLR;                    // Asynchronous active high reset
5
        sc_in<bool>     CLK;                    // Rising edge clock
6
        sc_in<double>   combIN;                 // Comb stage input
7
        sc_out<double>  combOUT;                // Comb stage output
8
 
9
        /// Internal signals
10
        sc_signal<double> r, r_delay;   // Internal signal used for delay
11
 
12
        /// Constructor
13
        SC_CTOR(comb)
14
        {
15
                SC_METHOD(algorithm);
16
                        sensitive << combIN ;//<< r_delay;
17
 
18
                SC_METHOD(delay);
19
                        sensitive << CLK.pos();
20
 
21
                combOUT.initialize(0);
22
        }
23
 
24
        /// Concurrent processes
25
        void algorithm()
26
        {
27
                if (CLR.read() == true)
28
                {
29
                        r.write(0);
30
                }
31
                else
32
                {
33
                        r.write(combIN.read());
34
                        combOUT.write( combIN.read() - r_delay.read() );
35
                }
36
        }
37
 
38
        /*
39
         * This process emulates the non-recursive feedback from the
40
         * input to the output through a delay path.
41
         */
42
        void delay()
43
        {
44
                if (CLR.read() == true)
45
                {
46
                        r_delay.write(0);
47
                }
48
                else
49
                {
50
                        r_delay.write(r.read());
51
                }
52
        }
53
 
54
};
55
 
56
 
57
/* Comb Stage
58
 
59
                                                ***
60
    ------------------>* - *--->
61
                  |                             ***
62
                  |                      ^
63
                  |       *****          |
64
                  --->* z *------
65
                          *****
66
 
67
*/

powered by: WebSVN 2.1.0

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