proteldxp 发表于 2013-10-11 12:58 ![](static/image/common/back.gif)
verilog用case语句就搞定了啊
下面是我写的程序
// dzkg.v
module mux_case1(
int1,int2,int3,select,
a1,b1,c1,d1,e1,f1,g1,h1,
a2,b2,c2,d2,e2,f2,g2,h2,
a3,b3,c3,d3,e3,f3,g3,h3,
);
input int1,int2,int3;
output a1,b1,c1,d1,e1,f1,g1,h1;
output a2,b2,c2,d2,e2,f2,g2,h2;
output a3,b3,c3,d3,e3,f3,g3,h3;
input [2:0] select;
reg a1,b1,c1,d1,e1,f1,g1,h1;
reg a2,b2,c2,d2,e2,f2,g2,h2;
reg a3,b3,c3,d3,e3,f3,g3,h3;
always @(select or int1)
begin
case(select)
3'b000 : a1<=int1;
3'b001 : b1<=int1;
3'b010 : c1<=int1;
3'b011 : d1<=int1;
3'b100 : e1<=int1;
3'b101 : f1<=int1;
3'b110 : g1<=int1;
3'b111 : h1<=int1;
endcase
end
always @(select or int2)
begin
case(select)
3'b000 : a2<=int2;
3'b001 : b2<=int2;
3'b010 : c2<=int2;
3'b011 : d2<=int2;
3'b100 : e2<=int2;
3'b101 : f2<=int2;
3'b110 : g2<=int2;
3'b111 : h2<=int2;
endcase
end
always @(select or int3)
begin
case(select)
3'b000 : a3<=int3;
3'b001 : b3<=int3;
3'b010 : c3<=int3;
3'b011 : d3<=int3;
3'b100 : e3<=int3;
3'b101 : f3<=int3;
3'b110 : g3<=int3;
3'b111 : h3<=int3;
endcase
end
endmodule
编译的时候有警告 ,估计是产生锁存器
int1,int2接单片机串口 ,int3为使能信号
要达到的效果是
由单片机串口输出的收发信号直接输出,而不用FPGA 寄存器(a1,b1... a2,b2... a3,b3...)存储单片机发过来的数据 ,而是将单片机发过来的数直接通过FPGA输出(意思是电子开关)如001表示电子开关1导通 int1, int2 就直接连接a1,b1 这样
怎么解决 ,帮忙啊,各位大侠!!! |