Electronic Voting Machine Verilog Code
Electronic Voting Machine Verilog Code
More
Hello people,
Following code may be useful for students or enthusiasts who are trying to design a voting
machine. It has been successfully simulated as well as implemented on Spartan 3 xc3s400
FPGA. If you are having any doubts regarding following code then post a comment. I will try my
best to answer the questions.
//////////////////////////////////////////////////////////////////////////////////
// Description: This is simple Voting machine code in which total 3 partys were considered.
// A voter can vote to any of the parties only one at a time. If a voter votes two parties
// at a time then that vote will be invalid. This code has been successfully simulated as well as
//
// Additional Comments: To register a vote, operate a voter_switch and then press push button to register
// a vote. This operation was chosen to simplify a coding and get better understanding
//////////////////////////////////////////////////////////////////////////////////
module evm(clk,voter_switch,PB,voting_en,opled,invalid,dout);
input [2:0]voter_switch;
Chaitannya Supe
//counters to count each party votes
reg [6:0]cnt_reg1=0;//party1
View my complete profile
reg [6:0]cnt_nxt1=0;//party1
reg [6:0]cnt_reg2=0;//party2
Blog Archive
reg [6:0]cnt_nxt2=0;//party2
reg [6:0]cnt_reg3=0;//party3
▼
2015
(1)
▼
reg [6:0]cnt_nxt3=0;//party3
▼
April
(1)
▼
Electronics Voting Machine Verilog Code
reg PB_reg1;
reg PB_reg2;
reg PB_state;
//debounce circuit to detect only one rising edge of push button PB(Refer http://www.fpga4fun.com/Debouncer2.html for more information
always @(posedge clk)
wire PB_cnt_max = &PB_cnt; // true when all bits of PB_cnt are 1's
if(PB_idle)
else
begin
if(PB_cnt_max)
end
https://evmbychaitannya.blogspot.com 1/3
9/14/21, 5:55 PM Electronic Voting Machine Verilog Code
always@(posedge PB_down)
begin
end
always@(*)
begin
cnt_nxt1 = cnt_reg1 + 1;
end
always@(posedge PB_down)
begin
end
always@(*)
begin
cnt_nxt2 = cnt_reg2 + 1;
end
always@(posedge PB_down)
begin
end
always@(*)
begin
cnt_nxt3 = cnt_reg3 + 1;
end
always@(*)
if(voting_en)
case(voter_switch)
3'b100 : begin
opled = 3'b100;
invalid = 1'b0;
end
3'b010 : begin
opled = 3'b010;
invalid = 1'b0;
end
3'b001 : begin
opled = 3'b001;
invalid = 1'b0;
end
3'b011 : begin
opled = 3'b000;
invalid = 1'b1;
end
3'b110 : begin
opled = 3'b000;
invalid = 1'b1;
end
3'b101 : begin
opled = 3'b000;
invalid = 1'b1;
end
3'b111 : begin
opled = 3'b000;
invalid = 1'b1;
end
3'b000 : begin
opled = 3'b000;
invalid = 1'b0;
end
default : begin
opled = 3'b000;
invalid = 1'b0;
end
endcase
endmodule
Posted by
Chaitannya Supe
at
03:54
53 comments:
Labels:
Verilog
https://evmbychaitannya.blogspot.com 2/3
9/14/21, 5:55 PM Electronic Voting Machine Verilog Code
Home
Subscribe to:
Posts (Atom)
https://evmbychaitannya.blogspot.com 3/3