Question

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 out1;

wire [3:0] out2;

wire [0:7] out3;

wire [15:0] out4;

vector_defn UUT(.num1(in1),.res1(out1),.res2(out2),.res3(out3));

initial begin

in1 = 8’hEC;

#100;

end

endmodule

b. the following code describes a 3-bit shift register.

module register(

input [2:0] R,

input Load,

input Clock,

output reg [2:0] Q);

always@ (posedge Clock)

     if (Load)

             Q <= R;

     else

             Q <= {Q[0], Q[1] ^ Q[2], Q[2]};

endmodule

If 001 is loaded into the shift register initially, what is the sequence of numbers generated? List the binary numbers it generates, starting from 001.

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
a Read the following codes in Verilog and the corresponding testbench file. Describe what the codes...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • 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 testbench for LFShift shift register example module 1f3r input clk, input reset, output a...

    Write a testbench for LFShift shift register example module 1f3r input clk, input reset, output a ); reg (5:0] shift; wire xor_sum; assign xor_sum = shift[1] ^ shift[4]; // feedback taps always @ (posedge clk) if (reset) shift <= 6'b111111; // initialize LFSR else shift <= { xor_sum, shift [5:1] }; // shift right assign a = shift[0]; // output of LFSR endmodule

  • 5.28 The Verilog code in Figure P5.9 represents a 3-bit linear-feedback shift register (LFSR) This type...

    5.28 The Verilog code in Figure P5.9 represents a 3-bit linear-feedback shift register (LFSR) This type of circuit generates a counting sequence of pseudo-random numbers that repeats after 2" - 1 clock cycles, where n is the number of flip-flops in the LFSR. Synthesize a circuit to implement the LFSR in a chip. Draw a diagram of the circuit. Simulate the circuit's behavior by loading the pattern 001 into the LFSR and then enabling the register to count. What is...

  • Please help to complete the code and write the testbench to design the following adder. 1.In...

    Please help to complete the code and write the testbench to design the following adder. 1.In this section, you add pipeline stage. 8 bits are used at every pipeline stage.Use the following template to complete your Verilog coding. // Addition of two 16 bit, 2's complement nos., n1 and n2. 8 bits addition at a time. Result is 17 bits. module adder_b (clk, n1, n2, sum) ; input clk ; input [15:0] n1 ; input [15:0] n2 ; output [16:0]...

  • Please explain what he verilog code does: module lab7_2_3( input clk, input Enable, input Clear, input...

    Please explain what he verilog code does: module lab7_2_3( input clk, input Enable, input Clear, input Load, output [3:0] Q, reg [3:0] count,      wire cnt_done );             assign cnt_done = ~| count;     assign Q = count;     always @(posedge clk)          if (Clear)              count <= 0;          else if (Enable)          if (Load | cnt_done)          count <= 4'b1010; // decimal 10          else          count <= count - 1; Endmodule

  • 7. Which of the following Verilog code segments will generate errors when compiled? A. module demo...

    7. Which of the following Verilog code segments will generate errors when compiled? A. module demo output reg F, input a): ire b; reg c assign b-c; initial begin end endmodule module demo5 output reg F, input reg a); ire b reg c assign bC; initial begin end C. module demooutput reg F, input wire a ire b reg c assign b c; initial begin F c& b; end D. O both A) and C) E. O none will generate...

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

  • Question 3: Realize the circuit below using Verilog. Include a signal “reset_n” for asynchronously clearing the...

    Question 3: Realize the circuit below using Verilog. Include a signal “reset_n” for asynchronously clearing the flip-flop. What type of circuit is this? Complete the following Verilog code. Write a test bench to test it. clk sel module aff (clk, reset_n, sel, q); input clk ; // Declare the inputs and outputs of the module. input reset_n; input sel; output q; reg q; wire D; ; // model the combinational logic assign D= always @( begin if ( else end...

  • WRITE THE CODE IN VERILOG: Instead of using Registers, USE D FLIP FLOPS and a clock....

    WRITE THE CODE IN VERILOG: Instead of using Registers, USE D FLIP FLOPS and a clock. Include the logic for a reset A sequential circuit with three D flip-flops A, B, and C, a trigger x, and an output z1, and zo. On this state machine diagram, the label of the states are in the order of (ABC), the transition is the one bit x, and the output is under the forward slash. x/z1zo. The start state is 001 0/01...

  • why its 4-to-1 mux behavioral? What does the logic circuit represented by the following Verilog module...

    why its 4-to-1 mux behavioral? What does the logic circuit represented by the following Verilog module do, and what Verilog description style does it use? // My Verilog module #1 module mymodl ( x, d, q) input[1:0] x;input[3:0] d;output q; reg q; wire [1:0] x; wire [3:0] d; always ( x or d) begin case ( x ) 1 : q=d[1]; 2 : g=d[2]; 3 q d[3]; endcase end endmodule

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