27 changed files with 1992 additions and 71 deletions
-
2ip_backup/20240321095414/ShiftRegister/.last_generated
-
92ip_backup/20240321095414/ShiftRegister/ShiftRegister.idf
-
83ip_backup/20240321095414/ShiftRegister/ShiftRegister.v
-
168ip_backup/20240321095414/ShiftRegister/ShiftRegister_tb.v
-
15ip_backup/20240321095414/ShiftRegister/ShiftRegister_tmpl.v
-
27ip_backup/20240321095414/ShiftRegister/ShiftRegister_tmpl.vhdl
-
21ip_backup/20240321095414/ShiftRegister/generate.log
-
111ip_backup/20240321095414/ShiftRegister/rtl/ipm_distributed_sdpram_v1_2_ShiftRegister.v
-
111ip_backup/20240321095414/ShiftRegister/rtl/ipm_distributed_shiftregister_v1_2_ShiftRegister.v
-
2ipcore/ShiftRegister/.last_generated
-
92ipcore/ShiftRegister/ShiftRegister.idf
-
83ipcore/ShiftRegister/ShiftRegister.v
-
168ipcore/ShiftRegister/ShiftRegister_tb.v
-
15ipcore/ShiftRegister/ShiftRegister_tmpl.v
-
27ipcore/ShiftRegister/ShiftRegister_tmpl.vhdl
-
21ipcore/ShiftRegister/generate.log
-
111ipcore/ShiftRegister/rtl/ipm_distributed_sdpram_v1_2_ShiftRegister.v
-
111ipcore/ShiftRegister/rtl/ipm_distributed_shiftregister_v1_2_ShiftRegister.v
-
94led_test.pds
-
1source/src/config.v
-
4source/src/output/camera_sync_signal_output.v
-
4source/src/spi_reg_bus.v
-
266source/src/sys_signal_delayer.v
-
129source/src/top.v
-
77source/src/zutils/zutils_pluse_delayer.v
-
104source/src/zutils/zutils_sig_delayer.v
-
124source/src/zutils/zutils_sig_delayer_v2.v
@ -0,0 +1,2 @@ |
|||
2024-03-20 17:08 |
|||
rev_1 |
@ -0,0 +1,92 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<ip_inst> |
|||
<header> |
|||
<vendor>Pango</vendor> |
|||
<id>06100103</id> |
|||
<display_name>Distributed Shift Register</display_name> |
|||
<name>Distributed Shift Register</name> |
|||
<version>1.2</version> |
|||
<instance>ShiftRegister</instance> |
|||
<family>Logos</family> |
|||
<device>PGL22G</device> |
|||
<package>MBG324</package> |
|||
<speedgrade>-6</speedgrade> |
|||
<generator version="2021.1-SP7" build="86875">IP Compiler</generator> |
|||
</header> |
|||
<param_list> |
|||
<param> |
|||
<name>DATA_WIDTH</name> |
|||
<value>1</value> |
|||
</param> |
|||
<param> |
|||
<name>SHIFT_REG_TYPE</name> |
|||
<value>dynamic_latency</value> |
|||
</param> |
|||
<param> |
|||
<name>VARIABLE_MAX_DEPTH</name> |
|||
<value>1024</value> |
|||
</param> |
|||
<param> |
|||
<name>RST_TYPE</name> |
|||
<value>ASYNC</value> |
|||
</param> |
|||
<param> |
|||
<name>FIXED_DEPTH</name> |
|||
<value>1024</value> |
|||
</param> |
|||
<param> |
|||
<name>SHIFT_REG_TYPE_BOOL</name> |
|||
<value>true</value> |
|||
</param> |
|||
</param_list> |
|||
<pin_list> |
|||
<pin> |
|||
<name>din</name> |
|||
<text>din</text> |
|||
<dir>input</dir> |
|||
<pos>left</pos> |
|||
</pin> |
|||
<pin> |
|||
<name>addr</name> |
|||
<text>addr</text> |
|||
<dir>input</dir> |
|||
<pos>left</pos> |
|||
<msb>9</msb> |
|||
<lsb>0</lsb> |
|||
</pin> |
|||
<pin> |
|||
<name>clk</name> |
|||
<text>clk</text> |
|||
<dir>input</dir> |
|||
<pos>left</pos> |
|||
</pin> |
|||
<pin> |
|||
<name>rst</name> |
|||
<text>rst</text> |
|||
<dir>input</dir> |
|||
<pos>left</pos> |
|||
</pin> |
|||
<pin> |
|||
<name>dout</name> |
|||
<text>dout</text> |
|||
<dir>output</dir> |
|||
<pos>right</pos> |
|||
</pin> |
|||
</pin_list> |
|||
<synthesis> |
|||
<script><![CDATA[set_option -vlog_std v2001]]></script> |
|||
<script><![CDATA[set_option -disable_io_insertion 1]]></script> |
|||
</synthesis> |
|||
<file_list> |
|||
<output> |
|||
<file pathname="generate.log" format="log" description="Generate Log"/> |
|||
<file pathname="ShiftRegister_tmpl.v" format="verilog" description="Instantiation Template"/> |
|||
<file pathname="ShiftRegister_tmpl.vhdl" format="vhdl" description="Instantiation Template"/> |
|||
</output> |
|||
<source> |
|||
<file pathname="rtl/ipm_distributed_sdpram_v1_2_ShiftRegister.v"/> |
|||
<file pathname="rtl/ipm_distributed_shiftregister_v1_2_ShiftRegister.v"/> |
|||
<file pathname="ShiftRegister.v"/> |
|||
</source> |
|||
</file_list> |
|||
</ip_inst> |
@ -0,0 +1,83 @@ |
|||
// Created by IP Generator (Version 2021.1-SP7 build 86875) |
|||
|
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////// |
|||
// |
|||
// Copyright (c) 2014 PANGO MICROSYSTEMS, INC |
|||
// ALL RIGHTS REVERVED. |
|||
// |
|||
// THE SOURCE CODE CONTAINED HEREIN IS PROPRIETARY TO PANGO MICROSYSTEMS, INC. |
|||
// IT SHALL NOT BE REPRODUCED OR DISCLOSED IN WHOLE OR IN PART OR USED BY |
|||
// PARTIES WITHOUT WRITTEN AUTHORIZATION FROM THE OWNER. |
|||
// |
|||
////////////////////////////////////////////////////////////////////////////// |
|||
// |
|||
// Library: |
|||
// Filename:ShiftRegister.v |
|||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|||
|
|||
`timescale 1 ns / 1 ps |
|||
module ShiftRegister |
|||
( |
|||
din , |
|||
|
|||
addr , |
|||
|
|||
clk , |
|||
rst , |
|||
dout |
|||
); |
|||
|
|||
localparam FIXED_DEPTH = 1024 ; // @IPC int 1,1024 |
|||
|
|||
localparam VARIABLE_MAX_DEPTH = 1024 ; // @IPC int 1,1024 |
|||
|
|||
localparam DATA_WIDTH = 1 ; // @IPC int 1,256 |
|||
|
|||
localparam SHIFT_REG_TYPE = "dynamic_latency" ; // @IPC enum fixed_latency,dynamic_latency |
|||
|
|||
localparam SHIFT_REG_TYPE_BOOL = 1 ; // @IPC bool |
|||
|
|||
localparam RST_TYPE = "ASYNC" ; // @IPC enum ASYNC,SYNC |
|||
|
|||
|
|||
localparam DEPTH = (SHIFT_REG_TYPE=="fixed_latency" ) ? FIXED_DEPTH : |
|||
(SHIFT_REG_TYPE=="dynamic_latency") ? VARIABLE_MAX_DEPTH : 0; |
|||
|
|||
|
|||
localparam ADDR_WIDTH = (DEPTH<=16) ? 4 : |
|||
(DEPTH<=32) ? 5 : |
|||
(DEPTH<=64) ? 6 : |
|||
(DEPTH<=128) ? 7 : |
|||
(DEPTH<=256) ? 8 : |
|||
(DEPTH<=512) ? 9 : 10 ; |
|||
|
|||
|
|||
input wire [DATA_WIDTH-1:0] din ; |
|||
|
|||
input wire [ADDR_WIDTH-1:0] addr ; |
|||
|
|||
input wire clk ; |
|||
input wire rst ; |
|||
output wire [DATA_WIDTH-1:0] dout ; |
|||
|
|||
|
|||
ipm_distributed_shiftregister_v1_2_ShiftRegister |
|||
#( |
|||
.FIXED_DEPTH (FIXED_DEPTH ) , |
|||
.VARIABLE_MAX_DEPTH (VARIABLE_MAX_DEPTH ) , |
|||
.DATA_WIDTH (DATA_WIDTH ) , |
|||
.SHIFT_REG_TYPE (SHIFT_REG_TYPE ) , |
|||
.RST_TYPE (RST_TYPE ) |
|||
)u_ipm_distributed_shiftregister_ShiftRegister |
|||
( |
|||
.din (din ) , |
|||
|
|||
.addr (addr ) , |
|||
|
|||
.clk (clk ) , |
|||
.rst (rst ) , |
|||
.dout (dout ) |
|||
); |
|||
endmodule |
@ -0,0 +1,168 @@ |
|||
// Created by IP Generator (Version 2021.1-SP7 build 86875) |
|||
|
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////// |
|||
// |
|||
// Copyright (c) 2014 PANGO MICROSYSTEMS, INC |
|||
// ALL RIGHTS REVERVED. |
|||
// |
|||
// THE SOURCE CODE CONTAINED HEREIN IS PROPRIETARY TO PANGO MICROSYSTEMS, INC. |
|||
// IT SHALL NOT BE REPRODUCED OR DISCLOSED IN WHOLE OR IN PART OR USED BY |
|||
// PARTIES WITHOUT WRITTEN AUTHORIZATION FROM THE OWNER. |
|||
// |
|||
////////////////////////////////////////////////////////////////////////////// |
|||
// |
|||
// Library: |
|||
// Filename:TB ShiftRegister_tb.v |
|||
////////////////////////////////////////////////////////////////////////////// |
|||
|
|||
`timescale 1ns / 1ps |
|||
|
|||
module ShiftRegister_tb (); |
|||
|
|||
localparam T_CLK_PERIOD = 10 ; //clock a half perid |
|||
localparam T_RST_TIME = 200 ; //reset time |
|||
|
|||
localparam FIXED_DEPTH = 1024 ; // @IPC int 1,1024 |
|||
|
|||
localparam VARIABLE_MAX_DEPTH = 1024 ; // @IPC int 1,1024 |
|||
|
|||
localparam DATA_WIDTH = 1 ; // @IPC int 1,256 |
|||
|
|||
localparam SHIFT_REG_TYPE = "dynamic_latency" ; // @IPC enum fixed_latency,dynamic_latency |
|||
|
|||
localparam SHIFT_REG_TYPE_BOOL = 1 ; // @IPC bool |
|||
|
|||
localparam RST_TYPE = "ASYNC" ; // @IPC enum ASYNC,SYNC |
|||
|
|||
|
|||
|
|||
localparam DEPTH = (SHIFT_REG_TYPE=="fixed_latency") ? FIXED_DEPTH : |
|||
(SHIFT_REG_TYPE=="dynamic_latency") ? VARIABLE_MAX_DEPTH : 0; |
|||
|
|||
|
|||
localparam ADDR_WIDTH = (DEPTH<=16) ? 4 : |
|||
(DEPTH<=32) ? 5 : |
|||
(DEPTH<=64) ? 6 : |
|||
(DEPTH<=128) ? 7 : |
|||
(DEPTH<=256) ? 8 : |
|||
(DEPTH<=512) ? 9 : 10 ; |
|||
|
|||
|
|||
// variable declaration |
|||
reg clk_tb ; |
|||
reg tb_rst ; |
|||
reg [ADDR_WIDTH-1:0] tb_addr ; |
|||
reg [ADDR_WIDTH-1:0] addr ; |
|||
reg [DATA_WIDTH-1:0] tb_wrdata ; |
|||
wire [DATA_WIDTH-1:0] tb_rddata ; |
|||
reg check_err ; |
|||
reg [2:0] results_cnt; |
|||
wire [DATA_WIDTH-1:0] tb_tmp ; |
|||
reg [ADDR_WIDTH-1:0] cnt ; |
|||
reg cmp_en ; |
|||
|
|||
assign tb_tmp = tb_rddata + DEPTH + 1; |
|||
//************************************************************ CGU **************************************************************************** |
|||
//generate clk_tb |
|||
initial |
|||
begin |
|||
|
|||
clk_tb = 0; |
|||
forever #(T_CLK_PERIOD/2) clk_tb = ~clk_tb; |
|||
end |
|||
|
|||
|
|||
//********************************************************* DGU ******************************************************************************** |
|||
|
|||
initial begin |
|||
|
|||
tb_addr = 0; |
|||
tb_wrdata = 0; |
|||
cnt = 0; |
|||
tb_rst = 1; |
|||
|
|||
addr = VARIABLE_MAX_DEPTH; |
|||
|
|||
#T_RST_TIME ; |
|||
tb_rst = 0; |
|||
#10 ; |
|||
$display("writing shiftregister"); |
|||
write_shiftregister; |
|||
#10; |
|||
$display("shiftregister Simulation done"); |
|||
if (|results_cnt) |
|||
$display("Simulation Failed due to Error Found.") ; |
|||
else |
|||
$display("Simulation Success.") ; |
|||
$finish ; |
|||
end |
|||
|
|||
|
|||
//***************************************************************** DUT INST ************************************************************************************** |
|||
|
|||
always@(posedge clk_tb or posedge tb_rst) begin |
|||
if(tb_rst) |
|||
check_err = 0; |
|||
else begin |
|||
cnt = cnt + 1; |
|||
if(cnt > DEPTH + 2 && tb_wrdata != tb_tmp && cmp_en) begin |
|||
check_err = 1; |
|||
end |
|||
else |
|||
check_err = 0; |
|||
end |
|||
end |
|||
|
|||
always @(posedge clk_tb or posedge tb_rst) |
|||
begin |
|||
if (tb_rst) |
|||
results_cnt <= 3'b000 ; |
|||
else if (&results_cnt) |
|||
results_cnt <= 3'b100 ; |
|||
else if (check_err) |
|||
results_cnt <= results_cnt + 3'd1 ; |
|||
end |
|||
|
|||
integer result_fid; |
|||
initial begin |
|||
result_fid = $fopen ("sim_results.log","a"); |
|||
$fmonitor(result_fid,"err_chk=%b",check_err); |
|||
end |
|||
|
|||
GTP_GRS GRS_INST( |
|||
.GRS_N(1'b1) |
|||
); |
|||
ShiftRegister U_ShiftRegister ( |
|||
|
|||
.addr (addr ), //input wire [`T_A_ADDR_WIDTH-1 : 0] |
|||
|
|||
.din (tb_wrdata ), //input wire [`T_A_DATA_WIDTH-1 : 0] |
|||
.dout (tb_rddata ), //output wire [`T_A_DATA_WIDTH-1 : 0] |
|||
.rst (tb_rst ), //input wire |
|||
.clk (clk_tb ) |
|||
); |
|||
|
|||
task write_shiftregister; |
|||
|
|||
integer i; |
|||
begin |
|||
tb_wrdata = 0; |
|||
tb_addr = 0; |
|||
cmp_en = 0; |
|||
|
|||
while ( tb_addr < 2**ADDR_WIDTH - 1) |
|||
|
|||
begin |
|||
@(posedge clk_tb); |
|||
tb_addr = tb_addr + 1'b1; |
|||
tb_wrdata = tb_wrdata + 1'b1; |
|||
cmp_en = 1'b1; |
|||
end |
|||
cmp_en = 0; |
|||
end |
|||
endtask |
|||
|
|||
endmodule |
|||
|
@ -0,0 +1,15 @@ |
|||
// Created by IP Generator (Version 2021.1-SP7 build 86875) |
|||
// Instantiation Template |
|||
// |
|||
// Insert the following codes into your Verilog file. |
|||
// * Change the_instance_name to your own instance name. |
|||
// * Change the signal names in the port associations |
|||
|
|||
|
|||
ShiftRegister the_instance_name ( |
|||
.din(din), // input |
|||
.addr(addr), // input [9:0] |
|||
.clk(clk), // input |
|||
.rst(rst), // input |
|||
.dout(dout) // output |
|||
); |
@ -0,0 +1,27 @@ |
|||
-- Created by IP Generator (Version 2021.1-SP7 build 86875) |
|||
-- Instantiation Template |
|||
-- |
|||
-- Insert the following codes into your VHDL file. |
|||
-- * Change the_instance_name to your own instance name. |
|||
-- * Change the net names in the port map. |
|||
|
|||
|
|||
COMPONENT ShiftRegister |
|||
PORT ( |
|||
din : IN STD_LOGIC; |
|||
addr : IN STD_LOGIC_VECTOR(9 DOWNTO 0); |
|||
clk : IN STD_LOGIC; |
|||
rst : IN STD_LOGIC; |
|||
dout : OUT STD_LOGIC |
|||
); |
|||
END COMPONENT; |
|||
|
|||
|
|||
the_instance_name : ShiftRegister |
|||
PORT MAP ( |
|||
din => din, |
|||
addr => addr, |
|||
clk => clk, |
|||
rst => rst, |
|||
dout => dout |
|||
); |
@ -0,0 +1,21 @@ |
|||
IP Generator (Version 2021.1-SP7 build 86875) |
|||
Check out license ... |
|||
Start generating at 2024-03-20 17:08 |
|||
Instance: ShiftRegister (D:\workspace\p_lusterinc\xsync_fpge\ipcore\ShiftRegister\ShiftRegister.idf) |
|||
IP: Distributed Shift Register (1.2) |
|||
Part: Logos-PGL22G-MBG324--6 |
|||
Create directory 'rtl' ... |
|||
Copy 'rtl\ipm_distributed_sdpram_v1_2.v.xml' to 'rtl' ... |
|||
Copy 'rtl\ipm_distributed_shiftregister_v1_2.v.xml' to 'rtl' ... |
|||
Compile file 'rtl\ipm_distributed_sdpram_v1_2.v.xml' to 'rtl\ipm_distributed_sdpram_v1_2_ShiftRegister.v' ... |
|||
Compile file 'rtl\ipm_distributed_shiftregister_v1_2.v.xml' to 'rtl\ipm_distributed_shiftregister_v1_2_ShiftRegister.v' ... |
|||
Copy 'ipm_distributed_shiftregister_wrapper_v1_2.v.xml' ... |
|||
Copy 'ipm_distributed_shiftregister_wrapper_v1_2_tb.v.xml' ... |
|||
Compile file 'ipm_distributed_shiftregister_wrapper_v1_2.v.xml' to 'ShiftRegister.v' ... |
|||
Found top module 'ShiftRegister' in file 'ShiftRegister.v'. |
|||
Compile file 'ipm_distributed_shiftregister_wrapper_v1_2_tb.v.xml' to 'ShiftRegister_tb.v' ... |
|||
Create template file 'ShiftRegister_tmpl.v' ... |
|||
Create template file 'ShiftRegister_tmpl.vhdl' ... |
|||
There are 3 source files to synthesize. |
|||
Synthesis is disabled. |
|||
Done: 0 error(s), 0 warning(s) |
@ -0,0 +1,111 @@ |
|||
// Created by IP Generator (Version 2021.1-SP7 build 86875) |
|||
|
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////// |
|||
// |
|||
// Copyright (c) 2014 PANGO MICROSYSTEMS, INC |
|||
// ALL RIGHTS REVERVED. |
|||
// |
|||
// THE SOURCE CODE CONTAINED HEREIN IS PROPRIETARY TO PANGO MICROSYSTEMS, INC. |
|||
// IT SHALL NOT BE REPRODUCED OR DISCLOSED IN WHOLE OR IN PART OR USED BY |
|||
// PARTIES WITHOUT WRITTEN AUTHORIZATION FROM THE OWNER. |
|||
// |
|||
////////////////////////////////////////////////////////////////////////////// |
|||
// |
|||
// Library: |
|||
// Filename:ipm_distributed_sdpram_v1_2_ShiftRegister.v |
|||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|||
|
|||
`timescale 1 ns / 1 ps |
|||
|
|||
module ipm_distributed_sdpram_v1_2_ShiftRegister |
|||
#( |
|||
parameter ADDR_WIDTH = 4 , //address width range:4-10 |
|||
parameter DATA_WIDTH = 4 , //data width range:1-256 |
|||
parameter RST_TYPE = "ASYNC" , //reset type "ASYNC" "SYNC" |
|||
parameter OUT_REG = 0 , //output options :non_register(0) register(1) |
|||
parameter INIT_FILE = "NONE" , //legal value:"NONE" or "initial file name" |
|||
parameter FILE_FORMAT = "BIN" //initial data format : "BIN" or "HEX" |
|||
) |
|||
( |
|||
input wire [DATA_WIDTH-1:0] wr_data , |
|||
input wire [ADDR_WIDTH-1:0] wr_addr , |
|||
input wire [ADDR_WIDTH-1:0] rd_addr , |
|||
input wire wr_clk , |
|||
input wire rd_clk , |
|||
input wire wr_en , |
|||
input wire rst , |
|||
output wire [DATA_WIDTH-1:0] rd_data |
|||
)/* synthesis syn_ramstyle = "select_ram" */; |
|||
|
|||
|
|||
wire asyn_rst ; |
|||
wire syn_rst ; |
|||
wire [DATA_WIDTH-1:0] q ; |
|||
reg [DATA_WIDTH-1:0] q_reg ; |
|||
|
|||
reg [DATA_WIDTH-1:0] mem [2**ADDR_WIDTH-1:0]; |
|||
|
|||
//***********************************************************************reset******************************************************************* |
|||
assign asyn_rst = (RST_TYPE == "ASYNC") ? rst : 0 ; |
|||
assign syn_rst = (RST_TYPE == "SYNC" ) ? rst : 0 ; |
|||
|
|||
//initialize sdpram |
|||
generate |
|||
integer i,j; |
|||
if (INIT_FILE != "NONE") begin |
|||
if (FILE_FORMAT == "BIN") begin |
|||
initial begin |
|||
$readmemb(INIT_FILE,mem); |
|||
end |
|||
end |
|||
else if (FILE_FORMAT == "HEX") begin |
|||
initial begin |
|||
$readmemh(INIT_FILE,mem); |
|||
end |
|||
end |
|||
end |
|||
else begin |
|||
initial begin |
|||
for (i=0;i<2**ADDR_WIDTH;i=i+1) begin |
|||
for (j=0;j<DATA_WIDTH;j=j+1) begin |
|||
mem[i][j] = 1'b0; |
|||
end |
|||
end |
|||
end |
|||
end |
|||
endgenerate |
|||
|
|||
//write & read |
|||
generate |
|||
always @(posedge wr_clk) begin |
|||
if(wr_en) |
|||
mem[wr_addr] <= wr_data; |
|||
end |
|||
|
|||
assign q = mem[rd_addr]; |
|||
|
|||
if (RST_TYPE == "ASYNC") begin |
|||
always@(posedge rd_clk or posedge asyn_rst) |
|||
begin |
|||
if(asyn_rst) |
|||
q_reg <= {DATA_WIDTH{1'b0}}; |
|||
else |
|||
q_reg <= q; |
|||
end |
|||
end |
|||
else if (RST_TYPE == "SYNC") begin |
|||
always@(posedge rd_clk) |
|||
begin |
|||
if(syn_rst) |
|||
q_reg <= {DATA_WIDTH{1'b0}}; |
|||
else |
|||
q_reg <= q; |
|||
end |
|||
end |
|||
endgenerate |
|||
|
|||
assign rd_data = (OUT_REG == 1) ? q_reg : q; |
|||
|
|||
endmodule |
@ -0,0 +1,111 @@ |
|||
// Created by IP Generator (Version 2021.1-SP7 build 86875) |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////// |
|||
// |
|||
// Copyright (c) 2014 PANGO MICROSYSTEMS, INC |
|||
// ALL RIGHTS REVERVED. |
|||
// |
|||
// THE SOURCE CODE CONTAINED HEREIN IS PROPRIETARY TO PANGO MICROSYSTEMS, INC. |
|||
// IT SHALL NOT BE REPRODUCED OR DISCLOSED IN WHOLE OR IN PART OR USED BY |
|||
// PARTIES WITHOUT WRITTEN AUTHORIZATION FROM THE OWNER. |
|||
// |
|||
////////////////////////////////////////////////////////////////////////////// |
|||
// |
|||
// Library: |
|||
// Filename:ipm_distributed_shiftregister_v1_2_ShiftRegister.v |
|||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|||
|
|||
`timescale 1 ns / 1 ps |
|||
|
|||
module ipm_distributed_shiftregister_v1_2_ShiftRegister |
|||
#( |
|||
parameter FIXED_DEPTH = 16 , //range:1-1024 |
|||
parameter VARIABLE_MAX_DEPTH = 16 , //range:1-1024 |
|||
parameter DATA_WIDTH = 16 , //data width range:1-256 |
|||
parameter SHIFT_REG_TYPE = "fixed_latency" , //default value :"fixed_latency" or "dynamic_latency" |
|||
parameter RST_TYPE = "ASYNC" //reset type "ASYNC" "SYNC" |
|||
|
|||
) |
|||
( |
|||
din , |
|||
addr, |
|||
clk , |
|||
rst , |
|||
dout |
|||
); |
|||
|
|||
localparam DEPTH = (SHIFT_REG_TYPE=="fixed_latency" ) ? FIXED_DEPTH : |
|||
(SHIFT_REG_TYPE=="dynamic_latency") ? VARIABLE_MAX_DEPTH : 0; |
|||
|
|||
localparam ADDR_WIDTH = (DEPTH<=16 ) ? 4 : |
|||
(DEPTH<=32 ) ? 5 : |
|||
(DEPTH<=64 ) ? 6 : |
|||
(DEPTH<=128) ? 7 : |
|||
(DEPTH<=256) ? 8 : |
|||
(DEPTH<=512) ? 9 : 10; |
|||
|
|||
//***********************************************************IO****************************** |
|||
input wire [DATA_WIDTH-1:0] din ; |
|||
input wire [ADDR_WIDTH-1:0] addr ; |
|||
input wire clk ; |
|||
input wire rst ; |
|||
output wire [DATA_WIDTH-1:0] dout ; |
|||
//******************************************************************************************* |
|||
reg [ADDR_WIDTH-1:0] wr_addr ; |
|||
reg [ADDR_WIDTH-1:0] rd_addr ; |
|||
|
|||
wire asyn_rst ; |
|||
wire syn_rst ; |
|||
|
|||
assign asyn_rst = (RST_TYPE == "ASYNC") ? rst : 0; |
|||
assign syn_rst = (RST_TYPE == "SYNC" ) ? rst : 0; |
|||
|
|||
generate |
|||
if (RST_TYPE == "ASYNC") begin |
|||
always @(posedge clk or posedge asyn_rst) begin |
|||
if (asyn_rst) |
|||
wr_addr <= 0; |
|||
else |
|||
wr_addr <= wr_addr+1; |
|||
end |
|||
end |
|||
else if (RST_TYPE == "SYNC") begin |
|||
always @(posedge clk) begin |
|||
if (syn_rst) |
|||
wr_addr <= 0; |
|||
else |
|||
wr_addr <= wr_addr+1; |
|||
end |
|||
end |
|||
endgenerate |
|||
|
|||
always @(*) begin |
|||
if (SHIFT_REG_TYPE=="fixed_latency") |
|||
rd_addr = wr_addr+2**ADDR_WIDTH-DEPTH; |
|||
else if (SHIFT_REG_TYPE=="dynamic_latency") |
|||
rd_addr = wr_addr+2**ADDR_WIDTH-addr; |
|||
end |
|||
|
|||
//********************************************************* SDP INST ************************************************** |
|||
ipm_distributed_sdpram_v1_2_ShiftRegister |
|||
#( |
|||
.ADDR_WIDTH (ADDR_WIDTH ) , |
|||
.DATA_WIDTH (DATA_WIDTH ) , |
|||
.RST_TYPE (RST_TYPE ) , |
|||
.OUT_REG (1'b1 ) , |
|||
.INIT_FILE ("NONE" ) , |
|||
.FILE_FORMAT ("BIN" ) |
|||
) u_ipm_distributed_sdpram_ShiftRegister |
|||
( |
|||
.wr_data (din ) , |
|||
.wr_addr (wr_addr ) , |
|||
.rd_addr (rd_addr ) , |
|||
.wr_clk (clk ) , |
|||
.rd_clk (clk ) , |
|||
.wr_en (1'b1 ) , |
|||
.rst (rst ) , |
|||
.rd_data (dout ) |
|||
); |
|||
endmodule |
|||
|
@ -0,0 +1,2 @@ |
|||
2024-03-21 09:54 |
|||
rev_1 |
@ -0,0 +1,92 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<ip_inst> |
|||
<header> |
|||
<vendor>Pango</vendor> |
|||
<id>06100103</id> |
|||
<display_name>Distributed Shift Register</display_name> |
|||
<name>Distributed Shift Register</name> |
|||
<version>1.2</version> |
|||
<instance>ShiftRegister</instance> |
|||
<family>Logos</family> |
|||
<device>PGL22G</device> |
|||
<package>MBG324</package> |
|||
<speedgrade>-6</speedgrade> |
|||
<generator version="2021.1-SP7" build="86875">IP Compiler</generator> |
|||
</header> |
|||
<param_list> |
|||
<param> |
|||
<name>DATA_WIDTH</name> |
|||
<value>1</value> |
|||
</param> |
|||
<param> |
|||
<name>SHIFT_REG_TYPE</name> |
|||
<value>dynamic_latency</value> |
|||
</param> |
|||
<param> |
|||
<name>VARIABLE_MAX_DEPTH</name> |
|||
<value>1024</value> |
|||
</param> |
|||
<param> |
|||
<name>RST_TYPE</name> |
|||
<value>ASYNC</value> |
|||
</param> |
|||
<param> |
|||
<name>FIXED_DEPTH</name> |
|||
<value>1024</value> |
|||
</param> |
|||
<param> |
|||
<name>SHIFT_REG_TYPE_BOOL</name> |
|||
<value>true</value> |
|||
</param> |
|||
</param_list> |
|||
<pin_list> |
|||
<pin> |
|||
<name>din</name> |
|||
<text>din</text> |
|||
<dir>input</dir> |
|||
<pos>left</pos> |
|||
</pin> |
|||
<pin> |
|||
<name>addr</name> |
|||
<text>addr</text> |
|||
<dir>input</dir> |
|||
<pos>left</pos> |
|||
<msb>9</msb> |
|||
<lsb>0</lsb> |
|||
</pin> |
|||
<pin> |
|||
<name>clk</name> |
|||
<text>clk</text> |
|||
<dir>input</dir> |
|||
<pos>left</pos> |
|||
</pin> |
|||
<pin> |
|||
<name>rst</name> |
|||
<text>rst</text> |
|||
<dir>input</dir> |
|||
<pos>left</pos> |
|||
</pin> |
|||
<pin> |
|||
<name>dout</name> |
|||
<text>dout</text> |
|||
<dir>output</dir> |
|||
<pos>right</pos> |
|||
</pin> |
|||
</pin_list> |
|||
<synthesis> |
|||
<script><![CDATA[set_option -vlog_std v2001]]></script> |
|||
<script><![CDATA[set_option -disable_io_insertion 1]]></script> |
|||
</synthesis> |
|||
<file_list> |
|||
<output> |
|||
<file pathname="generate.log" format="log" description="Generate Log"/> |
|||
<file pathname="ShiftRegister_tmpl.v" format="verilog" description="Instantiation Template"/> |
|||
<file pathname="ShiftRegister_tmpl.vhdl" format="vhdl" description="Instantiation Template"/> |
|||
</output> |
|||
<source> |
|||
<file pathname="rtl/ipm_distributed_sdpram_v1_2_ShiftRegister.v"/> |
|||
<file pathname="rtl/ipm_distributed_shiftregister_v1_2_ShiftRegister.v"/> |
|||
<file pathname="ShiftRegister.v"/> |
|||
</source> |
|||
</file_list> |
|||
</ip_inst> |
@ -0,0 +1,83 @@ |
|||
// Created by IP Generator (Version 2021.1-SP7 build 86875) |
|||
|
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////// |
|||
// |
|||
// Copyright (c) 2014 PANGO MICROSYSTEMS, INC |
|||
// ALL RIGHTS REVERVED. |
|||
// |
|||
// THE SOURCE CODE CONTAINED HEREIN IS PROPRIETARY TO PANGO MICROSYSTEMS, INC. |
|||
// IT SHALL NOT BE REPRODUCED OR DISCLOSED IN WHOLE OR IN PART OR USED BY |
|||
// PARTIES WITHOUT WRITTEN AUTHORIZATION FROM THE OWNER. |
|||
// |
|||
////////////////////////////////////////////////////////////////////////////// |
|||
// |
|||
// Library: |
|||
// Filename:ShiftRegister.v |
|||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|||
|
|||
`timescale 1 ns / 1 ps |
|||
module ShiftRegister |
|||
( |
|||
din , |
|||
|
|||
addr , |
|||
|
|||
clk , |
|||
rst , |
|||
dout |
|||
); |
|||
|
|||
localparam FIXED_DEPTH = 1024 ; // @IPC int 1,1024 |
|||
|
|||
localparam VARIABLE_MAX_DEPTH = 1024 ; // @IPC int 1,1024 |
|||
|
|||
localparam DATA_WIDTH = 1 ; // @IPC int 1,256 |
|||
|
|||
localparam SHIFT_REG_TYPE = "dynamic_latency" ; // @IPC enum fixed_latency,dynamic_latency |
|||
|
|||
localparam SHIFT_REG_TYPE_BOOL = 1 ; // @IPC bool |
|||
|
|||
localparam RST_TYPE = "ASYNC" ; // @IPC enum ASYNC,SYNC |
|||
|
|||
|
|||
localparam DEPTH = (SHIFT_REG_TYPE=="fixed_latency" ) ? FIXED_DEPTH : |
|||
(SHIFT_REG_TYPE=="dynamic_latency") ? VARIABLE_MAX_DEPTH : 0; |
|||
|
|||
|
|||
localparam ADDR_WIDTH = (DEPTH<=16) ? 4 : |
|||
(DEPTH<=32) ? 5 : |
|||
(DEPTH<=64) ? 6 : |
|||
(DEPTH<=128) ? 7 : |
|||
(DEPTH<=256) ? 8 : |
|||
(DEPTH<=512) ? 9 : 10 ; |
|||
|
|||
|
|||
input wire [DATA_WIDTH-1:0] din ; |
|||
|
|||
input wire [ADDR_WIDTH-1:0] addr ; |
|||
|
|||
input wire clk ; |
|||
input wire rst ; |
|||
output wire [DATA_WIDTH-1:0] dout ; |
|||
|
|||
|
|||
ipm_distributed_shiftregister_v1_2_ShiftRegister |
|||
#( |
|||
.FIXED_DEPTH (FIXED_DEPTH ) , |
|||
.VARIABLE_MAX_DEPTH (VARIABLE_MAX_DEPTH ) , |
|||
.DATA_WIDTH (DATA_WIDTH ) , |
|||
.SHIFT_REG_TYPE (SHIFT_REG_TYPE ) , |
|||
.RST_TYPE (RST_TYPE ) |
|||
)u_ipm_distributed_shiftregister_ShiftRegister |
|||
( |
|||
.din (din ) , |
|||
|
|||
.addr (addr ) , |
|||
|
|||
.clk (clk ) , |
|||
.rst (rst ) , |
|||
.dout (dout ) |
|||
); |
|||
endmodule |
@ -0,0 +1,168 @@ |
|||
// Created by IP Generator (Version 2021.1-SP7 build 86875) |
|||
|
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////// |
|||
// |
|||
// Copyright (c) 2014 PANGO MICROSYSTEMS, INC |
|||
// ALL RIGHTS REVERVED. |
|||
// |
|||
// THE SOURCE CODE CONTAINED HEREIN IS PROPRIETARY TO PANGO MICROSYSTEMS, INC. |
|||
// IT SHALL NOT BE REPRODUCED OR DISCLOSED IN WHOLE OR IN PART OR USED BY |
|||
// PARTIES WITHOUT WRITTEN AUTHORIZATION FROM THE OWNER. |
|||
// |
|||
////////////////////////////////////////////////////////////////////////////// |
|||
// |
|||
// Library: |
|||
// Filename:TB ShiftRegister_tb.v |
|||
////////////////////////////////////////////////////////////////////////////// |
|||
|
|||
`timescale 1ns / 1ps |
|||
|
|||
module ShiftRegister_tb (); |
|||
|
|||
localparam T_CLK_PERIOD = 10 ; //clock a half perid |
|||
localparam T_RST_TIME = 200 ; //reset time |
|||
|
|||
localparam FIXED_DEPTH = 1024 ; // @IPC int 1,1024 |
|||
|
|||
localparam VARIABLE_MAX_DEPTH = 1024 ; // @IPC int 1,1024 |
|||
|
|||
localparam DATA_WIDTH = 1 ; // @IPC int 1,256 |
|||
|
|||
localparam SHIFT_REG_TYPE = "dynamic_latency" ; // @IPC enum fixed_latency,dynamic_latency |
|||
|
|||
localparam SHIFT_REG_TYPE_BOOL = 1 ; // @IPC bool |
|||
|
|||
localparam RST_TYPE = "ASYNC" ; // @IPC enum ASYNC,SYNC |
|||
|
|||
|
|||
|
|||
localparam DEPTH = (SHIFT_REG_TYPE=="fixed_latency") ? FIXED_DEPTH : |
|||
(SHIFT_REG_TYPE=="dynamic_latency") ? VARIABLE_MAX_DEPTH : 0; |
|||
|
|||
|
|||
localparam ADDR_WIDTH = (DEPTH<=16) ? 4 : |
|||
(DEPTH<=32) ? 5 : |
|||
(DEPTH<=64) ? 6 : |
|||
(DEPTH<=128) ? 7 : |
|||
(DEPTH<=256) ? 8 : |
|||
(DEPTH<=512) ? 9 : 10 ; |
|||
|
|||
|
|||
// variable declaration |
|||
reg clk_tb ; |
|||
reg tb_rst ; |
|||
reg [ADDR_WIDTH-1:0] tb_addr ; |
|||
reg [ADDR_WIDTH-1:0] addr ; |
|||
reg [DATA_WIDTH-1:0] tb_wrdata ; |
|||
wire [DATA_WIDTH-1:0] tb_rddata ; |
|||
reg check_err ; |
|||
reg [2:0] results_cnt; |
|||
wire [DATA_WIDTH-1:0] tb_tmp ; |
|||
reg [ADDR_WIDTH-1:0] cnt ; |
|||
reg cmp_en ; |
|||
|
|||
assign tb_tmp = tb_rddata + DEPTH + 1; |
|||
//************************************************************ CGU **************************************************************************** |
|||
//generate clk_tb |
|||
initial |
|||
begin |
|||
|
|||
clk_tb = 0; |
|||
forever #(T_CLK_PERIOD/2) clk_tb = ~clk_tb; |
|||
end |
|||
|
|||
|
|||
//********************************************************* DGU ******************************************************************************** |
|||
|
|||
initial begin |
|||
|
|||
tb_addr = 0; |
|||
tb_wrdata = 0; |
|||
cnt = 0; |
|||
tb_rst = 1; |
|||
|
|||
addr = VARIABLE_MAX_DEPTH; |
|||
|
|||
#T_RST_TIME ; |
|||
tb_rst = 0; |
|||
#10 ; |
|||
$display("writing shiftregister"); |
|||
write_shiftregister; |
|||
#10; |
|||
$display("shiftregister Simulation done"); |
|||
if (|results_cnt) |
|||
$display("Simulation Failed due to Error Found.") ; |
|||
else |
|||
$display("Simulation Success.") ; |
|||
$finish ; |
|||
end |
|||
|
|||
|
|||
//***************************************************************** DUT INST ************************************************************************************** |
|||
|
|||
always@(posedge clk_tb or posedge tb_rst) begin |
|||
if(tb_rst) |
|||
check_err = 0; |
|||
else begin |
|||
cnt = cnt + 1; |
|||
if(cnt > DEPTH + 2 && tb_wrdata != tb_tmp && cmp_en) begin |
|||
check_err = 1; |
|||
end |
|||
else |
|||
check_err = 0; |
|||
end |
|||
end |
|||
|
|||
always @(posedge clk_tb or posedge tb_rst) |
|||
begin |
|||
if (tb_rst) |
|||
results_cnt <= 3'b000 ; |
|||
else if (&results_cnt) |
|||
results_cnt <= 3'b100 ; |
|||
else if (check_err) |
|||
results_cnt <= results_cnt + 3'd1 ; |
|||
end |
|||
|
|||
integer result_fid; |
|||
initial begin |
|||
result_fid = $fopen ("sim_results.log","a"); |
|||
$fmonitor(result_fid,"err_chk=%b",check_err); |
|||
end |
|||
|
|||
GTP_GRS GRS_INST( |
|||
.GRS_N(1'b1) |
|||
); |
|||
ShiftRegister U_ShiftRegister ( |
|||
|
|||
.addr (addr ), //input wire [`T_A_ADDR_WIDTH-1 : 0] |
|||
|
|||
.din (tb_wrdata ), //input wire [`T_A_DATA_WIDTH-1 : 0] |
|||
.dout (tb_rddata ), //output wire [`T_A_DATA_WIDTH-1 : 0] |
|||
.rst (tb_rst ), //input wire |
|||
.clk (clk_tb ) |
|||
); |
|||
|
|||
task write_shiftregister; |
|||
|
|||
integer i; |
|||
begin |
|||
tb_wrdata = 0; |
|||
tb_addr = 0; |
|||
cmp_en = 0; |
|||
|
|||
while ( tb_addr < 2**ADDR_WIDTH - 1) |
|||
|
|||
begin |
|||
@(posedge clk_tb); |
|||
tb_addr = tb_addr + 1'b1; |
|||
tb_wrdata = tb_wrdata + 1'b1; |
|||
cmp_en = 1'b1; |
|||
end |
|||
cmp_en = 0; |
|||
end |
|||
endtask |
|||
|
|||
endmodule |
|||
|
@ -0,0 +1,15 @@ |
|||
// Created by IP Generator (Version 2021.1-SP7 build 86875) |
|||
// Instantiation Template |
|||
// |
|||
// Insert the following codes into your Verilog file. |
|||
// * Change the_instance_name to your own instance name. |
|||
// * Change the signal names in the port associations |
|||
|
|||
|
|||
ShiftRegister the_instance_name ( |
|||
.din(din), // input |
|||
.addr(addr), // input [9:0] |
|||
.clk(clk), // input |
|||
.rst(rst), // input |
|||
.dout(dout) // output |
|||
); |
@ -0,0 +1,27 @@ |
|||
-- Created by IP Generator (Version 2021.1-SP7 build 86875) |
|||
-- Instantiation Template |
|||
-- |
|||
-- Insert the following codes into your VHDL file. |
|||
-- * Change the_instance_name to your own instance name. |
|||
-- * Change the net names in the port map. |
|||
|
|||
|
|||
COMPONENT ShiftRegister |
|||
PORT ( |
|||
din : IN STD_LOGIC; |
|||
addr : IN STD_LOGIC_VECTOR(9 DOWNTO 0); |
|||
clk : IN STD_LOGIC; |
|||
rst : IN STD_LOGIC; |
|||
dout : OUT STD_LOGIC |
|||
); |
|||
END COMPONENT; |
|||
|
|||
|
|||
the_instance_name : ShiftRegister |
|||
PORT MAP ( |
|||
din => din, |
|||
addr => addr, |
|||
clk => clk, |
|||
rst => rst, |
|||
dout => dout |
|||
); |
@ -0,0 +1,21 @@ |
|||
IP Generator (Version 2021.1-SP7 build 86875) |
|||
Check out license ... |
|||
Start generating at 2024-03-21 09:54 |
|||
Instance: ShiftRegister (D:\workspace\p_lusterinc\xsync_fpge\ipcore\ShiftRegister\ShiftRegister.idf) |
|||
IP: Distributed Shift Register (1.2) |
|||
Part: Logos-PGL22G-MBG324--6 |
|||
Create directory 'rtl' ... |
|||
Copy 'rtl\ipm_distributed_sdpram_v1_2.v.xml' to 'rtl' ... |
|||
Copy 'rtl\ipm_distributed_shiftregister_v1_2.v.xml' to 'rtl' ... |
|||
Compile file 'rtl\ipm_distributed_sdpram_v1_2.v.xml' to 'rtl\ipm_distributed_sdpram_v1_2_ShiftRegister.v' ... |
|||
Compile file 'rtl\ipm_distributed_shiftregister_v1_2.v.xml' to 'rtl\ipm_distributed_shiftregister_v1_2_ShiftRegister.v' ... |
|||
Copy 'ipm_distributed_shiftregister_wrapper_v1_2.v.xml' ... |
|||
Copy 'ipm_distributed_shiftregister_wrapper_v1_2_tb.v.xml' ... |
|||
Compile file 'ipm_distributed_shiftregister_wrapper_v1_2.v.xml' to 'ShiftRegister.v' ... |
|||
Found top module 'ShiftRegister' in file 'ShiftRegister.v'. |
|||
Compile file 'ipm_distributed_shiftregister_wrapper_v1_2_tb.v.xml' to 'ShiftRegister_tb.v' ... |
|||
Create template file 'ShiftRegister_tmpl.v' ... |
|||
Create template file 'ShiftRegister_tmpl.vhdl' ... |
|||
There are 3 source files to synthesize. |
|||
Synthesis is disabled. |
|||
Done: 0 error(s), 0 warning(s) |
@ -0,0 +1,111 @@ |
|||
// Created by IP Generator (Version 2021.1-SP7 build 86875) |
|||
|
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////// |
|||
// |
|||
// Copyright (c) 2014 PANGO MICROSYSTEMS, INC |
|||
// ALL RIGHTS REVERVED. |
|||
// |
|||
// THE SOURCE CODE CONTAINED HEREIN IS PROPRIETARY TO PANGO MICROSYSTEMS, INC. |
|||
// IT SHALL NOT BE REPRODUCED OR DISCLOSED IN WHOLE OR IN PART OR USED BY |
|||
// PARTIES WITHOUT WRITTEN AUTHORIZATION FROM THE OWNER. |
|||
// |
|||
////////////////////////////////////////////////////////////////////////////// |
|||
// |
|||
// Library: |
|||
// Filename:ipm_distributed_sdpram_v1_2_ShiftRegister.v |
|||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|||
|
|||
`timescale 1 ns / 1 ps |
|||
|
|||
module ipm_distributed_sdpram_v1_2_ShiftRegister |
|||
#( |
|||
parameter ADDR_WIDTH = 4 , //address width range:4-10 |
|||
parameter DATA_WIDTH = 4 , //data width range:1-256 |
|||
parameter RST_TYPE = "ASYNC" , //reset type "ASYNC" "SYNC" |
|||
parameter OUT_REG = 0 , //output options :non_register(0) register(1) |
|||
parameter INIT_FILE = "NONE" , //legal value:"NONE" or "initial file name" |
|||
parameter FILE_FORMAT = "BIN" //initial data format : "BIN" or "HEX" |
|||
) |
|||
( |
|||
input wire [DATA_WIDTH-1:0] wr_data , |
|||
input wire [ADDR_WIDTH-1:0] wr_addr , |
|||
input wire [ADDR_WIDTH-1:0] rd_addr , |
|||
input wire wr_clk , |
|||
input wire rd_clk , |
|||
input wire wr_en , |
|||
input wire rst , |
|||
output wire [DATA_WIDTH-1:0] rd_data |
|||
)/* synthesis syn_ramstyle = "select_ram" */; |
|||
|
|||
|
|||
wire asyn_rst ; |
|||
wire syn_rst ; |
|||
wire [DATA_WIDTH-1:0] q ; |
|||
reg [DATA_WIDTH-1:0] q_reg ; |
|||
|
|||
reg [DATA_WIDTH-1:0] mem [2**ADDR_WIDTH-1:0]; |
|||
|
|||
//***********************************************************************reset******************************************************************* |
|||
assign asyn_rst = (RST_TYPE == "ASYNC") ? rst : 0 ; |
|||
assign syn_rst = (RST_TYPE == "SYNC" ) ? rst : 0 ; |
|||
|
|||
//initialize sdpram |
|||
generate |
|||
integer i,j; |
|||
if (INIT_FILE != "NONE") begin |
|||
if (FILE_FORMAT == "BIN") begin |
|||
initial begin |
|||
$readmemb(INIT_FILE,mem); |
|||
end |
|||
end |
|||
else if (FILE_FORMAT == "HEX") begin |
|||
initial begin |
|||
$readmemh(INIT_FILE,mem); |
|||
end |
|||
end |
|||
end |
|||
else begin |
|||
initial begin |
|||
for (i=0;i<2**ADDR_WIDTH;i=i+1) begin |
|||
for (j=0;j<DATA_WIDTH;j=j+1) begin |
|||
mem[i][j] = 1'b0; |
|||
end |
|||
end |
|||
end |
|||
end |
|||
endgenerate |
|||
|
|||
//write & read |
|||
generate |
|||
always @(posedge wr_clk) begin |
|||
if(wr_en) |
|||
mem[wr_addr] <= wr_data; |
|||
end |
|||
|
|||
assign q = mem[rd_addr]; |
|||
|
|||
if (RST_TYPE == "ASYNC") begin |
|||
always@(posedge rd_clk or posedge asyn_rst) |
|||
begin |
|||
if(asyn_rst) |
|||
q_reg <= {DATA_WIDTH{1'b0}}; |
|||
else |
|||
q_reg <= q; |
|||
end |
|||
end |
|||
else if (RST_TYPE == "SYNC") begin |
|||
always@(posedge rd_clk) |
|||
begin |
|||
if(syn_rst) |
|||
q_reg <= {DATA_WIDTH{1'b0}}; |
|||
else |
|||
q_reg <= q; |
|||
end |
|||
end |
|||
endgenerate |
|||
|
|||
assign rd_data = (OUT_REG == 1) ? q_reg : q; |
|||
|
|||
endmodule |
@ -0,0 +1,111 @@ |
|||
// Created by IP Generator (Version 2021.1-SP7 build 86875) |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////// |
|||
// |
|||
// Copyright (c) 2014 PANGO MICROSYSTEMS, INC |
|||
// ALL RIGHTS REVERVED. |
|||
// |
|||
// THE SOURCE CODE CONTAINED HEREIN IS PROPRIETARY TO PANGO MICROSYSTEMS, INC. |
|||
// IT SHALL NOT BE REPRODUCED OR DISCLOSED IN WHOLE OR IN PART OR USED BY |
|||
// PARTIES WITHOUT WRITTEN AUTHORIZATION FROM THE OWNER. |
|||
// |
|||
////////////////////////////////////////////////////////////////////////////// |
|||
// |
|||
// Library: |
|||
// Filename:ipm_distributed_shiftregister_v1_2_ShiftRegister.v |
|||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|||
|
|||
`timescale 1 ns / 1 ps |
|||
|
|||
module ipm_distributed_shiftregister_v1_2_ShiftRegister |
|||
#( |
|||
parameter FIXED_DEPTH = 16 , //range:1-1024 |
|||
parameter VARIABLE_MAX_DEPTH = 16 , //range:1-1024 |
|||
parameter DATA_WIDTH = 16 , //data width range:1-256 |
|||
parameter SHIFT_REG_TYPE = "fixed_latency" , //default value :"fixed_latency" or "dynamic_latency" |
|||
parameter RST_TYPE = "ASYNC" //reset type "ASYNC" "SYNC" |
|||
|
|||
) |
|||
( |
|||
din , |
|||
addr, |
|||
clk , |
|||
rst , |
|||
dout |
|||
); |
|||
|
|||
localparam DEPTH = (SHIFT_REG_TYPE=="fixed_latency" ) ? FIXED_DEPTH : |
|||
(SHIFT_REG_TYPE=="dynamic_latency") ? VARIABLE_MAX_DEPTH : 0; |
|||
|
|||
localparam ADDR_WIDTH = (DEPTH<=16 ) ? 4 : |
|||
(DEPTH<=32 ) ? 5 : |
|||
(DEPTH<=64 ) ? 6 : |
|||
(DEPTH<=128) ? 7 : |
|||
(DEPTH<=256) ? 8 : |
|||
(DEPTH<=512) ? 9 : 10; |
|||
|
|||
//***********************************************************IO****************************** |
|||
input wire [DATA_WIDTH-1:0] din ; |
|||
input wire [ADDR_WIDTH-1:0] addr ; |
|||
input wire clk ; |
|||
input wire rst ; |
|||
output wire [DATA_WIDTH-1:0] dout ; |
|||
//******************************************************************************************* |
|||
reg [ADDR_WIDTH-1:0] wr_addr ; |
|||
reg [ADDR_WIDTH-1:0] rd_addr ; |
|||
|
|||
wire asyn_rst ; |
|||
wire syn_rst ; |
|||
|
|||
assign asyn_rst = (RST_TYPE == "ASYNC") ? rst : 0; |
|||
assign syn_rst = (RST_TYPE == "SYNC" ) ? rst : 0; |
|||
|
|||
generate |
|||
if (RST_TYPE == "ASYNC") begin |
|||
always @(posedge clk or posedge asyn_rst) begin |
|||
if (asyn_rst) |
|||
wr_addr <= 0; |
|||
else |
|||
wr_addr <= wr_addr+1; |
|||
end |
|||
end |
|||
else if (RST_TYPE == "SYNC") begin |
|||
always @(posedge clk) begin |
|||
if (syn_rst) |
|||
wr_addr <= 0; |
|||
else |
|||
wr_addr <= wr_addr+1; |
|||
end |
|||
end |
|||
endgenerate |
|||
|
|||
always @(*) begin |
|||
if (SHIFT_REG_TYPE=="fixed_latency") |
|||
rd_addr = wr_addr+2**ADDR_WIDTH-DEPTH; |
|||
else if (SHIFT_REG_TYPE=="dynamic_latency") |
|||
rd_addr = wr_addr+2**ADDR_WIDTH-addr; |
|||
end |
|||
|
|||
//********************************************************* SDP INST ************************************************** |
|||
ipm_distributed_sdpram_v1_2_ShiftRegister |
|||
#( |
|||
.ADDR_WIDTH (ADDR_WIDTH ) , |
|||
.DATA_WIDTH (DATA_WIDTH ) , |
|||
.RST_TYPE (RST_TYPE ) , |
|||
.OUT_REG (1'b1 ) , |
|||
.INIT_FILE ("NONE" ) , |
|||
.FILE_FORMAT ("BIN" ) |
|||
) u_ipm_distributed_sdpram_ShiftRegister |
|||
( |
|||
.wr_data (din ) , |
|||
.wr_addr (wr_addr ) , |
|||
.rd_addr (rd_addr ) , |
|||
.wr_clk (clk ) , |
|||
.rd_clk (clk ) , |
|||
.wr_en (1'b1 ) , |
|||
.rst (rst ) , |
|||
.rd_data (dout ) |
|||
); |
|||
endmodule |
|||
|
@ -0,0 +1,266 @@ |
|||
module sys_signal_delayer #( |
|||
parameter REG_START_ADD = 0, |
|||
parameter SYS_CLOCK_FREQ = 10000000 |
|||
) ( |
|||
|
|||
input clk, //! 时钟输入 |
|||
input rst_n, //! 复位输入 |
|||
|
|||
input [31:0] addr, //! 寄存器地址 |
|||
input [31:0] wr_data, //! 写入数据 |
|||
input wr_en, //! 写使能 |
|||
output wire [31:0] rd_data, //! 读出数据 |
|||
|
|||
/******************************************************************************* |
|||
* 输入信号延迟 * |
|||
*******************************************************************************/ |
|||
input sync_ttl_in1, |
|||
input sync_ttl_in2, |
|||
input sync_ttl_in3, |
|||
input sync_ttl_in4, |
|||
input timecode_headphone_in, |
|||
input timecode_bnc_in, |
|||
|
|||
input genlock_in_hsync, |
|||
input genlock_in_vsync, |
|||
input genlock_in_fsync, |
|||
|
|||
output af_delay__sync_ttl_in1, |
|||
output af_delay__sync_ttl_in2, |
|||
output af_delay__sync_ttl_in3, |
|||
output af_delay__sync_ttl_in4, |
|||
output af_delay__timecode_headphone_in, |
|||
output af_delay__timecode_bnc_in, |
|||
|
|||
output af_delay__genlock_in_hsync, |
|||
output af_delay__genlock_in_vsync, |
|||
output af_delay__genlock_in_fsync, |
|||
|
|||
/******************************************************************************* |
|||
* 输出接口延迟 * |
|||
*******************************************************************************/ |
|||
|
|||
output sync_ttl_out1, |
|||
output sync_ttl_out2, |
|||
output sync_ttl_out3, |
|||
output sync_ttl_out4, |
|||
|
|||
output stm32if_start_signal_out, |
|||
output stm32if_camera_sync_out, |
|||
output stm32if_timecode_sync_out, |
|||
|
|||
input before_delay__sync_ttl_out1, |
|||
input before_delay__sync_ttl_out2, |
|||
input before_delay__sync_ttl_out3, |
|||
input before_delay__sync_ttl_out4, |
|||
|
|||
input before_delay__stm32if_start_signal_out, |
|||
input before_delay__stm32if_camera_sync_out, |
|||
input before_delay__stm32if_timecode_sync_out |
|||
|
|||
); |
|||
|
|||
|
|||
reg [31:0] r1_ctrl; |
|||
reg [31:0] r2_input_delay_cnt; |
|||
reg [31:0] r3_input_delay_freq_div; |
|||
reg [31:0] r4_output_delay_cnt; |
|||
reg [31:0] r5_output_delay_freq_div; |
|||
|
|||
wire [31:0] reg_wr_index; |
|||
zutils_register_advanced #( |
|||
.REG_START_ADD(REG_START_ADD) |
|||
) _register ( |
|||
.clk (clk), |
|||
.rst_n (rst_n), |
|||
.addr (addr), |
|||
.wr_data (wr_data), |
|||
.wr_en (wr_en), |
|||
.rd_data (rd_data), |
|||
.reg1 (r1_ctrl), |
|||
.reg2 (r2_input_delay_cnt), |
|||
.reg3 (r3_input_delay_freq_div), |
|||
.reg4 (r4_output_delay_cnt), |
|||
.reg5 (r5_output_delay_freq_div), |
|||
.reg_wr_sig(reg_wr_sig), |
|||
.reg_index (reg_wr_index) |
|||
); |
|||
|
|||
reg delayer_rst_n_ctrl; |
|||
always @(posedge clk or negedge rst_n) begin |
|||
if (!rst_n) begin |
|||
r1_ctrl <= 32'hffff_ffff; |
|||
r2_input_delay_cnt <= 32'd100; |
|||
r3_input_delay_freq_div <= 1; |
|||
r4_output_delay_cnt <= 0; |
|||
r5_output_delay_freq_div <= 1; |
|||
delayer_rst_n_ctrl <= 1; |
|||
end else begin |
|||
if (reg_wr_sig) begin |
|||
case (reg_wr_index) |
|||
1: begin |
|||
r1_ctrl <= wr_data; |
|||
delayer_rst_n_ctrl <= 0; |
|||
end |
|||
2: r2_input_delay_cnt <= wr_data; |
|||
3: r3_input_delay_freq_div <= wr_data; |
|||
4: r4_output_delay_cnt <= wr_data; |
|||
5: r5_output_delay_freq_div <= wr_data; |
|||
default: begin |
|||
end |
|||
endcase |
|||
end else begin |
|||
delayer_rst_n_ctrl <= 1; |
|||
end |
|||
end |
|||
end |
|||
|
|||
|
|||
|
|||
assign delayer_rst_n = delayer_rst_n_ctrl & rst_n; |
|||
zutils_sig_delayer_v2 sig_delayer_inst ( |
|||
.clk (clk), |
|||
.rst_n (delayer_rst_n), |
|||
.delay_cnt (r2_input_delay_cnt), |
|||
.freq_division(r3_input_delay_freq_div), |
|||
.in (sync_ttl_in1), |
|||
.out (af_delay__sync_ttl_in1) |
|||
); |
|||
|
|||
zutils_sig_delayer_v2 sig_delayer_inst1 ( |
|||
.clk (clk), |
|||
.rst_n (delayer_rst_n), |
|||
.delay_cnt (r2_input_delay_cnt), |
|||
.freq_division(r3_input_delay_freq_div), |
|||
.in (sync_ttl_in2), |
|||
.out (af_delay__sync_ttl_in2) |
|||
); |
|||
|
|||
zutils_sig_delayer_v2 sig_delayer_inst2 ( |
|||
.clk (clk), |
|||
.rst_n (delayer_rst_n), |
|||
.delay_cnt (r2_input_delay_cnt), |
|||
.freq_division(r3_input_delay_freq_div), |
|||
.in (sync_ttl_in3), |
|||
.out (af_delay__sync_ttl_in3) |
|||
); |
|||
|
|||
zutils_sig_delayer_v2 sig_delayer_inst3 ( |
|||
.clk (clk), |
|||
.rst_n (delayer_rst_n), |
|||
.delay_cnt (r2_input_delay_cnt), |
|||
.freq_division(r3_input_delay_freq_div), |
|||
.in (sync_ttl_in4), |
|||
.out (af_delay__sync_ttl_in4) |
|||
); |
|||
|
|||
zutils_sig_delayer_v2 sig_delayer_inst4 ( |
|||
.clk (clk), |
|||
.rst_n (delayer_rst_n), |
|||
.delay_cnt (r2_input_delay_cnt), |
|||
.freq_division(r3_input_delay_freq_div), |
|||
.in (timecode_headphone_in), |
|||
.out (af_delay__timecode_headphone_in) |
|||
); |
|||
|
|||
zutils_sig_delayer_v2 sig_delayer_inst5 ( |
|||
.clk (clk), |
|||
.rst_n (delayer_rst_n), |
|||
.delay_cnt (r2_input_delay_cnt), |
|||
.freq_division(r3_input_delay_freq_div), |
|||
.in (timecode_bnc_in), |
|||
.out (af_delay__timecode_bnc_in) |
|||
); |
|||
|
|||
zutils_sig_delayer_v2 sig_delayer_inst6 ( |
|||
.clk (clk), |
|||
.rst_n (delayer_rst_n), |
|||
.delay_cnt (r2_input_delay_cnt), |
|||
.freq_division(r3_input_delay_freq_div), |
|||
.in (genlock_in_hsync), |
|||
.out (af_delay__genlock_in_hsync) |
|||
); |
|||
|
|||
zutils_sig_delayer_v2 sig_delayer_inst7 ( |
|||
.clk (clk), |
|||
.rst_n (delayer_rst_n), |
|||
.delay_cnt (r2_input_delay_cnt), |
|||
.freq_division(r3_input_delay_freq_div), |
|||
.in (genlock_in_vsync), |
|||
.out (af_delay__genlock_in_vsync) |
|||
); |
|||
|
|||
zutils_sig_delayer_v2 sig_delayer_inst8 ( |
|||
.clk (clk), |
|||
.rst_n (delayer_rst_n), |
|||
.delay_cnt (r2_input_delay_cnt), |
|||
.freq_division(r3_input_delay_freq_div), |
|||
.in (genlock_in_fsync), |
|||
.out (af_delay__genlock_in_fsync) |
|||
); |
|||
|
|||
zutils_sig_delayer_v2 sig_delayer_inst9 ( |
|||
.clk (clk), |
|||
.rst_n (delayer_rst_n), |
|||
.delay_cnt (r4_output_delay_cnt), |
|||
.freq_division(r5_output_delay_freq_div), |
|||
.in (before_delay__sync_ttl_out1), |
|||
.out (sync_ttl_out1) |
|||
); |
|||
|
|||
zutils_sig_delayer_v2 sig_delayer_inst10 ( |
|||
.clk (clk), |
|||
.rst_n (delayer_rst_n), |
|||
.delay_cnt (r4_output_delay_cnt), |
|||
.freq_division(r5_output_delay_freq_div), |
|||
.in (before_delay__sync_ttl_out2), |
|||
.out (sync_ttl_out2) |
|||
); |
|||
|
|||
zutils_sig_delayer_v2 sig_delayer_inst11 ( |
|||
.clk (clk), |
|||
.rst_n (delayer_rst_n), |
|||
.delay_cnt (r4_output_delay_cnt), |
|||
.freq_division(r5_output_delay_freq_div), |
|||
.in (before_delay__sync_ttl_out3), |
|||
.out (sync_ttl_out3) |
|||
); |
|||
|
|||
zutils_sig_delayer_v2 sig_delayer_inst12 ( |
|||
.clk (clk), |
|||
.rst_n (delayer_rst_n), |
|||
.delay_cnt (r4_output_delay_cnt), |
|||
.freq_division(r5_output_delay_freq_div), |
|||
.in (before_delay__sync_ttl_out4), |
|||
.out (sync_ttl_out4) |
|||
); |
|||
|
|||
zutils_sig_delayer_v2 sig_delayer_inst13 ( |
|||
.clk (clk), |
|||
.rst_n (delayer_rst_n), |
|||
.delay_cnt (r4_output_delay_cnt), |
|||
.freq_division(r5_output_delay_freq_div), |
|||
.in (before_delay__stm32if_start_signal_out), |
|||
.out (stm32if_start_signal_out) |
|||
); |
|||
|
|||
zutils_sig_delayer_v2 sig_delayer_inst14 ( |
|||
.clk (clk), |
|||
.rst_n (delayer_rst_n), |
|||
.delay_cnt (r4_output_delay_cnt), |
|||
.freq_division(r5_output_delay_freq_div), |
|||
.in (before_delay__stm32if_camera_sync_out), |
|||
.out (stm32if_camera_sync_out) |
|||
); |
|||
|
|||
zutils_sig_delayer_v2 sig_delayer_inst15 ( |
|||
.clk (clk), |
|||
.rst_n (delayer_rst_n), |
|||
.delay_cnt (r4_output_delay_cnt), |
|||
.freq_division(r5_output_delay_freq_div), |
|||
.in (before_delay__stm32if_timecode_sync_out), |
|||
.out (stm32if_timecode_sync_out) |
|||
); |
|||
|
|||
|
|||
endmodule |
@ -0,0 +1,77 @@ |
|||
module zutils_pluse_delayer ( |
|||
input clk, //clock input |
|||
input rst_n, //asynchronous reset input, low active |
|||
input [31:0] delay_cnt, |
|||
|
|||
input wire in_sig, |
|||
|
|||
output wire out_sig, |
|||
output reg gen_pulse |
|||
); |
|||
|
|||
reg [31:0] cnt; |
|||
reg state; |
|||
|
|||
always @(posedge clk or negedge rst_n) begin |
|||
if (!rst_n) begin |
|||
cnt <= 0; |
|||
state <= 0; |
|||
gen_pulse <= 0; |
|||
end else begin |
|||
if (!state) begin |
|||
if (in_sig) begin |
|||
state <= 1; |
|||
cnt <= delay_cnt; |
|||
end |
|||
gen_pulse <= 0; |
|||
end else begin |
|||
if (cnt == 0) begin |
|||
gen_pulse <= 1; |
|||
state <= 0; |
|||
end else begin |
|||
cnt <= cnt - 1; |
|||
end |
|||
end |
|||
end |
|||
end |
|||
assign out_sig = in_sig & state & rst_n; |
|||
|
|||
|
|||
// always @(posedge clk or negedge rst_n) begin |
|||
// if (!rst_n) begin |
|||
// cnt <= 0; |
|||
// busy <= 0; |
|||
// out <= 0; |
|||
// state <= 0; |
|||
// end else begin |
|||
// if (handle_reset) begin |
|||
// cnt <= 0; |
|||
// busy <= 0; |
|||
// out <= 0; |
|||
// state <= 0; |
|||
// end else begin |
|||
// if (!state) begin |
|||
// if (in) begin |
|||
// state <= 1; |
|||
// cnt <= delay_cnt; |
|||
// busy <= 1; |
|||
// end |
|||
// out <= 0; |
|||
// end else begin |
|||
// if (cnt == 0) begin |
|||
// out <= 1; |
|||
// state <= 0; |
|||
// busy <= 0; |
|||
// end else begin |
|||
// cnt <= cnt - 1; |
|||
// end |
|||
// end |
|||
// end |
|||
// end |
|||
// end |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
endmodule |
@ -0,0 +1,104 @@ |
|||
module zutils_sig_delayer ( |
|||
input clk, |
|||
input rst_n, |
|||
|
|||
input [31:0] delay_cnt, |
|||
input [31:0] freq_division, |
|||
input in, |
|||
output reg out, |
|||
output reg ready |
|||
); |
|||
|
|||
reg [31:0] freq_division_cache; //! freq_division 配置缓存 |
|||
|
|||
reg [ 1:0] state; //! 状态机状态 |
|||
reg [31:0] cnt; //! 采样预分频cnt |
|||
reg shift_register_clk; //! 移位寄存器时钟 |
|||
reg [ 9:0] shift_register_add; //! 移位寄存器偏移地址 |
|||
reg [31:0] shift_register_freq_div_clk_cnt; //! 移位寄存器分频时钟计数 |
|||
|
|||
wire dout; |
|||
|
|||
ShiftRegister shift1 ( |
|||
.din (in), |
|||
.addr(shift_register_add), |
|||
.clk (clk), |
|||
.rst (!rst_n), |
|||
.dout(dout) |
|||
); |
|||
// assign out = dout; |
|||
|
|||
always @(posedge clk or negedge rst_n) begin |
|||
if (!rst_n) begin |
|||
freq_division_cache <= 0; |
|||
cnt <= 0; |
|||
shift_register_clk <= 0; |
|||
shift_register_add <= 0; |
|||
out <= 0; |
|||
ready <= 0; |
|||
state <= 0; |
|||
end else begin |
|||
case (state) |
|||
0: begin |
|||
if (delay_cnt == 0) begin |
|||
shift_register_add <= 1; |
|||
end else if (delay_cnt >= 1000) begin |
|||
shift_register_add <= 1000; |
|||
end else begin |
|||
shift_register_add <= delay_cnt; |
|||
end |
|||
|
|||
if (freq_division == 0) begin |
|||
freq_division_cache <= 1; |
|||
end else begin |
|||
freq_division_cache <= freq_division; |
|||
end |
|||
|
|||
state <= 1; |
|||
out <= in; |
|||
end |
|||
|
|||
1: begin |
|||
state <= 2; |
|||
shift_register_clk <= 1; |
|||
cnt <= 0; |
|||
end |
|||
|
|||
2: begin |
|||
|
|||
if (cnt == 0) begin |
|||
shift_register_clk <= 1; |
|||
cnt <= freq_division_cache; |
|||
|
|||
shift_register_freq_div_clk_cnt <= shift_register_freq_div_clk_cnt + 1; |
|||
if (shift_register_freq_div_clk_cnt > shift_register_add + 1) begin |
|||
state <= 3; |
|||
end |
|||
end else begin |
|||
cnt <= cnt - 1; |
|||
shift_register_clk <= 0; |
|||
end |
|||
end |
|||
|
|||
3: begin |
|||
ready <= 1; |
|||
out <= dout; |
|||
if (cnt == 0) begin |
|||
shift_register_clk <= 1; |
|||
cnt <= freq_division_cache; |
|||
end else begin |
|||
shift_register_clk <= 0; |
|||
cnt <= cnt - 1; |
|||
end |
|||
|
|||
end |
|||
|
|||
default: begin |
|||
state <= 0; |
|||
end |
|||
|
|||
endcase |
|||
end |
|||
end |
|||
|
|||
endmodule |
@ -0,0 +1,124 @@ |
|||
// |
|||
// 波形延时器 |
|||
// 特点: |
|||
// 1. 如果要延后的时间小于原始信号的周期,延时时间可随意设置。 |
|||
// 2. 相比使用FIFO的方式缓存信号的方式,这个延时模块使用的资源更少。 |
|||
// 3. 无法延迟非周期短时高频信号。最多缓存3个短时脉冲(缓存脉冲数量与zutils_edge_detecter的实力数量有关) |
|||
// |
|||
module zutils_sig_delayer_v2 ( |
|||
input clk, |
|||
input rst_n, |
|||
|
|||
input [31:0] delay_cnt, |
|||
input [31:0] freq_division, |
|||
input in, |
|||
output reg out, |
|||
output reg ready |
|||
); |
|||
|
|||
reg [31:0] delay_cache; |
|||
reg internal_reset_sig; |
|||
zutils_edge_detecter _signal_in ( |
|||
.clk (clk), |
|||
.rst_n (internal_reset_sig), |
|||
.in_signal (in), |
|||
.in_signal_rising_edge (in_signal_rising_edge), |
|||
.in_signal_falling_edge(in_signal_falling_edge) |
|||
); |
|||
|
|||
zutils_pluse_delayer _pluse_delayer11 ( |
|||
.clk (clk), |
|||
.rst_n (internal_reset_sig), |
|||
.delay_cnt(delay_cache), |
|||
.in_sig (in_signal_rising_edge), |
|||
.out_sig (out_sig11), |
|||
.gen_pulse(gen_pluse11) |
|||
); |
|||
|
|||
zutils_pluse_delayer _pluse_delayer12 ( |
|||
.clk (clk), |
|||
.rst_n (internal_reset_sig), |
|||
.delay_cnt(delay_cache), |
|||
.in_sig (out_sig11), |
|||
.out_sig (out_sig12), |
|||
.gen_pulse(gen_pluse12) |
|||
); |
|||
|
|||
zutils_pluse_delayer _pluse_delayer13 ( |
|||
.clk (clk), |
|||
.rst_n (internal_reset_sig), |
|||
.delay_cnt(delay_cache), |
|||
.in_sig (out_sig12), |
|||
.out_sig (final_out_sig1), |
|||
.gen_pulse(gen_pluse13) |
|||
); |
|||
|
|||
zutils_pluse_delayer _pluse_delayer21 ( |
|||
.clk (clk), |
|||
.rst_n (internal_reset_sig), |
|||
.delay_cnt(delay_cache), |
|||
.in_sig (in_signal_falling_edge), |
|||
.out_sig (out_sig21), |
|||
.gen_pulse(gen_pluse21) |
|||
); |
|||
|
|||
zutils_pluse_delayer _pluse_delayer22 ( |
|||
.clk (clk), |
|||
.rst_n (internal_reset_sig), |
|||
.delay_cnt(delay_cache), |
|||
.in_sig (out_sig21), |
|||
.out_sig (out_sig22), |
|||
.gen_pulse(gen_pluse22) |
|||
); |
|||
|
|||
zutils_pluse_delayer _pluse_delayer23 ( |
|||
.clk (clk), |
|||
.rst_n (internal_reset_sig), |
|||
.delay_cnt(delay_cache), |
|||
.in_sig (out_sig22), |
|||
.out_sig (final_out_sig2), |
|||
.gen_pulse(gen_pluse23) |
|||
); |
|||
|
|||
|
|||
assign final_gen_pluse1 = gen_pluse11 | gen_pluse12 | gen_pluse13; |
|||
assign final_gen_pluse2 = gen_pluse21 | gen_pluse22 | gen_pluse23; |
|||
|
|||
reg state; |
|||
always @(posedge clk or negedge rst_n) begin |
|||
if (!rst_n) begin |
|||
state <= 0; |
|||
ready <= 0; |
|||
out <= 0; |
|||
internal_reset_sig <= 0; |
|||
end else begin |
|||
case (state) |
|||
0: begin |
|||
state <= 1; |
|||
out <= in; |
|||
internal_reset_sig <= 0; |
|||
ready <= 0; |
|||
delay_cache <= delay_cnt; |
|||
end |
|||
1: begin |
|||
if (final_out_sig2 | final_out_sig1) begin |
|||
state <= 0; |
|||
ready <= 0; |
|||
out <= in; |
|||
internal_reset_sig <= 0; |
|||
end else begin |
|||
ready <= 1; |
|||
internal_reset_sig <= 1; |
|||
if (final_gen_pluse1) begin |
|||
out <= 1; |
|||
end else if (final_gen_pluse2) begin |
|||
out <= 0; |
|||
end |
|||
end |
|||
end |
|||
endcase |
|||
end |
|||
end |
|||
|
|||
|
|||
endmodule |
Reference in new issue