Question

Verilog Assignment l. (a) Use Modelsim to debug and compile a while loop statement syntax while expression statement module while example reg [5:0] location reg [7:0] data. always (data or location) begin. location If Data is 0, then location is 32 (invalid value) if (data 0) begin location. 32 end else begin while (data [0] 0) begin location. location 1. data data 1 end end. display (DATA 8b LOCATION d, data, location) end initial begin #1 data. 8 b11 #1 data. 8 b100 #1 data. 8 b1000 1 data. J: 8 b1000 0000 #1 data. 8 bo #1 finish; end endmodule (b) After running and simulating this code, printout the results. Provide explanation in a short paragraph (few lines) what this while example did (in the code), based on your output.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

After runnig this code i got the following output:

Data=00000011 LOCATION= 0
Data=00000001 LOCATION= 2
Data=00000001 LOCATION= 3
Data=00000001 LOCATION= 7
Data=00000000 LOCATION=32

so lets start with the first if condition, if data is 0 then location 32,as we can see the 5th data value is 0 location is 32.

coming to else part, while loop works as follows:

data[0] means first element of the data if it is 0 the increment location by 1 and perform binary right shift adding 0 to msb of the data say 00000011 >> 1 will give 00000001, this while continues till data[0] is 0.

Add a comment
Know the answer?
Add Answer to:
Use Modelsim to debug and compile a while loop statement syntax: while (< expression >) <...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • – Write and test a constrained random stimulus testcase for the testbench. Use ModelSim or a simi...

    – Write and test a constrained random stimulus testcase for the testbench. Use ModelSim or a similar simulator to test the transactor. Provide the code and evidence of its function. // ---------------------------------------------------------------------------- // File name: alu.v // Designed by: Jim Moran // ---------------------------------------------------------------------------- // // This module is the Arithmetic Logic Unit // // ---------------------------------------------------------------------------- `timescale 1ns/1ps //----------------------------------------------------------------------------- // Module Declaration //----------------------------------------------------------------------------- module alu (    // Global Signals    Clk_In, // Rising Edge Clock Input    Rst_l_In, // Active Low Reset Input   ...

  • Write a testbench for use in Quartus' ModelSim Altera in verilog for the following code of...

    Write a testbench for use in Quartus' ModelSim Altera in verilog for the following code of a 4x16 register: module regFile4x16 (input clk, input write, input [2:0] wrAddr, input [15:0] wrData, input [2:0] rdAddrA, output [15:0] rdDataA, input [2:0] rdAddrB, output [15:0] rdDataB); reg [15:0]    reg0, reg1, reg2, reg3; assign rdDataA = rdAddrA == 0 ? reg0 :        rdAddrA == 1 ? reg1 :        rdAddrA == 2 ? reg2 :        rdAddrA == 3...

  • I need the following in verilog. Attached is also the test bench. CODE // Design a...

    I need the following in verilog. Attached is also the test bench. CODE // Design a circuit that divides a 4-bit signed binary number (in) // by 3 to produce a 3-bit signed binary number (out). Note that // integer division rounds toward zero for both positive and negative // numbers (e.g., -5/3 is -1). module sdiv3(out, in); output [2:0] out; input [3:0]   in; endmodule // sdiv3 TEST BENCH module test; // these are inputs to "circuit under test" reg...

  • PLEASE READ AND CODE IN BASIC C++ CODE. ALSO, PLEASE CODE USING THIS DO WHILE LOOP...

    PLEASE READ AND CODE IN BASIC C++ CODE. ALSO, PLEASE CODE USING THIS DO WHILE LOOP AND FORMAT: #include <iostream> using namespace std; int main() { //variables here    do { // program here             }while (true);    } Objectives To learn to code, compile and run a program containing SELECTION structures Assignment Write an interactive C++.program to have a user input the length of three sides of a triangle. Allow the user to enter the sides...

  • 6-1 Test and debug the Invoice Application i need help with this please.. all help is...

    6-1 Test and debug the Invoice Application i need help with this please.. all help is appreciated Source code Java: import java.util.Scanner; import java.text.NumberFormat; public class InvoiceApp { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String choice = "y"; while (!choice.equalsIgnoreCase("n")) { // get the input from the user System.out.print("Enter customer type (r/c): "); String customerType = sc.next(); System.out.print("Enter subtotal: "); double subtotal = sc.nextDouble(); // get the discount percent double discountPercent = 0.0; switch(customerType) {...

  • program an 8-to-1 multiplexor using verilog output of time table from 1 - 2047 For example...

    program an 8-to-1 multiplexor using verilog output of time table from 1 - 2047 For example output should look like.... --------- [Start of table] ---------------------------- [End of table] ---------- Here is example of 4x1 Multiplexor ... Just need code for 8x1 Multiplexor module DecoderMod(s, o); input [1:0] s; output [0:3] o; wire [1:0] inv_s; not(inv_s[1], s[1]); not(inv_s[0], s[0]); and(o[0], inv_s[1], inv_s[0]); and(o[1], inv_s[1], s[0]); and(o[2], s[1], inv_s[0]); and(o[3], s[1], s[0]); endmodule module MuxMod(s, d, o); input [1:0] s; input [0:3]...

  • Debug the following java code so that it will have given out put at the bottom....

    Debug the following java code so that it will have given out put at the bottom. Make sure to fix all syntax and logical errors. import java.util.Scanner; public class Graphs { // draws 5 histograms public void drawHistograms() Scanner input = new Scanner( System.in ); int number1 = 0; // first number int number2 = 0; // second number int number3 = 0; // third number int number4 = 0; // fourth number int number5 = 0; // fifth number...

  • You will use Quartus II to build an 8 bit arithmetic logic unit that performs the...

    You will use Quartus II to build an 8 bit arithmetic logic unit that performs the following functions: Control Value Function                                000 Copy In1 to theResult unchanged 001 Copy In2 to theResult unchanged 010 Add In1 to In2 011 Subtract In2 from In1 100 And In1 and In2 101 Or In1 and In2 110 Shift left In1 by 1 bit 111 Shift right In1 by 1 bit You are allowed to use either gates/logic schematic, or else Verilog. We suggest...

  • Q10: Which of the following is not an error (either a syntax error or a logic...

    Q10: Which of the following is not an error (either a syntax error or a logic error)? Neglecting to include an action in the body of a while statement that will eventually cause the condition to become false. Spelling a key word (such as while or if) with a capitalized first letter. Using a condition for a while statement that is initially false. An infinite loop. Q11: How many times is the body of the loop below executed? int counter;...

  • 31. True or False: The condition in the following if statement is a syntax error:

     31. True or False: The condition in the following if statement is a syntax error: int number=50;…… if (number)…… 32. True or False: The standard C functlon strlen) will return 4 when invoked upon the varlable name, declared below: char namel = (e', 'p', 't', 's', '\0', '1', '2', '1', '\0']; 33. True or False: A structure is a collection of related variables under one name. 34. True or False: In C, output parameters allow for a function to return more than one value Indirectly. 35. True or...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT