Question

In: Electrical Engineering

write a verilog code to implement a digital system that has an odd counter that counts...

write a verilog code to implement a digital system that has an odd counter that counts from 1 to 11. Also, this system has an output Y that detects a specific number in the odd counter. Test your code when you detect the number 3, the output Y is 1, if the counter value is set to 3, otherwise 0.

Solutions

Expert Solution

Solution:

Verilog code is developed to get the counter to count only odd numbers from 1,3,5,7,9 and 11 and reset to 1. It has one output called Y = 1 when the count is equal to 3.

Verilog code:

//////////////////////////////////////////////////////////////////////////////////
module count4bit (Clock, reset, Y, Q);
input Clock, reset;
output Y;
output reg [3:0] Q;
always @(posedge Clock)
if (reset)
Q <= 1;
else
begin
Q <= Q+2;
if(Q > 10)
   Q<= 1;
end
assign Y= (Q == 3);
endmodule
///end of the code/////////////////

Test bench code:


module tb_Odd;

   // Inputs
   reg Clock;
   reg reset;

   // Outputs
   wire Y;
   wire [3:0] Q;

   // Instantiate the Unit Under Test (UUT)
   count4bit uut (
       .Clock(Clock),
       .reset(reset),
       .Y(Y),
       .Q(Q)
   );

   initial begin
       // Initialize Inputs
       Clock = 0;
       reset = 1;

       // Wait 100 ns for global reset to finish
       #100;
        reset = 0;

       // Add stimulus here

   end
            initial forever #5 Clock = ~ Clock;

endmodule
//end of the test bench code/////////////////

SImulated results:

The design has inputs Clock and reset

outputs Y and Q


Related Solutions

Write a Verilog code to implement 16 bit LFSR
Write a Verilog code to implement 16 bit LFSR
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.
1a. Write your Verilog program to implement the timer counter. HEX0 should show tenths of seconds...
1a. Write your Verilog program to implement the timer counter. HEX0 should show tenths of seconds from 0 to 9. HEX1 and HEX2 should show a count of seconds, from 00 to 59. The ones count is on HEX1 and the tens count is on HEX2. 1b. Count backwards and forwards. Add a button or switch to control counting direction. When counting forwards or backwards, your count should not stop but rollover appropriately at the correct time. When counting forward,...
use modelsim write Verilog code for the following digital logic circuits and then simulate them by...
use modelsim write Verilog code for the following digital logic circuits and then simulate them by writing a testbench module for each of them , (a)The FSMs for the snail problem that is in the slides (a snail crawls over a tape that has 0 and 1 and smiles if it has detected the '10' bits using both Moore and Mealy FSM. Note that the pattern is '10' not '01' as in the slides. (b) A rock-paper-scissor game played by...
Write a verilog code for digital clock and display it’s seven segment using fpga?
Write a verilog code for digital clock and display it’s seven segment using fpga?
Write in verilog, code to implement a 6 bit multiplier. Cascade a 1 bit multiplier to...
Write in verilog, code to implement a 6 bit multiplier. Cascade a 1 bit multiplier to implement this.
Create a counter that continuously counts odd numbers backwards (i.e from ‘F’ to ‘0’) and display...
Create a counter that continuously counts odd numbers backwards (i.e from ‘F’ to ‘0’) and display it on 7-sd by using the Verilog code. On this part, you are required to use the clock from the FPGA board. However, the clock frequency is 100 MHz, and it is too fast to be used (10 ?s). Thus, we need to derive a slower clock with a speed of almost 1 s, which the frequency of it is 1 Hz. This process...
Write VHDL code (behavior model) to implement a 4-bit modulo-9 counter and simulate your VHDL code...
Write VHDL code (behavior model) to implement a 4-bit modulo-9 counter and simulate your VHDL code of 4-bit modulo-9 counter in ModelSim, and capture the screenshot of your simulated waveform. Assume clock period Tclk=100ns, initially, the counter is reset to Q3Q2Q1Q0=0000 you need to simulate a complete counting cycle plus one more additional clock period after it is reset to “0000” state.
Implement a JK Flip flop using behavioral modeling in verilog, also write its test bench code.
Implement a JK Flip flop using behavioral modeling in verilog, also write its test bench code.
verilog code to implement 32 bit Floating Point Adder in Verilog using IEEE 754 floating point...
verilog code to implement 32 bit Floating Point Adder in Verilog using IEEE 754 floating point representation.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT