|
楼主 |
发表于 2014-11-5 20:06:21
|
显示全部楼层
回复 4# chengroc
按你说的方法成功了,添加Core的时候就已经加到工程中了,按.v文件端口列表输出就行了。
还有个问题,我分频器分频系数是parameter类型的,但是音符译码器译出来的分频系数是reg类型的,在例化的时候译出来的分频系数不能传递到分频器模块里,试了一下function好像也不能用parameter作为输出...
附上译码器和分频器代码:
译码器:
- `timescale 1ns / 1ps
- module dfmratio(music,dfmratio);
- input [4:0]music;
- output [17:0]dfmratio;
- reg [17:0]dfmratio;
- always @(music)
- begin
- case(music)
- 5'b00000:dfmratio=192308;
- 5'b00001:dfmratio=171232;
- 5'b00010:dfmratio=152440;
- 5'b00011:dfmratio=143678;
- 5'b00100:dfmratio=127552;
- 5'b00101:dfmratio=113636;
- 5'b00110:dfmratio=101626;
- 5'b00111:dfmratio=95786;
- 5'b01000:dfmratio=85324;
- 5'b01001:dfmratio=75988;
- 5'b01010:dfmratio=71634;
- 5'b01011:dfmratio=63776;
- 5'b01100:dfmratio=56818;
- 5'b01101:dfmratio=50710;
- 5'b01110:dfmratio=47892;
- 5'b01111:dfmratio=42662;
- 5'b10000:dfmratio=37994;
- 5'b10001:dfmratio=35816;
- 5'b10010:dfmratio=31888;
- 5'b10011:dfmratio=28410;
- 5'b10100:dfmratio=25354;
- default dfmratio=0;
- endcase
- end
- endmodule
复制代码
分频器:
- `timescale 1ns / 1ps
- module DFm
- (
- input CLK_In,
- input RSTn,
- output CLK_Out
- );
- parameter DIV_N=2;
- reg [DIV_N:0] count;
- reg clk_N;
- always @ ( posedge CLK_In or negedge RSTn)
- begin
- if(!RSTn)
- begin
- count <= 1'b0;
- clk_N <= 1'b0;
- end
- else if( count == DIV_N/2 - 1'b1)
- begin
- count <= 1'b0;
- clk_N <= ~clk_N;
- end
- else
- count <= count + 1'b1;
- end
- assign CLK_Out = clk_N;
- endmodule
复制代码
|
|