0 dept. of electrical engineering national cheng kung university tainan, taiwan, r.o.c

12
1 Dept. of Electrical Engineering National Cheng Kung University Tainan, Taiwan, R.O.C

Upload: margaret-york

Post on 19-Dec-2015

217 views

Category:

Documents


1 download

TRANSCRIPT

1

Dept. of Electrical EngineeringNational Cheng Kung University

Tainan, Taiwan, R.O.C

SoC Hw-Sw Co-design.

2

Half Adder ( / )

module Add_half(sum, c_out, a ,b); input a, b; output sum, c_out; wire c_out_bar;

xor x1(sum, a, b); nand (c_out_bar, a, b); not (c_out, c_out_bar);endmodule

module Add_half(sum, c_out, a ,b); input a, b; output sum, c_out;

assign sum = a^b assign c_out = ~(a&b); endmodule

Structural description: Data flow description:

SoC Hw-Sw Co-design.

3

Half Adder ( / )

module Add_half(sum, c_out, a ,b); input a, b; output sum, c_out;

assign {c_out, sum} = a + b;endmodule

Data flow description:

assign: continuous assignment

SoC Hw-Sw Co-design.

4

Half Adder ( / )

module Add_half(sum, c_out, a ,b); input a, b; output sum, c_out; reg sum, c_out; always@(a or b) begin {c_out, sum} = a + b; endendmodule

Behavior description:

SoC Hw-Sw Co-design.

5

Full Adder ( / )

module Add_full(sum, c_out, a ,b, c_in); input a, b, c_in; output sum, c_out; reg sum, c_out; assign {c_out, sum} = a + b + c_in; endmodule

Data flow description:

module Add_full(sum, c_out, a ,b, c_in); input a, b, c_in; output sum, c_out; reg sum, c_out; always@(a or b or c_in) begin {c_out, sum} = a + b + c_in; endendmodule

Behavior description:

SoC Hw-Sw Co-design.

6

Hierarchical Description of Circuit

c_in3 c_in2 c_in1

half

module Add_full(sum, c_out, a ,b); input a, b; output sum, c_out; wire c_in3, c_in2, c_in1; Add_half G1(sum[0], c_in1, a[0], b[0]); Add_full G2(sum[0], c_in2, a[1], b[1], c_in1); Add_full G3(sum[0], c_in3, a[2], b[2], c_in2); Add_full G4(sum[0], c_out, a[3], b[3], c_in3);endmodule

Ripple-Carry Adder:

SoC Hw-Sw Co-design.

7

Full Adder with high level description

module Add_4bit(sum, c_out, a ,b); input [3:0] a, b; output [3:0] sum; output c_out;

assign {c_out, sum} = a + b;

endmodule

The synthesized circuit is dependent on the tool you use (might be ripple-carry Adder or other Adders).

SoC Hw-Sw Co-design.

8

If-Else Statements ( / )

SoC Hw-Sw Co-design.

9

If-Else Statements ( / )

SoC Hw-Sw Co-design.

10

Case Statements ( / )

SoC Hw-Sw Co-design.

11

Case Statements ( / )

SoC Hw-Sw Co-design.

12

Decoder with Case Statements