Question

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] = E & ~A[2] & A[1] & ~A[0];
   assign D[3] = E & ~A[2] & A[1] & A[0];
   assign D[4] = E & A[2] & ~A[1] & ~A[0];
   assign D[5] = E & A[2] & ~A[1] & A[0];
   assign D[6] = E & A[2] & A[1] & ~A[0];
   assign D[7] = E & A[2] & A[1] & A[0];
endmodule

The source code for the 4 to 16 decoder using the two 3 to 8 decoders is:

module Dec4to16(
   input[3:0] A,
   output[15:0] D
   );
   Dec3to8 dec1(.A(A[2:0]), .E(A[3]), .D(D[15:8]));
   Dec3to8 dec2(.A(A[2:0]), .E(~A[3]), .D(D[7:0]));
endmodule

and the simulation code I'm using is:

module Dec4to16_Sim( );

reg[3:0] A_t;
wire[15:0] D_t;

Dec4to16 UUT(
.A(A_t),   
.D(D_t)
);
initial begin
A_t = 4'b000;
end
always #10 A_t = A_t + 1;

endmodule

These codes don't show the minterms for the function posted above and I'm not sure how to that.

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

For the required output you have to take one more output of 1 bit.

module Dec4to16(
input[3:0] A,

output g,
output[15:0] D
);
   Dec3to8 dec1(.A(A[2:0]), .E(A[3]), .D(D[15:8]));
   Dec3to8 dec2(.A(A[2:0]), .E(~A[3]), .D(D[7:0]));

assign g = D[1] or D[2] or D[4] or D[8] or D[15];
endmodule

Simulation code :-

module Dec4to16_Sim( );

reg[3:0] A_t;

wire g_t;
wire[15:0] D_t;

Dec4to16 UUT(
.A(A_t),

.g(g_t),
.D(D_t)
);
initial begin
A_t = 4'b000;
end
always #10 A_t = A_t + 1;

endmodule

Note that i have taken the decoders whose outputs are active high.

Add a comment
Know the answer?
Add Answer to:
Using Verilog, write a simulation code that shows the function g(w, x, y, z) = wxyz...
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 a VERILOG simulation code for a 3 to 8 decoder and a simulation code for...

    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: Code used for 4 to 16 decoder: 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 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...

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

  • help me to finish the verilog code and test bench Part 2: Sequence Counter Design the...

    help me to finish the verilog code and test bench Part 2: Sequence Counter Design the sequence counter using Xilinx Vivado. Consider the required number of D flip-flops(4). A sample VERILOG source file is as shown: module Seq_COUNT(     ??? clock,     ??? wire [?:?] D,     ??? ??? [?:?] out     );     always @ (??? ???)     ???         // 3 bit Sequence Given is 0 2 4 6 1 3 5 7         out[N-1] <= some expression;...

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

  • I need a test bench code for this module in verilog. Verilog Code module part6 (А.В.us,G,E,L);...

    I need a test bench code for this module in verilog. Verilog Code module part6 (А.В.us,G,E,L); AlL ((Al --AI --op AIL (us) I-AIL input [2:0]A,B; input us; output G,E.I; reg G,E,L wire [2:0] A,B; always@(A or B) if (us 1)//unsigned mode begin しくーAB: //А is less G-A>B; //B is less 区-A-B; //logical (A equality end --oper AlL1 A[0] & -AIL E<-Ssigned(A) Ssigned(B); //logical equality opera AIL1I -AILI -operat else //signed mode begin しく=$signed(A)<$signed(B); //Ais less G-Ssigned(A)>Ssigned(B);: //B is less end...

  • (15 pts) 1. Draw a logic diagram for the Verilog code. module Seq_Ckt ( CLK, PR,...

    (15 pts) 1. Draw a logic diagram for the Verilog code. module Seq_Ckt ( CLK, PR, sel, Q); input CLK, PR, sel; output reg [2:0] Q; reg [2:0] y; assign Q = y; always @ (posedge PR, posedge CLK) begin if (PR== 1) then y <= 3'b111; else if (sel) begin y[2] <= y[1] ^ y[0]; y[1] <= y[2]; y[1]; end else y[2] <= y[2] ; y[1] <= y[1]; y[0]; y[O] <= y[0] <= 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