|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2014-3-14 09:47:13
|
显示全部楼层
module Multplier(Outcome,A,B);
parameter size_A=8,size_B=8;
input[size_A:1] A;
input[size_B:1] B;
output[(size_A+size_B):1] Outcome;
reg[(size_A+size_B):1] temp_a,Outcome;
reg[size_B:1] temp_b;
always @(A or B)
begin
Outcome=0;
temp_a=A;
temp_b=B;
repeat(size_B)
begin
if(temp_b[1])
Outcome=Outcome+temp_a;
temp_a=temp_a<<1;
temp_b=temp_b>>1;
end
end
endmodule
module Photoprocessor(Dat,R,G,B);
input[12:1] Dat;
output[4:1] R,G,B;
wire[4:1] A_r,A_g,A_b;
wire Out_r,Out_g,Out_b;
parameter B_r=10,B_g=19,B_b=5;
assign {A_r,A_g,A_b}=Dat;
assign R=Out_r+Out_g+Out_b;
assign G=R;
assign B=G;
Multplier #(5,4) mult_r(.Outcome(Out_r),.A(A_r),.B(B_r));
Multplier #(5,4) mult_g(.Outcome(Out_g),.A(A_g),.B(B_g));
Multplier #(5,4) mult_b(.Outcome(Out_b),.A(A_b),.B(B_b));
endmodule
就像这个例子 |
|