From the course: Learning Verilog for FPGA Development
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Solution: Make a 4-bit arithmetic logic unit (ALU) - FPGA Tutorial
From the course: Learning Verilog for FPGA Development
Solution: Make a 4-bit arithmetic logic unit (ALU)
(upbeat music) - How did you do? I hope you didn't run into much trouble. Now let's look at my solution. Here's the ALU module. As you can see, it simply consists of a case statement in an always block. Looking at the cases, you'll see that all of the operations are implemented in the language. So they are all just one line long. You may want to take a minute to verify that these operators are correct. And now let's look at the test bench. As you can see, it has the usual definition of stimulus variables, and the DUT instantiation. To keep it simple I've reported all values with the monitor task in line 32. Now this line may not look so simple, but you may want to hit pause to verify that it's simply showing what A, operated with B results in. The long sequence of conditional operations, the ternary operator, is placing the right operator in the string. So when the operation is true, for example the percentage…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Arithmetic and logic operators2m 59s
-
(Locked)
Challenge: Make a 4-bit arithmetic logic unit (ALU)1m 54s
-
(Locked)
Solution: Make a 4-bit arithmetic logic unit (ALU)2m 36s
-
(Locked)
Getting your ALU on a field-programmable gate array (FPGA)4m 26s
-
(Locked)
A functional demo of the ALU1m 44s
-
(Locked)
-
-