Prime Number Detection
Prime Number Detection:
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: Weekendvlsi.blogspot.com
// Engineer: Weekendvlsi
// Create Date: 27-11-2021
// Design Name: Prime Number Detection
// Module Name: prime_number
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
// Dependencies:
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module prime_number ( input clk, reset) ;
parameter N =50; // size of array
reg [31:0] dump[0:N-1]; // memory array for product
integer i=0 ;
integer result_done =1;
integer count =0;
always @(posedge clk )
begin
if(reset)
for(i=0;i<N;i=i+1)
begin
dump[i]='d0;
end
else begin
count = count+1 ;
if ((count%2==0 && count!=2) || (count%3==0 && count!=3)|| (count%5==0 && count!=5) || (count%7==0 && count!=7)||(count%11==0 &&count!=11))
begin
dump[i] <= count;
i <= i + 1;
end
else
begin
$display("Prime Number=%0d",count);
end
end
end
endmodule
TEST BENCH:
module tb;
reg clk,reset;
prime_number dut (clk, reset) ;
always #5 clk =~clk;
initial begin
clk=0;reset=1;
#10 reset='d0;
#1000 $stop;
end
initial begin
$dumpfile("dump.vcd");
$dumpvars;
end
endmodule
RESULT:
Comments
Post a Comment