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

Subversion Repositories sc2v

[/] [sc2v/] [trunk/] [examples/] [dummy1.cpp] - Blame information for rev 22

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

Line No. Rev Author Line
1 21 jcastillo
#include "systemc.h"
2
 
3
#define HOLA 1
4
#define CONCAT 1
5
 
6 22 jcastillo
sc_uint<2> dummy1::func1(sc_uint<2> a, sc_uint<2> b){
7 21 jcastillo
   sc_uint<2> c;
8
   c=a+b;
9
   return c+5;
10
}
11
 
12
 
13
void
14 22 jcastillo
dummy1::regs ()
15 21 jcastillo
{
16
  if (rst.read ())
17
    {
18
      state.write (S0);
19
    }
20
  else
21
    state.write (next_state);
22
}
23
 
24
void
25 22 jcastillo
dummy1::fsm_proc ()
26 21 jcastillo
{
27
/*Verilog begin
28
        cfsm_proc={a[1:0],b[1:0]};
29
verilog end*/
30
 
31
  sc_uint < 2 > c;
32
  sc_uint < 4 > f;
33
  next_state.write (state.read ());
34
  a.write (func1(a.read(),b.read()));
35
  b.write (HOLA);
36
 
37
#ifdef CONCAT
38
  c.write ((a.range (1, 0), b.range (1, 0)));
39
#else
40
  c.write ((a, a));
41
#endif
42
 
43
  switch ((int) state.read ())
44
    {
45
    case 0x1:                   //Case 0
46
      if (input1.read ())
47
        {
48
          next_state.write (S1);
49
          a.write (true);
50
        }
51
      else if (input2.read () < input1.read())
52
        {
53
          next_state.write (S2);
54
          a.write (false);
55
        }
56
      else
57
        {
58
          next_state.write (S0);
59
          a.write (1);
60
        }
61
      break;
62
//   tRaNsLaTe   oFF              
63
    case S1:
64
      if (input2.read ())
65
        {
66
          next_state.write (S2);
67
          b.write (1);
68
        }
69
      break;
70
//   tRaNsLaTe   oN               
71
    case S2:
72
          for(int i=0;i<=10;i++){
73
              c.write(i);
74
          }
75
      next_state.write (S0);
76
      break;
77
    }
78
}

powered by: WebSVN 2.1.0

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