AMI Tool: Difference between revisions
Capn freako (talk | contribs) (→Installation: Added `Customization' section.) |
Capn freako (talk | contribs) (→Supporting functions: Initial revision) |
||
Line 70: | Line 70: | ||
==== Supporting functions ==== | ==== Supporting functions ==== | ||
The '''AMIParse''' module exposes the following public functions: | |||
; | ; amiToken :: Parser AmiToken | ||
: | : Parses an AMI parameter string, returning an AmiToken. | ||
; | ; getAmiExp :: AmiToken -> [String] -> Maybe AmiExp | ||
: | : Scans through an AmiToken (presumably, returned by ''amiToken'') for a particular requested value. For example: | ||
getAmiExp (amiToken "(rootName (Mode 2))") ["rootName", "Mode"] = Just (Vals "2") | |||
: | |||
== Usage == | == Usage == |
Revision as of 20:44, 12 September 2011
AMITool is a Haskell package, which provides the essential tools necessary, in order to create IBIS-AMI models using Haskell.
Authors: David Banas
Usage
Installation
NOTE) This package is currently only supported on Linux.
If you haven't already, install the Haskell Platform on your system.
(This is necessary, because the shared object library produced by this package needs to dynamically link to certain standard Haskell libraries, at run time. I'm working on a statically linked version of this package, which won't require this step. Please, stay tuned.)
Download the [source tarball] and extract it:
$ tar xzf amitool-v0.1.tgz
Move into the newly created directory, and build the project:
$ cd amitool-v0.1 $ make
If the make succeeds, you'll find the following output files in the directory:
- libami.so - This is the shared object library plug-in, which contains your AMI model. It will be dynamically loaded, at run time, by your EDA tool when simulating.
- ami_test - This is an example C program, which will attempt to load libami.so and call its AMI_Init and AMI_Close functions, as a check on correct compilation. That is, for this simple test, it functions as a stand-in for the EDA tool.
You can quickly verify correct compilation and/or system infrastructural integrity by executing the following command:
$ ./ami_test test.ami
Customization
The source code of this package has been arranged such that, presumably, all you have to do, in order to model your own device, is edit the following section of the ExmplUsrModel.hs file, and re-run make:
-- Change the line, below, as follows: -- - Change "testAMI" to the root name of your AMI parameter tree. -- - Change "Mode" to the name you've given to the filter mode selection parameter. = case getAmiExp amiTree ["testAMI", "Mode"] of -- Change the `Vals' lines, below, to reflect your possible values of filter -- mode, and the corresponding action to be taken in that mode, adding/deleting -- lines as necessary. Just (Vals ["0"]) -> impulse -- Bypassed. Just (Vals ["1"]) -> fir (lpf 0.5 2) impulse -- 2nd order FIR LPF w/ cutoff at 1/2 Nyquist -- That's it; no more changes are required.
Description
Source Files
- AMIParse.hs - Haskell source code for parsing an AMI parameter string
- AMIModel.hs - Haskell source code for generic implementation of AMI functions
- ExmplUsrModel.hs - Haskell source code for model specific behavior
- ami_model.c - C source code for implementation of dynamic loading interface, as well as setup/tear-down of Haskell run-time system
- ami_test.c - example C source code showing how to dynamically load a shared object library and call the AMI functions
Public interface
New data types
The AMIParse module defines a new type alias, AmiToken, and a new abstract data type, AmiExp, as follows:
type AmiToken = (String, AmiExp)
data AmiExp = Vals [String] | Tokens [AmiToken]
Note that, taken together, the two new data items, above, form a recursive structure. This helps shorten the code that parses an AMI parameter string, which itself is recursive in nature.
Supporting functions
The AMIParse module exposes the following public functions:
- amiToken
- : Parser AmiToken
- Parses an AMI parameter string, returning an AmiToken.
- getAmiExp
- : AmiToken -> [String] -> Maybe AmiExp
- Scans through an AmiToken (presumably, returned by amiToken) for a particular requested value. For example:
getAmiExp (amiToken "(rootName (Mode 2))") ["rootName", "Mode"] = Just (Vals "2")
Usage
For more extensive usage examples, see the `test/Test.hs` file.
Construction of a probability space representing a fair coin
fairCoin = ProbSpace [point 0.0, point 1.0] [Measure ( [Empty]) 0, Measure ( [point 0]) 0.5 , Measure ( [point 1]) 0.5, Measure ( [point 0, point 1]) 1.0]
Testing the probability space defined, above
checkProbMeas fairCoin
Documentation
The documentation for this library is generated, via Haddock.
Related work
- Probabilistic Functional Programming
- I suspect a potential symbiosis between this library and `RandProc`
Community
- RandProcNotes
- Blog dedicated to the `RandProc` Haskell library
- Bug Tracker
- Bug tracker for the `RandProc` Haskell library
- Mailing List
- Mailing list for `RandProc` users and developers
- Source Code Tree
- Browsable source tree
- Darcs repository
darcs get http://code.haskell.org/RandProc/