Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A little update for program #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions bin/sc2v.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
#
# usage: sc2v <filename_without_extension>
#
echo Cpp file processing...
../bin/sc2v_step1 < $1.cpp
echo Header file processing...
../bin/sc2v_step2 < $1.h > $1.sc2v
echo SC2V file processing...
../bin/sc2v_step3 < $1.sc2v > $1.v
\rm *.sc2v
6 changes: 3 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ YACC = bison -y
all:
$(LEX) sc2v_step1.l
$(YACC) -d sc2v_step1.y
gcc lex.yy.c y.tab.c sc2v_step1.c -Isrc -o ../bin/sc2v_step1 -lm
gcc -m32 lex.yy.c y.tab.c sc2v_step1.c global_vars.c -Isrc -o ../bin/sc2v_step1 -lm

$(LEX) sc2v_step2.l
$(YACC) -d sc2v_step2.y
gcc lex.yy.c y.tab.c sc2v_step2.c -Isrc -o ../bin/sc2v_step2 -lm
gcc -m32 lex.yy.c y.tab.c sc2v_step2.c global_vars.c -Isrc -o ../bin/sc2v_step2 -lm

$(LEX) sc2v_step3.l
$(YACC) -d sc2v_step3.y
gcc lex.yy.c y.tab.c -Isrc -o ../bin/sc2v_step3 -lm
gcc -m32 lex.yy.c y.tab.c global_vars.c -Isrc -o ../bin/sc2v_step3 -lm

clean:
rm -rf lex.* y.* *.o ../bin/sc2v_step2* ../bin/sc2v_step1* ../bin/sc2v_step3*
31 changes: 31 additions & 0 deletions src/global_vars.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "sc2v_step1.h"

/* Global var to store Regs */
RegNode *regslist;
/* Global var to store Defines */
DefineNode *defineslist;
/*Global var to store Structs */
StructNode *structslist;
StructRegNode *structsreglist;

#include "sc2v_step2.h"

/*Global var to read from file_writes.sc2v*/
WriteNode *writeslist;
/*Global var to store ports*/
PortNode *portlist;
/* Global var to store signals*/
SignalNode *signalslist;
/* Global var to store sensitivity list*/
SensibilityNode *sensibilitylist;
/* Global var to store process list*/
ProcessNode *processlist;
/* Global var to store instantiated modules*/
InstanceNode *instanceslist;
/*List of enumerates*/
EnumeratesNode *enumerateslist;
EnumListNode *enumlistlist;
/* Global var to store functions inputs list*/
FunctionInputNode *funcinputslist;
/* Global var to store process list*/
FunctionNode *functionslist;
1 change: 1 addition & 0 deletions src/sc2v_step1.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>

Expand Down
15 changes: 7 additions & 8 deletions src/sc2v_step1.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#ifndef SC2V_STEP_1_H
#define SC2V_STEP_1_H
#include "sglib.h"

#define MAX_NAME_LENGTH 256
Expand Down Expand Up @@ -51,13 +52,10 @@ typedef struct _StructNode
struct _StructNode *next;
} StructNode;

/* Global var to store Regs */
RegNode *regslist;
/* Global var to store Defines */
DefineNode *defineslist;
/*Global var to store Structs */
StructNode *structslist;
StructRegNode *structsreglist;
extern RegNode *regslist;
extern DefineNode *defineslist;
extern StructNode *structslist;
extern StructRegNode *structsreglist;

/* Functions for defines list*/
DefineNode *InsertDefine(DefineNode *list,char *name);
Expand All @@ -74,3 +72,4 @@ void ShowStructs (StructNode * list);



#endif
1 change: 1 addition & 0 deletions src/sc2v_step1.y
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
%{
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sglib.h"
#include "sc2v_step1.h"

Expand Down
1 change: 1 addition & 0 deletions src/sc2v_step2.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

#include "sc2v_step2.h"
Expand Down
34 changes: 14 additions & 20 deletions src/sc2v_step2.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#ifndef SC2V_STEP_2_H
#define SC2V_STEP_2_H
#include "sglib.h"

#define MAX_NAME_LENGTH 256
Expand Down Expand Up @@ -111,25 +112,16 @@ typedef struct _enumlist_node
} EnumListNode;


/*Global var to read from file_writes.sc2v*/
WriteNode *writeslist;
/*Global var to store ports*/
PortNode *portlist;
/* Global var to store signals*/
SignalNode *signalslist;
/* Global var to store sensitivity list*/
SensibilityNode *sensibilitylist;
/* Global var to store process list*/
ProcessNode *processlist;
/* Global var to store instantiated modules*/
InstanceNode *instanceslist;
/*List of enumerates*/
EnumeratesNode *enumerateslist;
EnumListNode *enumlistlist;
/* Global var to store functions inputs list*/
FunctionInputNode *funcinputslist;
/* Global var to store process list*/
FunctionNode *functionslist;
extern WriteNode *writeslist;
extern PortNode *portlist;
extern SignalNode *signalslist;
extern SensibilityNode *sensibilitylist;
extern ProcessNode *processlist;
extern InstanceNode *instanceslist;
extern EnumeratesNode *enumerateslist;
extern EnumListNode *enumlistlist;
extern FunctionInputNode *funcinputslist;
extern FunctionNode *functionslist;



Expand Down Expand Up @@ -182,3 +174,5 @@ void ShowFunctionInputs (FunctionInputNode * list);
/* Functions for functions list*/
FunctionNode *InsertFunction (FunctionNode *list, char *name,FunctionInputNode *InputsList,int outputlenght,int flag);
void ShowFunctionCode (FunctionNode *list);

#endif
1 change: 1 addition & 0 deletions src/sc2v_step2.y
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#include "sc2v_step2.h"
Expand Down
1 change: 1 addition & 0 deletions src/sc2v_step3.y
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
%{
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int module_found = 0;
int concat_found = 0;
Expand Down