共三个模块:
- 1.top模块:module connect
- (
- CLK,
- RSTn,
- Output_Led,
- Mode_Key
- );
- input CLK;
- input RSTn;
- input[2:0] Mode_Key;
- output[2:0] Output_Led;
- wire CLK_Led;
- led_w_dir U1
- (
- .CLK(CLK),
- .RSTn(RSTn),
- .Mode_Key(Mode_Key),
- .Output_Led(Output_Led),
- .CLK_Led(CLK_Led)
- );
- div_frequency U2
- (
- .CLK(CLK),
- .RSTn(RSTn),
- .Output_CLK(CLK_Led)
- );
- endmodule
- 2.分频模块
- module div_frequency
- (
- CLK,
- RSTn,
- Output_CLK
- );
- ////////
- parameter Width_Div =1;
- parameter Factor_Div =1;
- input CLK;
- input RSTn;
- output Output_CLK;
- reg[Width_Div:0] Count;
- reg Output_CLK;
- ////////
- always@(posedge CLK or negedge RSTn)
- if(!RSTn)
- begin
- Count <= 0;
- Output_CLK <= 0;
- end
- else
- if(Count <= Factor_Div)
- begin
- Count <= Count + 1'b1;
- end
- else
- begin
- Count <=0;
- Output_CLK <= ~Output_CLK;
- end
- endmodule
- 3.流水灯模块
- `include "div_frequency.v"
- module led_w_dir
- (
- CLK,
- RSTn,
- Mode_Key,
- Output_Led,
- CLK_Led
- );
- ////////////
- defparam div_frequency.Width_Div = 23,div_frequency.Factor_Div = 10_000_000;
- ////////////
- input CLK;
- input RSTn;
- input CLK_Led;
- input[2:0] Mode_Key;
- output[2:0] Output_Led;
- reg[2:0] Output_Led;
- reg[2:0] Count;
- ///////////////
- always@(posedge CLK_Led or negedge RSTn)
- if(RSTn == 1'b0)
- begin
- Output_Led <= 3'b111;
- Count <= 3'b000;
- end
- else
- if(Mode_Key == 3'b000)
- begin
- if(Count <= 3'd2)//3'b2 is illegal
- begin
- Count <= Count+1'b1;
- Output_Led <= {Output_Led[1:0],1'b0};
- end
- else
- begin
- Count <= 3'b0;
- Output_Led <= 3'b001;
- end
- end
- else if(Mode_Key == 3'b111)
- begin
- if(Count <= 3'd2)
- begin
- Count <= Count+1'b1;
- Output_Led <= {1'b0,Output_Led[2:1]};
- end
- else
- begin
- Count <= 3'b0;
- Output_Led <= 3'b100;
- end
- end
- endmodule
复制代码
主要问题是在defparam这里出了问题无法综合,求高手指教。。。本人新手一枚。Quartus II 12.0 (32-Bit)综合无法通过。
比如
module #(
parameter a,
patameter b
) div_frequency (
input clk;
...........
output wire dat_o
);
...........
endmodule
一周热门 更多>