firmware (is that what you call FPGA code?).
I have no idea what's been written for it by others, but even if no one has turned the device into something entirely different, I'll bet I could learn FPGA coding with it as well.
It is called
bitstream. The fundamental difference between an FPGA and a micocontroller(MCU)/microprocessor(CPU) is that in an FPGA one loads a schematic diagram, while in an MCU one loads a program.
You can think about the FPGA as being a bunch load of unconnected logic gates and flip-flops, and the
bitstream is in fact a long list of connections, that tells the FPGA conect this pin from this NAND gate to that pin from that D-type flip-flop, and so on. Once all the interconnections are made according to the
bitstream, that's it, the schematic is loaded and the FPGA will just sit there reacting to input signals.
An FPGA does not execute a program instruction by instruction, like an MCU does, an FPGA simply reacts to input data (please do not nitpick here about the possibility to have a CPU core inside a FPGA, this is irrelevant for the moment and will only add confusion).
There is no order of execution in an FPGA, all its gates and flip-flops are doing their thing as long as they are powered. On the contrary, an MCU executes instructions in order, fundamentally speaking one after another. An MCU is a serial machine, while an FPGA is a parallel machine (please don't nitpick here about multicore processors or SIMD instruction in modern CPUs).
My point is, while both the FPGA and the MCU are using ASCII text files for their sources
- the FPGA text "code" describes a
schematic diagram, and the toolchain converts that schematic into a
bitstream, which is a list of electrical interconnections to be permanently made inside the FPGA
- the MCU/CPU text source "code" describes an
algorithm, and is converted into machine code, sometimes called firmware, which is a step by step list of instructions to be executed by the MCU/CPU (again, it's a bird eye view, please don't nitpick here about interpreters or just in time compilers being different from compiled code, and so on)
MCU: text program -> firmware -> MCU executing machine code step by step
FPGA: text schematic -> bitstream -> FPGA fixed schematic reacting all the time to inputs in no particular order
To get back on topic, a sound card can be more than enough for basic AC circuits study without buying an oscilloscope or a signal generator. There are programs to turn the sound card into an oscilloscope, into a signal generator, into a spectrum analyzer or into an AC voltmeter upon wish. There are many free tools that can do all that, for example this one:
https://www.zeitnitz.eu/scope_enA solderless breadboard is very handy during hands-on learning or experimenting with physical components.
Even if you prefer experimenting over simulating, from time to time you will still need to simulate a circuit or an idea, and the best tool for that will be LTspice, also free.
Same, Python or LabVIEW (LabVIEW is now free for home use) or almost any other language can control the soundcard and make plots, charts and so on.
For the language, one of the best choices will be Python, probably the most productive programming language ever (I am using it with Spyder as IDE). Since we were talking about sound card and plots, this is an example that reads a wav file, then plots the waveform and the spectrogram, all in less than 10 lines or so:
#!/usr/bin/env python3
from scipy.io import wavfile
rate, x = wavfile.read('test_mono.wav')
from matplotlib import pyplot as plt
fig, (ax1) = plt.subplots(1, 1)
ax1.plot(x); ax1.set_title('Raw audio signal')
fig, (ax2) = plt.subplots(1, 1)
ax2.specgram(x[:, 0]); ax2.set_title('Spectrogram');
# avoid subplot (title) overlaping
plt.tight_layout()
Or maybe you are a Linux user and prefer to pipe some bytes into aplay to make
(sorry for the pun) a signal generator straight from the command line:
.LOG
00:15 2020.01.12
================
Created proj "P079 - Sound with aplayer C and Makefile" after founding an example of a 1 kHz audio generator
[url]https://www.eevblog.com/forum/testgear/question-cheap-pure-sine-wave-genertor-1khz/msg2866736/#msg2866736[/url]
Contentents of Makefile:
------------------------
all : sin
./sin | aplay -r 48000 -c 2 -f S16_BE
sin : sin.c
gcc -o sin sin.c -Wall -pedantic -O4 -lm
Contentents of sin.c:
---------------------
#include <stdio.h>
#include <stdint.h>
#include <math.h>
int main(int argc, char *argv[]) {
int i = 0;
while(1) {
double angle = i * 2 *M_PI / 48.0;
double s = sin(angle);
uint32_t u_sample = (s+1.0) * 16384;
int32_t i_sample = u_sample - 16384;
putchar((i_sample>>8) & 0xFF);
putchar((i_sample>>0) & 0xFF);
putchar((i_sample>>8) & 0xFF);
putchar((i_sample>>0) & 0xFF);
i = (i == 47 ? 0 : i+1) ;
}
}
00:35 2020.01.12
================
sin.c and Makefile example files in folder:
'__Pnnn/P079 - Sound with aplayer C and Makefile/Software/'
cd '__Pnnn/P079 - Sound with aplayer C and Makefile/Software/'
make
It works!
:o)