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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [rtl/] [spiarbiter.v] - Diff between revs 2 and 64

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

Rev 2 Rev 64
Line 45... Line 45...
//
//
//
//
module  spiarbiter(i_clk,
module  spiarbiter(i_clk,
                i_cs_a_n, i_ck_a, i_mosi_a,
                i_cs_a_n, i_ck_a, i_mosi_a,
                i_cs_b_n, i_ck_b, i_mosi_b,
                i_cs_b_n, i_ck_b, i_mosi_b,
                o_cs_a_n, o_cs_b_n, o_ck, o_mosi); // , i_en, o_err
                o_cs_a_n, o_cs_b_n, o_ck, o_mosi,
 
                o_grant);
        input           i_clk;
        input           i_clk;
        input           i_cs_a_n, i_ck_a, i_mosi_a;
        input           i_cs_a_n, i_ck_a, i_mosi_a;
        // output       wire    o_grant_a;
        // output       wire    o_grant_a;
        input           i_cs_b_n, i_ck_b, i_mosi_b;
        input           i_cs_b_n, i_ck_b, i_mosi_b;
        // output       wire    o_grant_b;
        // output       wire    o_grant_b;
        output  wire    o_cs_a_n, o_cs_b_n, o_ck, o_mosi;
        output  wire    o_cs_a_n, o_cs_b_n, o_ck, o_mosi;
 
        //
 
        output  wire    o_grant; // == o_grant_a = ~o_grant_b
 
 
        reg     a_owner;
        reg     a_owner;
        initial a_owner = 1'b1;
        initial a_owner = 1'b1;
        always @(posedge i_clk)
        always @(posedge i_clk)
                if ((i_cs_a_n)&&(i_cs_b_n))
                if ((i_cs_a_n)&&(i_cs_b_n))
                        a_owner <= 1'b1; // Keep control
                        a_owner <= 1'b1; // Keep control
                else if ((i_cs_a_n)&&(~i_cs_b_n))
                else if ((i_cs_a_n)&&(~i_cs_b_n))
                        a_owner <= 1'b0; // Give up control
                        a_owner <= 1'b0; // Give up control
 
                else if ((~i_cs_a_n)&&(i_cs_b_n))
 
                        a_owner <= 1'b1; // Take control
 
 
        // assign       o_grant_a = a_owner;
        // assign       o_grant_a = a_owner;
        // assign       o_grant_b = (~a_owner);
        // assign       o_grant_b = (~a_owner);
 
 
        assign  o_cs_a_n = (~a_owner)||(~i_cs_a_n);
        assign  o_cs_a_n = (~a_owner)||(i_cs_a_n);
        assign  o_cs_b_n = ( a_owner)||(~i_cs_b_n);
        assign  o_cs_b_n = ( a_owner)||(i_cs_b_n);
        assign  o_ck     = ( a_owner)?i_ck_a   : i_ck_b;
        assign  o_ck     = ( a_owner)?i_ck_a   : i_ck_b;
        assign  o_mosi   = ( a_owner)?i_mosi_a : i_mosi_b;
        assign  o_mosi   = ( a_owner)?i_mosi_a : i_mosi_b;
 
 
 
        assign  o_grant = ~a_owner;
 
 
endmodule
endmodule
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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