-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d74edf6
Showing
18 changed files
with
948 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
build/ | ||
Makefile.in | ||
INSTALL | ||
aclocal.m4 | ||
autom4te.cache/ | ||
configure | ||
depcomp | ||
install-sh | ||
missing | ||
*.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Written by: | ||
|
||
Nick Gasson <nickg@nickg.me.uk> | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Empty | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SUBDIRS = src test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Nothing here yet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Nothing here yet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
aclocal -I m4 | ||
autoconf | ||
automake -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* config.h.in. Generated from configure.ac by autoheader. */ | ||
|
||
/* Name of package */ | ||
#undef PACKAGE | ||
|
||
/* Define to the address where bug reports for this package should be sent. */ | ||
#undef PACKAGE_BUGREPORT | ||
|
||
/* Define to the full name of this package. */ | ||
#undef PACKAGE_NAME | ||
|
||
/* Define to the full name and version of this package. */ | ||
#undef PACKAGE_STRING | ||
|
||
/* Define to the one symbol short name of this package. */ | ||
#undef PACKAGE_TARNAME | ||
|
||
/* Define to the home page for this package. */ | ||
#undef PACKAGE_URL | ||
|
||
/* Define to the version of this package. */ | ||
#undef PACKAGE_VERSION | ||
|
||
/* Version number of package */ | ||
#undef VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
AC_INIT([nhdl], [0.1], | ||
[Nick Gasson <nick@nick.me.uk>], | ||
[xcowsay]) | ||
AM_INIT_AUTOMAKE([-Wall color-tests]) | ||
|
||
AC_PROG_CC | ||
AC_PROG_INSTALL | ||
|
||
AC_CONFIG_HEADERS([config.h]) | ||
AC_OUTPUT([Makefile src/Makefile test/Makefile]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
bin_PROGRAMS = nhdl | ||
|
||
AM_CFLAGS = -Wall | ||
|
||
nhdl_SOURCES = nhdl.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef _IDENT_H | ||
#define _IDENT_H | ||
|
||
#include "lib.h" | ||
|
||
typedef struct ident *ident_t; | ||
|
||
ident_t make_ident(const char *str); | ||
const char *istr(ident_t ident); | ||
|
||
void ident_freeze(void); | ||
void ident_store(lib_t lib); | ||
void ident_load(lib_t lib); | ||
size_t ident_key(ident_t ident); | ||
|
||
#endif // _IDENT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
/* -*- mode: c -*- */ | ||
|
||
/* | ||
* Copyright (C) 2008, 2010-2011 Nick Gasson | ||
* | ||
* This program 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. | ||
* | ||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
%{ | ||
#include "tokens.h" | ||
|
||
#define YY_INPUT(buf, result, max_size) { \ | ||
result = get_next_char(buf, max_size); \ | ||
if (result <= 0) \ | ||
result = YY_NULL; \ | ||
} | ||
|
||
Lvals lvals; | ||
%} | ||
|
||
/* TODO: look at string_literal and character_literal */ | ||
|
||
ID [a-zA-Z][a-zA-Z_0-9]* | ||
STRING \".*\" | ||
CHAR '.' | ||
COMMENT --.*\n | ||
INT [0-9]+ | ||
|
||
A [aA] | ||
B [bB] | ||
C [cC] | ||
D [dD] | ||
E [eE] | ||
F [fF] | ||
G [gG] | ||
H [hH] | ||
I [iI] | ||
L [lL] | ||
N [nN] | ||
M [mM] | ||
O [oO] | ||
P [pP] | ||
R [rR] | ||
S [sS] | ||
T [tT] | ||
U [uU] | ||
W [wW] | ||
Y [yY] | ||
X [xX] | ||
|
||
ENTITY {E}{N}{T}{I}{T}{Y} | ||
IS {I}{S} | ||
END {E}{N}{D} | ||
GENERIC {G}{E}{N}{E}{R}{I}{C} | ||
PORT {P}{O}{R}{T} | ||
CONSTANT {C}{O}{N}{S}{T}{A}{N}{T} | ||
CONFIGURATION {C}{O}{N}{F}{I}{G}{U}{R}{A}{T}{I}{O}{N} | ||
COMPONENT {C}{O}{M}{P}{O}{N}{E}{N}{T} | ||
ARCHITECTURE {A}{R}{C}{H}{I}{T}{E}{C}{T}{U}{R}{E} | ||
OF {O}{F} | ||
BEGIN {B}{E}{G}{I}{N} | ||
AND {A}{N}{D} | ||
OR {O}{R} | ||
XOR {X}{O}{R} | ||
XNOR {X}{N}{O}{R} | ||
NAND {N}{A}{N}{D} | ||
ABS {A}{B}{S} | ||
NOT {N}{O}{T} | ||
ALL {A}{L}{L} | ||
IN {I}{N} | ||
OUT {O}{U}{T} | ||
BUFFER {B}{U}{F}{F}{E}{R} | ||
BUS {B}{U}{S} | ||
UNAFFECTED {U}{N}{A}{F}{F}{E}{C}{T}{E}{D} | ||
SIGNAL {S}{I}{G}{N}{A}{L} | ||
PROCESS {P}{R}{O}{C}{E}{S}{S} | ||
WAIT {W}{A}{I}{T} | ||
REPORT {R}{E}{P}{O}{R}{T} | ||
|
||
%% | ||
|
||
{COMMENT} { begin_token(yytext); } | ||
|
||
{ENTITY} { begin_token(yytext); return tENTITY; } | ||
{IS} { begin_token(yytext); return tIS; } | ||
{END} { begin_token(yytext); return tEND; } | ||
{GENERIC} { begin_token(yytext); return tGENERIC; } | ||
{PORT} { begin_token(yytext); return tPORT; } | ||
{CONSTANT} { begin_token(yytext); return tCONSTANT; } | ||
{COMPONENT} { begin_token(yytext); return tCOMPONENT; } | ||
{CONFIGURATION} { begin_token(yytext); return tCONFIGURATION; } | ||
{ARCHITECTURE} { begin_token(yytext); return tARCHITECTURE; } | ||
{OF} { begin_token(yytext); return tOF; } | ||
{BEGIN} { begin_token(yytext); return tBEGIN; } | ||
{AND} { begin_token(yytext); return tAND; } | ||
{OR} { begin_token(yytext); return tOR; } | ||
{XOR} { begin_token(yytext); return tXOR; } | ||
{XNOR} { begin_token(yytext); return tXNOR; } | ||
{NAND} { begin_token(yytext); return tNAND; } | ||
{ABS} { begin_token(yytext); return tABS; } | ||
{NOT} { begin_token(yytext); return tNOT; } | ||
{ALL} { begin_token(yytext); return tALL; } | ||
{IN} { begin_token(yytext); return tIN; } | ||
{OUT} { begin_token(yytext); return tOUT; } | ||
{BUFFER} { begin_token(yytext); return tBUFFER; } | ||
{BUS} { begin_token(yytext); return tBUS; } | ||
{UNAFFECTED} { begin_token(yytext); return tUNAFFECTED; } | ||
{SIGNAL} { begin_token(yytext); return tSIGNAL; } | ||
{PROCESS} { begin_token(yytext); return tPROCESS; } | ||
{WAIT} { begin_token(yytext); return tWAIT; } | ||
{REPORT} { begin_token(yytext); return tREPORT; } | ||
|
||
"(" { begin_token(yytext); return tLPAREN; } | ||
")" { begin_token(yytext); return tRPAREN; } | ||
";" { begin_token(yytext); return tSEMI; } | ||
":=" { begin_token(yytext); return tASSIGN; } | ||
":" { begin_token(yytext); return tCOLON; } | ||
"**" { begin_token(yytext); return tPOWER; } | ||
"," { begin_token(yytext); return tCOMMA; } | ||
"<=" { begin_token(yytext); return tLE; } | ||
{INT} { begin_token(yytext); return tINT; } | ||
{STRING} { begin_token(yytext); return tSTRING; } | ||
{CHAR} { begin_token(yytext); return tCHAR; } | ||
{ID} { begin_token(yytext); lvals.sval = strdup(yytext); return tID; } | ||
[ \t\r\n] { begin_token(yytext); } | ||
<<EOF>> { begin_token(yytext); return 0; } | ||
. { begin_token(yytext); return tERROR; } | ||
%% | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef _LIB_H | ||
#define _LIB_H | ||
|
||
#include <stdio.h> | ||
|
||
typedef struct lib *lib_t; | ||
|
||
lib_t find_lib(const char *name); | ||
lib_t make_lib(const char *name); | ||
FILE *lib_fopen(lib_t lib, const char *name, const char *mode); | ||
|
||
#endif // _LIB_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
int main(int argc, char **argv) | ||
{ | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef _TREE_H | ||
#define _TREE_H | ||
|
||
#include "lib.h" | ||
|
||
typedef enum tree_kind { | ||
T_ENTITY | ||
} tree_kind_t; | ||
|
||
typedef struct tree *tree_t; | ||
|
||
tree_t make_tree(tree_kind_t kind); | ||
|
||
void tree_freeze(void); | ||
void tree_store(lib_t lib, tree_t tree); | ||
tree_t tree_load(lib_t lib, ident_t ident); | ||
|
||
#endif // _TREE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
check_PROGRAMS = test_lib | ||
TESTS = $(check_PROGRAMS) | ||
|
||
AM_CFLAGS = -I $(top_srcdir)/src | ||
|
||
test_lib_SOURCES = test_lib.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "lib.h" | ||
|
||
#include <check.h> | ||
|
||
START_TEST(test_name) | ||
{ | ||
|
||
} | ||
END_TEST | ||
|
||
|
||
int main(void) | ||
{ | ||
return 1; | ||
} | ||
|