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...

  • Write a test bench to thoroughly test the Verilog module dff_fe_asyn_h. below is the module ddff_fe_asyn_h.code...

    Write a test bench to thoroughly test the Verilog module dff_fe_asyn_h. below is the module ddff_fe_asyn_h.code Simulate the circuit using ISim and analyze the resulting waveform. Verilog Code for dff_fe_asyn_h is mentioned below:- //DFF module with asynchronous active high reset with negative edge trigger with clock module dff_fe_asyn_h ( input clock, // Clock Input input reset, // Reset Input input data_in, // Input Data output reg data_out // Output Data ); always @ (negedge clock or posedge reset) // triggers...

  • Given the following verilog code, draw the corresponding state diagram for it. module mysterious (input reset,...

    Given the following verilog code, draw the corresponding state diagram for it. module mysterious (input reset, clk, TB, TA, output reg [1:0] LB, LA); reg [1:0] cstate, nstate; parameter S0 = 2'b00; parameter S1 = 2'b01; parameter S2 = 2'b10; parameter S3 = 2'b11; parameter grn = 2'b00; parameter ylw = 2'b01; parameter rd = 2'b10; // state register always @ (posedge clk, posedge reset) begin if (reset) cstate <= S0; else cstate <= nstate; end // next state logic...

  • 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...

  • Modify the Moore FSM below to detect the sequence "110" , simulate using the same test...

    Modify the Moore FSM below to detect the sequence "110" , simulate using the same test bench and create a Moore Transition Diagram for the new sequence 110. module moore_seq (    input clock, reset, x,    output reg z ); //assign binary encoded codes to the states A through D parameter    A = 2'b00,    B = 2'b01,    C = 2'b10,    D = 2'b11; reg [1 : 0] current_state, next_state; //Section 1: Next state generator (NSG)...

  • a Read the following codes in Verilog and the corresponding testbench file. Describe what the codes...

    a Read the following codes in Verilog and the corresponding testbench file. Describe what the codes are doing by adding comments in the code. Then write down the simulation results of res1, res2, res3, and res4, respectively. Source code module vector_defn (num1, res1, res2, res3, res4); input [7:0] num1; output res1; output [3:0] res2; output [0:7] res3; output [15:0] res4; assign res1=num1[2]; assign res2=num1[7:4]; assign res3=num1; assign res4={2{num1}}; endmodule testbench: `timescale 1ns / 1ps module vector_defn_tb; reg [7:0] in1; wire...

  • Using Verilog, write a simulation code that shows the function g(w, x, y, z) = wxyz...

    Using Verilog, write a simulation code that shows the function g(w, x, y, z) = wxyz + w’x’y’z+w’x’yz’+w’xy’z’+wx’y’z’ using a 4 to 16 decoder that is built with two 3 to 8 decoders. The 3 to 8 source code I'm using is: module Dec3to8(    input[2:0] A,    input E,    output[7:0] D    );    assign D[0] = E & ~A[2] & ~A[1] & ~A[0];    assign D[1] = E & ~A[2] & ~A[1] & A[0];    assign D[2]...

  • How do I create a testbench with the verilog code below? module ganada(Clk, U1, D2, U2,...

    How do I create a testbench with the verilog code below? module ganada(Clk, U1, D2, U2, D3, U3, D4, F1, F2, F3, F4, CF, S); input Clk, U1, D2, U2, D3, U3, D4, F1, F2, F3, F4; output [6:0] CF, S; reg [6:0] CF, S; reg [1:0] SS, B, NS; initial begin NS=2'b00; SS=2'b00; end always@(posedge Clk) begin    case(NS)    2'b00: CF=7'b1111001; 2'b01: CF=7'b0100100; 2'b10: CF=7'b0110000; 2'b11: CF=7'b0011001; endcase case(SUD) 2'b00: S=7'b1000000;    2'b01: S=7'b1111001; 2'b10: S=7'b0100100; default: S=7'b0000000; endcase if(U1==1 ||...

  • 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...

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
ADVERTISEMENT