19 changed files with 1233 additions and 1225 deletions
-
4README.md
-
125led_test.pds
-
29source/src/debuger.v
-
0source/src/input/src_genlock.v
-
208source/src/input/src_timecode.v
-
131source/src/input/src_ttl_parser.v
-
0source/src/input/timecode_input.v
-
56source/src/input/ttl_input.v
-
0source/src/output/camera_sync_signal_output.v
-
0source/src/output/timecode_output.v
-
314source/src/output/ttl_output.v
-
95source/src/rd_data_router.v
-
240source/src/top.v
-
164source/src/zutils/zsimple_pll.v
-
10source/src/zutils/zutils_freq_detector.v
@ -1,29 +0,0 @@ |
|||
/* |
|||
* Hacky baud rate generator to divide a 50MHz clock into a 115200 baud |
|||
* rx/tx pair where the rx clcken oversamples by 16x. |
|||
*/ |
|||
module rd_data_router ( |
|||
input [31:0] addr, |
|||
|
|||
input [31:0] stm32_rd_data, |
|||
input [31:0] fpga_test_rd_data, |
|||
input [31:0] xsync_internal_sig_generator_rd_data, |
|||
input [31:0] ttlin1_rd_data, |
|||
input [31:0] ttlin2_rd_data, |
|||
input [31:0] ttlin3_rd_data, |
|||
input [31:0] ttlin4_rd_data, |
|||
input [31:0] timecode_in_rd_data, |
|||
input [31:0] genlock_in_rd_data, |
|||
input [31:0] ttlout1_rd_data, |
|||
input [31:0] ttlout2_rd_data, |
|||
input [31:0] ttlout3_rd_data, |
|||
input [31:0] ttlout4_rd_data, |
|||
input [31:0] timecode_out_rd_data, |
|||
input [31:0] genlock_out_rd_data, |
|||
input [31:0] camera_sync_out_rd_data, |
|||
input [31:0] debuger_rd_data, |
|||
|
|||
output reg [31:0] rd_data_out |
|||
); |
|||
|
|||
endmodule |
@ -1,208 +0,0 @@ |
|||
// module src_timecode_parser #( |
|||
// parameter REG_START_ADD = 0 |
|||
// ) ( |
|||
// input clk, //clock input |
|||
// input rst_n, //asynchronous reset input, low active |
|||
|
|||
// //regbus interface |
|||
// output reg [31:0] addr, |
|||
// input [31:0] wr_data, |
|||
// input wr_en, |
|||
|
|||
// inout wire [31:0] rd_data, //received serial data |
|||
// // 输入 |
|||
// input timecode_signal_in, |
|||
// //输出 |
|||
// output wire timecode_signal_orgin_output, //ttl原始数据 |
|||
// output wire timecode_freq_trigger_signal |
|||
// ); |
|||
|
|||
// /******************************************************************************* |
|||
// * 寄存器读写 * |
|||
// *******************************************************************************/ |
|||
|
|||
// // |
|||
// // @功能: |
|||
// // 1. 采样TIMECODE信号 |
|||
// // 2. 转发TIMECODE信号 |
|||
// // 3. TIMECODE信号成功解析 |
|||
// // 4. TIMECODE采样计数 |
|||
// // |
|||
// // @寄存器列表: |
|||
// // 地址 读写 默认 描述 |
|||
// // 0x00 wr 0x0 timecode bit周期 |
|||
// // 0x01 r 0x0 flag bit[0]:timecode_ready_flag |
|||
// // 0x02 r 0x0 timecode [31:0] |
|||
// // 0x03 r 0x0 timecode [63:32] |
|||
// // 0x04 r 0x0 timecode_ready_signal_pluse_width //识别到一帧timecode信号后,输出一个脉冲信号,用于同步其他模块 |
|||
|
|||
// parameter REG_TIMECODE_BIT_PERIOD_ADD = REG_START_ADD + 0; //timecode bit周期寄存器地址 |
|||
|
|||
|
|||
// parameter ADD_NUM = 5; //寄存器数量 |
|||
// parameter REG_END_ADD = REG_START_ADD + ADD_NUM - 1; //寄存器结束地址 |
|||
// reg [31:0] register[REG_START_ADD:REG_END_ADD]; |
|||
// integer i; |
|||
// always @(posedge clk or negedge rst_n) begin |
|||
// if (!rst_n) begin |
|||
// for (i = 0; i < ADD_NUM; i = i + 1) begin |
|||
// register[i] <= 0; |
|||
// end |
|||
// end else begin |
|||
// if (wr_en && addr >= REG_START_ADD && addr <= REG_END_ADD) register[addr] <= wr_data; |
|||
// end |
|||
// end |
|||
// assign rd_data = (addr >= REG_START_ADD && addr <= REG_END_ADD) ? register[addr] : 31'bz; |
|||
|
|||
|
|||
|
|||
// // 416us 500us 520us |
|||
// // 边沿触发--> 采样偏移同步 |
|||
// // |
|||
|
|||
// // 416us采用 160byte 采样到同步 |
|||
// // 电平变化修正采样计数 |
|||
|
|||
// // |
|||
// // 配置: |
|||
// // 1. 制式 |
|||
// // 2. |
|||
|
|||
// // 边沿信号捕获 |
|||
|
|||
|
|||
// reg [160-1:0] tc_bit_2x; //timecode 每1/2bit |
|||
// reg [79:0] tc_bit; //timecode 每1bit |
|||
// reg sample_signal; //采样信号 |
|||
// reg [31:0] sample_time_cnt; //采样计数 |
|||
// wire sample_time_calibrate_signal; //采样信号修正器 |
|||
// reg time_code_signal_edge; //timecode原始信号的边沿信号,即timecode上升沿或者下降沿时,置1 |
|||
// assign timecode_signal_in_a = timecode_signal_in; // |
|||
// reg timecode_signal_in_b; // |
|||
// reg tc_sync_signal_edge; // timecode捕获到同步信号时,置1,此时可以解析timecode信号,并将其存放到寄存中 |
|||
|
|||
|
|||
// /******************************************************************************* |
|||
// * timecode边沿信号捕获 * |
|||
// *******************************************************************************/ |
|||
// always @(posedge clk or negedge rst_n) begin |
|||
// if (!rst_n) begin |
|||
// timecode_signal_in_b <= 0; |
|||
// end else begin |
|||
// timecode_signal_in_b <= timecode_signal_in_a; |
|||
// end |
|||
// end |
|||
|
|||
// always @(posedge clk or negedge rst_n) begin |
|||
// if (!rst_n) begin |
|||
// time_code_signal_edge <= 0; |
|||
// end else begin |
|||
// if (timecode_signal_in_a != timecode_signal_in_b) begin |
|||
// time_code_signal_edge <= 1; |
|||
// end else begin |
|||
// time_code_signal_edge <= 0; |
|||
// end |
|||
// end |
|||
// end |
|||
|
|||
// assign sample_time_calibrate_signal = time_code_signal_edge; |
|||
|
|||
|
|||
// /******************************************************************************* |
|||
// * BIT信号映射 * |
|||
// *******************************************************************************/ |
|||
// // |
|||
// // 采样点 采样点 采样点 采样点 |
|||
// // + + + + |
|||
// // ___------------_______-------- |
|||
// // 0 1 |
|||
// // timecode的每个bit要通过两个点进行判断,所以需要2x的采样率 |
|||
// // |
|||
// always @(*) begin |
|||
// for (i = 0; i < 79; i = i + 1) begin |
|||
// tc_bit[i] = !tc_bit_2x[i*2] & tc_bit_2x[i*2+1]; |
|||
// end |
|||
// end |
|||
|
|||
// /******************************************************************************* |
|||
// * 采样信号生成器 * |
|||
// *******************************************************************************/ |
|||
// // |
|||
// // 1. 当捕获到timecode原始信号的边沿时,校准采样信号计数器 |
|||
// // 2. 当采样信号计数器到达采样点时,输出采样信号 |
|||
// // 3. 当采样信号计数器到达2倍采样点时,重置采样信号计数器 |
|||
// // |
|||
// assign timecode_sample_cnt_reset_signal = ( |
|||
// sample_time_calibrate_signal|| |
|||
// sample_time_cnt >= (register[REG_TIMECODE_BIT_PERIOD_ADD] << 1) |
|||
// ); |
|||
// always @(posedge clk or negedge rst_n) begin |
|||
// if (!rst_n) begin |
|||
// sample_time_cnt <= 0; |
|||
// sample_signal <= 0; |
|||
// end else begin |
|||
// if (timecode_sample_cnt_reset_signal) begin |
|||
// sample_time_cnt <= 0; |
|||
// sample_signal <= 0; |
|||
// end else if (sample_time_cnt == register[REG_TIMECODE_BIT_PERIOD_ADD]) begin |
|||
// sample_time_cnt <= sample_time_cnt + 1; |
|||
// sample_signal <= 1; |
|||
// end else begin |
|||
// sample_time_cnt <= sample_time_cnt + 1; |
|||
// sample_signal <= 0; |
|||
// end |
|||
// end |
|||
// end |
|||
|
|||
// // |
|||
// // 根据sample_signal捕获timecode信号 |
|||
// // |
|||
// always @(posedge clk or negedge rst_n) begin |
|||
// if (!rst_n) begin |
|||
// tc_bit_2x <= 0; |
|||
// end else begin |
|||
// if (sample_signal) begin |
|||
// tc_bit_2x <= {tc_bit_2x[158:0], timecode_signal_in}; |
|||
// end else begin |
|||
// tc_bit_2x <= tc_bit_2x; |
|||
// end |
|||
// end |
|||
// end |
|||
|
|||
// /******************************************************************************* |
|||
// * tc_sync_signal_edge * |
|||
// *******************************************************************************/ |
|||
// // ___------------_______-------- |
|||
// // 0 1 |
|||
// // |
|||
// // 捕获timecode同步信号 |
|||
// // |
|||
// // 同步信号 |
|||
// // 0011_1111_11111_1101 |
|||
// // 1111_0101__0101_0101__0101_0101__0101_1101 |
|||
// // |
|||
// reg [31:0] sync_code_pattern = 32'b1111_0101__0101_0101__0101_0101__0101_1101; |
|||
// assign tc_sync_signal = (tc_bit == sync_code_pattern); |
|||
// reg tc_sync_signal_b; |
|||
// always @(posedge clk or negedge rst_n) begin |
|||
// if (!rst_n) begin |
|||
// tc_sync_signal_b <= 0; |
|||
// end else begin |
|||
// tc_sync_signal_b <= tc_sync_signal; |
|||
|
|||
// if (tc_sync_signal & !tc_sync_signal_b) begin |
|||
// tc_sync_signal_edge <= 1; |
|||
// end else begin |
|||
// tc_sync_signal_edge <= 0; |
|||
// end |
|||
// end |
|||
// end |
|||
|
|||
|
|||
|
|||
|
|||
// assign timecode_freq_trigger_signal = tc_sync_signal_edge; |
|||
|
|||
|
|||
|
|||
// endmodule |
@ -1,131 +0,0 @@ |
|||
// module src_ttl_parser #( |
|||
// parameter REG_START_ADD = 0 |
|||
// ) ( |
|||
// input clk, //clock input |
|||
// input rst_n, //asynchronous reset input, low active |
|||
|
|||
// //regbus interface |
|||
// output reg [31:0] addr, |
|||
// input [31:0] wr_data, |
|||
// input wr_en, |
|||
|
|||
// inout wire [31:0] rd_data, //received serial data |
|||
// // 输入 |
|||
// input ttlin, |
|||
// //输出 |
|||
// output wire ttl_output //ttl原始数据 |
|||
// ); |
|||
// // |
|||
// // @功能: |
|||
// // 1. 计算ttl频率 |
|||
// // 2. 转发ttl信号 |
|||
// // 3. 分频倍频 |
|||
// // |
|||
// // @寄存器列表: |
|||
// // 地址 读写 默认 描述 |
|||
// // 0x00 r 0x0 function 0:原始信号输出 1:频率信号源 |
|||
// // 0x01 r 0x0 freq //一个周期的计数,单位为 1/50M s |
|||
// // 0x02 wr 0x0 pll_mul //暂不支持 |
|||
// // 0x03 wr 0x0 pll_div |
|||
// // 0x04 wr 0x0 [0]:信号源是上升沿触发,还是下降沿触发 |
|||
// // |
|||
|
|||
|
|||
// reg ttl_origin_output; //ttl原始信号输出 |
|||
// reg ttl_after_process_output; //ttl处理后信号输出 |
|||
|
|||
|
|||
// /******************************************************************************* |
|||
// * 寄存器读写 * |
|||
// *******************************************************************************/ |
|||
|
|||
// parameter ADD_NUM = 5; //寄存器数量 |
|||
// parameter REG_END_ADD = REG_START_ADD + ADD_NUM - 1; //寄存器结束地址 |
|||
// reg [31:0] register[REG_START_ADD:REG_END_ADD]; |
|||
// integer i; |
|||
// always @(posedge clk or negedge rst_n) begin |
|||
// if (!rst_n) begin |
|||
// for (i = 0; i < ADD_NUM; i = i + 1) begin |
|||
// register[i] <= 0; |
|||
// end |
|||
// end else begin |
|||
// if (wr_en && addr >= REG_START_ADD && addr <= REG_END_ADD) register[addr] <= wr_data; |
|||
// end |
|||
// end |
|||
// assign rd_data = (addr >= REG_START_ADD && addr <= REG_END_ADD) ? register[addr] : 31'bz; |
|||
|
|||
// parameter REG_FUNC_ADD = REG_START_ADD + 0; |
|||
// parameter REG_FREQ_ADD = REG_START_ADD + 1; |
|||
// parameter REG_PLL_MUL_ADD = REG_START_ADD + 2; |
|||
// parameter REG_PLL_DIV_ADD = REG_START_ADD + 3; |
|||
// parameter REG_TTL_EDGE_ADD = REG_START_ADD + 4; |
|||
|
|||
// /******************************************************************************* |
|||
// * ttl输出路径选择 * |
|||
// *******************************************************************************/ |
|||
|
|||
// assign ttl_output = (register[REG_FUNC_ADD] == 0) ? ttl_origin_output : ttl_after_process_output; |
|||
|
|||
// /******************************************************************************* |
|||
// * 原始信号输出 * |
|||
// *******************************************************************************/ |
|||
// always @(posedge clk or negedge rst_n) begin |
|||
// if (!rst_n) begin |
|||
// ttl_origin_output <= 0; |
|||
// end else begin |
|||
// ttl_origin_output <= ttlin; |
|||
// end |
|||
// end |
|||
|
|||
// /******************************************************************************* |
|||
// * ttl_in_last信号捕获 * |
|||
// *******************************************************************************/ |
|||
// reg ttl_in_last; |
|||
// always @(posedge clk or negedge rst_n) begin |
|||
// if (!rst_n) begin |
|||
// ttl_in_last <= 0; |
|||
// end else begin |
|||
// ttl_in_last <= ttlin; |
|||
// end |
|||
// end |
|||
|
|||
|
|||
// /******************************************************************************* |
|||
// * 频率探测 * |
|||
// *******************************************************************************/ |
|||
// reg [31:0] ttl_freq_cnt; |
|||
// always @(posedge clk or negedge rst_n) begin |
|||
// if (!rst_n) begin |
|||
// ttl_freq_cnt <= 0; |
|||
// end else begin |
|||
// if (ttlin && !ttl_in_last) begin |
|||
// register[REG_FREQ_ADD] <= ttl_freq_cnt; |
|||
// ttl_freq_cnt <= 0; |
|||
// end |
|||
// if (ttl_freq_cnt != 32'hffff_ffff_ffff_ffff) begin |
|||
// ttl_freq_cnt <= ttl_freq_cnt + 1; |
|||
// end |
|||
// end |
|||
// end |
|||
|
|||
// /******************************************************************************* |
|||
// * 分频 * |
|||
// *******************************************************************************/ |
|||
// reg [31:0] ttl_in_cnt; |
|||
// always @(posedge clk or negedge rst_n) begin |
|||
// if (!rst_n) begin |
|||
// ttl_in_cnt <= 0; |
|||
// end else begin |
|||
// if (ttlin && !ttl_in_last) begin |
|||
// if (ttl_in_cnt <= register[REG_PLL_MUL_ADD]) begin |
|||
// ttl_in_cnt <= ttl_in_cnt + 1; |
|||
// end else begin |
|||
// ttl_in_cnt <= 0; |
|||
// ttl_after_process_output <= 1; |
|||
// end |
|||
// end else begin |
|||
// ttl_after_process_output <= 0; |
|||
// end |
|||
// end |
|||
// end |
|||
// endmodule |
@ -1,95 +0,0 @@ |
|||
/* |
|||
* Hacky baud rate generator to divide a 50MHz clock into a 115200 baud |
|||
* rx/tx pair where the rx clcken oversamples by 16x. |
|||
*/ |
|||
module rd_data_router #( |
|||
parameter REG_ADD_OFF_STM32 = 0, |
|||
parameter REG_ADD_OFF_FPGA_TEST = 0, |
|||
parameter REG_ADD_OFF_XSYNC_INTERNAL_SIG_GENERATOR = 0, |
|||
parameter REG_ADD_OFF_TTLIN1 = 0, |
|||
parameter REG_ADD_OFF_TTLIN2 = 0, |
|||
parameter REG_ADD_OFF_TTLIN3 = 0, |
|||
parameter REG_ADD_OFF_TTLIN4 = 0, |
|||
parameter REG_ADD_OFF_TIMECODE_IN = 0, |
|||
parameter REG_ADD_OFF_GENLOCK_IN = 0, |
|||
parameter REG_ADD_OFF_TTLOUT1 = 0, |
|||
parameter REG_ADD_OFF_TTLOUT2 = 0, |
|||
parameter REG_ADD_OFF_TTLOUT3 = 0, |
|||
parameter REG_ADD_OFF_TTLOUT4 = 0, |
|||
parameter REG_ADD_OFF_TIMECODE_OUT = 0, |
|||
parameter REG_ADD_OFF_GENLOCK_OUT = 0, |
|||
parameter REG_ADD_OFF_CAMERA_SYNC_OUT = 0, |
|||
parameter REG_ADD_OFF_DEBUGER = 0 |
|||
|
|||
) ( |
|||
input [31:0] addr, |
|||
|
|||
input [31:0] stm32_rd_data, |
|||
input [31:0] fpga_test_rd_data, |
|||
input [31:0] xsync_internal_sig_generator_rd_data, |
|||
input [31:0] ttlin1_rd_data, |
|||
input [31:0] ttlin2_rd_data, |
|||
input [31:0] ttlin3_rd_data, |
|||
input [31:0] ttlin4_rd_data, |
|||
input [31:0] timecode_in_rd_data, |
|||
input [31:0] genlock_in_rd_data, |
|||
input [31:0] ttlout1_rd_data, |
|||
input [31:0] ttlout2_rd_data, |
|||
input [31:0] ttlout3_rd_data, |
|||
input [31:0] ttlout4_rd_data, |
|||
input [31:0] timecode_out_rd_data, |
|||
input [31:0] genlock_out_rd_data, |
|||
input [31:0] camera_sync_out_rd_data, |
|||
input [31:0] debuger_rd_data, |
|||
|
|||
output reg [31:0] rd_data_out |
|||
); |
|||
|
|||
// initial rd_data_out = 0; |
|||
// wire [31:0] addr_8 = addr >> 8; |
|||
wire [31:0] addr_group; |
|||
assign addr_group = addr & 31'hFFFF_FFF0; |
|||
|
|||
always @(*) |
|||
begin |
|||
case (addr_group) |
|||
REG_ADD_OFF_STM32: |
|||
rd_data_out = stm32_rd_data; |
|||
REG_ADD_OFF_FPGA_TEST: |
|||
rd_data_out = fpga_test_rd_data; |
|||
REG_ADD_OFF_XSYNC_INTERNAL_SIG_GENERATOR: |
|||
rd_data_out = xsync_internal_sig_generator_rd_data; |
|||
REG_ADD_OFF_TTLIN1: |
|||
rd_data_out = ttlin1_rd_data; |
|||
REG_ADD_OFF_TTLIN2: |
|||
rd_data_out = ttlin2_rd_data; |
|||
REG_ADD_OFF_TTLIN3: |
|||
rd_data_out = ttlin3_rd_data; |
|||
REG_ADD_OFF_TTLIN4: |
|||
rd_data_out = ttlin4_rd_data; |
|||
REG_ADD_OFF_TIMECODE_IN: |
|||
rd_data_out = timecode_in_rd_data; |
|||
REG_ADD_OFF_GENLOCK_IN: |
|||
rd_data_out = genlock_in_rd_data; |
|||
REG_ADD_OFF_TTLOUT1: |
|||
rd_data_out = ttlout1_rd_data; |
|||
REG_ADD_OFF_TTLOUT2: |
|||
rd_data_out = ttlout2_rd_data; |
|||
REG_ADD_OFF_TTLOUT3: |
|||
rd_data_out = ttlout3_rd_data; |
|||
REG_ADD_OFF_TTLOUT4: |
|||
rd_data_out = ttlout4_rd_data; |
|||
REG_ADD_OFF_TIMECODE_OUT: |
|||
rd_data_out = timecode_out_rd_data; |
|||
REG_ADD_OFF_GENLOCK_OUT: |
|||
rd_data_out = genlock_out_rd_data; |
|||
REG_ADD_OFF_CAMERA_SYNC_OUT: |
|||
rd_data_out = camera_sync_out_rd_data; |
|||
REG_ADD_OFF_DEBUGER: |
|||
rd_data_out = debuger_rd_data; |
|||
default: |
|||
rd_data_out = 0; |
|||
endcase |
|||
end |
|||
|
|||
endmodule |
@ -0,0 +1,164 @@ |
|||
module zsimple_pll ( |
|||
input clk, //!clock input |
|||
input rst_n, //!asynchronous reset input, low active |
|||
|
|||
input insignal, //!输入信号 |
|||
input trigger_eage_type, |
|||
input wire [31:0] freq_division, |
|||
input wire [31:0] freq_multiplication, |
|||
input wire cfg_change, |
|||
output wire outsignal |
|||
); |
|||
|
|||
// |
|||
// |
|||
//insignal |
|||
// -----> |
|||
// insignal_trigger_sig |
|||
// -------> |
|||
// insignal_division |
|||
// --------> |
|||
// insignal_multiplication |
|||
|
|||
|
|||
|
|||
wire insignal_rising_edge; //! 输入信号上升沿 |
|||
wire insignal_falling_edge; //! 输入信号下降沿 |
|||
wire insignal_trigger_sig; //! 触发信号 |
|||
wire module_reset; //! 模块内部复位信号 |
|||
|
|||
reg insignal_division; //! 输入信号分频后的信号 |
|||
reg insignal_multiplication;//! 输入信号倍频后的信号 |
|||
|
|||
|
|||
zutils_edge_detecter edge_detecter ( |
|||
.clk(clk), |
|||
.rst_n(rst_n), |
|||
.in_signal(insignal), |
|||
.in_signal_rising_edge(insignal_rising_edge), |
|||
.in_signal_falling_edge(insignal_falling_edge) |
|||
); |
|||
|
|||
|
|||
assign insignal_trigger_sig = trigger_eage_type ? insignal_rising_edge : insignal_falling_edge; |
|||
assign module_reset = !rst_n || cfg_change; |
|||
|
|||
// 分频 |
|||
reg [31:0] insignal_division_cnt; |
|||
always @(posedge clk or posedge module_reset) begin |
|||
if (module_reset) begin |
|||
insignal_division_cnt <= 0; |
|||
insignal_division <= 0; |
|||
end |
|||
else begin |
|||
if(insignal_trigger_sig) begin |
|||
if(insignal_division_cnt >= freq_division) begin |
|||
insignal_division_cnt <= 0; |
|||
insignal_division <= 1; |
|||
end |
|||
else begin |
|||
insignal_division_cnt <= insignal_division_cnt + 1; |
|||
end |
|||
end |
|||
else begin |
|||
insignal_division <= 0; |
|||
end |
|||
end |
|||
end |
|||
|
|||
// 倍频 |
|||
// |
|||
// 触发计数 |
|||
// 更新计数 |
|||
// |
|||
// |
|||
|
|||
// 计数器 |
|||
reg [31:0] freq_cnt_cache; |
|||
reg [31:0] freq_cnt; |
|||
always @(posedge clk or posedge module_reset) begin |
|||
if (module_reset) begin |
|||
freq_cnt <= 0; |
|||
freq_cnt_cache <= 32'hffff_ffff; |
|||
end |
|||
else begin |
|||
if (insignal_division) begin |
|||
if(freq_cnt == 0) begin |
|||
freq_cnt_cache <= 32'hffff_ffff; |
|||
end |
|||
else begin |
|||
freq_cnt_cache <= freq_cnt; |
|||
end |
|||
freq_cnt <= 0; |
|||
end |
|||
else begin |
|||
freq_cnt <= freq_cnt + 1; |
|||
if(freq_cnt >= 32'hffff_ffff) begin |
|||
freq_cnt_cache <= 32'hffff_ffff; |
|||
freq_cnt <= 0; |
|||
end |
|||
end |
|||
end |
|||
end |
|||
|
|||
|
|||
reg [31:0] multiplication_state; |
|||
reg [31:0] multiplication_cnt; |
|||
reg [31:0] append_pluse_cnt; |
|||
|
|||
always @(posedge clk or posedge module_reset) begin |
|||
if (module_reset) begin |
|||
multiplication_cnt <= 0; |
|||
insignal_multiplication <= 0; |
|||
append_pluse_cnt <= 0; |
|||
multiplication_state <= 0; |
|||
end |
|||
else begin |
|||
case (multiplication_state) |
|||
0 : begin // !默认状态 |
|||
if(insignal_division) begin |
|||
|
|||
//触发一次脉冲 |
|||
insignal_multiplication <= 1; |
|||
|
|||
if(freq_multiplication >= 1 && freq_cnt_cache != 32'hffff_ffff) begin |
|||
// 进入额外脉冲状态 |
|||
multiplication_state <= 1; |
|||
append_pluse_cnt <= 0; |
|||
multiplication_cnt <= 0; |
|||
end |
|||
end |
|||
else begin |
|||
insignal_multiplication <= 0; |
|||
end |
|||
end |
|||
1 : begin |
|||
|
|||
if(append_pluse_cnt < freq_multiplication && freq_cnt_cache != 32'hffff_ffff && freq_multiplication > 0) begin |
|||
|
|||
if(multiplication_cnt < freq_cnt_cache) begin |
|||
multiplication_cnt <= multiplication_cnt + freq_multiplication + 1; |
|||
insignal_multiplication <= 0; |
|||
end |
|||
else begin |
|||
insignal_multiplication <= 1; |
|||
multiplication_cnt <= 0; |
|||
append_pluse_cnt <= append_pluse_cnt + 1; |
|||
end |
|||
|
|||
end |
|||
else begin |
|||
multiplication_state <= 0; |
|||
insignal_multiplication <= 0; |
|||
end |
|||
|
|||
end |
|||
default: begin |
|||
multiplication_state <= 0; |
|||
end |
|||
endcase |
|||
end |
|||
end |
|||
|
|||
assign outsignal = insignal_multiplication; |
|||
endmodule |
Write
Preview
Loading…
Cancel
Save
Reference in new issue