Just need the code for the random counter,Thanks
// Counter Block in Whole Micro-Architechture of
Random_Counter
module counter(
//Input Ports
input Clock,
input Reset,
input L,
//Output Ports
output reg [3:0] O,
output reg [1:0] S
);
//Internal Wires and Regs
reg [1:0]S_w;
reg [3:0]O_w;
//Sequential Block
always@(posedge Clock or negedge Reset) begin
if(~Reset) begin // Asynchronous active low reset
O <= 4'b0000;
S <= 2'b00;
end
else begin
O <= O_w;
S <= S_w;
end
end
//Combinational Block for O output
always@(O or L) begin // When input or counter transition this
block trigger
case(O)
4'b0000 : O_w = 4'b0100;
4'b0100 : O_w = 4'b0010;
4'b0010 : O_w = 4'b1001;
4'b1001 : O_w = 4'b0001;
4'b0001 : O_w = 4'b0110;
4'b0110 : O_w = 4'b1000;
4'b1000 : O_w = 4'b0101;
4'b0101 : O_w = 4'b0111;
4'b0111 : O_w = 4'b0011;
4'b0011 : O_w = 4'b0000;
default : O_w = 4'b0000; //Default is given to remove
latches when using mux.
endcase
end
//Combinational Block for S output
always@(O or L) begin
if(L) begin
case(O)
4'b0000 : S_w = 2'b01;
4'b0100 : S_w = 2'b10;
4'b0010 : S_w = 2'b11;
4'b1001 : S_w = 2'b00;
4'b0001 : S_w = 2'b01;
4'b0110 : S_w = 2'b10;
4'b1000 : S_w = 2'b11;
4'b0101 : S_w = 2'b00;
4'b0111 : S_w = 2'b01;
4'b0011 : S_w = 2'b10;
default : S_w = 2'b00; //Default is given to remove
latches when using mux.
endcase
end
else begin
case(O)
4'b0000 : S_w = 2'b01;
4'b0100 : S_w = 2'b00;
4'b0010 : S_w = 2'b11;
4'b1001 : S_w = 2'b10;
4'b0001 : S_w = 2'b01;
4'b0110 : S_w = 2'b00;
4'b1000 : S_w = 2'b11;
4'b0101 : S_w = 2'b10;
4'b0111 : S_w = 2'b01;
4'b0011 : S_w = 2'b00;
default : S_w = 2'b00; //Default is given to remove
latches when using mux.
endcase
end
end
endmodule
//Binary Decoder 2 to 4 Verilog code module
module binary_decoder_2_4(
//Input Port
input [1:0]S,
//Output Ports
output reg Y0,Y1,Y2,Y3
);
//Binary Decoder Logic
always@(*) begin
case(S)
2'b00 : {Y0,Y1,Y2,Y3} = 4'b1000;
2'b01 : {Y0,Y1,Y2,Y3} = 4'b0100;
2'b10 : {Y0,Y1,Y2,Y3} = 4'b0010;
2'b11 : {Y0,Y1,Y2,Y3} = 4'b0001;
endcase
end
endmodule
//BCD to 7 Segment Decoder common cathode
module bcd_7_seg(
//Input Ports
input enable, //Decoder enable or disable
input [3:0]bcd,
//Output Port
output reg [6:0]HEX_O
);
//Combinational Block for BCD to 7 Segment Decoder Common
cathode
//For common anode we have to invert 1's to 0's and 0's to
1's
always @(*) begin
if(enable) begin
case(bcd)
4'b0000: HEX_O = 7'b0000001; // "0"
4'b0001: HEX_O = 7'b1001111; // "1"
4'b0010: HEX_O = 7'b0010010; // "2"
4'b0011: HEX_O = 7'b0000110; // "3"
4'b0100: HEX_O = 7'b1001100; // "4"
4'b0101: HEX_O = 7'b0100100; // "5"
4'b0110: HEX_O = 7'b0100000; // "6"
4'b0111: HEX_O = 7'b0001111; // "7"
4'b1000: HEX_O = 7'b0000000; // "8"
4'b1001: HEX_O = 7'b0000100; // "9"
default: HEX_O = 7'b0000001; // "0"
endcase
end
else begin
HEX_O = 7'b1111111; //If enable is "0"
end
end
endmodule
//Random_Counter Verilog Code Top module
module Random_Counter(
//Input Ports
input [1:0]KEY,
input SW,
//Output Ports
output [6:0]HEX0,HEX1,HEX2,HEX3
);
//Declaration of Internal Wires required to connect between modules
instances
wire [1:0]S;
wire [3:0]O;
wire Y0,Y1,Y2,Y3;
//Modules Instantiation for counter,binary decoder, 7 segment
decoder
counter COUNTER_INST(KEY[0],KEY[1],SW,O,S);
binary_decoder_2_4 BINARY_DECODER_INST(S,Y0,Y1,Y2,Y3);
bcd_7_seg BCD_TO_7_SEG_INST_0(Y0,O,HEX0);
bcd_7_seg BCD_TO_7_SEG_INST_1(Y1,O,HEX1);
bcd_7_seg BCD_TO_7_SEG_INST_2(Y2,O,HEX2);
bcd_7_seg BCD_TO_7_SEG_INST_3(Y3,O,HEX3);
endmodule
//Testbench for Random Counter
//DUT means Random Counter here
module test;
reg Clock,Reset,SW; //Regs to Drive stimulus to DUT inputs
wire [6:0]HEX0,HEX1,HEX2,HEX3; //Wires to connect for DUT
outputs
//Clock Generation
always begin
#5 Clock = 1'b1;
#5 Clock = 1'b0;
end
//Instantiation of DUT - Random_Counter
Random_Counter RANDOM_COUNTER_INST(
.KEY({Reset,Clock}),
.SW(SW),
.HEX0(HEX0),
.HEX1(HEX1),
.HEX2(HEX2),
.HEX3(HEX3)
);
//Driving Stimulus to DUT(Random_Counter)
initial begin
SW = 1'b0;
Reset = 1'b0; // Asynchronous active low reset
#15 Reset = 1'b1;
SW = 1'b1;
#100 SW = 1'b0;
#100 $finish; // Finishing the simulation
end
endmodule
//Simulation Waveform
1)
2)
Objective: In this lab, we will learn how we can design sequential circuits using behavioral mode...
Assignment 9 ENGR 205-01 Date of Submisson: April 23, 2019 Name: Design a decade counter which counts in the sequence 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001, 0000,.. 1. Use a T flipflop. Use a J-K flipflop. a. b.
1 Simulations to verify a 4-bit Register Simulate and verify a 4-bit Register using behavioral VHDL code in ModelSim. Recall that sequential circuits depend on both present and past state. Sequential circuits are in contrast to combinational circuits, which depend on input values from only the present state. Fur- thermore, recall that a flip-flop is a fundamental circuit used to create more complex sequential circuits. A register is an array of storage components, such as flip-flops. For example, a 4-bit...
Design C-1 (modulo-10 up-counter): Using the behavioral VHDL coding, create an up-counter to count upward. The up counter has the following control inputs En.reset, CLK. The counting outputs are Q0, O1, Q2. and O3 reset clears the outputs of the counter to 0. En enables the counting when En-1. When En-0, the counter stops. The counter sequentially counts all the possible numbers and loops again, from 0 to 9, back to 0 and 9, etc Design C-2: Ten-second Counter with...
Consider the circuit in Figure 1. It is a 4-bit (QQ2Q3) synchronous counter which uses four T-type flip-flops. The counter increases its value on each positive edge of the clock if the Enable signal is asserted. The counter is reset to 0 by setting the Clear signal low. You are to implement an 8-bit counter of this type Enable T Q Clock Clear Figure 1. 4-bit synchronous counter (but you need to implement 8-bit counter in this lab) Specific notes:...
ECE 1552- Summer 2019 Homework 2: Solve all questions. HW is to be turned in as a PDF or word document on canvas. Show all working. Answers provided should be typed or written CLEARLY 1: Find a function to detect an error in the representation of a decimal digit in BCD. In other words, write an equation with value 1 when the inputs are any one of the six unused bit combinations in the BCD code, and value 0 otherwise...
Preparation (Pre-lab) Before coming to the first lab session, complete the following tasks: Generate a truth table showing inputs vs outputs for the following circuit blocks in Part I: Comparator, Circuit A, and Circuit B. o Use the truth tables to produce minimized SOP (sum of products) for the Comparator, Circuit A and Circuit B. Part I - Simple Binary to BCD Conversion Design Specifications You are to design a circuit that converts a four-bit binary number V[3..0] = V[3]...
A seven segment decoder is a digital circuit that displays an input value 0 through 9 as a digital output in the 7-segment display. The behavior of this design can be modeled with the schematic diagram below, where DCBA is the 4-bit input (D is the most significant bit and A is the least significant bit) and abcdefg is the 7-segment output. 2. (20 POINTS) A seven segment decoder is a digital circuit that displays an input value 0 through...
please answer question 4 (all parts of question4 please) will rate! 3. (30 pts) Design a 2-bit Gray code generator that ropetitively delivers the sequence 00301911-10-00when the input signal UP- 1,or in reverse order 009 10기け01 →00→ when UP-0. Your design should include an asynchronous low. active reset operation: the FSM goes to 00 state when a reset signal is applied In addition to the state output z[1). 2[0]. there is a carry/borrow output bit e which is I when...
I need little help with C language. I need to pass what I get from HexToBin(char* hexdec) into char* input so that what I got there it should pass it as string array parametr. Example: Enter IEEE-Hex: 40200000 Equivalent Binary value is : 01000000001000000000000000000000 Decimal Number: 2.5 #include <stdio.h> void HexToBin(char* hexdec) { long int i = 0; while (hexdec[i]) { switch (hexdec[i]) { case '0': printf("0000"); break;...
Can you use Multisim or something similar. I got the truth table and design, but having a hard time with the actual wiring. I need to see where each cable and light bulb go. 3.4. Multiplexer Multiplexers are very useful components in digital systems. They transfer a large number of information units over a smaller number of channels, (usually one channel) under the control of selection signals. Fig. 3 is a 4-line to l-line MUX. In this circuit, lo, 11, 12,...