Google-apper
Hovedmeny

Post a Comment On: Ken Shirriff's blog

"Implementing FizzBuzz on an FPGA"

12 Comments -

1 – 12 of 12
Blogger Sebazzz said...

How does Verilog compare to VHDL? Have you tried VHDL? I have heard it is easier to write and easier to read.

March 13, 2018 at 11:18 AM

Blogger Ken Shirriff said...

Hi Sebazzz, I haven't tried VHDL, so I don't know how they compare. I chose Verilog kind of arbitrarily.

March 13, 2018 at 11:39 AM

Blogger Unknown said...

To use a software analogy: if Verilog is Python, then VHDL is Java.

More specifically, the main difference is that VHDL has stronger static checking (e.g., assigning two signals with different bit widths throws an error). The downside is that this usually entails less expressiveness/more code verbosity.

The other difference is that VHDL is used more by defense contractors (and DoD in general) due to its development history. Verilog on the other hand is more prevalent in industry (e.g., Intel).

March 13, 2018 at 12:08 PM

Anonymous Anonymous said...

No OpenCL support for this board?

March 13, 2018 at 2:12 PM

Blogger Carl Wyles said...

hm. what would you get if your begining code reference program was something like this? eg no division, no mod? add, compare only (cscropt example)
' cscript
dim i
dim f
dim b
f = 3
b = 5
t =""
For i = 1 To 100
t = ""
If i = f Then
t = "Fizz"
f = f + 3
End If
If i = b Then
t = t + "Buzz"
b = b + 5
End If
if t = "" then t = i
'wscript.echo i, f, b, t
wscript.echo t
Next

March 13, 2018 at 2:50 PM

Blogger Ken Shirriff said...

Carl, that's an interesting approach: keeping track of the next number that's Fizz and the next that's Buzz. One complication is that I used a BCD counter for "i", so for the comparison, "t" and "f" would also need to be BCD. So they would be 12 bits instead of 2 or 3. I'd also need to implement BCD addition. The result would be more hardware used.

March 13, 2018 at 4:13 PM

Blogger Unknown said...

"If Verilog is C, VHDL is ADA" would be more apt, in my mind.

March 13, 2018 at 4:41 PM

Anonymous JoshO said...

Interesting choice of RS232 for output method. I think if I was going to try this, I couldn't resist trying to do VGA, or monochrome NTSC. You could do it without too much ram just having 24 text-line registers that store either the bcd digits, or some values that mean to put either fizz, buzz or fizzbuzz. The horizontal counter would just multiplex the pixel column the value to be output on that line and the current line's subline against the rom of the character generators. It'd be fun.

March 15, 2018 at 10:32 AM

Blogger Ken Shirriff said...

JoshO: I've actually been thinking about doing this with VGA, and I've already ordered a VGA connector. (Many FPGA boards include VGA but the Mojo doesn't.) But I want to come up with something more interesting than just plain text, maybe cool colors.

March 15, 2018 at 12:03 PM

Blogger Ed said...

Might be worth mentioning that the tools to design and simulate your circuit are free-of-charge downloads from the vendor. In the case of Xilinx at least, they run on Windows or Linux. In the case of Lattice, there's also an open source tool suite (see icestorm on github). All this means that you can get started with FPGAs without even buying a board.

March 17, 2018 at 8:25 AM

Blogger Unknown said...

Did you consider using circular shift registers rather than increment/compare/reset for your modular counters and state machine? Obviously, it ended up using a pretty small fraction of the FPGA, but I would guess that an adder is a lot more gates than just having 3, 5, or 16 lines to track Fizz, Buzz, and the state machine.

March 17, 2018 at 2:40 PM

Anonymous Anonymous said...

Nice writeup, just wanted to mention that a % 3 check can also be easily implemented when doing BCD: Simply add up all numbers and check the sum for multiples of 3. With 99 being the largest number divisible by 3 you only need to check whether the sum is 0, 3, 6, 9, 12, 15 or 18.

March 19, 2018 at 6:50 AM

You can use some HTML tags, such as <b>, <i>, <a>

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.
Please prove you're not a robot