Click here to Skip to main content
Click here to Skip to main content
Articles » Multimedia » OpenGL » General » Downloads
 
Add your own
alternative version
Go to top

Circuit Engine

, 20 Dec 2010
A System for Simulation and Analysis of Logic Circuits
cesl_cec_examples.zip
Examples
4BitAdder
4bitAdder.cesl
74LS08
74LS08.CESL
Async1
Async1.cesl
ASYNC1~1.cec
Dual4InputMux
74153.pdf
DUAL4I~1.cec
DUAL4INPUTMUX.CESL
ExPage58
Page58.cesl
FullAdder
FULLAD~1.cec
fULLaDDER.CESL
FunctionF
FunctionF.cesl
CircuitEngine_-_Executable.zip
glut32.dll
4bitAdder.cesl
74LS08.cec
74LS08.CESL
Asynchronous
Asynchronous.cec
Asynchronous.cesl
74153.pdf
DUAL4INPUTMUX.cec
DUAL4INPUTMUX.CESL
Page58.cesl
FullAdder.cec
FullAdder.CESL
FunctionF.cesl
CEngine.exe
circuitengine_code_files.zip
C.dep
C.mak
ce.oldmain
C.opt
C.plg
C.dsp
C.dsw
C.ncb
C.suo
Debug
C.pch
CEngine.exe
CEngine.ilk
CEngine.obj
CEngine.pdb
CEngine.sbr
try.cesl
vc70.idb
vc70.pdb
Release
4BitAdder
4bitAdder.cesl
74LS08
74LS08.CESL
Async1
Async1.cesl
ASYNC1~1.cec
C.pch
C.pdb
CEngine.exe
CEngine.obj
DENEME.CESL
Dual4InputMux
74153.pdf
DUAL4I~1.cec
DUAL4INPUTMUX.CESL
empty.cesl
ExPage58
Page58.cesl
FF.cesl
FullAdder
FULLAD~1.cec
fULLaDDER.CESL
FunctionF
FunctionF.cesl
InitialScreen.bmp
Thumbs.db
Many.CESL
Page58.cesl
SavedLogs
try.cesl
vc70.idb
circuitengine_code_files_vs6.0.zip
C.dep
C.mak
ce.oldmain
C.opt
C.plg
C.dsp
C.dsw
C.ncb
C.suo
C.pch
CEngine.exe
CEngine.ilk
CEngine.obj
CEngine.pdb
CEngine.sbr
try.cesl
vc70.idb
vc70.pdb
4bitAdder.cesl
74LS08.CESL
Async1.cesl
ASYNC1~1.cec
C.pch
C.pdb
CEngine.exe
CEngine.obj
DENEME.CESL
74153.pdf
DUAL4I~1.cec
DUAL4INPUTMUX.CESL
empty.cesl
Page58.cesl
FF.cesl
FULLAD~1.cec
fULLaDDER.CESL
FunctionF.cesl
InitialScreen.bmp
Thumbs.db
Many.CESL
Page58.cesl
try.cesl
vc70.idb
circuitengine_code_files_vs6.0_vs8.0.zip
4bitAdder.cesl
74LS08.CESL
Async1.cesl
ASYNC1~1.cec
Counter.cec
Counter.cesl
DUAL4I~1.cec
DUAL4INPUTMUX.CESL
FULLAD~1.cec
fULLaDDER.CESL
FunctionF.cesl
Page58.cesl
try.cesl
glut-3.7.6-bin.zip
glut-3.7.6-bin
glut.def
glut32.dll
glut32.lib
glut-3.spec.zip
glut-3.spec.pdf
/*
This file is part of Circuit Engine.
 
Circuit Engine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
 
Circuit Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with Circuit Engine.  If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------
*/
char *ScriptFilePath;
#include "Artist.h"
#include <time.h>
#include <io.h>
#include <new.h>


FILE *logfile;

int handle_program_memory_depletion(size_t mem)
{
	printf("(!e!)CEngine: Not enough memory. CEngine halted");	
	exit(1);
}
int main(int argc, char **argv)
{
	int CheckTheFile;
	char FileIdBuf[9];
	char LogFileName[32];

	//log file name
	strcpy(LogFileName,"CEngineLog_");
	_strdate(LogFileName+11);
	LogFileName[19] = '_';
	_strtime(LogFileName+20);
	LogFileName[13] = '.';
	LogFileName[16] = '.';
	LogFileName[22] = '.';
	LogFileName[25] = '.';
	strcat(LogFileName + 28, ".txt");

	_set_new_handler( handle_program_memory_depletion );

	printf("\n%s\n",LogFileName);

	if((logfile = fopen(LogFileName, "w")) == 0)
	{
		perror("log creat error");
		exit(1);
	}

	
	if(-1 == _dup2( _fileno( logfile ), 1) )
	{
		perror( "Can't _dup2 stdout to log file" );
		exit( 1 );
	}	

	ScriptFilePath = argv[1];
	CEngineArtist = new CECircuit();

	//resolve the file whether it is CESL of CEC file.
	//:check if the file has CEC_FILE id, if so, treat as CEC file
	//else send it to the CECircuit parser
	CheckTheFile = _open(ScriptFilePath, _O_RDONLY);
	_read(CheckTheFile, &FileIdBuf, sizeof(char)*9);
	_close(CheckTheFile);

	if(strncmp("CEC_FILE:", FileIdBuf, 9))
	{//this is surely not the CEC file, so treat the file as a CESL file
		//sending to the parser		
        CEngineArtist->ParseScriptFile(ScriptFilePath);	
		CEngineArtist->InsertTempVG();
		
	}
	else //it is a CEC file, so retrieve the circuit information from the file
	{		
        CEngineArtist->LoadCircuit(ScriptFilePath);
		SelectedCE = (CircuitElement *)LastSelectedCE;
	}
	
	InitArtist();	
	EnterMainLoop();	

	return 0;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

Share

About the Author

Emre Guldogan
Team Leader
Turkey Turkey
I've graduated from computer engineering department in 2004 July, and developed the Circuit Engine as my graduation project at Eastern Mediterranean University (EMU - http://ww1.emu.edu.tr/en/academics/faculties/faculty-of-engineering/computer-engineering/c/748). I've also graduated from MBA, Istanbul University in 2008 February. From 2004 until now, I've developed many web sites (B2B, B2C). Currently work for D&R Music-Book as a software engineer and team leader. I still continue to develop my personal projects about encryption algorithms, maths, OpenGL and Real-time Systems and Web Solutions (mostly ASP.NET C#, JQuery/JS, MVC, WinForms, Win/Web Services, T-SQL and less PHP, ASP, MySQL and some possible other methods about problem solving if necessary).
Follow on   Twitter

| Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 20 Dec 2010
Article Copyright 2008 by Emre Guldogan
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid