Question

Write a VERILOG simulation code for a 3 to 8 decoder and a simulation code for a 4 to 16 decoder using two 3 to 8 decoders.

The code used for 3 to 8 decoder:

22 module Dec3to8 ( 23 input [2:0 A input E output [7:0] D 24 25 26 27 E &A[2]& 28 assign D[0] A[1 A[0] E &A[2] &A[1] assign

Code used for 4 to 16 decoder:

xDec3to8.v Schematic (2) Schematic (3) Project Summary Schematic Dec4to16.v X X X E:/EEE3342X/Lab_5/Test 1/Test 1.srcs/source

Need help with simulation code.

22 module Dec3to8 ( 23 input [2:0 A input E output [7:0] D 24 25 26 27 E &A[2]& 28 assign D[0] A[1 A[0] E &A[2] &A[1] assign D[1] & A[0] 29 E & A[2] & A[1] & A[0]; 30 assign D[2] assign D[3 E & A[2] & A[1] & A[0]; 31 & A[1 ~A[0] E & A[2]& A[1] & A[0] E & A[2] 32 assign D[4] 33 assign D[5] assign D[6] assign D[7] = E & A[2] 34 A[1 A[01 & A[1 A[0] E &A[2] 35 endmodule 36 37
xDec3to8.v Schematic (2) Schematic (3) Project Summary Schematic Dec4to16.v X X X E:/EEE3342X/Lab_5/Test 1/Test 1.srcs/sources_1/new/Dec4to16.v 13 // /Dependencies: 14 15 //Revision: 16 //Revision 0.01 - File Created 17 //Additional Comments: 18 // 19 20 21 22 23 module Dec4tol6 ( input [3:0 A output [15:0] D 24 25 26 Dec3t08 decl ( .A (A[2:01, .E (A[3]), .D(D [15:8])); Dec3t08 dec2(.A (A[2:01), .E(~A [3]), .D(D[7:0])) 27 28 29 endmodule 30
0 0
Add a comment Improve this question Transcribed image text
Answer #1

//Testbench

`timescale 1ns/1ps

module Dec4to16_tb();

   reg [3:0] A;
   wire [15:0] D;

   Dec4to16 dec1(.A(A), .D(D));
  
   initial
   begin
   A <= 4'b0000;
   #5;
   A <= 4'b0001;
   #5;
   A <= 4'b0010;
   #5;
   A <= 4'b0011;
   #5;
   A <= 4'b0100;
   #5;
   A <= 4'b0101;
   #5;
   A <= 4'b0110;
   #5;
   A <= 4'b0111;
   #5;
   A <= 4'b1000;
   #5;
   A <= 4'b1001;
   #5;
   A <= 4'b1010;
   #5;
   A <= 4'b1011;
   #5;
   A <= 4'b1100;
   #5;
   A <= 4'b1101;
   #5;
   A <= 4'b1110;
   #5;
   A <= 4'b1111;
   #5;
   end

endmodule

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Simulation

M ModelSim INTEL FPGA STARIER EDITION 10.5b File Edit View Compile Simulate Add Wave Tools Lavout Bookmarks Window Help 3 E.

Add a comment
Know the answer?
Add Answer to:
Write a VERILOG simulation code for a 3 to 8 decoder and a simulation code for...
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
  • 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]...

  • Write Verilog modules: a 3x8 decoder and a 8x1 multiplexor. The multiplexor “includes” the decoder module...

    Write Verilog modules: a 3x8 decoder and a 8x1 multiplexor. The multiplexor “includes” the decoder module as part of it. Use arrays as much as possible. EXAMPLE: module DecoderMod(s, o); // module definition input s; output [0:1] o; not(o[0], s); assign o[1] = s; endmodule module MuxMod(s, d, o); input s; input [0:1] d; output o; wire [0:1] s_decoded, and_out; DecoderMod my_decoder(s, s_decoded); // create instance and(and_out[0], d[0], s_decoded[0]); and(and_out[1], d[1], s_decoded[1]); or(o, and_out[0], and_out[1]); endmodule

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

  • 3. (10 Points) RTL Combinational Circuit Design a Draw the schematic for the Verilog code given...

    3. (10 Points) RTL Combinational Circuit Design a Draw the schematic for the Verilog code given below: module abc (a, b, c, d, si, s0); input 31, 30; output a, b, c,d; not (51_, 51), (50_, 0); and (a, s1_, SO_); and (b, s1_, 0); and (c, sl, s0_); and (d, sl, s0); endmodule b. Draw the schematic for the Verilog code given below: module Always_Code input a, b, c, output reg F ); always @(a, b, c) begin F...

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

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

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

  • 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

  • Please code the following in Verilog: Write the HDL gate-level hierarchical description of a four-bit adder-subtractor...

    Please code the following in Verilog: Write the HDL gate-level hierarchical description of a four-bit adder-subtractor for unsigned binary numbers similar to the following circuit. You can instantiate the four-bit full adder described in the following example code Figure 4.13a, 4-Bit adder-subtractor without overflow Inputs: 4-Bit A, 4-Bit B, and Mode M (0-add/1-subtract) Interfaces: Carry Bits C1, C2, C3 Outputs: Carry C (1 Bit, C4), Sum S (4 bit) Bo A FA FA FA FA module Add half (input a,...

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