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

Subversion Repositories gpio

[/] [gpio/] [trunk/] [bench/] [verilog/] [tb_tasks.v] - Diff between revs 13 and 18

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 13 Rev 18
Line 42... Line 42...
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
//
// CVS Revision History
// CVS Revision History
//
//
// $Log: not supported by cvs2svn $
// $Log: not supported by cvs2svn $
 
// Revision 1.3  2001/09/18 16:37:55  lampret
 
// Changed VCD output location.
 
//
// Revision 1.2  2001/09/18 15:43:27  lampret
// Revision 1.2  2001/09/18 15:43:27  lampret
// Changed gpio top level into gpio_top. Changed defines.v into gpio_defines.v.
// Changed gpio top level into gpio_top. Changed defines.v into gpio_defines.v.
//
//
// Revision 1.1  2001/08/21 21:39:27  lampret
// Revision 1.1  2001/08/21 21:39:27  lampret
// Changed directory structure, port names and drfines.
// Changed directory structure, port names and drfines.
Line 364... Line 367...
//
//
// Test operation of control bit RGPIO_CTRL[ECLK]
// Test operation of control bit RGPIO_CTRL[ECLK]
//
//
task test_eclk;
task test_eclk;
integer         l1, l2, l3;
integer         l1, l2, l3;
integer         r1, r2;
integer         r1, r2, r3;
begin
begin
 
 
 
        // Set external clock to low state
 
        tb_top.gpio_mon.set_gpioeclk(0);
 
        @(posedge tb_top.clk);
 
        @(posedge tb_top.clk);
 
 
        //
        //
        // Phase 1
        // Phase 1
        //
        //
        // GPIO uses WISHBONE clock to latch gpio_in
        // GPIO uses WISHBONE clock to latch gpio_in
        //
        //
Line 381... Line 389...
 
 
        // Reset GPIO_CTRL
        // Reset GPIO_CTRL
        setctrl(0);
        setctrl(0);
 
 
        // Wait for time to advance
        // Wait for time to advance
        #1000;
        @(posedge tb_top.clk);
 
        @(posedge tb_top.clk);
 
 
        // Read GPIO_RGPIO_IN
        // Read GPIO_RGPIO_IN
        getin(l1);
        getin(l1);
 
 
        //
        //
        // Phase 2
        // Phase 2
        //
        //
        // GPIO uses external clock to latch gpio_in
        // GPIO uses external clock to latch gpio_in
        //
        //
 
 
        // Set GPIO to use external clock
        // Set GPIO to use external clock, NEC bit cleared
        setctrl(1 << `GPIO_RGPIO_CTRL_ECLK);
        setctrl(1 << `GPIO_RGPIO_CTRL_ECLK);
 
 
        // Put something else on gpio_in pins
        // Put something else on gpio_in pins
        random_gpio(r2);
        random_gpio(r2);
        tb_top.gpio_mon.set_gpioin(r2);
        tb_top.gpio_mon.set_gpioin(r2);
 
 
        // Wait for time to advance
        // Make an external posedge clock pulse
        #1000;
        tb_top.gpio_mon.set_gpioeclk(0);
 
        @(posedge tb_top.clk);
 
        @(posedge tb_top.clk);
 
        tb_top.gpio_mon.set_gpioeclk(1);
 
        @(posedge tb_top.clk);
 
        @(posedge tb_top.clk);
 
 
        // Read GPIO_RGPIO_IN (should be the same as l1)
        // Read RGPIO_IN
        getin(l2);
        getin(l2);
 
 
        // Make an external clock
        //
        tb_top.gpio_mon.set_gpioeclk(0);
        // Phase 3
        #10;
        //
        tb_top.gpio_mon.set_gpioeclk(1);
        // Change GPIO inputs and WB clock but not external clock.
        #10;
        // RGPIO_IN should not change.
 
        //
 
 
        // Read RGPIO_IN (should be different than l2)
        // Put something else on gpio_in pins
 
        random_gpio(r3);
 
        tb_top.gpio_mon.set_gpioin(r3);
 
 
 
        // Wait for WB clock
 
        @(posedge tb_top.clk);
 
        @(posedge tb_top.clk);
 
 
 
        // Read RGPIO_IN
        getin(l3);
        getin(l3);
 
 
        //
        //
        // Phase 3
        // Phase 4
        //
        //
        // Compare phases
        // Compare phases
        //
        //
        if (l1 == l2 && l2 == r1 && l3 == r2)
        if (l1 == r1 && l2 == r2 && l2 == l3)
                $write(".");
                $write(".");
        else
        else
                local_errs = local_errs + 1;
                local_errs = local_errs + 1;
end
end
endtask
endtask
Line 431... Line 454...
//
//
// Test operation of control bit RGPIO_CTRL[NEC]
// Test operation of control bit RGPIO_CTRL[NEC]
//
//
task test_nec;
task test_nec;
integer         l1, l2;
integer         l1, l2;
integer         r2;
integer         r1, r2;
begin
begin
        //
        //
        // Phase 1
        // Phase 1
        //
        //
        // Compare RGPIO_IN before and after negative edge
        // Compare RGPIO_IN before and after negative edge
        //
        //
 
 
        // Clear GPIO_RGPIO_IN
        // Set external clock to low state
        tb_top.gpio_mon.set_gpioin('d0);
        tb_top.gpio_mon.set_gpioeclk(0);
 
        @(posedge tb_top.clk);
        // Set GPIO to use WB clock
        @(posedge tb_top.clk);
        setctrl(0);
 
 
 
        // Advance time
 
        #1000;
 
 
 
        // Set GPIO to use external clock and set RGPIO_CTRL[NEC]
        // Set GPIO to use external clock and set RGPIO_CTRL[NEC]
        setctrl(1 << `GPIO_RGPIO_CTRL_ECLK | 1 << `GPIO_RGPIO_CTRL_NEC);
        setctrl(1 << `GPIO_RGPIO_CTRL_ECLK | 1 << `GPIO_RGPIO_CTRL_NEC);
 
 
 
        // Put random on gpio inputs
 
        random_gpio(r1);
 
        tb_top.gpio_mon.set_gpioin(r1);
 
 
 
        // Advance time by making an external negedge clock pulse
 
        tb_top.gpio_mon.set_gpioeclk(1);
 
        @(posedge tb_top.clk);
 
        @(posedge tb_top.clk);
 
        tb_top.gpio_mon.set_gpioeclk(0);
 
        @(posedge tb_top.clk);
 
        @(posedge tb_top.clk);
 
 
        // Put something on gpio_in pins
        // Put something on gpio_in pins
        random_gpio(r2);
        random_gpio(r2);
        tb_top.gpio_mon.set_gpioin(r2);
        tb_top.gpio_mon.set_gpioin(r2);
 
 
        // Wait for time to advance
        // Make an external posedge clock pulse
        #1000;
        tb_top.gpio_mon.set_gpioeclk(0);
 
        @(posedge tb_top.clk);
 
        @(posedge tb_top.clk);
 
        tb_top.gpio_mon.set_gpioeclk(1);
 
        @(posedge tb_top.clk);
 
        @(posedge tb_top.clk);
 
 
        // Read RGPIO_IN
        // Read RGPIO_IN (should be the same as r1)
        getin(l1);
        getin(l1);
 
 
        // Make an external clock
        // Make an external negedge clock pulse
        tb_top.gpio_mon.set_gpioeclk(1);
        tb_top.gpio_mon.set_gpioeclk(1);
        #10;
        @(posedge tb_top.clk);
 
        @(posedge tb_top.clk);
        tb_top.gpio_mon.set_gpioeclk(0);
        tb_top.gpio_mon.set_gpioeclk(0);
        #10;
        @(posedge tb_top.clk);
 
        @(posedge tb_top.clk);
 
 
        // Read RGPIO_IN (should be different than l1)
        // Read RGPIO_IN (should be the same as r2)
        getin(l2);
        getin(l2);
 
 
        //
        //
        // Phase 2
        // Phase 2
        //
        //
        // Compare phases
        // Compare phases
        //
        //
        if (!l1 && l2 == r2)
//      $display("l1 %h  l2 %h  r1 %h  r2 %h", l1, l2, r1, r2);
 
        if (l1 == r1 && l2 == r2)
                $write(".");
                $write(".");
        else
        else
                local_errs = local_errs + 1;
                local_errs = local_errs + 1;
end
end
endtask
endtask
Line 507... Line 546...
                // Put something on gpio_in pins
                // Put something on gpio_in pins
                random_gpio(l1);
                random_gpio(l1);
                tb_top.gpio_mon.set_gpioin(l1);
                tb_top.gpio_mon.set_gpioin(l1);
 
 
                // Advance time
                // Advance time
                #1000;
                @(posedge tb_top.clk);
 
                @(posedge tb_top.clk);
 
 
                // Read GPIO_RGPIO_IN
                // Read GPIO_RGPIO_IN
                getin(l2);
                getin(l2);
 
 
                // Compare gpio_in and RGPIO_IN. Should be equal.
                // Compare gpio_in and RGPIO_IN. Should be equal.
Line 541... Line 581...
                // Put something in RGPIO_OUT pins
                // Put something in RGPIO_OUT pins
                l1 = $random;
                l1 = $random;
                setout(l1);
                setout(l1);
 
 
                // Advance time
                // Advance time
                #1000;
                @(posedge tb_top.clk);
 
                @(posedge tb_top.clk);
 
 
                // Read gpio_out
                // Read gpio_out
                tb_top.gpio_mon.get_gpioout(l2);
                tb_top.gpio_mon.get_gpioout(l2);
 
 
                // Compare gpio_out and RGPIO_OUT. Should be equal.
                // Compare gpio_out and RGPIO_OUT. Should be equal.
Line 575... Line 616...
                // Put something in RGPIO_OE pins
                // Put something in RGPIO_OE pins
                l1 = $random;
                l1 = $random;
                setoe(l1);
                setoe(l1);
 
 
                // Advance time
                // Advance time
                #1000;
                @(posedge tb_top.clk);
 
                @(posedge tb_top.clk);
 
 
                // Read gpio_oen
                // Read gpio_oen
                tb_top.gpio_mon.get_gpiooen(l2);
                tb_top.gpio_mon.get_gpiooen(l2);
 
 
                // Compare gpio_oen and RGPIO_OE. Should be exactly opposite.
                // Compare gpio_oen and RGPIO_OE. Should be exactly opposite.
Line 617... Line 659...
                // Put something in RGPIO_OUT pins
                // Put something in RGPIO_OUT pins
                l3 = $random;
                l3 = $random;
                setout(l3);
                setout(l3);
 
 
                // Advance time
                // Advance time
                #1000;
                @(posedge tb_top.clk);
 
                @(posedge tb_top.clk);
 
 
                // Read gpio_out
                // Read gpio_out
                tb_top.gpio_mon.get_gpioout(l4);
                tb_top.gpio_mon.get_gpioout(l4);
 
 
                // Compare gpio_out, RGPIO_OUT, RGPIO_AUX and gpio_aux.
                // Compare gpio_out, RGPIO_OUT, RGPIO_AUX and gpio_aux.
Line 650... Line 693...
integer         l1, l2, l3;
integer         l1, l2, l3;
integer         i, rnd, err;
integer         i, rnd, err;
integer         r1;
integer         r1;
begin
begin
 
 
        $write("  Testing control bis RGPIO_CTRL[INTE] and RGPIO_CTRL[INT] ...");
        $write("  Testing control bit RGPIO_CTRL[INTE] and RGPIO_CTRL[INT] ...");
 
 
        //
        //
        // Phase 1
        // Phase 1
        //
        //
        // Generate patterns on inputs in interrupt mode
        // Generate patterns on inputs in interrupt mode
Line 678... Line 721...
 
 
                // Enable interrupts in RGPIO_INTE
                // Enable interrupts in RGPIO_INTE
                setinte(r1);
                setinte(r1);
 
 
                // Advance time
                // Advance time
                #100;
                @(posedge tb_top.clk);
 
                @(posedge tb_top.clk);
 
 
                // Sample interrupt request. Should be zero.
                // Sample interrupt request. Should be zero.
                l1 = tb_top.gpio_top.wb_inta_o;
                l1 = tb_top.gpio_top.wb_inta_o;
 
 
                // Clear gpio_in pins
                // Clear gpio_in pins
                tb_top.gpio_mon.set_gpioin(0);
                tb_top.gpio_mon.set_gpioin(0);
 
 
                // Advance time
                // Advance time
                #100;
                @(posedge tb_top.clk);
 
                @(posedge tb_top.clk);
 
 
                // Sample interrupt request. Should be one.
                // Sample interrupt request. Should be one.
                l2 = tb_top.gpio_top.wb_inta_o;
                l2 = tb_top.gpio_top.wb_inta_o;
 
 
                // Clear interrupt request
                // Clear interrupt request
                setctrl(0);
                setctrl(0);
 
 
                // Advance time
                // Advance time
                #100;
                @(posedge tb_top.clk);
 
                @(posedge tb_top.clk);
 
 
                // Sample interrupt request. Should be zero.
                // Sample interrupt request. Should be zero.
                l3 = tb_top.gpio_top.wb_inta_o;
                l3 = tb_top.gpio_top.wb_inta_o;
 
 
                // Check for errors
                // Check for errors
Line 758... Line 804...
 
 
                // Enable interrupts in RGPIO_INTE
                // Enable interrupts in RGPIO_INTE
                setinte(r1);
                setinte(r1);
 
 
                // Advance time
                // Advance time
                #100;
                @(posedge tb_top.clk);
 
                @(posedge tb_top.clk);
 
 
                // Sample interrupt request. Should be zero.
                // Sample interrupt request. Should be zero.
                l1 = tb_top.gpio_top.wb_inta_o;
                l1 = tb_top.gpio_top.wb_inta_o;
 
 
                // Clear gpio_in pins
                // Clear gpio_in pins
                tb_top.gpio_mon.set_gpioin('hffffffff);
                tb_top.gpio_mon.set_gpioin('hffffffff);
 
 
                // Advance time
                // Advance time
                #100;
                @(posedge tb_top.clk);
 
                @(posedge tb_top.clk);
 
 
                // Sample interrupt request. Should be one.
                // Sample interrupt request. Should be one.
                l2 = tb_top.gpio_top.wb_inta_o;
                l2 = tb_top.gpio_top.wb_inta_o;
 
 
                // Clear interrupt request
                // Clear interrupt request
                setctrl(0);
                setctrl(0);
 
 
                // Advance time
                // Advance time
                #100;
                @(posedge tb_top.clk);
 
                @(posedge tb_top.clk);
 
 
                // Sample interrupt request. Should be zero.
                // Sample interrupt request. Should be zero.
                l3 = tb_top.gpio_top.wb_inta_o;
                l3 = tb_top.gpio_top.wb_inta_o;
 
 
                // Check for errors
                // Check for errors

powered by: WebSVN 2.1.0

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