Question

Write a Verilog program to implement and test a subtractor. The program should have three modules. The first module, called c
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Design code:

design.sv 1//- 2timescale 1 ns / 1 ps 3 module cfulladder (A,B,Cin,s,Cout) 4 input A, B,cin; output reg S,Cout; always@(A or

Test bench code:

testbench.sv 1//-- 2 timescale 1 ns/1 ps 3 module t_sub; reg [3:0]A, B; reg Cin wire [3:01S; wire Cout; --Test_bench-- 4 5 6output:

time time= 0,A 0000, B 0000,cin-0,S=0000,Cout-0 5,A 0001, B-0010,cin=0,S=0011, Cout-0 10,A 0010, B-0100,cin-0,S=0110,cout-0 1waveform:25,000 10.000 A[3:0] E[3:0] Cin s[3:01

Add a comment
Know the answer?
Add Answer to:
Write a Verilog program to implement and test a subtractor. The program should have three modules....
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
  • Building and testing basic combinational circuits using Verilog HDL Description: Build and test the following circuits using gate-level modeling in Verilog HDL 1.3-input majority function 2.Condition...

    Building and testing basic combinational circuits using Verilog HDL Description: Build and test the following circuits using gate-level modeling in Verilog HDL 1.3-input majority function 2.Conditional inverter (see the table below: x - control input, y -data input). Do NOT use XOR gates for the implementation. Output 3. Two-input multiplexer (see the table below: x.y -data inputs, z- control input) Output 4. 1-bit half adder. 5. 1-bit full adder by cascading two half adders 6.1-bit full adder directly (as in...

  • Write a behavioral Verilog module for a 4-bit Johnson counter that has 8 states. The counter load...

    Write a behavioral Verilog module for a 4-bit Johnson counter that has 8 states. The counter loads the "0000" state if reset is low. The counter should start and end with this state. Write a testbench to verify the correctness of the 4-bit Johnson counter. The testbenclh should have a clock with a period of 20ns and a reset signal. The testbench should store the 4-bit binary outputs of the counter in a file, which will be used to provide...

  • Building and testing basic combinational circuits using Verilog HDL Description: Build and test t...

    Building and testing basic combinational circuits using Verilog HDL Description: Build and test the following circuits using gate-level modeling in Verilog HDL. 1. 3-input majority function. 2. Conditional inverter (see the table below: x - control input, y - data input). Do NOT use XOR gates for the implementation.    x y Output 0   y 1   y' 3. Two-input multiplexer (see the table below: x,y - data inputs, z - control input).     z Output 0 x 1 y 4. 1-bit half...

  • a) Write a Verilog module that implements a 1-bit partial full adder (PFA). b) Through instantiating...

    a) Write a Verilog module that implements a 1-bit partial full adder (PFA). b) Through instantiating the module in a) plus other logic, implement a 4-bit full adder with Verilog. c) Write a proper test-bench and stimulus, thoroughly test your 4 bit carry lookahead adder. d) Show a waveform snapshot that indicates you adder can correctly compute 0101 + 1101 and show your results.

  • FPGA (Interconnected Adder Modules) In this lab you will implement adder circuits using data flow modelling....

    FPGA (Interconnected Adder Modules) In this lab you will implement adder circuits using data flow modelling. You will also create 3-bit adder by employing interconnected 1-bit full adders. Data flow modelling of a 1-bit full adder circuit. Data flow modelling of a 3-bit adder circuit. There will be 7 inputs (X2, X1, X0, Y2, Y1, YO, Cin) - please put them in that order - Switch 6 will represent X2 and Switch 0 will be the Cin. There should be...

  • In quartus prime Implement a 4-bit adder/subtractor using structural VHDL. The circuit will have two 4-bit...

    In quartus prime Implement a 4-bit adder/subtractor using structural VHDL. The circuit will have two 4-bit data inputs (A and B), a control line (add /sub), a 4-bit sum output (S), a carry-out bit (Cout), and an overflow flag. You need two VHDL files (fulladd.vhd) and (hybrid.vhd) to implement the design. VHDL code, fulladd.vhd, will implement a single-bit full adder. The VHDL file, hybrid.vhd, will create four instances of the single-bit full adder. Four XOR gates will be needed to...

  • 1. In this example, we have some modules that are defined in a way that specifies...

    1. In this example, we have some modules that are defined in a way that specifies no inputs. This is not something you will commonly see because many times our modules perform some intermediary processing for our overall task along with the fact that we'd like to reuse our modules. For this problem, select the variable names that would be able to successfully linked to a value and have no conflicts. Be thinking about the scope of the variables. Module...

  • [15 pts] Write a single Verilog module that will have three binary inputs, and have three...

    [15 pts] Write a single Verilog module that will have three binary inputs, and have three binary outputs, 7) as described by the following three Boolean equations: E = A B+ C; F= A (B+ C); and G= Ã- (B C). You must accomplish one using only primitive instantiations, one using a single assign statement, and one as a combinatorial block.

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

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