module counter(clock, reset, z); // z becomes 1 when counter reaches 1010
input clock, reset; // declaration of inputs
output reg z; // declaration of output
reg [3:0] ps,ns; // to store present state and next state, we need to declare it with reg
parameter s0=1010,s1=0010,s2=1011,s3=1110; // assigning counter states to s0,s1,s2,s3 respectively
always@(ps) // always block for switching to next state in a counter and displaying output for each state
begin
case(ps)
s0 : begin
z=1; ns=s1;
end
s1 : begin
z=0; ns=s2;
end
s2 : begin
z=0; ns=s3;
end
s3 : begin
z=0; ns=s0;
end
end
endcase
always@(posedge clock) // always block for starting of the counter
if(reset)
ps<=s0; // initial it should in first state
else
ps<=ns; // if not reset, then next state becomes present state
end
8. Write a complete VHDL code for the 4-bit counter shown below. Reset synchronously returns the...
Design in VHDL a 4-bit up-down counter as presented below: The operation of the up-down counter is described by the following truth table: S1 S0 Action 0 0 Hold 0 1 Count up 1 0 Count down 1 1 Parallel Load Provide VHDL code and testbench XЗ Q3 X3X2X1X0 Parallel Load X2 S1SO Function Select Input Q2 RST-Asynchronous Reset Input X1 CLK- Clock Input Q1 хо Q3Q2Q1Q0 - Parallel Output Q0 CLK S1 S0 RST XЗ Q3 X3X2X1X0 Parallel Load...
WRITE IN SYSTEM VERILOG: Write an HDL code for a 32-bit Up-Down counter with rising edge clock, synchronous reset, and an up_down selection input. B1. Write an HDL code for a 32-bit Up-Down counter with rising edge clock, synchronous reset, and an up_down selection input. B1.
Write VHDL code to complete the conversion process of the following image • 2-digit decimal counter (0 = 99 = 0), with external asynchronous reset plus binary-coded decimal (BCD) to seven-segment display (SSD) conversion. SSD clk => digit2 610 digit1 reset Input: "xabcdefg"
Write a VHDL code to implement the circuit function described below. Student Id : 8123405 Last 4 digits : 3405 6. Write a VHDL code to implement the circuit function described below The circuit is to display the last four digits of your student ID number on a 7-segment display, one digit at a time, triggered by the falling edge of the clock signal DIR: Direction of the display sequence, T-forward, Ό'-reverse. CLK: clock pulse for the display sequence. RST:...
Write a VHDL code to implement the circuit function described below. 6. The circuit is to display the last four digits of your student ID number on a 7-segment display, one digit at a time, triggered by the falling edge of the clock signal. DIR: Direction of the display sequence, '1 CLK: clock pulse for the display sequence RST: reset the display counter. forward, '0' - reverse. Student ID: 8480594 Vdd ABCDE F G DIR CLK RST For example, if...
Write a VHDL code to implement the circuit function described below. 6. The circuit is to display the last four digits of your student ID number on a 7-segment display, one digit at a time, triggered by the falling edge of the clock signal. DIR: Direction of the display sequence, '1 CLK: clock pulse for the display sequence RST: reset the display counter. forward, '0' - reverse. Student ID: 8243416 Vdd ABCDE F G DIR CLK RST For example, if...
6. Write a VHDL code to implement the circuit function described below. The circuit is to display the last four digits of your student ID number on a 7-segment display, one digit at a time, triggered by the falling edge of the clock signal DIR: Direction of the display sequence, '1'forward, '0'- reverse. CLK: clock pulse for the display sequence. RST: reset the display counter Student ID-8860729 Vdd ABC|DEFG DIR CLK RST For example, if your ID number is 1234567,...
Problem 8 (Lab, 20 points) (1) Write a VHDL module implementing a synchronous 16-bit counter. A "reset signal resets the counter to 0. An "en" signal enables the counter modification. An "up signal indicates whether the counter must be incremented (1)/decremented (0). (2) The output of the module is the value of the signal, represented as 16 bits wide. Using output timing diagram to verify your coding results.
4.9. Write the VHDL code for a 4-bit register. Inputs: clk,enable, data; ouput:q.
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...