The HDL paradigm in a Spreadsheet
From Hamsterworks Wiki!
Coding in an HDL is a completely different paradigm to software coding. It is so different that at first programmers find it hard to understand it - it is foreign to imagine how useful systems can be developed when all assignments happen at once, and you don't have any way to perform loops. All you have left is conditional evaluation.
You can experience the HDL design paradigm using nothing more than a spreadsheet.
How HDLs differ from software code
Although it isn't immediately apparent working with an HDL is 'just' about designing a mapping function that takes the system's present state, add the present inputs and maps it the next state.
state(n+1) <= f(state(n), inputs(n))
Given the same values for S(n) and inputs(n) you will always get the same values for state(n+1).
Simulating in a spreadsheet
This can be quite accurately simulated in spreadsheet, and in doing so can give people who are unfamiliar with the paradigm insight into what is going on without dealing with all the messy details.
Here's the ground rules.
- Rows represent 'clock ticks' - the evolution of the system over time.
- Each column represents a either an input or internal register of the design.
- The input columns can contain constants, usually a list of numbers, this represents the input signals connected to the hardware.
- You can use as many columns as you like, but all cells in each column must have exactly the same formula. These are the internal logic of the design feeding into an internal register made of flip-flips.
- If you were modeling ASICs all of row zero would be an invalid value, but as we are using FPGAs you can set the values in the first row.
- All functions can only access the values of the row immediately above. So all functions in row 3 can only access cells from row 2.
Paste this list of numbers into column A of your spreadsheet.
Your challenge is to calculate the average of these numbers, while not breaking any of the ground rules.
In code you would do something like:
total = 0; for i = 1 to count total = total + value(i) next average = total / count