The quest Imagine that one day, billionaire Steve Ballmer invites you to join his mission. Before you can sign on, he poses a challenge: “I am thinking of an integer between 1 and 100. You must guess the number. After each guess, I will tell you if my number is higher or lower. Each guess costs you $1. You must keep playing until you get it right.” 1 The question is: How much money should Steve…
This post is about design and analysis of digital circuits using haskell as a language and clash as tool to generate digital circuits. Main Idea Frequency analysis can be preformed for digital circuits using only adders, multiplies and register. Intuitive reasoning to get response of single frequency from such circuitry as black box goes as. We insert Signal of complex numbers in circuitry and…
Building software in haskell is frequently expressing problem in one domain and then transfer it into another. Previous post Remote fpga call was about using type system to use and define circuits in both hardware and software. Plan for this post is to show how to define circuits (using clash in haskell) for two different and related domains. One domain are circuits using Signal a that represent…
Fpga core in CλaSH Lets make matrix multiplication as Fpga core in language CλaSH . Clash is basically Haskell programming language where Ghc compiler is hacked to generate either verilog, vhdl or system verilog source that can be used by tools (Xilinx Vivado for example) to synthesize digital circuit. Both clash and ghc are free and open sourced. Multiplication of 2 matrices size 3x3 and using 16…
Programming FPGA using Haskell Here is very short introduction to functional programming language Haskel and functional reasoning. For this we will use CλaSH compiler, that is extension of Haskell language being able to convert large set of Haskell code in either VHLD, Verilog or SystemVerilog for now. Installation instructions are available in hackage doc . If you need just quick peek in…
Common way to write generic functions in C is to use macros. Problem with macros is that that they are hard to read, and hard to support. Just take max for example and it gets worse in this terms when complex functions are required. sglib is another example. This code just does not feel C any more. Approach in generic max without macros is: //use max with integers typedef int generic_max_t; //this…
Memoization is very useful technique for developing algorithms. Python3 has native support for memoization and here is how it is used. from functools import lru_cache @lru_cache #memoization def fib ( n ): if n < 2 : return 1 else : return fib ( n - 1 ) + fib ( n - 2 ) Similar feature can be implemeted in c++ . Here is an example on how to use. MEMOIZATION ( uint64_t , fib ,( int n )) { if ( n < 2…