July 7, 2011
freeDiameter, a free/open source Diameter protocol implementation is now available for Fedora/RHEL. Install it using:
$ sudo yum install freeDiameter freeDiameter-devel
It fully supports the Diameter Base Protocol as specified in RFC 3588, Diameter Extensible Authentication Protocol (EAP) application server from RFC 4072, and Diameter Session Initiation Protocol (SIP) application from RFC 4740. Thanks to Sebastien Decugis for accepting the upstream patches.
July 6, 2011
MyHDL, a Python hardware description and verification language is now available for Fedora/RHEL. Install it using:
$ sudo yum install python-myhdl
A simple example of a D flip-flop is given below:
#!/usr/bin/python
from myhdl import *
from random import randrange
def dff(q, d, clk):
@always(clk.posedge)
def logic():
q.next = d
return logic
def test_dff():
q, d, clk = [Signal(bool(0)) for i in range(3)]
dff_inst = dff(q, d, clk)
@always(delay(10))
def clkgen():
clk.next = not clk
@always(clk.negedge)
def stimulus():
d.next = randrange(2)
return dff_inst, clkgen, stimulus
def simulate(timesteps):
tb = traceSignals(test_dff)
sim = Simulation(tb)
sim.run(timesteps)
simulate(2000)
You can run it using:
$ python test.py
The generated test_dff.vcd can be viewed in GTKWave:
You can also generate Verilog code using the toVerilog() function. For example:
def convert():
q, d, clk = [Signal(bool(0)) for i in range(3)]
toVerilog(dff, q, d, clk)
convert()
The generated Verilog code looks like:
`timescale 1ns/10ps
module dff (
q,
d,
clk
);
output q;
reg q;
input d;
input clk;
always @(posedge clk) begin: DFF_LOGIC
q <= d;
end
endmodule
Refer their wiki for more documentation.
July 4, 2011
I have been wanting to attend the ‘Essential Abstractions in GCC’ workshop at IIT Bombay, Powai, Mumbai for many years, and I was finally able to make it this year (their fourth), June 30-July 3, 2011. Thanks to Red Hat for sponsoring me.
The first day started off with an introduction to the GCC Resource Center at IIT, Bombay, and their primary research interests in program analysis and optimization, translation validation, retargetable compilation, and parallelization and vectorization. They proceeded to give an overview of compiling GCC, and probing techniques used in understanding the functionality of the GNU C compiler. Lab sessions were held in the afternoon, and assignments were given to illustrate the concepts discussed. In general, lectures were scheduled in the morning, and lab sessions in the afternoon.
The second day focussed on introducing the control flow in gcc, adding passes to gcc, and manipulating GIMPLE for adding interprocedural and intraprocedural passes. Using simple GIMPLE API in gcc-4.6.0 were illustrated, along with adding static/dynamic plugin passes. The lab sessions were held in the afternoon. Teaching Assistants (students) were present to assist the participants during the lab sessions. There were regular tea breaks provided between breakfast, lunch, and dinner.
The third day began with an introduction to machine descriptions. Examples of retargetability mechanisms in gcc using spim, a MIPS processor simulator were illustrated with examples. The instructions sets were added incrementally at different machine description levels, beginning from assignment operations to arithmetic to pointers and function calls. The issues of retargetability mechanisms in gcc were also discussed.
The final day started with an introduction on parallelization and vectorization, theory, and concepts. Their implementation in gcc-4.6.0 was illustrated, specifically for the case of loops with data dependency diagrams. The use of graphite, and polyhedral compilation in gcc-4.6.0 were also discussed. We had lab assignments in the afternoon, and the session concluded with a summary of the essential concepts required in understanding the internals of GCC.
The workshop is useful if you have worked with compiler internals. I only wish they would release the sources of their work under a Free/Open Source license for everyone to benefit from.
Few photos taken during the trip are available in my /gallery.
June 29, 2011
MonadCatchIO-mtl, a monad-transformer version of the Control.Exception.catch function is now available for Fedora. Install it using:
$ sudo yum install ghc-MonadCatchIO-mtl ghc-MonadCatchIO-mtl-devel
A simple example to throw or catch an exception that is an instance of the Exception class:
{-# LANGUAGE DeriveDataTypeable #-}
import Control.Monad.CatchIO
import Data.Typeable
import Prelude hiding (catch)
data MyException = ThisException | ThatException
deriving (Show, Typeable)
instance Exception MyException
main = do
throw ThisException `catch` \e -> putStrLn ("Caught " ++ show (e :: MyException))
Thanks to Daniel Gorín for the upstream changes.
May 27, 2011
Hiredis, a minimalistic C client library for the Redis database is now available for Fedora/RHEL. Install it using:
$ sudo yum install hiredis hiredis-devel
May 25, 2011
Formal System Design (ForSyDe) from KTH Royal Institute of Technology, Sweden is now available for Fedora. It is a methodology with the objective to move system design (System on Chip, Hardware and Software systems) to a higher level of abstraction, and to bridge the abstraction gap by transformational design refinement. You can install it using:
$ sudo yum install ghc-ForSyDe
It is the 100th Haskell package in Fedora.
February 22, 2011
I had participated in the panel discussion on “Free/Open Source Hardware - What it means to Design Engineers” at the Electronics For You Expo 2011, Pragati Maidan, New Delhi on Saturday, February 19, 2011 representing Fedora, and Fedora Electronic Lab. Massimo Banzi (Arduino) chaired the session.
The presentation and photos are available. It was good to meet up with Massimo Banzi, Marcus Erlandsson (OpenCores.org) and Kyle Wiens (iFixit). Marcus Erlandsson gave a demo of the ORSoC development board:
I was also able to catch up with few Arduino hackers from Delhi. We had a good discussion about open hardware, licensing, community development, hardware hacking, and of course Fedora Electronic Lab. Special thanks to Electronics For You for sponsoring the travel.
February 21, 2011
parameterized-data is now available for Fedora. Install it using:
$ sudo yum install ghc-parameterized-data
A tutorial illustrating vectors parameterized in size using the above is written by Alfonso Acosta.
February 12, 2011
Presented Dum Ka Biryani, Make for each other at GNUnify 2011, Symbiosis Institute of Computer Studies and Research, Pune. The presentation is an illustrative, introduction on GNU Make.
The pdf and the LaTeX beamer sources are available under the GNU Free Documentation License. You can clone the sources using:
$ git clone git://gitorious.org/dum-ka-biryani-make-for-each-other/mainline.git
I had also conducted an introductory workshop on gcc, Makefiles, static, shared libraries for newbies at the (un)conference.
February 9, 2011
CUnit, a lightweight system for writing, administering, and running unit test cases in C is now available for Fedora.
$ sudo yum install cunit
An example code, is given below:
#include <stdio.h>
#include <string.h>
#include "CUnit/Basic.h"
static FILE* temp_file = NULL;
int init_suite1(void)
{
if (NULL == (temp_file = fopen("temp.txt", "w+"))) {
return -1;
}
else {
return 0;
}
}
int clean_suite1(void)
{
if (0 != fclose(temp_file)) {
return -1;
}
else {
temp_file = NULL;
return 0;
}
}
void testFPRINTF(void)
{
int i1 = 10;
if (NULL != temp_file) {
CU_ASSERT(0 == fprintf(temp_file, ""));
CU_ASSERT(2 == fprintf(temp_file, "Q\n"));
CU_ASSERT(7 == fprintf(temp_file, "i1 = %d", i1));
}
}
void testFREAD(void)
{
unsigned char buffer[20];
if (NULL != temp_file) {
rewind(temp_file);
CU_ASSERT(9 == fread(buffer, sizeof(unsigned char), 20, temp_file));
CU_ASSERT(0 == strncmp(buffer, "Q\ni1 = 10", 9));
}
}
int main()
{
CU_pSuite pSuite = NULL;
/* initialize the CUnit test registry */
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
/* add a suite to the registry */
pSuite = CU_add_suite("Suite_1", init_suite1, clean_suite1);
if (NULL == pSuite) {
CU_cleanup_registry();
return CU_get_error();
}
/* add the tests to the suite */
/* NOTE - ORDER IS IMPORTANT - MUST TEST fread() AFTER fprintf() */
if ((NULL == CU_add_test(pSuite, "test of fprintf()", testFPRINTF)) ||
(NULL == CU_add_test(pSuite, "test of fread()", testFREAD)))
{
CU_cleanup_registry();
return CU_get_error();
}
/* Run all tests using the CUnit Basic interface */
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_cleanup_registry();
return CU_get_error();
}
Compile it using:
$ gcc test.c -o test -lcunit
Output is given below:
~~~~ {.shell} $ ./test
CUnit - A unit testing framework for C - Version 2.1-2
http://cunit.sourceforge.net/
Suite: Suite_1 Test: test of fprintf() …passed Test: test of fread() …passed
Run Summary: Type Total Ran Passed Failed Inactive suites 1 1 n/a 0 0 tests 2 2 2 0 0 asserts 5 5 5 0 n/a
Elapsed time = 0.000 seconds ~~~~