-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathadder.sv
34 lines (31 loc) · 1.07 KB
/
adder.sv
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
module adder(input_if.port inter, output_if.port out_inter, output state);
enum logic [1:0] {INITIAL,WAIT,SEND} state;
always_ff @(posedge inter.clk)
if(inter.rst) begin
inter.ready <= 0;
out_inter.data <= 'x;
out_inter.valid <= 0;
state <= INITIAL;
end
else case(state)
INITIAL: begin
inter.ready <= 1;
state <= WAIT;
end
WAIT: begin
if(inter.valid) begin
inter.ready <= 0;
out_inter.data <= inter.A + inter.B;
out_inter.valid <= 1;
state <= SEND;
end
end
SEND: begin
if(out_inter.ready) begin
out_inter.valid <= 0;
inter.ready <= 1;
state <= WAIT;
end
end
endcase
endmodule: adder