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

Subversion Repositories warp

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 5 to Rev 6
    Reverse comparison

Rev 5 → Rev 6

warp/branches Property changes : Deleted: svn:mergeinfo ## -0,0 +0,0 ## Index: warp/tags =================================================================== --- warp/tags (revision 5) +++ warp/tags (nonexistent)
warp/tags Property changes : Deleted: svn:mergeinfo ## -0,0 +0,0 ## Index: warp/trunk/test/warptest.v =================================================================== --- warp/trunk/test/warptest.v (revision 5) +++ warp/trunk/test/warptest.v (nonexistent) @@ -1,215 +0,0 @@ -/* - * Testbench for the image warping core - * Copyright (C) 2008 Sebastien Bourdeauducq - http://lekernel.net - * This file is part of Milkymist. - * - * Milkymist is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -module warptest(); - -reg wb_clk_i; -reg wb_rst_i; - -wire [31:0] mwb_adr_o; -wire mwb_stb_o; -wire mwb_we_o; -reg mwb_ack_i; -wire [31:0] mwb_dat_o; -reg [31:0] mwb_dat_i; -wire [3:0] mwb_sel_o; - -reg [31:0] wb_adr_i; -wire wb_cyc_i; -reg wb_stb_i; -reg wb_we_i; -wire wb_ack_o; -wire [31:0] wb_dat_o; -reg [31:0] wb_dat_i; - -warp dut( - .wb_clk_i(wb_clk_i), - .wb_rst_i(wb_rst_i), - - .mwb_adr_o(mwb_adr_o), - .mwb_stb_o(mwb_stb_o), - .mwb_we_o(mwb_we_o), - .mwb_ack_i(mwb_ack_i), - .mwb_dat_o(mwb_dat_o), - .mwb_dat_i(mwb_dat_i), - .mwb_sel_o(mwb_sel_o), - - .wb_adr_i(wb_adr_i), - .wb_cyc_i(wb_cyc_i), - .wb_stb_i(wb_stb_i), - .wb_we_i(wb_we_i), - .wb_ack_o(wb_ack_o), - .wb_dat_o(wb_dat_o), - .wb_dat_i(wb_dat_i) -); - -parameter hres = 320; -parameter vres = 228; - -initial mwb_ack_i = 0; - -wire [6:0] meshx; -wire [6:0] meshy; - -assign meshx = mwb_adr_o[8:2]; -assign meshy = mwb_adr_o[15:9]; - -wire [27:0] px; -assign px = mwb_adr_o[29:2] % hres; -wire [27:0] py; -assign py = mwb_adr_o[29:2] / hres; - -always @(posedge wb_clk_i) begin - mwb_ack_i = mwb_ack_i ^ mwb_stb_o; - if(mwb_stb_o) begin - //$display("CYCLE we=%b adr=%x do=%x", mwb_we_o, mwb_adr_o, mwb_dat_o); - if(mwb_adr_o[31]) begin - mwb_dat_i[15:0] = meshx*50+meshy*6; - mwb_dat_i[31:16] = meshy*50+((10-meshx)*meshx)*3; - end else if(mwb_adr_o[30]) begin - //$display("%b %x write pixel at %d %d %x", mwb_we_o, mwb_adr_o, mwb_adr_o[29:2] % hres, mwb_adr_o[29:2] / hres, mwb_dat_o); - if((px >= hres) | (py >= vres)) begin - $display("Test failed: core attempted to write pixel (%d, %d) which is out of range", px, py); - $image_close; - $finish; - end - $image_set(px, py, mwb_dat_o); - end else begin - //$display("%b %x read pixel at %d %d %x", mwb_we_o, mwb_adr_o, mwb_adr_o[29:2] % hres, mwb_adr_o[29:2] / hres, mwb_dat_i); - if((px >= hres) | (py >= vres)) begin - $display("Test failed: core attempted to read pixel (%d, %d) which is out of range", px, py); - $image_close; - $finish; - end - $image_get(px, py, mwb_dat_i); - end - end -end - -assign wb_cyc_i = 1'b1; - -reg [31:0] i; - -initial begin - $display("Testing warp module"); - - $image_open; - - #1 wb_clk_i = 1'b0; - #1 wb_rst_i = 1'b1; - #1 wb_rst_i = 1'b0; - - wb_we_i = 1'b0; - wb_stb_i = 1'b0; - #1 wb_clk_i = 1'b1; - #1 wb_clk_i = 1'b0; - - wb_adr_i = 32'h00000004; - wb_dat_i = hres; - wb_we_i = 1'b1; - wb_stb_i = 1'b1; - $display("hres\t%d", wb_dat_i); - #1 wb_clk_i = 1'b1; - #1 wb_clk_i = 1'b0; - - wb_adr_i = 32'h00000008; - wb_dat_i = vres; - $display("vres\t%d", wb_dat_i); - #1 wb_clk_i = 1'b1; - #1 wb_clk_i = 1'b0; - - wb_adr_i = 32'h0000000C; - wb_dat_i = 32'h00000000; - $display("inaddr\t%x", wb_dat_i); - #1 wb_clk_i = 1'b1; - #1 wb_clk_i = 1'b0; - - wb_adr_i = 32'h00000010; - wb_dat_i = 32'h40000000; - $display("outaddr\t%x", wb_dat_i); - #1 wb_clk_i = 1'b1; - #1 wb_clk_i = 1'b0; - - wb_adr_i = 32'h00000014; - wb_dat_i = 255; - $display("decay\t%d", wb_dat_i); - #1 wb_clk_i = 1'b1; - #1 wb_clk_i = 1'b0; - - wb_adr_i = 32'h00000018; - wb_dat_i = 7; - $display("mcountx\t%d", wb_dat_i); - #1 wb_clk_i = 1'b1; - #1 wb_clk_i = 1'b0; - - wb_adr_i = 32'h0000001C; - wb_dat_i = 50; - $display("msizex\t%d", wb_dat_i); - #1 wb_clk_i = 1'b1; - #1 wb_clk_i = 1'b0; - - wb_adr_i = 32'h00000020; - wb_dat_i = 5; - $display("mcounty\t%d", wb_dat_i); - #1 wb_clk_i = 1'b1; - #1 wb_clk_i = 1'b0; - - wb_adr_i = 32'h00000024; - wb_dat_i = 50; - $display("msizey\t%d", wb_dat_i); - #1 wb_clk_i = 1'b1; - #1 wb_clk_i = 1'b0; - - wb_adr_i = 32'h00000028; - wb_dat_i = 32'h80000000; - $display("maddr\t%x", wb_dat_i); - #1 wb_clk_i = 1'b1; - #1 wb_clk_i = 1'b0; - - $display("Starting core"); - wb_adr_i = 32'h00000000; - wb_dat_i = 32'h00000001; - #1 wb_clk_i = 1'b1; - #1 wb_clk_i = 1'b0; - - wb_we_i = 1'b0; - wb_stb_i = 1'b0; - #1 wb_clk_i = 1'b1; - #1 wb_clk_i = 1'b0; - - wb_adr_i = 32'h00000000; - wb_stb_i = 1'b1; - - i = 0; - while(wb_dat_o[0]) begin - i = i + 1; - #1 wb_clk_i = 1'b1; - #1 wb_clk_i = 1'b0; - end - - $image_close; - - $display("Completed in %d cycles", i); - - $finish; -end - -endmodule Index: warp/trunk/test/Makefile =================================================================== --- warp/trunk/test/Makefile (revision 5) +++ warp/trunk/test/Makefile (nonexistent) @@ -1,17 +0,0 @@ -SOURCES=warptest.v ../rtl/arbiter3.v ../rtl/decay.v ../rtl/fetchsource.v ../rtl/triangleany.v ../rtl/warp.v ../rtl/boundarycheck.v ../rtl/divider10.v ../rtl/pixeladdresses.v ../rtl/triangle.v ../rtl/writedest.v ../rtl/bresenham.v ../rtl/fetchmesh.v ../rtl/roundrobin3.v ../rtl/warpreg.v - -all: image.vpi warptest - -sim: warptest image.vpi - vvp -M. -mimage warptest - -clean: - rm -f warptest image.vpi image.o out.png - -warptest: $(SOURCES) - iverilog -o warptest $(SOURCES) - -image.vpi: image.c - iverilog-vpi --name=image image.c -lgd -lpng -lz -ljpeg -lfreetype -lm - -.PHONY: clean sim Index: warp/trunk/test/image.c =================================================================== --- warp/trunk/test/image.c (revision 5) +++ warp/trunk/test/image.c (nonexistent) @@ -1,191 +0,0 @@ -/* - * Testbench for the image warping core (w/o WISHBONE) - * Copyright (C) 2008 Sebastien Bourdeauducq - http://lekernel.net - * This file is part of Milkymist. - * - * Milkymist is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -#include -#include -#include - -static void image_png_register(); - -void (*vlog_startup_routines[])() = { - image_png_register, - 0 -}; - -static gdImagePtr src; -static gdImagePtr dst; - -/* Open both input and output images */ -static int open_calltf(char *user_data) -{ - FILE *fd; - - fd = fopen("in.jpg", "rb"); - src = gdImageCreateFromJpeg(fd); - fclose(fd); - - dst = gdImageCreateTrueColor(src->sx, src->sy); - return 0; -} - -/* Get a pixel from the source image */ -static int get_calltf(char *user_data) -{ - vpiHandle sys; - vpiHandle argv; - vpiHandle item; - s_vpi_value value; - s_vpi_vecval vec; - unsigned int x, y; - unsigned int c; - unsigned int red, green, blue; - unsigned int r; - - sys = vpi_handle(vpiSysTfCall, 0); - argv = vpi_iterate(vpiArgument, sys); - - /* get x */ - item = vpi_scan(argv); - value.format = vpiIntVal; - vpi_get_value(item, &value); - x = value.value.integer; - - /* get y */ - item = vpi_scan(argv); - value.format = vpiIntVal; - vpi_get_value(item, &value); - y = value.value.integer; - - /* do the job */ - c = gdImageGetTrueColorPixel(src, x, y); - red = gdTrueColorGetRed(c); - green = gdTrueColorGetGreen(c); - blue = gdTrueColorGetBlue(c); - r = (red << 16)|(green << 8)|blue; - - /* write to the destination */ - item = vpi_scan(argv); - value.format = vpiVectorVal; - vec.aval = r; - vec.bval = 0; - value.value.vector = &vec; - vpi_put_value(item, &value, 0, vpiNoDelay); - - vpi_free_object(argv); - return 0; -} - -/* Set a pixel in the destination image */ -static int set_calltf(char *user_data) -{ - vpiHandle sys; - vpiHandle argv; - vpiHandle item; - s_vpi_value value; - s_vpi_vecval vec; - unsigned int x, y; - unsigned int c; - unsigned int red, green, blue; - unsigned int r; - - sys = vpi_handle(vpiSysTfCall, 0); - argv = vpi_iterate(vpiArgument, sys); - - /* get x */ - item = vpi_scan(argv); - value.format = vpiIntVal; - vpi_get_value(item, &value); - x = value.value.integer; - - /* get y */ - item = vpi_scan(argv); - value.format = vpiIntVal; - vpi_get_value(item, &value); - y = value.value.integer; - - /* get color */ - item = vpi_scan(argv); - value.format = vpiIntVal; - vpi_get_value(item, &value); - c = value.value.integer; - - vpi_free_object(argv); - - /* do the job */ - red = (c & 0xFF0000) >> 16; - green = (c & 0x00FF00) >> 8; - blue = c & 0x0000FF; - gdImageSetPixel(dst, x, y, - gdImageColorAllocate(dst, red, green, blue)); - - return 0; -} - -/* Close both input and output images */ -static int close_calltf(char *user_data) -{ - FILE *fd; - - gdImageDestroy(src); - - fd = fopen("out.png", "wb"); - gdImagePng(dst, fd); - fclose(fd); - gdImageDestroy(dst); - return 0; -} - -static void image_png_register() -{ - s_vpi_systf_data tf_data; - - tf_data.type = vpiSysTask; - tf_data.tfname = "$image_open"; - tf_data.calltf = open_calltf; - tf_data.compiletf = 0; - tf_data.sizetf = 0; - tf_data.user_data = 0; - vpi_register_systf(&tf_data); - - tf_data.type = vpiSysTask; - tf_data.tfname = "$image_get"; - tf_data.calltf = get_calltf; - tf_data.compiletf = 0; - tf_data.sizetf = 0; - tf_data.user_data = 0; - vpi_register_systf(&tf_data); - - tf_data.type = vpiSysTask; - tf_data.tfname = "$image_set"; - tf_data.calltf = set_calltf; - tf_data.compiletf = 0; - tf_data.sizetf = 0; - tf_data.user_data = 0; - vpi_register_systf(&tf_data); - - tf_data.type = vpiSysTask; - tf_data.tfname = "$image_close"; - tf_data.calltf = close_calltf; - tf_data.compiletf = 0; - tf_data.sizetf = 0; - tf_data.user_data = 0; - vpi_register_systf(&tf_data); -} Index: warp/trunk/test/in.jpg =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: warp/trunk/test/in.jpg =================================================================== --- warp/trunk/test/in.jpg (revision 5) +++ warp/trunk/test/in.jpg (nonexistent)
warp/trunk/test/in.jpg Property changes : Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: warp/trunk/rtl/fetchmesh.v =================================================================== --- warp/trunk/rtl/fetchmesh.v (revision 5) +++ warp/trunk/rtl/fetchmesh.v (nonexistent) @@ -1,384 +0,0 @@ -/* - * Image warping and decay, mesh data fetcher - * Copyright (C) 2008 Sebastien Bourdeauducq - http://lekernel.net - * This file is part of Milkymist. - * - * Milkymist is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -module fetchmesh( - input clk, - input rst, - - /* WISHBONE master, read-only */ - output [31:0] mwb_adr_o, - output reg mwb_stb_o, - input mwb_ack_i, - input [31:0] mwb_dat_i, - - /* Parameters */ - input [29:0] meshaddr, // unregistered - input [6:0] mesh_count_x, // registered - input [10:0] mesh_size_x, // unregistered - input [6:0] mesh_count_y, // registered - input [10:0] mesh_size_y, // unregistered - - /* Control */ - input start, - output reg finished, - - /* Interface to the triangle interpolator */ - output [10:0] td_xa, - output [10:0] td_ya, - output [10:0] ts_xa, - output [10:0] ts_ya, - - output [10:0] td_xb, - output [10:0] td_yb, - output [10:0] ts_xb, - output [10:0] ts_yb, - - output [10:0] td_xc, - output [10:0] td_yc, - output [10:0] ts_xc, - output [10:0] ts_yc, - - output reg t_load, - input t_finished -); - -reg [29:0] adr_w; -assign mwb_adr_o = {adr_w, 2'b00}; - -reg [6:0] remain_meshx; -reg reset_remain_meshx; -reg dec_remain_meshx; -reg [6:0] remain_meshy; -reg reset_remain_meshy; -reg dec_remain_meshy; - -reg reset_meshix; -reg inc_meshix; -reg dec_meshix; -reg reset_meshiy; -reg inc_meshiy; -reg dec_meshiy; - -reg [10:0] dst_topleftx; -reg [10:0] dst_toplefty; -reg [10:0] dst_toprightx; -reg [10:0] dst_toprighty; -reg [10:0] dst_bottomleftx; -reg [10:0] dst_bottomlefty; -reg [10:0] dst_bottomrightx; -reg [10:0] dst_bottomrighty; - -reg shiftright; -reg loaddst_topleft; -reg loaddst_topright; -reg loaddst_bottomleft; -reg loaddst_bottomright; - -reg [10:0] src_topleftx; -reg [10:0] src_toplefty; -reg [10:0] src_toprightx; -reg [10:0] src_toprighty; -reg [10:0] src_bottomleftx; -reg [10:0] src_bottomlefty; -reg [10:0] src_bottomrightx; -reg [10:0] src_bottomrighty; - -reg reset_srcx; -reg inc_srcx; -reg reset_srcy; -reg inc_srcy; - -reg bottom_triangle; - -reg [2:0] state; -reg [2:0] next_state; -parameter IDLE = 0, FETCH_TOPLEFT = 1, FETCH_BOTTOMLEFT = 2, FETCH_TOPRIGHT = 3, FETCH_BOTTOMRIGHT = 4, - LOAD_TRIANGLE = 5, LOAD_TRIANGLE_BOTTOM = 6, NEXT_SQUARE = 7; - -always @(posedge clk or posedge rst) begin - if(rst) begin - state <= IDLE; - - remain_meshx <= 0; - remain_meshy <= 0; - - adr_w <= 0; - - dst_topleftx <= 0; - dst_toplefty <= 0; - dst_toprightx <= 0; - dst_toprighty <= 0; - dst_bottomleftx <= 0; - dst_bottomlefty <= 0; - dst_bottomrightx <= 0; - dst_bottomrighty <= 0; - - src_topleftx <= 0; - src_toplefty <= 0; - src_toprightx <= 0; - src_toprighty <= 0; - src_bottomleftx <= 0; - src_bottomlefty <= 0; - src_bottomrightx <= 0; - src_bottomrighty <= 0; - - end else begin - state <= next_state; - //$display("state: %d -> %d", state, next_state); - - if(reset_remain_meshx) - remain_meshx <= mesh_count_x; - else if(dec_remain_meshx) - remain_meshx <= remain_meshx - 1; - if(reset_remain_meshy) - remain_meshy <= mesh_count_y; - else if(dec_remain_meshy) - remain_meshy <= remain_meshy - 1; - - /* - * Mesh coordinates are 7-bit numbers that add to the base address (meshaddr input). - * We just store them in the word address register (adr_w). - * 29...7 Y - * 6...0 X - */ - - if(reset_meshix) - adr_w[6:0] <= meshaddr[6:0]; - else if(inc_meshix) - adr_w[6:0] <= adr_w[6:0] + 1; - else if(dec_meshix) - adr_w[6:0] <= adr_w[6:0] - 1; - if(reset_meshiy) - adr_w[29:7] <= meshaddr[29:7]; - else if(inc_meshiy) - adr_w[29:7] <= adr_w[29:7] + 1; - else if(dec_meshiy) - adr_w[29:7] <= adr_w[29:7] - 1; - - if(shiftright) begin - dst_topleftx <= dst_toprightx; - dst_toplefty <= dst_toprighty; - dst_bottomleftx <= dst_bottomrightx; - dst_bottomlefty <= dst_bottomrighty; - end else begin - if(loaddst_topleft) begin - dst_topleftx <= mwb_dat_i[10:0]; - dst_toplefty <= mwb_dat_i[26:16]; - end - if(loaddst_bottomleft) begin - dst_bottomleftx <= mwb_dat_i[10:0]; - dst_bottomlefty <= mwb_dat_i[26:16]; - end - end - if(loaddst_topright) begin - dst_toprightx <= mwb_dat_i[10:0]; - dst_toprighty <= mwb_dat_i[26:16]; - end - if(loaddst_bottomright) begin - dst_bottomrightx <= mwb_dat_i[10:0]; - dst_bottomrighty <= mwb_dat_i[26:16]; - end - - if(reset_srcx) begin - src_topleftx <= 0; - src_toprightx <= mesh_size_x; - src_bottomleftx <= 0; - src_bottomrightx <= mesh_size_x; - end else if(inc_srcx) begin - src_topleftx <= src_topleftx + mesh_size_x; - src_toprightx <= src_toprightx + mesh_size_x; - src_bottomleftx <= src_bottomleftx + mesh_size_x; - src_bottomrightx <= src_bottomrightx + mesh_size_x; - end - - if(reset_srcy) begin - src_toplefty <= 0; - src_toprighty <= 0; - src_bottomlefty <= mesh_size_y; - src_bottomrighty <= mesh_size_y; - end else if(inc_srcy) begin - src_toplefty <= src_toplefty + mesh_size_y; - src_toprighty <= src_toprighty + mesh_size_y; - src_bottomlefty <= src_bottomlefty + mesh_size_y; - src_bottomrighty <= src_bottomrighty + mesh_size_y; - end - end -end - -assign td_xa = bottom_triangle ? dst_bottomrightx : dst_topleftx; -assign td_ya = bottom_triangle ? dst_bottomrighty : dst_toplefty; -assign ts_xa = bottom_triangle ? src_bottomrightx : src_topleftx; -assign ts_ya = bottom_triangle ? src_bottomrighty : src_toplefty; - -assign td_xb = dst_bottomleftx; -assign td_yb = dst_bottomlefty; -assign ts_xb = src_bottomleftx; -assign ts_yb = src_bottomlefty; - -assign td_xc = dst_toprightx; -assign td_yc = dst_toprighty; -assign ts_xc = src_toprightx; -assign ts_yc = src_toprighty; - -always @(state or start or mwb_ack_i or t_finished or bottom_triangle or remain_meshx or remain_meshy) begin - /* XST does not generate a pure combinatorial function if next_state is - * not pre-affected, maybe because of the unused states. - */ - next_state = IDLE; - - finished = 0; - - reset_remain_meshx = 0; - dec_remain_meshx = 0; - reset_remain_meshy = 0; - dec_remain_meshy = 0; - - reset_meshix = 0; - inc_meshix = 0; - dec_meshix = 0; - reset_meshiy = 0; - inc_meshiy = 0; - dec_meshiy = 0; - - mwb_stb_o = 0; - - shiftright = 0; - loaddst_topleft = 0; - loaddst_topright = 0; - loaddst_bottomleft = 0; - loaddst_bottomright = 0; - - t_load = 0; - - reset_srcx = 0; - inc_srcx = 0; - reset_srcy = 0; - inc_srcy = 0; - - bottom_triangle = 1'bx; - - case(state) - IDLE: begin - finished = 1; - - reset_meshix = 1; - reset_remain_meshx = 1; - reset_meshiy = 1; - reset_remain_meshy = 1; - reset_srcx = 1; - reset_srcy = 1; - if(start) - next_state = FETCH_TOPLEFT; - else - next_state = IDLE; - end - - FETCH_TOPLEFT: begin - mwb_stb_o = 1; - loaddst_topleft = 1; - if(mwb_ack_i) begin - inc_meshiy = 1; - next_state = FETCH_BOTTOMLEFT; - end else - next_state = FETCH_TOPLEFT; - end - FETCH_BOTTOMLEFT: begin - mwb_stb_o = 1; - loaddst_bottomleft = 1; - if(mwb_ack_i) begin - inc_meshix = 1; - dec_meshiy = 1; - next_state = FETCH_TOPRIGHT; - end else - next_state = FETCH_BOTTOMLEFT; - end - FETCH_TOPRIGHT: begin - mwb_stb_o = 1; - loaddst_topright = 1; - if(mwb_ack_i) begin - inc_meshiy = 1; - next_state = FETCH_BOTTOMRIGHT; - end else - next_state = FETCH_TOPRIGHT; - end - FETCH_BOTTOMRIGHT: begin - mwb_stb_o = 1; - loaddst_bottomright = 1; - if(mwb_ack_i) begin - dec_meshiy = 1; - next_state = LOAD_TRIANGLE; - end else - next_state = FETCH_BOTTOMRIGHT; - end - - LOAD_TRIANGLE: begin - //$display("in square [T]: topleft (%d, %d) topright (%d, %d) bottomleft (%d, %d) bottomright (%d, %d) %b", dst_topleftx, dst_toplefty, dst_toprightx, dst_toprighty, dst_bottomleftx, dst_bottomlefty, dst_bottomrightx, dst_bottomrighty, t_finished); - - //$image_set(dst_topleftx, dst_toplefty, 32'h00ffffff); - //$image_set(dst_toprightx, dst_toprighty, 32'h00ffffff); - //$image_set(dst_bottomleftx, dst_bottomlefty, 32'h00ffffff); - //$image_set(dst_bottomrightx, dst_bottomrighty, 32'h00ffffff); - - bottom_triangle = 0; - if(t_finished) begin - t_load = 1; - next_state = LOAD_TRIANGLE_BOTTOM; - end else - next_state = LOAD_TRIANGLE; - end - - LOAD_TRIANGLE_BOTTOM: begin - //$display("in square [B]: topleft (%d, %d) topright (%d, %d) bottomleft (%d, %d) bottomright (%d, %d) %b", dst_topleftx, dst_toplefty, dst_toprightx, dst_toprighty, dst_bottomleftx, dst_bottomlefty, dst_bottomrightx, dst_bottomrighty, t_finished); - - bottom_triangle = 1; - if(t_finished) begin - t_load = 1; - next_state = NEXT_SQUARE; - end else - next_state = LOAD_TRIANGLE_BOTTOM; - end - - NEXT_SQUARE: begin - if(remain_meshx == 0) begin - reset_srcx = 1; - inc_srcy = 1; - dec_remain_meshy = 1; - reset_meshix = 1; - reset_remain_meshx = 1; - inc_meshiy = 1; - - if(remain_meshy == 0) - next_state = IDLE; - else - next_state = FETCH_TOPLEFT; - end else begin - shiftright = 1; - inc_srcx = 1; - inc_meshix = 1; - dec_remain_meshx = 1; - next_state = FETCH_TOPRIGHT; - end - end - endcase -end - -endmodule - Index: warp/trunk/rtl/divider10.v =================================================================== --- warp/trunk/rtl/divider10.v (revision 5) +++ warp/trunk/rtl/divider10.v (nonexistent) @@ -1,63 +0,0 @@ -/* - * 10-bit, 10-cycle integer divider, non pipelined - * Copyright (C) 2008 Sebastien Bourdeauducq - http://lekernel.net - * This file is part of Milkymist. - * - * Milkymist is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -module divider10( - input clk, - - input start, - input [9:0] dividend, - input [9:0] divider, - - output ready, - output [9:0] quotient, - output [9:0] remainder -); - -reg [19:0] qr; -reg [10:0] diff; - -assign remainder = qr[19:10]; -assign quotient = qr[9:0]; - -reg [3:0] counter; -assign ready = (counter == 0); - -reg [9:0] divider_r; - -always @(posedge clk) begin - if(start) begin - counter = 10; - qr = {10'd0, dividend}; - divider_r = divider; - end else begin - if(~ready) begin - diff = qr[19:9] - {1'b0, divider_r}; - - if(diff[10]) - qr = {qr[18:0], 1'b0}; - else - qr = {diff[9:0], qr[8:0], 1'b1}; - counter = counter - 1; - end - end -end - -endmodule Index: warp/trunk/rtl/warpreg.v =================================================================== --- warp/trunk/rtl/warpreg.v (revision 5) +++ warp/trunk/rtl/warpreg.v (nonexistent) @@ -1,100 +0,0 @@ -/* - * Image warping and decay, WISHBONE control interface - * Copyright (C) 2008 Sebastien Bourdeauducq - http://lekernel.net - * This file is part of Milkymist. - * - * Milkymist is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -module warpreg( - input wb_clk_i, - input wb_rst_i, - - /* WISHBONE interface */ - input [31:0] wb_adr_i, - input wb_cyc_i, - input wb_stb_i, - input wb_we_i, - output wb_ack_o, - output reg [31:0] wb_dat_o, - input [31:0] wb_dat_i, - - /* Control signals and registers */ - output enabled_write, // 00 (0) - input enabled_read, // 00 (0) - output reg [10:0] hres, // 04 (1) - output reg [10:0] vres, // 08 (2) - output reg [29:0] inaddr, // 0C (3) - output reg [29:0] outaddr, // 10 (4) - output reg [7:0] decay, // 14 (5) - output reg [6:0] meshcountx, // 18 (6) - output reg [10:0] meshsizex, // 1C (7) - output reg [6:0] meshcounty, // 20 (8) - output reg [10:0] meshsizey, // 24 (9) - output reg [29:0] meshaddr // 28 (a) -); - -always @(posedge wb_clk_i or posedge wb_rst_i) begin - if(wb_rst_i) begin - hres <= 640; - vres <= 480; - inaddr <= 0; - outaddr <= 0; - decay <= 8'h80; - meshcountx <= 22; - meshsizex <= 26; - meshcounty <= 16; - meshsizey <= 26; - meshaddr <= 0; - end else begin - if(wb_cyc_i & wb_stb_i & wb_we_i) begin - case(wb_adr_i[5:2]) - 4'h1: hres <= wb_dat_i[10:0]; - 4'h2: vres <= wb_dat_i[10:0]; - 4'h3: inaddr <= wb_dat_i[31:2]; - 4'h4: outaddr <= wb_dat_i[31:2]; - 4'h5: decay <= wb_dat_i[7:0]; - 4'h6: meshcountx <= wb_dat_i[6:0]; - 4'h7: meshsizex <= wb_dat_i[10:0]; - 4'h8: meshcounty <= wb_dat_i[6:0]; - 4'h9: meshsizey <= wb_dat_i[10:0]; - 4'ha: meshaddr <= wb_dat_i[31:2]; - endcase - end - end -end -assign enabled_write = wb_cyc_i & wb_stb_i & wb_we_i & (wb_adr_i[5:2] == 4'h0) & wb_dat_i[0]; - -assign wb_ack_o = wb_cyc_i & wb_stb_i; - -always @(wb_adr_i[5:2] or enabled_read or hres or vres or inaddr or outaddr or decay or meshcountx or meshsizex or meshcounty or meshsizey or meshaddr) begin - case(wb_adr_i[5:2]) - 4'h0: wb_dat_o <= enabled_read; - 4'h1: wb_dat_o <= hres; - 4'h2: wb_dat_o <= vres; - 4'h3: wb_dat_o <= {inaddr, 2'b00}; - 4'h4: wb_dat_o <= {outaddr, 2'b00}; - 4'h5: wb_dat_o <= decay; - 4'h6: wb_dat_o <= meshcountx; - 4'h7: wb_dat_o <= meshsizex; - 4'h8: wb_dat_o <= meshcounty; - 4'h9: wb_dat_o <= meshsizey; - 4'ha: wb_dat_o <= {meshaddr, 2'b00}; - default: wb_dat_o <= 32'hxxxxxxxx; - endcase -end - -endmodule Index: warp/trunk/rtl/warp.v =================================================================== --- warp/trunk/rtl/warp.v (revision 5) +++ warp/trunk/rtl/warp.v (nonexistent) @@ -1,404 +0,0 @@ -/* - * Image warping and decay, top-level - * Copyright (C) 2008 Sebastien Bourdeauducq - http://lekernel.net - * This file is part of Milkymist. - * - * Milkymist is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -module warp( - /* Clock and Reset signals are shared between the two buses */ - input wb_clk_i, - input wb_rst_i, - - /* Wishbone master for accessing image and warp mesh data */ - output [31:0] mwb_adr_o, - output mwb_stb_o, - output mwb_we_o, - input mwb_ack_i, - output [31:0] mwb_dat_o, - input [31:0] mwb_dat_i, - output [3:0] mwb_sel_o, - - /* Wishbone slave for configuration registers */ - input [31:0] wb_adr_i, - input wb_cyc_i, - input wb_stb_i, - input wb_we_i, - output wb_ack_o, - output [31:0] wb_dat_o, - input [31:0] wb_dat_i -); - -/*** REGISTER BANK ***/ - -wire enabled_read; -wire enabled_write; -wire [10:0] hres; -wire [10:0] vres; -wire [29:0] inaddr; -wire [29:0] outaddr; -wire [7:0] decay; -wire [6:0] meshcountx; -wire [10:0] meshsizex; -wire [6:0] meshcounty; -wire [10:0] meshsizey; -wire [29:0] meshaddr; - -warpreg warpreg( - .wb_clk_i(wb_clk_i), - .wb_rst_i(wb_rst_i), - - /* WISHBONE interface */ - .wb_adr_i(wb_adr_i), - .wb_cyc_i(wb_cyc_i), - .wb_stb_i(wb_stb_i), - .wb_we_i(wb_we_i), - .wb_ack_o(wb_ack_o), - .wb_dat_o(wb_dat_o), - .wb_dat_i(wb_dat_i), - - /* Control signals and registers */ - .enabled_write(enabled_write), - .enabled_read(enabled_read), - .hres(hres), - .vres(vres), - .inaddr(inaddr), - .outaddr(outaddr), - .decay(decay), - .meshcountx(meshcountx), - .meshsizex(meshsizex), - .meshcounty(meshcounty), - .meshsizey(meshsizey), - .meshaddr(meshaddr) -); - -/*** ARBITER ***/ - -wire [31:0] fm_mwb_adr_o; -wire fm_mwb_stb_o; -wire fm_mwb_ack_i; -wire [31:0] fm_mwb_dat_i; - -wire [31:0] fs_mwb_adr_o; -wire fs_mwb_stb_o; -wire fs_mwb_ack_i; -wire [31:0] fs_mwb_dat_i; - -wire [31:0] w_mwb_adr_o; -wire w_mwb_stb_o; -wire w_mwb_ack_i; -wire [31:0] w_mwb_dat_o; -wire [3:0] w_mwb_sel_o; - -arbiter3 arbiter3( - .wb_clk_i(wb_clk_i), - .wb_rst_i(wb_rst_i), - - /* WISHBONE master */ - .mwb_adr_o(mwb_adr_o), - .mwb_stb_o(mwb_stb_o), - .mwb_we_o(mwb_we_o), - .mwb_ack_i(mwb_ack_i), - .mwb_dat_o(mwb_dat_o), - .mwb_dat_i(mwb_dat_i), - .mwb_sel_o(mwb_sel_o), - - /* WISHBONE slave input 0: fetchmesh unit */ - .s0wb_adr_i(fm_mwb_adr_o), - .s0wb_stb_i(fm_mwb_stb_o), - .s0wb_we_i(0), - .s0wb_ack_o(fm_mwb_ack_i), - .s0wb_dat_i(32'hxxxxxxxx), - .s0wb_dat_o(fm_mwb_dat_i), - .s0wb_sel_i(4'b1111), - - /* WISHBONE slave input 1 : fetchsource unit */ - .s1wb_adr_i(fs_mwb_adr_o), - .s1wb_stb_i(fs_mwb_stb_o), - .s1wb_we_i(0), - .s1wb_ack_o(fs_mwb_ack_i), - .s1wb_dat_i(32'hxxxxxxxx), - .s1wb_dat_o(fs_mwb_dat_i), - .s1wb_sel_i(4'b1111), - - /* WISHBONE slave input 2 : writedest unit */ - .s2wb_adr_i(w_mwb_adr_o), - .s2wb_stb_i(w_mwb_stb_o), - .s2wb_we_i(w_mwb_stb_o), - .s2wb_ack_o(w_mwb_ack_i), - .s2wb_dat_i(w_mwb_dat_o), - .s2wb_dat_o(), - .s2wb_sel_i(w_mwb_sel_o) -); - -/*** PIPELINE ***/ - -/* Stage 1: Mesh reading */ - -/* fetchmesh wires */ - -wire fm_finished; - -/* triangleamy wires */ -wire [10:0] td_xa; -wire [10:0] td_ya; -wire [10:0] ts_xa; -wire [10:0] ts_ya; - -wire [10:0] td_xb; -wire [10:0] td_yb; -wire [10:0] ts_xb; -wire [10:0] ts_yb; - -wire [10:0] td_xc; -wire [10:0] td_yc; -wire [10:0] ts_xc; -wire [10:0] ts_yc; - -wire t_load; -wire t_finished; - -fetchmesh fetchmesh( - .clk(wb_clk_i), - .rst(wb_rst_i), - - /* WISHBONE master, read-only */ - .mwb_adr_o(fm_mwb_adr_o), - .mwb_stb_o(fm_mwb_stb_o), - .mwb_ack_i(fm_mwb_ack_i), - .mwb_dat_i(fm_mwb_dat_i), - - /* Parameters */ - .meshaddr(meshaddr), - .mesh_count_x(meshcountx), - .mesh_size_x(meshsizex), - .mesh_count_y(meshcounty), - .mesh_size_y(meshsizey), - - /* Control */ - .start(enabled_write), - .finished(fm_finished), - - /* Interface to the triangle interpolator */ - .td_xa(td_xa), - .td_ya(td_ya), - .ts_xa(ts_xa), - .ts_ya(ts_ya), - - .td_xb(td_xb), - .td_yb(td_yb), - .ts_xb(ts_xb), - .ts_yb(ts_yb), - - .td_xc(td_xc), - .td_yc(td_yc), - .ts_xc(ts_xc), - .ts_yc(ts_yc), - - .t_load(t_load), - .t_finished(t_finished) -); - -/* Stage 2: Triangular interpolation */ - -wire [10:0] td_x; -wire [10:0] td_y; -wire [10:0] ts_x; -wire [10:0] ts_y; - -wire t_next; -wire t_ready; - -triangleany triangleany( - .clk(wb_clk_i), - .rst(wb_rst_i), - - .xa(td_xa), - .ya(td_ya), - .ua(ts_xa), - .va(ts_ya), - - .xb(td_xb), - .yb(td_yb), - .ub(ts_xb), - .vb(ts_yb), - - .xc(td_xc), - .yc(td_yc), - .uc(ts_xc), - .vc(ts_yc), - - .load(t_load), - - .x(td_x), - .y(td_y), - .u(ts_x), - .v(ts_y), - .next(t_next), - .ready(t_ready), - .finished(t_finished) -); - -/* Stage 3: Boundary check */ - -wire [10:0] td_x_checked; -wire [10:0] td_y_checked; -wire [10:0] ts_x_checked; -wire [10:0] ts_y_checked; - -wire bc_ready; -wire bc_next; - -boundarycheck boundarycheck( - .clk(wb_clk_i), - .rst(wb_rst_i), - - .hres(hres), - .vres(vres), - - .td_x(td_x), - .td_y(td_y), - .ts_x(ts_x), - .ts_y(ts_y), - .t_ready(t_ready), - .t_next(t_next), - - .td_x_checked(td_x_checked), - .td_y_checked(td_y_checked), - .ts_x_checked(ts_x_checked), - .ts_y_checked(ts_y_checked), - .bc_ready(bc_ready), - .bc_next(bc_next) -); - -//always @(bc_ready) $display("bc ready %b", bc_ready); - -/* Stage 4: Compute pixel addresses */ - -wire [29:0] s_addr; -wire [29:0] d_addr; -wire pa_ready; -wire pa_next; - -pixeladdresses pixeladdresses( - .clk(wb_clk_i), - .rst(wb_rst_i), - - .hres(hres), - .inaddr(inaddr), - .outaddr(outaddr), - - .td_x(td_x_checked), - .td_y(td_y_checked), - .ts_x(ts_x_checked), - .ts_y(ts_y_checked), - .t_ready(bc_ready), - .t_next(bc_next), - - .s_addr(s_addr), - .d_addr(d_addr), - .pa_ready(pa_ready), - .pa_next(pa_next) -); - -//always @(pa_ready) $display("pa ready %b", pa_ready); - -/* Stage 5: Fetch source pixel */ - -wire [23:0] s_data; -wire [29:0] d_addr2; -wire fs_ready; -wire fs_next; - -fetchsource fetchsource( - .clk(wb_clk_i), - .rst(wb_rst_i), - - /* Source address, and fetched data */ - .s_addr(s_addr), - .s_data(s_data), - .pa_ready(pa_ready), - .pa_next(pa_next), - - /* WISHBONE master, read-only */ - .mwb_adr_o(fs_mwb_adr_o), - .mwb_stb_o(fs_mwb_stb_o), - .mwb_ack_i(fs_mwb_ack_i), - .mwb_dat_i(fs_mwb_dat_i), - - /* Register for the destination address */ - .d_addr(d_addr), - .d_addr2(d_addr2), - - .fs_ready(fs_ready), - .fs_next(fs_next) -); - -//always @(fs_ready or fs_next) $display("fs_ready %b fs_next %b", fs_ready, fs_next); - -/* Stage 6: Apply decay effect */ - -wire d_ready; -wire d_next; -wire [23:0] d_data; -wire [29:0] d_addr3; - -decay decayunit( - .clk(wb_clk_i), - .rst(wb_rst_i), - - /* Parameters */ - .decay(decay), - - .fs_ready(fs_ready), - .fs_next(fs_next), - - .s_data(s_data), - .d_data(d_data), - .d_ready(d_ready), - .d_next(d_next), - - /* Register for the destination address */ - .d_addr(d_addr2), - .d_addr2(d_addr3) -); - -//always @(d_ready or d_next) $display("d_ready %b d_next %b", d_ready, d_next); - -/* Stage 7: Write destination pixel */ - -writedest writedest( - .clk(wb_clk_i), - .rst(wb_rst_i), - - /* Data */ - .d_addr(d_addr3), - .d_data(d_data), - .d_ready(d_ready), - .d_next(d_next), - - /* WISHBONE master, write-only */ - .mwb_adr_o(w_mwb_adr_o), - .mwb_stb_o(w_mwb_stb_o), - .mwb_ack_i(w_mwb_ack_i), - .mwb_dat_o(w_mwb_dat_o), - .mwb_sel_o(w_mwb_sel_o) -); - -assign enabled_read = ~fm_finished;// | ~t_finished | bc_ready | pa_ready | fs_ready | d_ready | w_mwb_stb_o; - -endmodule Index: warp/trunk/rtl/fetchsource.v =================================================================== --- warp/trunk/rtl/fetchsource.v (revision 5) +++ warp/trunk/rtl/fetchsource.v (nonexistent) @@ -1,68 +0,0 @@ -/* - * Image warping and decay, source pixel fetching - * Copyright (C) 2008 Sebastien Bourdeauducq - http://lekernel.net - * This file is part of Milkymist. - * - * Milkymist is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -module fetchsource( - input clk, - input rst, - - /* Source address, and fetched data */ - input [29:0] s_addr, - output reg [23:0] s_data, - input pa_ready, - output pa_next, - - /* WISHBONE master, read-only */ - output [31:0] mwb_adr_o, - output mwb_stb_o, - input mwb_ack_i, - input [31:0] mwb_dat_i, - - /* Register for the destination address */ - input [29:0] d_addr, - output reg [29:0] d_addr2, - - output reg fs_ready, - input fs_next -); - -assign pa_next = fs_next & mwb_ack_i; - -assign mwb_adr_o = {s_addr, 2'b00}; -assign mwb_stb_o = pa_ready & ~fs_ready; - -always @(posedge clk or posedge rst) begin - if(rst) begin - s_data <= 0; - fs_ready <= 0; - d_addr2 <= 0; - end else begin - if(fs_next) begin - if(pa_ready & mwb_ack_i) begin - s_data <= mwb_dat_i[23:0]; - d_addr2 <= d_addr; - fs_ready <= 1; - end else - fs_ready <= 0; - end - end -end - -endmodule Index: warp/trunk/rtl/writedest.v =================================================================== --- warp/trunk/rtl/writedest.v (revision 5) +++ warp/trunk/rtl/writedest.v (nonexistent) @@ -1,67 +0,0 @@ -/* - * Image warping and decay, write destination pixel - * Copyright (C) 2008 Sebastien Bourdeauducq - http://lekernel.net - * This file is part of Milkymist. - * - * Milkymist is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -module writedest( - input clk, - input rst, - - /* Data */ - input [29:0] d_addr, - input [23:0] d_data, - input d_ready, - output d_next, - - /* WISHBONE master, write-only */ - output reg [31:0] mwb_adr_o, - output reg mwb_stb_o, /* implies WE signal */ - input mwb_ack_i, - output reg [31:0] mwb_dat_o, - output [3:0] mwb_sel_o -); - -assign mwb_sel_o = 4'b0111; - -assign d_next = ~mwb_stb_o | mwb_ack_i; - -always @(posedge clk or posedge rst) begin - if(rst) begin - mwb_adr_o <= 0; - mwb_stb_o <= 0; - mwb_dat_o <= 0; - end else begin - if(mwb_ack_i) begin - if(d_ready) begin - mwb_adr_o <= {d_addr, 2'b00}; - mwb_dat_o <= {8'h00, d_data}; - mwb_stb_o <= 1; - end else - mwb_stb_o <= 0; - end else begin - if(d_ready & ~mwb_stb_o) begin - mwb_adr_o <= {d_addr, 2'b00}; - mwb_dat_o <= {8'h00, d_data}; - mwb_stb_o <= 1; - end - end - end -end - -endmodule Index: warp/trunk/rtl/arbiter3.v =================================================================== --- warp/trunk/rtl/arbiter3.v (revision 5) +++ warp/trunk/rtl/arbiter3.v (nonexistent) @@ -1,86 +0,0 @@ -/* - * Image warping and decay, bus arbiter - * Copyright (C) 2008 Sebastien Bourdeauducq - http://lekernel.net - * This file is part of Milkymist. - * - * Milkymist is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -module arbiter3( - /* Clock and Reset are shared on all busses */ - input wb_clk_i, - input wb_rst_i, - - /* WISHBONE master */ - output [31:0] mwb_adr_o, - output mwb_stb_o, - output mwb_we_o, - input mwb_ack_i, - output [31:0] mwb_dat_o, - input [31:0] mwb_dat_i, - output [3:0] mwb_sel_o, - - /* WISHBONE slave input 0 */ - input [31:0] s0wb_adr_i, - input s0wb_stb_i, - input s0wb_we_i, - output s0wb_ack_o, - input [31:0] s0wb_dat_i, - output [31:0] s0wb_dat_o, - input [3:0] s0wb_sel_i, - - /* WISHBONE slave input 1 */ - input [31:0] s1wb_adr_i, - input s1wb_stb_i, - input s1wb_we_i, - output s1wb_ack_o, - input [31:0] s1wb_dat_i, - output [31:0] s1wb_dat_o, - input [3:0] s1wb_sel_i, - - /* WISHBONE slave input 2 */ - input [31:0] s2wb_adr_i, - input s2wb_stb_i, - input s2wb_we_i, - output s2wb_ack_o, - input [31:0] s2wb_dat_i, - output [31:0] s2wb_dat_o, - input [3:0] s2wb_sel_i -); - -wire [2:0] gnt; - -roundrobin3 roundrobin3( - .clk(wb_clk_i), - .rst(wb_rst_i), - .req({s2wb_stb_i, s1wb_stb_i, s0wb_stb_i}), - .gnt(gnt) -); - -assign mwb_adr_o = ({32{gnt[2]}} & s2wb_adr_i)|({32{gnt[1]}} & s1wb_adr_i)|({32{gnt[0]}} & s0wb_adr_i); -assign mwb_stb_o = (gnt[2] & s2wb_stb_i)|(gnt[1] & s1wb_stb_i)|(gnt[0] & s0wb_stb_i); -assign mwb_we_o = (gnt[2] & s2wb_we_i)|(gnt[1] & s1wb_we_i)|(gnt[0] & s0wb_we_i); -assign mwb_dat_o = ({32{gnt[2]}} & s2wb_dat_i)|({32{gnt[1]}} & s1wb_dat_i)|({32{gnt[0]}} & s0wb_dat_i); -assign mwb_sel_o = ({4{gnt[2]}} & s2wb_sel_i)|({4{gnt[1]}} & s1wb_sel_i)|({4{gnt[0]}} & s0wb_sel_i); - -assign s2wb_ack_o = gnt[2] & mwb_ack_i; -assign s2wb_dat_o = mwb_dat_i; -assign s1wb_ack_o = gnt[1] & mwb_ack_i; -assign s1wb_dat_o = mwb_dat_i; -assign s0wb_ack_o = gnt[0] & mwb_ack_i; -assign s0wb_dat_o = mwb_dat_i; - -endmodule Index: warp/trunk/rtl/triangleany.v =================================================================== --- warp/trunk/rtl/triangleany.v (revision 5) +++ warp/trunk/rtl/triangleany.v (nonexistent) @@ -1,228 +0,0 @@ -/* - * Triangle interpolation - * Copyright (C) 2008 Sebastien Bourdeauducq - http://lekernel.net - * This file is part of Milkymist. - * - * Milkymist is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - - -/* No constraint on parameters */ - -module triangleany( - input clk, - input rst, - - /* coordinates are registered */ - input [10:0] xa, - input [10:0] ya, - input [10:0] ua, - input [10:0] va, - - input [10:0] xb, - input [10:0] yb, - input [10:0] ub, - input [10:0] vb, - - input [10:0] xc, - input [10:0] yc, - input [10:0] uc, - input [10:0] vc, - input load, - - output [10:0] x, - output [10:0] y, - output [10:0] u, - output [10:0] v, - input next, - output ready, - output finished -); - -reg [3:0] state; -reg [3:0] next_state; -parameter IDLERUN = 0, CHOOSEA = 1, CHOOSEBC = 2, START= 3; - -reg [10:0] xA; -reg [10:0] yA; -reg [10:0] uA; -reg [10:0] vA; - -reg [10:0] xB; -reg [10:0] yB; -reg [10:0] uB; -reg [10:0] vB; - -reg [10:0] xC; -reg [10:0] yC; -reg [10:0] uC; -reg [10:0] vC; - -reg loadall; -reg swapAB; -reg swapAC; -reg swapBC; - -reg triangleload; -wire triangleready; -wire trianglefinished; - -triangle dut( - .clk(clk), - .rst(rst), - - .xa(xA), - .ya(yA), - .ua(uA), - .va(vA), - - .xb(xB), - .yb(yB), - .ub(uB), - .vb(vB), - - .xc(xC), - .yc(yC), - .uc(uC), - .vc(vC), - .load(triangleload), - - .x(x), - .y(y), - .u(u), - .v(v), - .next(next), - .ready(triangleready), - .finished(trianglefinished) -); - -always @(posedge clk or posedge rst) begin - if(rst) begin - state <= IDLERUN; - - xA <= 0; - yA <= 0; - uA <= 0; - vA <= 0; - - xB <= 0; - yB <= 0; - uB <= 0; - vB <= 0; - - xC <= 0; - yC <= 0; - uC <= 0; - vC <= 0; - end else begin - state <= next_state; - if(loadall) begin - xA <= xa; - yA <= ya; - uA <= ua; - vA <= va; - - xB <= xb; - yB <= yb; - uB <= ub; - vB <= vb; - - xC <= xc; - yC <= yc; - uC <= uc; - vC <= vc; - end else begin - if(swapAB) begin - xA <= xB; - yA <= yB; - uA <= uB; - vA <= vB; - - xB <= xA; - yB <= yA; - uB <= uA; - vB <= vA; - end else if(swapAC) begin - xA <= xC; - yA <= yC; - uA <= uC; - vA <= vC; - - xC <= xA; - yC <= yA; - uC <= uA; - vC <= vA; - end else if(swapBC) begin - xB <= xC; - yB <= yC; - uB <= uC; - vB <= vC; - - xC <= xB; - yC <= yB; - uC <= uB; - vC <= vB; - end - end - end -end - -assign ready = (state == IDLERUN) & triangleready; -assign finished = (state == IDLERUN) & trianglefinished; - -always @(state or load or yA or yB or yC or xC or xB) begin - /* XST does not generate a pure combinatorial function if next_state is - * not pre-affected, maybe because of the unused states. - */ - next_state = IDLERUN; - - triangleload = 1'b0; - - loadall = 1'b0; - swapAB = 1'b0; - swapAC = 1'b0; - swapBC = 1'b0; - - - case(state) - IDLERUN: begin - if(load) begin - loadall = 1'b1; - //$display("Loading triangle: (%d,%d), (%d,%d), (%d,%d)", xa, ya, xb, yb, xc, yc); - //$display("Parameters: (%d,%d), (%d,%d), (%d,%d)", ua, va, ub, vb, uc, vc); - next_state = CHOOSEA; - end else - next_state = IDLERUN; - end - CHOOSEA: begin - swapAB = (yB < yA) & (yB < yC); - swapAC = (yC < yA) & (yC < yB); - next_state = CHOOSEBC; - end - CHOOSEBC: begin - swapBC = (xC < xB); - next_state = START; - end - START: begin - //$display("Ordered points: (%d,%d), (%d,%d), (%d,%d)", xA, yA, xB, yB, xC, yC); - //$display("Parameters: (%d,%d), (%d,%d), (%d,%d)", uA, vA, uB, vB, uC, vC); - triangleload = 1'b1; - next_state = IDLERUN; - end - endcase -end - -endmodule Index: warp/trunk/rtl/pixeladdresses.v =================================================================== --- warp/trunk/rtl/pixeladdresses.v (revision 5) +++ warp/trunk/rtl/pixeladdresses.v (nonexistent) @@ -1,60 +0,0 @@ -/* - * Image warping and decay, pixel addresses computation - * Copyright (C) 2008 Sebastien Bourdeauducq - http://lekernel.net - * This file is part of Milkymist. - * - * Milkymist is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -module pixeladdresses( - input clk, - input rst, - - input [10:0] hres, - input [29:0] inaddr, - input [29:0] outaddr, - - input [10:0] td_x, - input [10:0] td_y, - input [10:0] ts_x, - input [10:0] ts_y, - input t_ready, - output t_next, - - output reg [29:0] s_addr, - output reg [29:0] d_addr, - output reg pa_ready, - input pa_next -); - -assign t_next = ~pa_ready | pa_next; - -always @(posedge clk or posedge rst) begin - if(rst) begin - s_addr <= 0; - d_addr <= 0; - pa_ready <= 0; - end else begin - if(t_ready & (~pa_ready | pa_next)) begin - s_addr <= inaddr + hres*ts_y + ts_x; - d_addr <= outaddr + hres*td_y + td_x; - pa_ready <= 1; - end else if(pa_next) - if(pa_next) pa_ready <= 0; - end -end - -endmodule Index: warp/trunk/rtl/boundarycheck.v =================================================================== --- warp/trunk/rtl/boundarycheck.v (revision 5) +++ warp/trunk/rtl/boundarycheck.v (nonexistent) @@ -1,68 +0,0 @@ -/* - * Image warping and decay, boundary check - * Copyright (C) 2008 Sebastien Bourdeauducq - http://lekernel.net - * This file is part of Milkymist. - * - * Milkymist is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -module boundarycheck( - input clk, - input rst, - - input [10:0] hres, - input [10:0] vres, - - input [10:0] td_x, - input [10:0] td_y, - input [10:0] ts_x, - input [10:0] ts_y, - input t_ready, - output t_next, - - output reg [10:0] td_x_checked, - output reg [10:0] td_y_checked, - output reg [10:0] ts_x_checked, - output reg [10:0] ts_y_checked, - output reg bc_ready, - input bc_next -); - -wire passed; -assign passed = (td_x < hres) & (td_y < vres) & (ts_x < hres) & (ts_y < vres); - -assign t_next = ~passed | (~bc_ready | bc_next); - -always @(posedge rst or posedge clk) begin - if(rst) begin - td_x_checked <= 0; - td_y_checked <= 0; - ts_x_checked <= 0; - ts_y_checked <= 0; - bc_ready <= 0; - end else begin - if(passed & t_ready & (~bc_ready | bc_next)) begin - td_x_checked <= td_x; - td_y_checked <= td_y; - ts_x_checked <= ts_x; - ts_y_checked <= ts_y; - bc_ready <= 1; - end else - if(bc_next) bc_ready <= 0; - end -end - -endmodule Index: warp/trunk/rtl/bresenham.v =================================================================== --- warp/trunk/rtl/bresenham.v (revision 5) +++ warp/trunk/rtl/bresenham.v (nonexistent) @@ -1,101 +0,0 @@ -/* - * Bresenham-like interpolator - * Copyright (C) 2008 Sebastien Bourdeauducq - http://lekernel.net - * This file is part of Milkymist. - * - * Milkymist is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -/* This core computes the best integer linear interpolation - * between the points (x1, y1) and (x2, y2) with incrementing x's. - * Condition: x1 < x2. - */ - -module bresenham( - input clk, - - input [10:0] x1, - input [10:0] y1, - input [10:0] x2, - input [10:0] y2, - input load, - output ready, - - output reg [10:0] x, - output reg [10:0] y, - input next, - output finished -); - -wire quadrant_c; -wire [9:0] eps_dx_c; -wire [9:0] dy_c; - -assign eps_dx_c = x2 - x1; -assign quadrant_c = y2 > y1; -assign dy_c = quadrant_c ? y2 - y1 : y1 - y2; - -wire d_ready; -wire [9:0] qy; -wire [9:0] ry; // add trailing zero - -assign ready = d_ready; - -divider10 divider( - .clk(clk), - - .start(load), - .dividend(dy_c), - .divider(eps_dx_c), - - .ready(d_ready), - .quotient(qy), - .remainder(ry) -); - -reg quadrant; -reg [9:0] dx; // add trailing zero -reg [10:0] eps; - -assign finished = x == x2; - -always @(posedge clk) begin - if(load) begin - //$display("interp %d -> %d", x1, x2); - //$display(" %d -> %d", y1, y2); - eps = eps_dx_c; - dx = eps_dx_c; - quadrant = quadrant_c; - x = x1; - y = y1; - end else if(next & d_ready & ~finished) begin - x = x + 1; - if(quadrant) - y = y + qy; - else - y = y - qy; - if(eps <= {ry, 1'b0}) begin - if(quadrant) - y = y + 1; - else - y = y - 1; - eps = eps + ({dx, 1'b0} - {ry, 1'b0}); - end else - eps = eps - {ry, 1'b0}; - end -end - -endmodule Index: warp/trunk/rtl/roundrobin3.v =================================================================== --- warp/trunk/rtl/roundrobin3.v (revision 5) +++ warp/trunk/rtl/roundrobin3.v (nonexistent) @@ -1,116 +0,0 @@ -///////////////////////////////////////////////////////////////////// -//// //// -//// General Round Robin Arbiter //// -//// //// -//// //// -//// Author: Rudolf Usselmann //// -//// rudi@asics.ws //// -//// //// -//// //// -//// Downloaded from: http://www.opencores.org/cores/wb_conmax/ //// -//// //// -///////////////////////////////////////////////////////////////////// -//// //// -//// Copyright (C) 2000-2002 Rudolf Usselmann //// -//// www.asics.ws //// -//// rudi@asics.ws //// -//// //// -//// 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 SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY //// -//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED //// -//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS //// -//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR //// -//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, //// -//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES //// -//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE //// -//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR //// -//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF //// -//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT //// -//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT //// -//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE //// -//// POSSIBILITY OF SUCH DAMAGE. //// -//// //// -///////////////////////////////////////////////////////////////////// - -// Modified for Milkymist image warping -// Sebastien Bourdeauducq, 2008 - -module roundrobin3(clk, rst, req, gnt); - -input clk; -input rst; -input [2:0] req; // Req input -output [2:0] gnt; // Grant output - -/////////////////////////////////////////////////////////////////////// -// -// Parameters -// - -parameter [2:0] - grant0 = 3'b001, - grant1 = 3'b010, - grant2 = 3'b100; - -/////////////////////////////////////////////////////////////////////// -// -// Local Registers and Wires -// - -reg [2:0] state, next_state; - -/////////////////////////////////////////////////////////////////////// -// -// Misc Logic -// - -assign gnt = state; - -always@(posedge clk or posedge rst) - if(rst) state <= grant0; - else state <= next_state; - -/////////////////////////////////////////////////////////////////////// -// -// Next State Logic -// - implements round robin arbitration algorithm -// - switches grant if current req is dropped or next is asserted -// - parks at last grant -// - -always @(state or req) begin - next_state = state; // Default Keep State - //$display("master [%b]: %b -> %b", req, state, next_state); - case(state) // synopsys parallel_case full_case - grant0: - // if this req is dropped or next is asserted, check for other req's - if(!req[0]) - begin - if(req[1]) next_state = grant1; - else - if(req[2]) next_state = grant2; - end - grant1: - // if this req is dropped or next is asserted, check for other req's - if(!req[1]) - begin - if(req[2]) next_state = grant2; - else - if(req[0]) next_state = grant0; - end - grant2: - // if this req is dropped or next is asserted, check for other req's - if(!req[2]) - begin - if(req[0]) next_state = grant0; - else - if(req[1]) next_state = grant1; - end - endcase -end - -endmodule Index: warp/trunk/rtl/triangle.v =================================================================== --- warp/trunk/rtl/triangle.v (revision 5) +++ warp/trunk/rtl/triangle.v (nonexistent) @@ -1,384 +0,0 @@ -/* - * Triangle interpolation - * Copyright (C) 2008 Sebastien Bourdeauducq - http://lekernel.net - * This file is part of Milkymist. - * - * Milkymist is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -/* A must be the upper point (ya <= min(yb, yc)) - * B must be on the left of C (xb <= xc) - */ - -module triangle( - input clk, - input rst, - - /* coordinates are not registered */ - input [10:0] xa, - input [10:0] ya, - input [10:0] ua, - input [10:0] va, - - input [10:0] xb, - input [10:0] yb, - input [10:0] ub, - input [10:0] vb, - - input [10:0] xc, - input [10:0] yc, - input [10:0] uc, - input [10:0] vc, - input load, - - output reg [10:0] x, - output reg [10:0] y, - output [10:0] u, - output [10:0] v, - input next, - output reg ready, - output reg finished -); - -reg nextline; - -wire readyAB; -wire readyAC; -wire readyBC; -wire finishedAB; -wire finishedAC; -wire finishedBC; - -wire [10:0] xAB; -wire [10:0] xAC; -wire [10:0] xBC; - -wire swapBC; -assign swapBC = yc < yb; - -bresenham lineAB( - .clk(clk), - - .x1(ya), - .y1(xa), - .x2(yb), - .y2(xb), - .load(load), - .ready(readyAB), - - .x(), - .y(xAB), - .next(nextline), - .finished(finishedAB) -); - -bresenham lineAC( - .clk(clk), - - .x1(ya), - .y1(xa), - .x2(yc), - .y2(xc), - .load(load), - .ready(readyAC), - - .x(), - .y(xAC), - .next(nextline), - .finished(finishedAC) -); - -bresenham lineBC( - .clk(clk), - - .x1(swapBC ? yc : yb), - .y1(swapBC ? xc : xb), - .x2(swapBC ? yb : yc), - .y2(swapBC ? xb : xc), - .load(load), - .ready(readyBC), - - .x(), - .y(xBC), - .next(nextline & (finishedAB | finishedAC)), - .finished(finishedBC) -); - -wire [10:0] xmin; -wire [10:0] xmax; - -assign xmin = finishedAB ? xBC : xAB; -assign xmax = (finishedAC & ~finishedAB) // to handle horizontal BC - | (finishedAB & finishedBC) // to handle single-point BC with horizontal top line - ? xBC : xAC; - -wire readyuAB; -wire readyuAC; -wire readyuBC; -wire [10:0] uAB; -wire [10:0] uAC; -wire [10:0] uBC; - -bresenham buAB( - .clk(clk), - - .x1(ya), - .y1(ua), - .x2(yb), - .y2(ub), - .load(load), - .ready(readyuAB), - - .x(), - .y(uAB), - .next(nextline), - .finished() -); - -bresenham buAC( - .clk(clk), - - .x1(ya), - .y1(ua), - .x2(yc), - .y2(uc), - .load(load), - .ready(readyuAC), - - .x(), - .y(uAC), - .next(nextline), - .finished() -); - -bresenham buBC( - .clk(clk), - - .x1(swapBC ? yc : yb), - .y1(swapBC ? uc : ub), - .x2(swapBC ? yb : yc), - .y2(swapBC ? ub : uc), - .load(load), - .ready(readyuBC), - - .x(), - .y(uBC), - .next(nextline & (finishedAB | finishedAC)), - .finished() -); - -wire [10:0] umin; -wire [10:0] umax; - -assign umin = finishedAB ? uBC : uAB; -assign umax = (finishedAC & ~finishedAB) ? uBC : uAC; - -wire readyvAB; -wire readyvAC; -wire readyvBC; -wire [10:0] vAB; -wire [10:0] vAC; -wire [10:0] vBC; - -bresenham bvAB( - .clk(clk), - - .x1(ya), - .y1(va), - .x2(yb), - .y2(vb), - .load(load), - .ready(readyvAB), - - .x(), - .y(vAB), - .next(nextline), - .finished() -); - -bresenham bvAC( - .clk(clk), - - .x1(ya), - .y1(va), - .x2(yc), - .y2(vc), - .load(load), - .ready(readyvAC), - - .x(), - .y(vAC), - .next(nextline), - .finished() -); - -bresenham bvBC( - .clk(clk), - - .x1(swapBC ? yc : yb), - .y1(swapBC ? vc : vb), - .x2(swapBC ? yb : yc), - .y2(swapBC ? vb : vc), - .load(load), - .ready(readyvBC), - - .x(), - .y(vBC), - .next(nextline & (finishedAB | finishedAC)), - .finished() -); - -wire [10:0] vmin; -wire [10:0] vmax; - -assign vmin = finishedAB ? vBC : vAB; -assign vmax = (finishedAC & ~finishedAB) ? vBC : vAC; - -reg loadpixel; -reg nextpixel; - -wire readybupixel; - -bresenham bupixel( - .clk(clk), - - .x1(xmin), - .y1(umin), - .x2(xmax), - .y2(umax), - .load(loadpixel), - .ready(readybupixel), - - .x(), - .y(u), - .next(nextpixel), - .finished() -); - -wire readybvpixel; - -bresenham bvpixel( - .clk(clk), - - .x1(xmin), - .y1(vmin), - .x2(xmax), - .y2(vmax), - .load(loadpixel), - .ready(readybvpixel), - - .x(), - .y(v), - .next(nextpixel), - .finished() -); - -reg [3:0] state; -reg [3:0] next_state; -parameter IDLE = 0, INITWAIT = 1, START_DRAWH = 2, UVWAIT = 3, DRAWH = 4; - -reg [10:0] x_next; -reg [10:0] y_next; - -always @(posedge clk or posedge rst) begin - if(rst) begin - state <= IDLE; - x <= 0; - y <= 0; - end else begin - state <= next_state; - x <= x_next; - y <= y_next; - end -end - -always @(state or load - or readyAB or readyAC or readyBC - or readyuAB or readyuAC or readyuBC - or readyvAB or readyvAC or readyvBC - or readybupixel or readybvpixel - or xmin or xmax or finishedAB or finishedAC or finishedBC or next - or xa or ya or x or y) begin - - /* XST does not generate a pure combinatorial function if next_state is - * not pre-affected, maybe because of the unused states. - */ - next_state = IDLE; - - x_next = x; - y_next = y; - finished = 1'b0; - ready = 1'b0; - nextline = 1'b0; - loadpixel = 1'b0; - nextpixel = 1'b0; - - case(state) - IDLE: begin - finished = 1'b1; - ready = 1'b1; - x_next = xa; - y_next = ya; - if(load) - next_state = INITWAIT; - else - next_state = IDLE; - end - INITWAIT: begin - if(readyAB & readyAC & readyBC - & readyuAB & readyuAC & readyuBC - & readyvAB & readyvAC & readyvBC) - next_state = START_DRAWH; - else - next_state = INITWAIT; - end - START_DRAWH: begin - //$display("LINE %d -> %d finishedAB %b finishedAC %b", xmin, xmax, finishedAB, finishedAC); - //$display("xBC %d xAC %d", xBC, xAC); - x_next = xmin; - loadpixel = 1'b1; - next_state = UVWAIT; - end - UVWAIT: begin - if(readybupixel & readybvpixel) - next_state = DRAWH; - else - next_state = UVWAIT; - end - DRAWH: begin - ready = 1'b1; - if(next) begin - nextpixel = 1'b1; - if(x == xmax) begin - if(finishedAB & finishedAC & finishedBC) - next_state = IDLE; - else begin - y_next = y + 1; - nextline = 1'b1; - next_state = START_DRAWH; - end - end else begin - x_next = x + 1; - next_state = DRAWH; - end - end else begin - next_state = DRAWH; - end - end - endcase -end - -endmodule Index: warp/trunk/rtl/decay.v =================================================================== --- warp/trunk/rtl/decay.v (revision 5) +++ warp/trunk/rtl/decay.v (nonexistent) @@ -1,66 +0,0 @@ -/* - * Image warping and decay, decay (fade-to-black) effect - * Copyright (C) 2008 Sebastien Bourdeauducq - http://lekernel.net - * This file is part of Milkymist. - * - * Milkymist is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -module decay( - input clk, - input rst, - - /* Parameters */ - input [7:0] decay, // unregistered - - input fs_ready, - output fs_next, - - input [23:0] s_data, - output reg [23:0] d_data, - output reg d_ready, - input d_next, - - /* Register for the destination address */ - input [29:0] d_addr, - output reg [29:0] d_addr2 -); - -assign fs_next = ~d_ready | d_next; - -wire [15:0] decay1; -wire [15:0] decay2; -wire [15:0] decay3; -assign decay1 = s_data[23:16] * decay; -assign decay2 = s_data[15:8] * decay; -assign decay3 = s_data[7:0] * decay; - -always @(posedge clk or posedge rst) begin - if(rst) begin - d_data <= 0; - d_ready <= 0; - d_addr2 <= 0; - end else begin - if(fs_ready & (~d_ready | d_next)) begin - d_data <= decay == 8'hff ? s_data : {decay1[15:8], decay2[15:8], decay3[15:8]}; - d_addr2 <= d_addr; - d_ready <= 1; - end else - if(d_next) d_ready <= 0; - end -end - -endmodule Index: warp/trunk =================================================================== --- warp/trunk (revision 5) +++ warp/trunk (nonexistent)
warp/trunk Property changes : Deleted: svn:mergeinfo ## -0,0 +0,0 ## Index: warp/web_uploads =================================================================== --- warp/web_uploads (revision 5) +++ warp/web_uploads (nonexistent)
warp/web_uploads Property changes : Deleted: svn:mergeinfo ## -0,0 +0,0 ##

powered by: WebSVN 2.1.0

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