Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

verilog combinational logic: The fizzbuzz program outputs the first 100 integers

ID: 3727483 • Letter: V

Question

verilog combinational logic:

The fizzbuzz program outputs the first 100 integers, any integer which is a multiple of 3 should print fizz, any integer which is a multiple of 5 should print buzz, any integer a multiple of 3 and 5 should print fizzbuzz, the remaining integers should print their value.

The verilog module fizzbuzz.v contains fizzbuzz4( fizz, buzz, fizzbuzz, num ) and fizzbuzz5( fizz, buzz, fizzbuzz, num ). fizzbuzz4 provides a 4-bit number input, num and three outputs. fizz is true if num is a multiple of 3, buzz is true if num is a multiple of 5, and fizzbuzz is true if num is a multple of 3 and 5. fizzbuzz5 accepts 5 bit numbers.

The module, tb_fizzbuzz.v provides a test bench for fizzbuzz4 and fizzbuzz5.

Replace the behavioural coding in fizzbuzz4 with Boolean Expressions. The fizzbuzz5 behavioural must also be replaced. It can be implement with two four variable modules. One module handles the numbers from 0 to 15, and the other module handles 16 to 31. Since fizzbuzz4 already handles 0 to 15 it can be used in fizzbuzz5.

-----------------------------------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------------------------------

Replace the behavioural coding in fizzbuzz4 with Boolean Expressions. The fizzbuzz5 behavioural must also be replaced. It can be implement with two four variable modules. One module handles the numbers from 0 to 15, and the other module handles 16 to 31. Since fizzbuzz4 already handles 0 to 15 it can be used in fizzbuzz5.

Explanation / Answer

THANKS, LET ME KNOW IF THERE IS ANY CONCERN module main; wire fizz, buzz ; reg [5:0] num; integer fb30_passed, fb45_passed; wire test_fizz = (num % 3) == 0; wire test_buzz = (num % 5) == 0; fb30 test1( fizz30, buzz30, num[4:0]); fb45 test2( fizz45, buzz45, num); initial begin num = 0; fb30_passed = 1; repeat ( 31 ) begin #10; //$display("fb30: num=%d fizz=%b buzz=%b", num, fizz30, buzz30); if ( fizz30 != test_fizz || buzz30 != test_buzz ) begin $display("fb30 failed at %d", num); fb30_passed = 0; end num = num + 1; end if ( fb30_passed == 1 ) begin $display("fb30 passed"); end num = 0; fb45_passed = 1; repeat ( 46 ) begin #10; //$display("fb45: num=%d fizz=%b buzz=%b", num, fizz45, buzz45); if ( fizz45 != test_fizz || buzz45 != test_buzz ) begin $display("fb45 failed at %d", num); fb45_passed = 0; end num = num + 1; end if ( fb45_passed == 1 ) begin $display("fb45 passed"); end end endmodule