The Moore state machine is a finite state machine whose output values depend on the current state.
This blog is regarding the technologies of core electronics like Basic Electronics using Every Circuit, Very Large Scale Integration (VLSI) using (Verilog, System verilog and UVM), Embedded Systems using Arduino and Rasberry Pi, Matlab, Antenna design using Ansys Hfss, Product Design using Autodesk Fusion 360, Printed Circuit Board Design.
Showing posts with label verilog programming. Show all posts
Showing posts with label verilog programming. Show all posts
Friday, October 15, 2021
Moore state Machine of 101 verilog program
The Moore state machine output will have the n+1 states for n inputs. For example, if the input has 3 states then it will produce 4 output states.
THE MOORE STATE MACHINE OF 11:
The Moore state machine for 101. It has four states S0, S1, S2, S3. The output will be '1' when it enters state S3 and the outputs of the remaining state are '0'.
PROGRAM:
// The inputs and outputs are declared here
module moore_sequence_101(input CLK,RST,DIN, output reg DOUT);
parameter [1:0]S0 = 2'b00;
parameter [1:0]S1 = 2'b01;
parameter [1:0]S2 = 2'b10;
parameter [1:0]S3 = 2'b11;
reg [1:0] PS;
reg [1:0] NS;
// Moore state machine is designed using asynchronous
always @(posedge CLK or negedge RST)
begin
if(RST)
PS <= S0;
else
PS <= NS;
end
always @(PS,DIN)
begin
case(PS)
// For the state S0
S0:if(DIN)
begin
NS = S1;
DOUT = 1'b0;
end
else
begin
NS = S0;
DOUT = 1'b0;
end
// For the state S1
S1:if(DIN)
begin
NS = S1;
DOUT = 1'b0;
end
else
begin
NS = S2;
DOUT = 1'b0;
end
// For the state S2
S2:if(DIN)
begin
NS = S3;
DOUT = 1'b0;
end
else
begin
NS = S0;
DOUT = 1'b0;
end
// For the state S3
S3:if(DIN)
begin
NS = S1;
DOUT = 1'b1;
end
else
begin
NS = S2;
DOUT = 1'b1;
end
endcase
end
endmodule
OUTPUT WAVEFORM:
The output values are tested by forcing the input manually.
when the CLK input is high, rst is low, and based on din the output will be high. When the rst pin is high the output will be zero.
The input is given as 0,0,1,0,1,1,0.
Monday, September 20, 2021
Logic Gates Program using Gate Level Modeling
Logic Gates:
Logic gates are the deify model of the computation, which implements the Boolean function. The logic gates help us to perform the logic operation on one or more inputs to produce the single binary output.
There are 7 basic logic gates they are
- AND Gate.
- OR Gate.
- NOT Gate.
- NAND Gate.
- NOR Gate.
- XOR Gate.
- XNOR Gate.
The NAND Gate and NOR Gate are known as universal gates, any gates can be constructed by using these two gates.
1. AND GATE SYMBOL AND TRUTH TABLE:
AND gate will perform an operation of (A.B). This means the output will be '1' if and only both the inputs are '1' otherwise '0'.
2. OR GATE SYMBOL AND TRUTH TABLE:
OR gate will perform an operation of (A+B). This means the output will be '1' if any one input is '1' otherwise '0'.
3. NOT GATE SYMBOL AND TRUTH TABLE:
NOT gate will perform an operation of (~A). This means the output will be the complement of the input.
4. NAND GATE SYMBOL AND TRUTH TABLE:
NAND gate will perform the complement operation of AND Gate which is ~(A.B). This means the output will be '1' for all inputs except when both inputs are '1'.
NOR gate will perform the complement operation of OR Gate which is ~(A+B). This means the output will be '1' if and only if both inputs are '1' otherwise '0'.
7. XNOR GATE SYMBOL AND TRUTH TABLE:
XNOR gate will perform an operation of ((~(A.B)) + (A.B)). This means the output will be '1' if and only both inputs are the same otherwise '0'.
PROGRAM:
CODE:
This program is coded and simulated using ModelSim software. The program contains the primitives of gate which are and, or, not, nand, nor, xor, xnor.
The syntax for writing logic gate using primitive is:
Gate primitive(output, input);
Example for AND Gate:
and(t,a,b); // where a,b are inputs and t is output
module gate_level(input a,b, output t,u,v,w,x,y,z);
and(t,a,b);
or(u,a,b);
not(v,a);
nand(w,a,b);
nor(x,a,b);
xor(y,a,b);
xnor(z,a,b);
endmodule
TESTBENCH:
The test bench is used to test the code using the test case. The below test bench code is a linear test bench code.
module gate_level_testbench;
reg A,B;
wire T,U,V,W,X,Y,Z;
gate_level dut(.a(A), .b(B), .t(T), .u(U), .v(V), .w(W), .x(X), .y(Y), .z(Z));
initial
begin
A = 0; B = 0;
#10 A = 0; B = 1;
#10 A = 1; B = 0;
#10 A = 1; B = 1;
end
endmodule
OUTPUT WAVEFORM:
The below output is simulated using the Modelsim. The output is based on the testbench written above.
Subscribe to:
Posts (Atom)
Arrays in Verilog
ARRAYS : An array is a collection of similar types of variables and is accessed using the same name plus one or more indexes. An array c...
-
The Moore state machine is a finite state machine whose output values depend on the current state. The Moore state machine output will have ...
-
ARRAYS : An array is a collection of similar types of variables and is accessed using the same name plus one or more indexes. An array c...
-
The Moore state machine is a finite state machine whose output values depend on the current state. The Moore state machine output will have ...