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.

Verilog coding - error correction in Xilinx platform

Status
Not open for further replies.

shrikanthke

Newbie level 5
Joined
Jul 25, 2012
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,353
My code is as follows:


Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
module StateMachine(
    input start,
    input CLK,
    input stop,
    input input_type,
    input read_to_read,
    output reg input_to_lc,
    output reg logic_controller_enable,
    output reg  read_enable,
    output reg mem_read
    
);
 
reg [1:0] state,next_state;
 
parameter S0 = 2'b00;
parameter S1 = 2'b01;
parameter S2 = 2'b10;
parameter S3 = 2'b11;
 
 
always@(posedge CLK or posedge stop )    
begin
    if(stop)
    state<=S0;                                                 //default state
    else if(start)
    state<=next_state;
end
 
always @(state )
begin
    
case(state)
    S0:
        begin
            if(start == 1'b1)
            begin
            $display("hiiii");
            state <= S1;
            end
            else 
            state <= S0;
        end
 
    S1:
        begin
            mem_read <= 1'b1;
            $display("hiiii  new");
            if(read_to_read == 1)
            state  <= S2;
            else 
            state<=S1;
 
        end
    
    S2:
        begin
            logic_controller_enable <= 1'b1;
            read_enable <= 1'b1;
            state <= S3;
        end
        
    S3:
        begin
        //  mem_write = 1'b1;
        end
    
    endcase
end
 
endmodule





when i try to synthesixe this, im getting error as multiple drivers on signal state. Error occurs at always@(posedge CLK...) block. how to correct this code..
 
Last edited by a moderator:

Looks like a copy-and-paste error.

If you review the FSM templates in your text book, you'll notice that the always @(state) block should set next_state instead of state.
 

you'll notice that the always @(state) block should set next_state instead of state.
Which is a good reason to use the single clocked process FSM coding style as it avoids this pitfall.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top