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

Subversion Repositories ahb2wishbone

[/] [ahb2wishbone/] [trunk/] [src/] [ahb2wb.v] - Diff between revs 6 and 10

Only display areas with differences | Details | Blame | View Log

Rev 6 Rev 10
 
 
// Copyright (c) 2007 TooMuch Semiconductor Solutions Pvt Ltd.
// Copyright (c) 2007 TooMuch Semiconductor Solutions Pvt Ltd.
 
 
 
 
//File name             :       ahb2wb.v
//File name             :       ahb2wb.v
//Designer              :       Manish Agarwal
//Designer              :       Manish Agarwal
//Date                  :       18 May, 2007
//Date                  :       18 May, 2007
//Description   :       AHB WISHBONE BRIDGE :- This design will connect AHB master interface with Wishbone slave.
//Description   :       AHB WISHBONE BRIDGE :- This design will connect AHB master interface with Wishbone slave.
//                                      This design will perform only single read-write operation.
//                                      This design will perform only single read-write operation.
//Revision              :       1.0
//Revision              :       1.0
 
 
 
 
//******************************************************************************************************
//******************************************************************************************************
 
 
`timescale 1 ns/1 ns
`timescale 1 ns/1 ns
 
 
module ahb2wb(
module ahb2wb(
        adr_o, dat_o, dat_i, ack_i, cyc_o,
        adr_o, dat_o, dat_i, ack_i, cyc_o,
        we_o, stb_o, hclk, hresetn, haddr, htrans, hwrite, hsize, hburst,
        we_o, stb_o, hclk, hresetn, haddr, htrans, hwrite, hsize, hburst,
        hsel, hwdata, hrdata, hresp, hready, clk_i, rst_i
        hsel, hwdata, hrdata, hresp, hready, clk_i, rst_i
        );
        );
 
 
 
 
//parameter declaration
//parameter declaration
        parameter AWIDTH = 16;
        parameter AWIDTH = 16;
        parameter DWIDTH = 32;
        parameter DWIDTH = 32;
 
 
 
 
//**************************************
//**************************************
// input ports
// input ports
//**************************************
//**************************************
 
 
 //wishbone ports               
 //wishbone ports               
        input [DWIDTH-1:0]dat_i;                                         // data input from wishbone slave
        input [DWIDTH-1:0]dat_i;                                         // data input from wishbone slave
        input ack_i;                                                                    // acknowledment from wishbone slave
        input ack_i;                                                                    // acknowledment from wishbone slave
        input clk_i;
        input clk_i;
        input rst_i;
        input rst_i;
 
 
 //AHB ports    
 //AHB ports    
        input hclk;                                                                     // clock
        input hclk;                                                                     // clock
        input hresetn;                                                                  // active low reset
        input hresetn;                                                                  // active low reset
        input [DWIDTH-1:0]hwdata;                                                // data bus             
        input [DWIDTH-1:0]hwdata;                                                // data bus             
        input hwrite;                                                                   // write/read enable
        input hwrite;                                                                   // write/read enable
        input [2:0]hburst;                                                               // burst type
        input [2:0]hburst;                                                               // burst type
        input [2:0]hsize;                                                                // data size
        input [2:0]hsize;                                                                // data size
        input [1:0]htrans;                                                               // type of transfer
        input [1:0]htrans;                                                               // type of transfer
        input hsel;                                                                             // slave select 
        input hsel;                                                                             // slave select 
        input [AWIDTH-1:0]haddr;                                         // address bus  
        input [AWIDTH-1:0]haddr;                                         // address bus  
 
 
 
 
//**************************************
//**************************************
// output ports
// output ports
//**************************************
//**************************************
 
 
 //wishbone ports
 //wishbone ports
        output [AWIDTH-1:0]adr_o;                                                // address to wishbone slave 
        output [AWIDTH-1:0]adr_o;                                                // address to wishbone slave 
        output [DWIDTH-1:0]dat_o;                                                // data output for wishbone slave
        output [DWIDTH-1:0]dat_o;                                                // data output for wishbone slave
        output cyc_o;                                                                   // signal to indicate valid bus cycle
        output cyc_o;                                                                   // signal to indicate valid bus cycle
        output we_o;                                                                    // write enable
        output we_o;                                                                    // write enable
        output stb_o;                                                                   // strobe to indicate valid data transfer cycle
        output stb_o;                                                                   // strobe to indicate valid data transfer cycle
 
 
 
 
 // AHB ports
 // AHB ports
        output [DWIDTH-1:0]hrdata;                                               // data output for wishbone slave
        output [DWIDTH-1:0]hrdata;                                               // data output for wishbone slave
        output [1:0]hresp;                                                               // response signal from slave
        output [1:0]hresp;                                                               // response signal from slave
        output hready;                                                                  // slave ready
        output hready;                                                                  // slave ready
 
 
 
 
//**************************************
//**************************************
// inout ports
// inout ports
//**************************************
//**************************************
 
 
 
 
//**********************************************************************************
//**********************************************************************************
 
 
 
 
// datatype declaration
// datatype declaration
        reg [DWIDTH-1:0]hrdata;
        reg [DWIDTH-1:0]hrdata;
        reg hready;
        reg hready;
        reg [1:0]hresp;
        reg [1:0]hresp;
        reg stb_o;
        reg stb_o;
        wire we_o;
        wire we_o;
        reg cyc_o;
        reg cyc_o;
        wire [AWIDTH-1:0]adr_o;
        wire [AWIDTH-1:0]adr_o;
        reg [DWIDTH-1:0]dat_o;
        reg [DWIDTH-1:0]dat_o;
 
 
// local memory registers
// local memory registers
        reg [AWIDTH-1 : 0]addr_temp;
        reg [AWIDTH-1 : 0]addr_temp;
        reg hwrite_temp;                                                                // to hold write enable signal temporarily
        reg hwrite_temp;                                                                // to hold write enable signal temporarily
 
 
//*******************************************************************
//*******************************************************************
// AHB WISHBONE BRIDGE logic
// AHB WISHBONE BRIDGE logic
//*******************************************************************
//*******************************************************************
 
 
        assign #2 we_o = hwrite_temp;
        assign #2 we_o = hwrite_temp;
        assign #2 adr_o = addr_temp;
        assign #2 adr_o = addr_temp;
 
 
        always @ (posedge hclk ) begin
        always @ (posedge hclk ) begin
                if (!hresetn) begin
                if (!hresetn) begin
                        hresp  <= 2'b00;
                        hresp  <= 2'b00;
                        cyc_o <= 'b0;
                        cyc_o <= 'b0;
                        stb_o <= 'b0;
                        stb_o <= 'b0;
                        addr_temp <= 'bx;
                        addr_temp <= 'bx;
                        hwrite_temp <= 'bx;
                        hwrite_temp <= 'bx;
                        dat_o <='bx;
                        dat_o <='bx;
                end
                end
                else if(hready & hsel) begin
                else if(hready & hsel) begin
                        case (hburst)
                        case (hburst)
                                // single transfer
                                // single transfer
                                3'b000  :       begin
                                3'b000  :       begin
                                                                case (htrans)
                                                                case (htrans)
                                                                        // idle transfer type
                                                                        // idle transfer type
                                                                        2'b00 : begin
                                                                        2'b00 : begin
                                                                                                cyc_o <= 'b0;
                                                                                                cyc_o <= 'b0;
                                                                                                hresp <= 2'b00;                 // ok response
                                                                                                hresp <= 2'b00;                 // ok response
                                                                                                stb_o <= 'b0;
                                                                                                stb_o <= 'b0;
 
 
                                                                                        end
                                                                                        end
 
 
                                                                        // busy transfer type
                                                                        // busy transfer type
                                                                        2'b01 : begin
                                                                        2'b01 : begin
                                                                                                hresp <= 2'b00;                 // ok response
                                                                                                hresp <= 2'b00;                 // ok response
                                                                                                stb_o <= 'b0;
                                                                                                stb_o <= 'b0;
                                                                                                cyc_o <= 'b1;
                                                                                                cyc_o <= 'b1;
                                                                                        end
                                                                                        end
 
 
                                                                        // Non-Sequential
                                                                        // Non-Sequential
                                                                        2'b10 : begin
                                                                        2'b10 : begin
                                                                                                cyc_o <= 'b1;
                                                                                                cyc_o <= 'b1;
                                                                                                stb_o <= 'b1;
                                                                                                stb_o <= 'b1;
                                                                                                addr_temp <= haddr;
                                                                                                addr_temp <= haddr;
                                                                                                hwrite_temp <= hwrite;                  // control signal stored that was received in address phase
                                                                                                hwrite_temp <= hwrite;                  // control signal stored that was received in address phase
                                                                                        end
                                                                                        end
                                                                endcase
                                                                endcase
                                                        end
                                                        end
 
 
                                default :       cyc_o <= 'b0;
                                default :       cyc_o <= 'b0;
                        endcase
                        endcase
                end
                end
                else if (!hsel & hready) begin
                else if (!hsel & hready) begin
                        cyc_o <= 'b0;                                   //invalid bus transfer
                        cyc_o <= 'b0;                                   //invalid bus transfer
                end
                end
 
 
        end
        end
 
 
 
 
// combinational logic - asynchronous read/write
// combinational logic - asynchronous read/write
        always@(hwrite_temp or hwdata or dat_i or ack_i or hresetn or stb_o ) begin
        always@(hwrite_temp or hwdata or dat_i or ack_i or hresetn or stb_o ) begin
 
 
                if (!hresetn) begin
                if (!hresetn) begin
                        hready <= 'b1;
                        hready <= 'b1;
                end
                end
                else begin
                else begin
                        if (stb_o)
                        if (stb_o)
                                hready = ack_i;
                                hready = ack_i;
 
 
                        if ( hwrite_temp )
                        if ( hwrite_temp )
                                dat_o = hwdata;
                                dat_o = hwdata;
                        else if (!hwrite_temp)
                        else if (!hwrite_temp)
                                hrdata = dat_i;
                                hrdata = dat_i;
                end
                end
 
 
        end
        end
 
 
endmodule
endmodule
 
 
 
 
 
 

powered by: WebSVN 2.1.0

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