OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /qaz_libs/trunk/axi4_stream_lib
    from Rev 23 to Rev 28
    Reverse comparison

Rev 23 → Rev 28

/sim/libs/axi4_stream_lib_verilog/axi4_stream_lib.f
0,0 → 1,13
#
 
 
${ROOT_DIR}/qaz_libs/axi4_stream_lib/src/axis_if.sv
${ROOT_DIR}/qaz_libs/axi4_stream_lib/src/axis_video_debug.sv
${ROOT_DIR}/qaz_libs/axi4_stream_lib/src/data_to_axis_fsm.sv
 
${ROOT_DIR}/qaz_libs/axi4_stream_lib/src/axis_to_vid_fsm.sv
${ROOT_DIR}/qaz_libs/axi4_stream_lib/src/camera_link_to_axis.sv
${ROOT_DIR}/qaz_libs/axi4_stream_lib/src/camera_link_to_axis_fsm.sv
 
${ROOT_DIR}/qaz_libs/axi4_stream_lib/src/axis_register_slice.sv
 
/sim/libs/sim_verilog/avf.f
0,0 → 1,9
#
 
-mfcu
 
${ROOT_DIR}/qaz_libs/video_frame_class/src/video_frame_pkg.sv
${ROOT_DIR}/qaz_libs/axis_video_frame_bfm_class/src/axis_video_frame_bfm_pkg.sv
${ROOT_DIR}/qaz_libs/axis_video_frame_bfm_class/src/avf_agent_class_pkg.sv
 
 
/sim/libs/sim_verilog/tb_lib.f
0,0 → 1,16
#
 
-mfcu
 
${ROOT_DIR}/qaz_libs/tb_class/src/tb_clk_class.sv
 
${ROOT_DIR}/qaz_libs/tb_class/src/tb_clk.sv
${ROOT_DIR}/qaz_libs/tb_class/src/tb_base.sv
 
 
 
 
 
 
 
 
/sim/libs/sync_fifo_verilog/tiny_fifo.f
0,0 → 1,8
#
 
 
${ROOT_DIR}/qaz_libs/FIFOs/src/tiny_sync_fifo.sv
${ROOT_DIR}/qaz_libs/FIFOs/src/fifo_read_if.sv
${ROOT_DIR}/qaz_libs/FIFOs/src/fifo_write_if.sv
 
 
/sim/src/tb_axis_register_slice.sv
0,0 → 1,159
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2015 Authors and OPENCORES.ORG ////
//// ////
//// This source file may be used and distributed without ////
//// restriction provided that this copyright statement is not ////
//// removed from the file and that any derivative work contains ////
//// the original copyright notice and the associated disclaimer. ////
//// ////
//// This source file is free software; you can redistribute it ////
//// and/or modify it under the terms of the GNU Lesser General ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any ////
//// later version. ////
//// ////
//// This source is distributed in the hope that it will be ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
//// PURPOSE. See the GNU Lesser General Public License for more ////
//// details. ////
//// ////
//// You should have received a copy of the GNU Lesser General ////
//// Public License along with this source; if not, download it ////
//// from http://www.opencores.org/lgpl.shtml ////
//// ////
//////////////////////////////////////////////////////////////////////
 
 
module tb_top();
 
// --------------------------------------------------------------------
// test bench clock & reset
wire clk_200mhz;
wire tb_clk = clk_200mhz;
wire tb_rst;
wire aclk = tb_clk;
wire aresetn = ~tb_rst;
 
tb_base #( .PERIOD(5_000) ) tb( clk_200mhz, tb_rst );
 
 
// --------------------------------------------------------------------
//
localparam TILES = 1;
localparam WIDTH = 32; // tile width
localparam HEIGHT = 16; // tile height
localparam OUTPUTS_PER_TILE = 1; // outputs per tile
localparam BYTES_PER_PIXEL = 2;
localparam BITS_PER_PIXEL = 16;
localparam VERTICAL_BLANKING = 20;
 
 
// --------------------------------------------------------------------
//
localparam AVF_N = BYTES_PER_PIXEL * OUTPUTS_PER_TILE; // data bus width in bytes
localparam AVF_U = 1; // TUSER width
 
axis_if #(.N(AVF_N), .U(AVF_U)) axis_in[TILES](.*);
axis_if #(.N(AVF_N), .U(AVF_U)) axis_out[TILES](.*);
 
 
// --------------------------------------------------------------------
//
axis_register_slice #(.N(AVF_N), .U(AVF_U))
dut
(
.axis_en(1'b1),
.axis_in(axis_in.slave[0]),
.axis_out(axis_out.master[0]),
.*
);
// --------------------------------------------------------------------
//
import axis_video_frame_bfm_pkg::*;
import avf_agent_class_pkg::*;
 
 
// --------------------------------------------------------------------
//
avf_agent_config_class avf_agent_config_h;
avf_agent_class #(BYTES_PER_PIXEL, OUTPUTS_PER_TILE) avf_agent_h;
 
initial
begin
 
avf_agent_config_h = new
(
.width(WIDTH),
.height(HEIGHT),
.bytes_per_pixel(BYTES_PER_PIXEL),
.bits_per_pixel(BITS_PER_PIXEL),
.tiles(TILES),
.outputs_per_tile(OUTPUTS_PER_TILE),
.name("AVF_"),
.vertical_blanking(VERTICAL_BLANKING)
);
 
avf_agent_config_h.tile[0].direction = RIGHT_DOWN;
 
avf_agent_h = new
(
.avf_agent_config(avf_agent_config_h),
.avf_axis_in_if(axis_out),
.avf_axis_out_if(axis_in)
);
 
avf_agent_h.init();
 
end
 
 
// --------------------------------------------------------------------
// sim models
// | | | | | | | | | | | | | | | | |
// \|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/
// ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
 
// --------------------------------------------------------------------
//
 
 
// ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
// /|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\
// | | | | | | | | | | | | | | | | |
// sim models
// --------------------------------------------------------------------
 
 
// --------------------------------------------------------------------
// debug wires
for(genvar j = 0; j < TILES; j++)
axis_video_debug #(BYTES_PER_PIXEL, OUTPUTS_PER_TILE) avf_debug(axis_out[j]);
 
 
// --------------------------------------------------------------------
// test
the_test test( tb_clk, tb_rst );
 
initial
begin
 
test.run_the_test();
 
$display("^^^---------------------------------");
$display("^^^ %16.t | Testbench done.", $time);
$display("^^^---------------------------------");
 
$display("^^^---------------------------------");
 
$stop();
 
end
 
endmodule
 
 
 
/sim/tests/tb_axis_register_slice/init_test.do
0,0 → 1,35
# ------------------------------------
#
# ------------------------------------
 
global env
 
set env(ROOT_DIR) ../../../../..
set env(PROJECT_DIR) ../../..
set env(SIM_TARGET) fpga
 
# load sim procedures
do $env(ROOT_DIR)/qaz_libs/scripts/sim_procs.do
 
radix -hexadecimal
 
make_lib work 1
 
# sim_compile_all FPGA
sim_compile_all sim
sim_compile_all sync_fifo
sim_compile_all axi4_stream_lib
 
# simulation $root
vlog $env(PROJECT_DIR)/sim/src/tb_axis_register_slice.sv
 
# compile test last
vlog ./the_test.sv
 
# vopt work.glbl tb_top -L secureip -L simprims_ver -L unisims_ver -f opt_tb_top.f -o opt_tb_top
 
# run the sim
sim_run_test
 
 
 
/sim/tests/tb_axis_register_slice/sim.do
0,0 → 1,21
#
#
 
 
quit -sim
 
# vsim opt_tb_top
 
vsim -novopt work.tb_top
# vsim -novopt -L secureip -L simprims_ver -L unisims_ver work.glbl work.tb_top
 
# vsim -voptargs="+acc=rn+/tb_top/dut" -L secureip -L simprims_ver -L unisims_ver work.glbl work.tb_top
# vsim -pli "C:/Xilinx/Vivado/2015.4/lib/win64.o/libxil_vsim.dll" -novopt -L secureip -L simprims_ver -L unisims_ver work.glbl work.tb_top
 
 
# # log all signals
# log -r *
 
# run -all
 
 
/sim/tests/tb_axis_register_slice/the_test.sv
0,0 → 1,79
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2015 Authors and OPENCORES.ORG ////
//// ////
//// This source file may be used and distributed without ////
//// restriction provided that this copyright statement is not ////
//// removed from the file and that any derivative work contains ////
//// the original copyright notice and the associated disclaimer. ////
//// ////
//// This source file is free software; you can redistribute it ////
//// and/or modify it under the terms of the GNU Lesser General ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any ////
//// later version. ////
//// ////
//// This source is distributed in the hope that it will be ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
//// PURPOSE. See the GNU Lesser General Public License for more ////
//// details. ////
//// ////
//// You should have received a copy of the GNU Lesser General ////
//// Public License along with this source; if not, download it ////
//// from http://www.opencores.org/lgpl.shtml ////
//// ////
//////////////////////////////////////////////////////////////////////
 
`timescale 1ps/1ps
 
 
module
the_test(
input tb_clk,
input tb_rst
);
 
// --------------------------------------------------------------------
//
int mismatch_count = 0;
 
 
// --------------------------------------------------------------------
//
task run_the_test;
 
// --------------------------------------------------------------------
// insert test below
// --------------------------------------------------------------------
$display("^^^---------------------------------");
$display("^^^ %16.t | Testbench begun.\n", $time);
$display("^^^---------------------------------");
// --------------------------------------------------------------------
 
// --------------------------------------------------------------------
tb_top.tb.timeout_stop(4us);
wait(~tb_rst);
 
 
// --------------------------------------------------------------------
repeat(100) @(posedge tb_clk);
tb_top.avf_agent_h.make_frame("counting");
tb_top.avf_agent_h.get_frame();
tb_top.avf_agent_h.put_frame();
 
wait(~tb_top.avf_agent_h.put_frame_active);
wait(~tb_top.avf_agent_h.get_frame_active);
 
mismatch_count = tb_top.avf_agent_h.compare_frame();
 
// --------------------------------------------------------------------
// insert test above
// --------------------------------------------------------------------
 
endtask
 
 
endmodule
 
/sim/tests/tb_axis_register_slice/wip.do
0,0 → 1,12
#
 
 
vlog -f ../../libs/axi4_stream_lib_verilog/axi4_stream_lib.f
 
# simulation $root
vlog ../../src/tb_axis_register_slice.sv
 
# compile test last
vlog ./the_test.sv
 
/src/axis_flow_control.sv
0,0 → 1,127
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2015 Authors and OPENCORES.ORG ////
//// ////
//// This source file may be used and distributed without ////
//// restriction provided that this copyright statement is not ////
//// removed from the file and that any derivative work contains ////
//// the original copyright notice and the associated disclaimer. ////
//// ////
//// This source file is free software; you can redistribute it ////
//// and/or modify it under the terms of the GNU Lesser General ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any ////
//// later version. ////
//// ////
//// This source is distributed in the hope that it will be ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
//// PURPOSE. See the GNU Lesser General Public License for more ////
//// details. ////
//// ////
//// You should have received a copy of the GNU Lesser General ////
//// Public License along with this source; if not, download it ////
//// from http://www.opencores.org/lgpl.shtml ////
//// ////
//////////////////////////////////////////////////////////////////////
 
module
axis_flow_control
#(
N = 8, // data bus width in bytes
I = 0, // TID width
D = 0, // TDEST width
U = 1, // TUSER width
USE_TSTRB = 0, // set to 1 to enable, 0 to disable
USE_TKEEP = 0 // set to 1 to enable, 0 to disable
)
(
input axis_en,
input flow_enable, // enable / disable incoming tready & tvalid
input [1:0] tready_to_master_select, // 00:force 0, 01:force 1, 1X:from_slave
input [1:0] tvalid_to_master_select, // 00:force 0, 01:force 1, 1X:from_slave
output tready_from_slave, // from input of mux
output tvalid_from_slave, // from input of mux
axis_if.slave axis_in,
axis_if.master axis_out,
input aclk,
input aresetn
);
 
// --------------------------------------------------------------------
//
localparam W = (N * 8) + (N * USE_TSTRB) + (N * USE_TKEEP) + I + D + U + 1;
 
fifo_write_if #(.W(W)) fifo_sink(aclk, ~aresetn);
fifo_read_if #(.W(W)) fifo_source(aclk, ~aresetn);
 
tiny_sync_fifo #(.W(W))
tiny_sync_fifo_i(.source(fifo_sink.fifo), .sink(fifo_source.fifo));
 
 
// --------------------------------------------------------------------
//
wire data_to_axis_fsm_error;
 
data_to_axis_fsm
data_to_axis_fsm_i
(
.axis_tvalid(tvalid_from_slave), // axis_out.tvalid
.axis_tready(flow_enable & axis_out.tready),
.fifo_empty(fifo_source.empty),
.fifo_rd_en(fifo_source.rd_en),
.fifo_watermark(1'b1),
.*
);
 
 
// --------------------------------------------------------------------
//
reg axis_in_tready_r;
assign axis_in.tready = axis_in_tready_r;
always_comb
case(tready_to_master_select)
2'b00: axis_in_tready_r = 0;
2'b01: axis_in_tready_r = 1;
2'b10: axis_in_tready_r = tready_from_slave;
2'b11: axis_in_tready_r = tready_from_slave;
endcase
 
// --------------------------------------------------------------------
//
reg axis_out_tvalid_r;
assign axis_out.tvalid = axis_out_tvalid_r;
always_comb
case(tvalid_to_master_select)
2'b00: axis_out_tvalid_r = 0;
2'b01: axis_out_tvalid_r = 1;
2'b10: axis_out_tvalid_r = tvalid_from_slave;
2'b11: axis_out_tvalid_r = tvalid_from_slave;
endcase
 
 
// --------------------------------------------------------------------
//
assign tready_from_slave = ~fifo_sink.full; // axis_in.tready
 
assign fifo_sink.wr_en = flow_enable & axis_in.tvalid & ~fifo_sink.full;
assign fifo_sink.wr_data =
{
axis_in.tdata,
axis_in.tlast,
axis_in.tuser
};
 
assign
{
axis_out.tdata,
axis_out.tlast,
axis_out.tuser
} = fifo_source.rd_data;
 
 
endmodule
 
/src/axis_mux.sv
0,0 → 1,91
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2015 Authors and OPENCORES.ORG ////
//// ////
//// This source file may be used and distributed without ////
//// restriction provided that this copyright statement is not ////
//// removed from the file and that any derivative work contains ////
//// the original copyright notice and the associated disclaimer. ////
//// ////
//// This source file is free software; you can redistribute it ////
//// and/or modify it under the terms of the GNU Lesser General ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any ////
//// later version. ////
//// ////
//// This source is distributed in the hope that it will be ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
//// PURPOSE. See the GNU Lesser General Public License for more ////
//// details. ////
//// ////
//// You should have received a copy of the GNU Lesser General ////
//// Public License along with this source; if not, download it ////
//// from http://www.opencores.org/lgpl.shtml ////
//// ////
//////////////////////////////////////////////////////////////////////
 
module
axis_mux
#(
N = 8, // data bus width in bytes
I = 1, // TID width
D = 1, // TDEST width
U = 1, // TUSER width
USE_TSTRB = 0, // set to 1 to enable, 0 to disable
USE_TKEEP = 0 // set to 1 to enable, 0 to disable
)
(
input mux_select,
axis_if.slave axis_0_in,
axis_if.slave axis_1_in,
axis_if.master axis_out,
input axis_en,
input aclk,
input aresetn
);
 
// --------------------------------------------------------------------
//
axis_if #(.N(N), .I(I), .D(D), .U(U))
axis_mux_out(.*);
 
assign axis_0_in.tready = mux_select ? 0 : axis_mux_out.tready;
assign axis_1_in.tready = mux_select ? axis_mux_out.tready : 0;
 
assign axis_mux_out.tvalid = mux_select ? axis_1_in.tvalid : axis_0_in.tvalid;
assign axis_mux_out.tdata = mux_select ? axis_1_in.tdata : axis_0_in.tdata;
assign axis_mux_out.tstrb = mux_select ? axis_1_in.tstrb : axis_0_in.tstrb;
assign axis_mux_out.tkeep = mux_select ? axis_1_in.tkeep : axis_0_in.tkeep;
assign axis_mux_out.tlast = mux_select ? axis_1_in.tlast : axis_0_in.tlast;
assign axis_mux_out.tid = mux_select ? axis_1_in.tid : axis_0_in.tid;
assign axis_mux_out.tdest = mux_select ? axis_1_in.tdest : axis_0_in.tdest;
assign axis_mux_out.tuser = mux_select ? axis_1_in.tuser : axis_0_in.tuser;
 
 
// --------------------------------------------------------------------
//
axis_register_slice
#(
.N(N),
.I(I),
.D(D),
.U(U),
.USE_TSTRB(USE_TSTRB),
.USE_TKEEP(USE_TKEEP)
)
axis_register_slice_i
(
.axis_in(axis_mux_out), // .slave
.axis_out(axis_out), // .master
.*
);
 
 
// --------------------------------------------------------------------
//
 
 
endmodule
 
 
/src/axis_register_slice.sv
0,0 → 1,159
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2015 Authors and OPENCORES.ORG ////
//// ////
//// This source file may be used and distributed without ////
//// restriction provided that this copyright statement is not ////
//// removed from the file and that any derivative work contains ////
//// the original copyright notice and the associated disclaimer. ////
//// ////
//// This source file is free software; you can redistribute it ////
//// and/or modify it under the terms of the GNU Lesser General ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any ////
//// later version. ////
//// ////
//// This source is distributed in the hope that it will be ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
//// PURPOSE. See the GNU Lesser General Public License for more ////
//// details. ////
//// ////
//// You should have received a copy of the GNU Lesser General ////
//// Public License along with this source; if not, download it ////
//// from http://www.opencores.org/lgpl.shtml ////
//// ////
//////////////////////////////////////////////////////////////////////
 
module
axis_register_slice
#(
N = 8, // data bus width in bytes
I = 0, // TID width
D = 0, // TDEST width
U = 1, // TUSER width
USE_TSTRB = 0, // set to 1 to enable, 0 to disable
USE_TKEEP = 0 // set to 1 to enable, 0 to disable
)
(
input axis_en,
axis_if.slave axis_in,
axis_if.master axis_out,
input aclk,
input aresetn
);
 
// --------------------------------------------------------------------
//
localparam W = (N * 8) + (N * USE_TSTRB) + (N * USE_TKEEP) + I + D + U + 1;
 
fifo_write_if #(.W(W)) fifo_sink(aclk, ~aresetn);
fifo_read_if #(.W(W)) fifo_source(aclk, ~aresetn);
 
tiny_sync_fifo #(.W(W))
tiny_sync_fifo_i(.source(fifo_sink.fifo), .sink(fifo_source.fifo));
 
 
// --------------------------------------------------------------------
//
wire data_to_axis_fsm_error;
 
data_to_axis_fsm
data_to_axis_fsm_i
(
.axis_tvalid(axis_out.tvalid),
.axis_tready(axis_out.tready),
.fifo_empty(fifo_source.empty),
.fifo_rd_en(fifo_source.rd_en),
.fifo_watermark(1'b1),
.*
);
 
 
// --------------------------------------------------------------------
//
generate
begin: assign_gen
 
if(USE_TSTRB & USE_TKEEP)
begin
assign fifo_sink.wr_data =
{
axis_in.tdata,
axis_in.tlast,
axis_in.tuser,
axis_in.tstrb,
axis_in.tkeep
};
assign
{
axis_out.tdata,
axis_out.tlast,
axis_out.tuser,
axis_out.tstrb,
axis_out.tkeep
} = fifo_source.rd_data;
end
else if(USE_TSTRB)
begin
assign fifo_sink.wr_data =
{
axis_in.tdata,
axis_in.tlast,
axis_in.tuser,
axis_in.tstrb
};
assign
{
axis_out.tdata,
axis_out.tlast,
axis_out.tuser,
axis_out.tstrb
} = fifo_source.rd_data;
end
else if(USE_TKEEP)
begin
assign fifo_sink.wr_data =
{
axis_in.tdata,
axis_in.tlast,
axis_in.tuser,
axis_in.tkeep
};
assign
{
axis_out.tdata,
axis_out.tlast,
axis_out.tuser,
axis_out.tkeep
} = fifo_source.rd_data;
end
else
begin
assign fifo_sink.wr_data =
{
axis_in.tdata,
axis_in.tlast,
axis_in.tuser
};
assign
{
axis_out.tdata,
axis_out.tlast,
axis_out.tuser
} = fifo_source.rd_data;
end
 
end
endgenerate
 
 
// --------------------------------------------------------------------
//
assign axis_in.tready = ~fifo_sink.full;
assign fifo_sink.wr_en = axis_in.tvalid & ~fifo_sink.full;
 
 
 
endmodule
 
/src/axis_to_vid_fsm.sv
0,0 → 1,136
// --------------------------------------------------------------------
//
// --------------------------------------------------------------------
 
 
module
axis_to_vid_fsm
(
input axis_to_vid_fsm_en,
input [31:0] reg_active_size,
input [15:0] reg_hblanking,
input [15:0] reg_vblanking,
 
input vid_sof,
input vid_eol,
input vid_stall_at_vblank,
 
output fifo_rd_en,
 
output vid_timing_fsm_idle,
output vid_active_video,
output vid_hblank,
output vid_vblank,
output vid_timing_fsm_error,
input vid_clk,
input vid_clk_en,
input vid_reset
);
 
// --------------------------------------------------------------------
//
reg [15:0] pixel_counter;
reg [15:0] line_counter;
wire [15:0] active_hsize = reg_active_size[15:0];
wire [15:0] active_vsize = reg_active_size[31:16];
 
 
//---------------------------------------------------
// state machine binary definitions
enum reg [4:0] {
IDLE_STATE = 5'b0_0001,
PIXEL_DATA = 5'b0_0010,
HORIZONTAL_BLANKING = 5'b0_0100,
VERTICAL_BLANKING = 5'b0_1000,
ERROR_STATE = 5'b1_0000
} state, next_state;
 
 
//---------------------------------------------------
// state machine flop
always_ff @(posedge vid_clk)
if(vid_reset)
state <= IDLE_STATE;
else if(vid_clk_en)
state <= next_state;
 
 
//---------------------------------------------------
// state machine
always_comb
case(state)
IDLE_STATE: if(axis_to_vid_fsm_en)
if(vid_stall_at_vblank)
next_state <= VERTICAL_BLANKING;
else
next_state <= PIXEL_DATA;
else
next_state <= IDLE_STATE;
 
PIXEL_DATA: if(vid_eol)
next_state <= HORIZONTAL_BLANKING;
else
next_state <= PIXEL_DATA;
 
HORIZONTAL_BLANKING: if(pixel_counter < reg_hblanking)
next_state <= HORIZONTAL_BLANKING;
else if(line_counter < active_vsize)
next_state <= PIXEL_DATA;
else
next_state <= VERTICAL_BLANKING;
 
VERTICAL_BLANKING: if(pixel_counter < reg_vblanking)
next_state <= VERTICAL_BLANKING;
else if(axis_to_vid_fsm_en)
if(vid_stall_at_vblank)
next_state <= VERTICAL_BLANKING;
else
next_state <= PIXEL_DATA;
else
next_state <= IDLE_STATE;
ERROR_STATE: next_state <= IDLE_STATE;
 
default: next_state <= ERROR_STATE;
 
endcase
 
 
// --------------------------------------------------------------------
//
wire pixel_counter_reset = vid_reset | (state == IDLE_STATE) | (state != next_state);
 
always_ff @(posedge vid_clk)
if(pixel_counter_reset)
pixel_counter <= 1;
else if(vid_clk_en)
pixel_counter <= pixel_counter + 1;
// --------------------------------------------------------------------
//
wire line_counter_reset = vid_reset |
(state == IDLE_STATE) |
(vid_sof & (state != next_state));
 
always_ff @(posedge vid_clk)
if(line_counter_reset)
line_counter <= 0;
else if(vid_clk_en & (state == PIXEL_DATA) & vid_eol)
line_counter <= line_counter + 1;
//---------------------------------------------------
// output
assign vid_timing_fsm_error = (state == ERROR_STATE);
assign vid_timing_fsm_idle = (state == IDLE_STATE);
assign vid_active_video = (state == PIXEL_DATA);
assign vid_hblank = (state == HORIZONTAL_BLANKING);
assign vid_vblank = (state == VERTICAL_BLANKING);
assign fifo_rd_en = vid_active_video;
 
endmodule
 
 
 
/src/camera_link_to_axis.sv
0,0 → 1,59
// --------------------------------------------------------------------
//
// --------------------------------------------------------------------
 
 
module
camera_link_to_axis
#(
DATA_IN_WIDTH = 64 // same as axis_out_bus.TDATA_WIDTH
)
(
axis_if.master axis_out_bus,
input [DATA_IN_WIDTH-1:0] cl_data_in,
input cl_frame_valid,
input cl_line_valid,
input cl_data_valid,
input cl_reset, // same as axis_out_bus.aresetn
input cl_clk // same as axis_out_bus.aclk
);
 
// --------------------------------------------------------------------
//
reg [DATA_IN_WIDTH-1:0] cl_data_in_r0;
reg cl_frame_valid_r0;
reg cl_line_valid_r0;
reg cl_data_valid_r0;
always @(posedge cl_clk)
begin
cl_data_in_r0 <= cl_data_in;
cl_frame_valid_r0 <= cl_frame_valid;
cl_line_valid_r0 <= cl_line_valid;
cl_data_valid_r0 <= cl_data_valid;
end
 
 
// --------------------------------------------------------------------
//
reg [DATA_IN_WIDTH-1:0] cl_data_in_r1;
reg cl_frame_valid_r1;
reg cl_line_valid_r1;
reg cl_data_valid_r1;
always @(posedge cl_clk)
begin
cl_data_in_r1 <= cl_data_in_r0;
cl_frame_valid_r1 <= cl_frame_valid_r0;
cl_line_valid_r1 <= cl_line_valid_r0;
cl_data_valid_r1 <= cl_data_valid_r0;
end
 
// --------------------------------------------------------------------
//
 
endmodule
 
 
/src/camera_link_to_axis_fsm.sv
0,0 → 1,83
// --------------------------------------------------------------------
//
// --------------------------------------------------------------------
 
 
module
camera_link_to_axis_fsm
(
input axis_en,
output axis_tvalid,
input axis_tready,
input fifo_almost_full,
input fifo_empty,
output fifo_rd_en,
output data_to_axis_fsm_error,
 
input aclk,
input aresetn
);
 
//---------------------------------------------------
// state machine binary definitions
enum reg [3:0] {
IDLE_STATE = 4'b0001,
TVALID = 4'b0010,
TREADY = 4'b0100,
ERROR_STATE = 4'b1000
} state, next_state;
 
 
//---------------------------------------------------
// state machine flop
always_ff @(posedge aclk)
if(~aresetn)
state <= IDLE_STATE;
else
state <= next_state;
 
 
//---------------------------------------------------
// state machine
always_comb
case(state)
IDLE_STATE: if(axis_en & fifo_almost_full)
if(axis_tready)
next_state <= TREADY;
else
next_state <= TVALID;
else
next_state <= IDLE_STATE;
 
TVALID: if(axis_tready) // wait for slave to be ready
next_state <= TREADY;
else
next_state <= TVALID;
 
TREADY: if(fifo_empty) // slave can accept data
next_state <= IDLE_STATE;
else if(axis_tready)
next_state <= TREADY;
else
next_state <= TVALID;
 
ERROR_STATE: next_state <= IDLE_STATE;
 
default: next_state <= ERROR_STATE;
 
endcase
 
 
//---------------------------------------------------
// outputs
assign axis_tvalid = (next_state == TVALID) | (next_state == TREADY);
assign fifo_rd_en = axis_tvalid & axis_tready;
assign data_to_axis_fsm_error = (state == ERROR_STATE);
 
endmodule
 
 
 
/src/data_to_axis_fsm.sv
66,7 → 66,7
// state machine
always_comb
case(state)
IDLE_STATE: if(axis_en & fifo_watermark)
IDLE_STATE: if(axis_en & fifo_watermark & ~fifo_empty)
if(axis_tready)
next_state <= TREADY;
else
/syn/src/axis_if.sv
0,0 → 1,92
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2015 Authors and OPENCORES.ORG ////
//// ////
//// This source file may be used and distributed without ////
//// restriction provided that this copyright statement is not ////
//// removed from the file and that any derivative work contains ////
//// the original copyright notice and the associated disclaimer. ////
//// ////
//// This source file is free software; you can redistribute it ////
//// and/or modify it under the terms of the GNU Lesser General ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any ////
//// later version. ////
//// ////
//// This source is distributed in the hope that it will be ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
//// PURPOSE. See the GNU Lesser General Public License for more ////
//// details. ////
//// ////
//// You should have received a copy of the GNU Lesser General ////
//// Public License along with this source; if not, download it ////
//// from http://www.opencores.org/lgpl.shtml ////
//// ////
//////////////////////////////////////////////////////////////////////
 
 
interface
axis_if
#(
N = 8, // data bus width in bytes
I = 1, // TID width
D = 1, // TDEST width
U = 1 // TUSER width
)
(
input aclk,
input aresetn
);
wire tvalid;
wire tready;
wire [(8*N)-1:0] tdata;
wire [N-1:0] tstrb;
wire [N-1:0] tkeep;
wire tlast;
wire [I-1:0] tid;
wire [D-1:0] tdest;
wire [U-1:0] tuser;
 
 
// --------------------------------------------------------------------
//
modport
master
(
input aresetn,
input aclk,
output tvalid,
input tready,
output tdata,
output tstrb,
output tkeep,
output tlast,
output tid,
output tdest,
output tuser
);
 
 
// --------------------------------------------------------------------
//
modport
slave
(
input aresetn,
input aclk,
input tvalid,
output tready,
input tdata,
input tstrb,
input tkeep,
input tlast,
input tid,
input tdest,
input tuser
);
 
 
endinterface: axis_if
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.