Hdelossantos.com

Verilog SyntaxHighlighter Brush

by Hanly on May.20, 2010, under Code

I was trying to add some sample Verilog code on my website, but the code syntax highlighter I use did not have a brush. I made my own Verilog brush for Alex Gorbatchev’s SyntaxHighlighter. Feel free to modify and improve the code. The only thing that I ask is that you share the modifications.

/**
 * SyntaxHighlighter Verilog Brush
 * http://hdelossantos.com/
 *
 * SyntaxHighlighter is donationware. If you are using it, please donate.
 * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate
 *
 * @version
 * 1.0.0 (May 20, 2010)
 *
 * @copyright
 * Copyright (C) 2010 Hanly De Los Santos.
 *
 * @license
 * This file is a SyntaxHighlighter brush and is licensed under
 * the same license as SyntaxHighlighter.
 *
 * SyntaxHighlighter is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * SyntaxHighlighter 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 SyntaxHighlighter.  If not, see <http://www.gnu.org/copyleft/lesser.html>.
 */
SyntaxHighlighter.brushes.Verilog = function() {
	var keywords = 'always end ifnone or rpmos tranif1 and endcase ' +
			  'initial output rtran tri assign endmodule inout ' +
			  'parameter rtranif0 tri0 begin endfunction input ' +
			  'pmos rtranif1 tri1 buf endprimitive integer ' +
			  'posedge scalared triand bufif0 endspecify join ' +
			  'primitive small trior bufif1 endtable large pull0 ' +
			  'specify trireg case endtask macromodule pull1 ' +
			  'specparam vectored casex event medium pullup ' +
			  'strong0 wait casez for module pulldown strong1 ' +
			  'wand cmos force nand rcmos supply0 weak0 deassign ' +
			  'forever negedge real supply1 weak1 default for ' +
			  'nmos realtime table while defparam function nor ' +
			  'reg task wire disable highz0 not release time wor ' +
			  'edge highz1 notif0 repeat tran xnor else if ' +
			  'notif1 rnmos tranif0 xor';
	var sysTasks = '$display $monitor $dumpall $dumpfile $dumpflush ' +
			  '$dumplimit $dumpoff $dumpon $dumpvars $fclose ' +
			  '$fdisplay $fopen $finish $fmonitor $fstrobe ' +
			  '$fwrite $fgetc $ungetc $fgets $fscanf $fread ' +
			  '$ftell $fseek $frewind $ferror $fflush $feof ' +
			  '$random $readmemb $readmemh $readmemx $signed ' +
			  '$stime $stop $strobe $time $unsigned $write';
	var macros = 'default-net define celldefine default_nettype ' +
			  'else elsif endcelldefine endif ifdef ifndef ' +
			  'include line nounconnected_drive resetall ' +
			  'timescale unconnected_drive undef';

	this.regexList = [
		{ regex: SyntaxHighlighter.regexLib.singleLineCComments,	css: 'comments' },
		{ regex: /\/\*([^\*][\s\S]*)?\*\//gm,						css: 'comments' },
		{ regex: /\/\*(?!\*\/)\*[\s\S]*?\*\//gm,					css: 'preprocessor' },
		{ regex: SyntaxHighlighter.regexLib.doubleQuotedString,		css: 'string' },
		{ regex: SyntaxHighlighter.regexLib.singleQuotedString,		css: 'string' },
		{ regex: /\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi,			css: 'value' },
		{ regex: /(?!\@interface\b)\@[\$\w]+\b/g,			css: 'color1' },
		{ regex: /\@interface\b/g,					css: 'color2' },
		{ regex: new RegExp(this.getKeywords(keywords), 'gm'),		css: 'keyword' },
		{ regex: new RegExp(this.getKeywords(macros), 'gm'),		css: 'keyword' },
		{ regex: new RegExp(this.getKeywords(sysTasks), 'gm'),		css: 'keyword' }
];

};

SyntaxHighlighter.brushes.Verilog.prototype = new SyntaxHighlighter.Highlighter();
SyntaxHighlighter.brushes.Verilog.aliases = ['verilog', 'v'];

You can download the Wordpress plugin below. You must have the SyntaxHighlighter plugin installed and active.


Leave a Comment :, , , , , , more...

Using a SQLite Database in Android

by Hanly on Jan.07, 2010, under Tutorials

This tutorial will demonstrate how to use the database adapter created in “Creating a SQLite Database in Android” to add and get data to and from the database to populate a ListView.
(continue reading…)

10 Comments :, , , , , , , , more...

Quick and easy Android HTTP POST of JSON string

by Hanly on Dec.24, 2009, under Tutorials

There are several ways to send data across the internet to a server on the Android. I was recently working on a project and needed to send a JSON string to the server to add data to a database. Additionally in certain cases I wanted to receive data back from the server. The fastest and easiest way to do this was to use HTTP POST android library and capture the response from the server using a response handler. On the server side the response was simply generated by echoing a JSON string.
(continue reading…)

4 Comments :, , , , , , , , , , more...

Creating a SQLite database in Android

by Hanly on Dec.23, 2009, under Tutorials

This example will show you how to create a somewhat abstracted SQLite adapter on Android. This adapter can then be utilized by your program to do common database functions such as, querying and searching. I start by creating the class DBAdapter in my Android project and declaring the variable data necessary to create the database.

EDIT: The code has been modified since it originally assumed that a key option would be passed for every key. It will now work if no key options are passed. Additionally, “null” can also be passed to it if no key options are desired.

(continue reading…)

10 Comments :, , , , , , more...

I’ve earned my Android Badge :)

by Hanly on Nov.08, 2009, under Computer Science, Technology

After having been developing Android applications for 2 months I like to think that I have earned my Android badge. Last week at the SHPE conference I was given an android sticker at the Google booth, which now adorns my laptop.

My Laptop's Android

Of course calling myself a developer makes me think of:

Leave a Comment :, , , more...

It’s that time of the year again.

by Hanly on Oct.11, 2009, under The Wisconsin Experience

Here comes the snow.

Here comes the snow.

2 Comments :, , more...

Talking Twitter

by Hanly on Oct.10, 2009, under Computer Engineering, Computer Science, Sample Work

A week ago, for my mobile device programming class, I had to add text-to-speech and speech-to-text capabilities to a freely available Android program called Twitta. The features I added were very crudely superimposed on the Twitta interface, therefore this edit is by no means polished or intended for production usage.

There are 3 button “S”, “X”, and “R”. “S” starts the playback of all of the tweets which are currently displayed on the screen. Once the user scrolls down and new tweets appear on the screen the button can be pressed again and only the new ones will be read. “X” stops the playback of the messages. “R” prompts the user to speak their tweet. The google speech to text engine converts it to text and is displayed on the edit bar. If the message was wrong, pressing “R” again clears it and prompts for new speech. The message can also be edited with the keyboard. Below is a video of the application in action:

(continue reading…)

5 Comments :, , , , , , , , , , , , , more...

Apparently I don’t know Spanish.

by Hanly on Sep.27, 2009, under Uncategorized

It seems that despite being born in a Spanish speaking country, having gone to school solely in Spanish for 3 years, having Spoken only Spanish at home my entire life (21 years), and having taken Spanish classes throughout elementary, high school, and a semester in college, still doesn’t qualify me as knowing Spanish according to Tyler.

In his deeply distorted mind he believes that the verb “gustar” means to please. While I will admit that depending on the context it does mean that, he would apply that meaning to the translation of:
“A Hanly le gusta la muchacha.” thus making it “The girl pleases Hanly.” This translation completely redefines the meaning of the sentence giving it a sexual undertone and changing the structure from Hanly liking the girl (the correct meaning) to the girl pleasing Hanly (Tyler’s translation). Even applying it to the mother tongue of all romance languages Tyler’s translation would not make sense. For example this sentence in Latin would be “Hanly amat puellam.” Which would of course be translated into English as “Hanly likes(or loves) the girl.” The subject of the sentence being Hanly and the girl taking the singular accusative ending of -am because she is the direct object of Hanly’s love or liking. I’m sure he would argue that this is Latin and not Spanish, but the “A” in the beginning of the Spanish sentence preceding Hanly clearly makes Hanly the subject of the sentence stating that Hanly is the one doing the liking and not the girl. The girl of course being the direct object of Hanly’s liking.

My translation is of course wrong since I am completely inept and unable to speak my own country’s language. Does this mean that I communicate with my family through a telepathic link? Tyler of course, with his much higher standards, 4 years (a generous assumption considering he might have taken fewer years of it) of Spanish classes, and an inability to properly enunciate Spanish words, knows more Spanish than I could ever hope to learn. Debido a esto estoy avergonzado de haber nacido en Cuba y no saber hablar mi propio idioma. En verdad es un gran insulto no solamente a mi, pero a mi familia que venga este chiquito a decirme que yo no se hablar mi propio idioma. Que se valla para casa del carajo y me deje tranquilo este chiquito que se tira los peos mas altos que culo.

—Disculpenme por mi vulgaridad en esta explosión de mi temperamento sarcástico cubano.

Leave a Comment more...

My thoughts on the state of government

by Hanly on Aug.22, 2009, under Politics

A friend of mine sent me this video:

and it got me thinking about the reasons why my family came to the United States. (continue reading…)

Leave a Comment more...

Sunset After a Storm

by Hanly on Jun.25, 2009, under Photography

Sunset After a StormAn oldie but I do have to admit it is one of my favorite pictures I have ever taken. I love the colors as the sun sets behind the clouds. I took this on my trip to Cuba in 2005.

Leave a Comment :, , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...