Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

its very urgent...can you do it for me

Status
Not open for further replies.

shiva

Junior Member level 3
Joined
Oct 18, 2005
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,537
divisible_by_5

design a state machine for a serial input number to be divisible by 5. if the number is divisible by 5 (101, 1010,…..) output 1.
 

you need some code ??? or just the state diagram or wat
 

Hi
r the numbers expressed in BCD format or unsigned binary .... in either cases ... u shud check last 3 bit ...is whether they r 000 or 101 then give output as "1"
 

someone has replied to this n deleted .....yeah i agree
in case 8 (1000) ... 000 is nt satisfying !!
may b BCD shud b fallowed
 

i want only state diagram if you can....if you can suggest me circuit itll be better
 

I posted the code for same question here few months back.
Here I am posting it again.
There register in which ur shifting the random bit stream is infinite.
Here for illustration perpose i have taken 128 bit shift register, same is
applicable to infinite bit shift register.
The idea here is simple. We know that for decimal no.s if the no. ends with
0 or 5 its divisible by 5. We just extend this idea for bianary no.s. If decimal
equivalent of binay no. has 0 or 5 at last digit position its divisible by 5.
See the code below its behavioral one but you can easily convert it in RTL!
Hope this helps.

Code:
module divisibleby5();
   reg [127:0] my_reg;
   reg [4:0]   bcd_lsb;
   reg         divisible_by_5;
   reg         clk;
   reg         din;
   
   initial begin
      clk = 0;
      din = $random;
      my_reg = 128'h0000000000000000;
      bcd_lsb = 0;
      divisible_by_5 = 0;
      $monitor ("my_reg = %d divisible_by_5 = %b bcd_lsb = %h", my_reg, divisible_by_5, bcd_lsb);
      fork
         forever #5 clk = ~clk;
         forever begin
            @(posedge clk);
            my_reg = {my_reg[126:0], din};
            bcd_lsb = 2*bcd_lsb + din;
            if (bcd_lsb > 9 || bcd_lsb[4])
              bcd_lsb[4:0] = bcd_lsb[3:0] + 6;
            divisible_by_5 = (bcd_lsb[3:0] == 0 || bcd_lsb[3:0] == 5);
            din = $random;
         end
         #1000 $finish;
      join
   end
endmodule // divisibleby5
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top