Question

In: Electrical Engineering

I need assistance with using Verilog to code the following: The decoder needs attention. Its function...

I need assistance with using Verilog to code the following:

The decoder needs attention. Its function is to take the 10‐bit input, and give three 4‐bit signals. The first 4‐bit signal should be the number of hundreds, the second 4‐bit signal should be the number of tens, and the final 4‐bit signal should be the number of units. In Verilog, these can be calculated simply using the numerical operators, specifically: Divide (/)  Modulus(%)

Given:

input[9:0] number

reg[3:0] numb_bcd0, numb_bcd1, numb_bcd2;

       numb_bcd0 = number % 4'd10; //units
       numb_bcd1 = (number / 4'd10) % 4'd10; //tenths
       numb_bcd2 = ... //hundredths

I am having trouble figuring out how to calculate the hundredths place for numb_bcd2; Thanks for the help!

Solutions

Expert Solution

design module:

// Code your design here
module decoder(number,bcd2,bcd1,bcd0);
input [9:0] number;
output reg [4:0] bcd2,bcd1,bcd0;
always@(*)
begin
bcd0=(number % 10);
bcd1=(number / 10)%10;
bcd2=(number/100)%10;// for 100 place u need to divide the number by100 and mod to by10
end
endmodule

//testbench

// Code your testbench here
// or browse Examples
module test();
reg [9:0] number;
wire [4:0] bcd2,bcd1,bcd0;
  
decoder d1(.*);
initial
begin
number=400;
#2 number=677;
#2 number=0;
#2 number=1000;
#2 number=344;
end
initial
$monitor("number=%d bcd2=%d bcd1=%d bcd0=%d",number,bcd2,bcd1,bcd0);
endmodule

output:

[2019-12-21 03:13:20 EST] iverilog '-Wall' '-g2012' design.sv testbench.sv && unbuffer vvp a.out
number= 400 bcd2= 4 bcd1= 0 bcd0= 0
number= 677 bcd2= 6 bcd1= 7 bcd0= 7
number= 0 bcd2= 0 bcd1= 0 bcd0= 0
number=1000 bcd2= 0 bcd1= 0 bcd0= 0
number= 344 bcd2= 3 bcd1= 4 bcd0= 4
Done


Related Solutions

I need to make changes to code following the steps below. The code that needs to...
I need to make changes to code following the steps below. The code that needs to be modified is below the steps. Thank you. 1. Refactor Base Weapon class: a.            Remove the Weapon abstract class and create a new Interface class named WeaponInterface. b.            Add a public method fireWeapon() that returns void and takes no arguments. c.             Add a public method fireWeapon() that returns void and takes a power argument as an integer type. d.            Add a public method activate()...
I need a Verilog code that makes the LEDs on the FPGA board works like this....
I need a Verilog code that makes the LEDs on the FPGA board works like this. https://image.ibb.co/mu5tnS/6.gif There are 16 LEDs in the FPGA board
I need assistance translating a custom C++ program to MIPS. My C++ code is the following:...
I need assistance translating a custom C++ program to MIPS. My C++ code is the following: I have made numerous attempts on my own to no avail, any assistance is appreciated. Also, template code for this solution is provided below: #include int moveRobots(int *, int *, int, int ); int getNew(int, int); int main() { int x[4], y[4], i, j, myX = 25, myY = 25, move, status = 1; // initialize positions of four robots x[0] = 0; y[0]...
Analyze the following Verilog code and write down its output as pictured in the code. module...
Analyze the following Verilog code and write down its output as pictured in the code. module blocking; reg [0:7] A, B; initial begin: init1 A = last decimal digit of your ID; #1 A = A + 1; // blocking procedural assignment B = A + 1; $display("Output 1: A= %b B= %b", A, B ); A = last decimal digit of your ID; #1 A <= A + 1; B <= A + 1; #1 $display ("Output 2: A=...
Verilog code for Traffic light controller. Need a block diagram, Verilog codes used with testbench, and...
Verilog code for Traffic light controller. Need a block diagram, Verilog codes used with testbench, and the waveforms screen-prints.
Digital System Design Write the verilog HDL code for 2-4 decoder (Gate level modeling) along with...
Digital System Design Write the verilog HDL code for 2-4 decoder (Gate level modeling) along with the testbench and simulate using ModelSim. Upload the assignment (i) code (ii) testbench (iii) simulation in single pdf file.
I need a synthesizable Verilog code/module implementing the IEEE 754 Floating Point multiplication and a corresponding...
I need a synthesizable Verilog code/module implementing the IEEE 754 Floating Point multiplication and a corresponding test bench. It should set a flag for underflow and overflow conditions if they arise during the multiplication for the output. It would be greatly appreciated if someone could write this floating point multiplication code in Verilog with some comment lines so i could understand the functioning too with a test bench module ! I have tried to explain everything as clearly as possible...
This problem needs to be solved with source code. I need a C++ program that will...
This problem needs to be solved with source code. I need a C++ program that will help me solve this question. I need it in C++, please. Writing with comments so it maybe cleared. 1.2. We received the following ciphertext which was encoded with a shift cipher: xultpaajcxitltlxaarpjhtiwtgxktghidhipxciwtvgtpilpit ghlxiwiwtxgqadds. 1. Perform an attack against the cipher based on a letter frequency count: How many letters do you have to identify through a frequency count to recover the key? What is...
I need to reverse strings with spaces using the nextLine() with Scanner in the following code:...
I need to reverse strings with spaces using the nextLine() with Scanner in the following code: package Chapter8; //To import the necessary libraries import java.util.Scanner; public class BackwardString { public static void main(String[] args) { //To read string from user input String input; Scanner scanner = new Scanner(System.in); System.out.print("Enter String here : "); input=scanner.next(); //To reverse passed string backward(input); //To close Scanner object scanner.close(); } //To reverse the input string private static void backward(String source) { int i, len =...
I need an original matlab code and gui for a simple double pendulum. This needs to...
I need an original matlab code and gui for a simple double pendulum. This needs to be original and not too complicated. Please provide basic instructions. Thank you!
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT