H
hover
Guest
Hei, nedenfor er det to typer av statlige maskinen koding stiler.
Code:
1.
alltid @ (posedge clk eller negedge rst_n)
...
current_state <= next_state;
...
alltid @ (current_state)
...
case (current_state)
...
S1:
hvis ...
next_state = s2;
...
...
alltid @ (posedge clk eller negedge rst_n)
...
ellers
a <= 1'b0;
b <= 1'b0;
c <= 1'b0;
case (current_state)
S1:
a <= 1'b1;
s2:
b <= 1'b1;
s3:
c <= 1'b1;
default:
....2.
alltid @ (posedge clk eller negedge rst_n)
...
current_state <= next_state;
...alltid @ (current_state)
...
A = 1'b0;
b = 1'b0;
c = 1'b0;
case (current_state)
...
S1:
hvis ...
begynne
next_state = s2;
A = 1'b1;
slutt
s2:
hvis ...
begynne
next_state = s3
b = 1'b1;
slutt
s3:
c = 1'b1;
default:
.........
Code:
1.
alltid @ (posedge clk eller negedge rst_n)
...
current_state <= next_state;
...
alltid @ (current_state)
...
case (current_state)
...
S1:
hvis ...
next_state = s2;
...
...
alltid @ (posedge clk eller negedge rst_n)
...
ellers
a <= 1'b0;
b <= 1'b0;
c <= 1'b0;
case (current_state)
S1:
a <= 1'b1;
s2:
b <= 1'b1;
s3:
c <= 1'b1;
default:
....2.
alltid @ (posedge clk eller negedge rst_n)
...
current_state <= next_state;
...alltid @ (current_state)
...
A = 1'b0;
b = 1'b0;
c = 1'b0;
case (current_state)
...
S1:
hvis ...
begynne
next_state = s2;
A = 1'b1;
slutt
s2:
hvis ...
begynne
next_state = s3
b = 1'b1;
slutt
s3:
c = 1'b1;
default:
.........